forked from microsoft/PowerToys
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mouse Jump] - adding predefined "preview types" to settings ui - mic…
- Loading branch information
1 parent
e764470
commit 9442d29
Showing
11 changed files
with
420 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/modules/MouseUtils/MouseJump.Common/Models/Settings/PreviewType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) Microsoft Corporation | ||
// The Microsoft Corporation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace MouseJumpUI.Common.Models.Settings; | ||
|
||
public enum PreviewType | ||
{ | ||
Custom = 0, | ||
Compact = 1, | ||
Bezelled = 2, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/settings-ui/Settings.UI/Converters/MouseJumpPreviewTypeConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright (c) Microsoft Corporation | ||
// The Microsoft Corporation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using Microsoft.UI.Xaml.Data; | ||
using MouseJumpUI.Common.Models.Settings; | ||
|
||
namespace Microsoft.PowerToys.Settings.UI.Converters | ||
{ | ||
public sealed class MouseJumpPreviewTypeConverter : IValueConverter | ||
{ | ||
private static readonly PreviewType[] PreviewTypeOrder = | ||
[ | ||
PreviewType.Compact, PreviewType.Bezelled, PreviewType.Custom, | ||
]; | ||
|
||
private static readonly PreviewType DefaultPreviewType = PreviewType.Bezelled; | ||
|
||
// Receives a string as a parameter and returns an int representing the index | ||
// to select in the Segmented control on the Mouse Jump settings page | ||
public object Convert(object value, Type targetType, object parameter, string language) | ||
{ | ||
var previewType = MouseJumpPreviewTypeConverter.DefaultPreviewType; | ||
|
||
if (value is not string previewTypeName) | ||
{ | ||
// the value isn't a string so just use the default preview type | ||
} | ||
else if (Enum.IsDefined(typeof(PreviewType), previewTypeName)) | ||
{ | ||
// there's a case-sensitive match for the value | ||
previewType = Enum.Parse<PreviewType>(previewTypeName); | ||
} | ||
else if (Enum.TryParse<PreviewType>(previewTypeName, true, out var previewTypeResult)) | ||
{ | ||
// there's a case-insensitive match for the value | ||
previewType = previewTypeResult; | ||
} | ||
|
||
return Array.IndexOf( | ||
MouseJumpPreviewTypeConverter.PreviewTypeOrder, | ||
previewType); | ||
} | ||
|
||
// Receives an int as a parameter that represents the selected index in the Segmented | ||
// control on the Mouse Jump settings page, and returns the name of the PreviewType enum | ||
// for that index. | ||
public object ConvertBack(object value, Type targetType, object parameter, string language) | ||
{ | ||
var previewType = MouseJumpPreviewTypeConverter.DefaultPreviewType; | ||
|
||
if (value is not int segmentedIndex) | ||
{ | ||
// the value isn't an int so just use the default preview type | ||
} | ||
else if ((segmentedIndex < 0) || (segmentedIndex > MouseJumpPreviewTypeConverter.PreviewTypeOrder.Length)) | ||
{ | ||
// not a valid selected index so just use the default preview type | ||
} | ||
else | ||
{ | ||
previewType = MouseJumpPreviewTypeConverter.PreviewTypeOrder[segmentedIndex]; | ||
} | ||
|
||
return previewType.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
9442d29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@check-spelling-bot Report
🔴 Please review
See the 📜action log or 📝 job summary for details.
Unrecognized words (1)
bezelled
Previously acknowledged words that are now absent
COMMANDTITLE FILELOCKSMITHLIB gdnbaselines GPT interactable JArray ksh localport OOBEPT Pathto qwertyuiopasdfghjklzxcvbnm qwrtyuiopsghjklzxvnm redirectedfrom runsettings runspace testhost toggleswitch 🫥Some files were automatically ignored 🙈
These sample patterns would exclude them:
You should consider adding them to:
File matching is via Perl regular expressions.
To check these files, more of their words need to be in the dictionary than not. You can use
patterns.txt
to exclude portions, add items to the dictionary (e.g. by adding them toallow.txt
), or fix typos.To accept these unrecognized words as correct and remove the previously acknowledged and now absent words and update file exclusions, you could run the following commands
... in a clone of the [email protected]:mikeclayton/PowerToys.git repository
on the
dev/mikeclayton/mousejump-styles
branch (ℹ️ how do I use this?):Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary
This includes both expected items (1889) from .github/actions/spell-check/expect.txt and unrecognized words (1)
Consider adding them (in
.github/workflows/spelling2.yml
) foruses: check-spelling/[email protected]
in itswith
:To stop checking additional dictionaries, add (in
.github/workflows/spelling2.yml
) foruses: check-spelling/[email protected]
in itswith
:Warnings (1)
See the 📜action log or 📝 job summary for details.
See ℹ️ Event descriptions for more information.
If the flagged items are 🤯 false positives
If items relate to a ...
binary file (or some other file you wouldn't want to check at all).
Please add a file path to the
excludes.txt
file matching the containing file.File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^
refers to the file's path from the root of the repository, so^README\.md$
would exclude README.md (on whichever branch you're using).well-formed pattern.
If you can write a pattern that would match it,
try adding it to the
patterns.txt
file.Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.