Skip to content

Commit

Permalink
UI tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflord committed Jan 11, 2024
1 parent 8cb1039 commit f66aa43
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 8 deletions.
15 changes: 15 additions & 0 deletions src/settings-ui/Settings.UI.Library/AppSpecificKeysDataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ public class AppSpecificKeysDataModel : KeysDataModel
return base.GetMappedOriginalKeys();
}

public new List<string> GetMappedOriginalKeys(bool ignoreSecondKeyInChord)
{
return base.GetMappedOriginalKeys(ignoreSecondKeyInChord);
}

public List<string> GetMappedOriginalKeysWithoutChord()
{
return base.GetMappedOriginalKeys(true);
}

public new List<string> GetMappedOriginalKeysOnlyChord()
{
return base.GetMappedOriginalKeysOnlyChord();
}

public new List<string> GetMappedNewRemapKeys(int runProgramMaxLength)
{
return base.GetMappedNewRemapKeys(runProgramMaxLength);
Expand Down
63 changes: 60 additions & 3 deletions src/settings-ui/Settings.UI.Library/KeysDataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class KeysDataModel : INotifyPropertyChanged
[JsonPropertyName("originalKeys")]
public string OriginalKeys { get; set; }

[JsonPropertyName("secondKeyOfChord")]
public int SecondKeyOfChord { get; set; }

[JsonPropertyName("newRemapKeys")]
public string NewRemapKeys { get; set; }

Expand Down Expand Up @@ -150,23 +153,69 @@ private static void BringProcessToFront(Process process)
NativeMethods.SetForegroundWindow(handle);
}

private static List<string> MapKeys(string stringOfKeys)
private static List<string> MapKeysOnlyChord(int secondKeyOfChord)
{
var result = new List<string>();
if (secondKeyOfChord <= 0)
{
return result;
}

result.Add(Helper.GetKeyName((uint)secondKeyOfChord));

return result;
}

private static List<string> MapKeys(string stringOfKeys, int secondKeyOfChord)
{
if (stringOfKeys == null)
{
return new List<string>();
}

return stringOfKeys
if (secondKeyOfChord > 0)
{
var keys = stringOfKeys.Split(';');
return keys.Take(keys.Length - 1)
.Select(uint.Parse)
.Select(Helper.GetKeyName)
.ToList();
}
else
{
return stringOfKeys
.Split(';')
.Select(uint.Parse)
.Select(Helper.GetKeyName)
.ToList();
}
}

private static List<string> MapKeys(string stringOfKeys)
{
return MapKeys(stringOfKeys, 0);
}

public List<string> GetMappedOriginalKeys(bool ignoreSecondKeyInChord)
{
if (ignoreSecondKeyInChord && SecondKeyOfChord > 0)
{
return MapKeys(OriginalKeys, SecondKeyOfChord);
}
else
{
return MapKeys(OriginalKeys);
}
}

public List<string> GetMappedOriginalKeysOnlyChord()
{
return MapKeysOnlyChord(SecondKeyOfChord);
}

public List<string> GetMappedOriginalKeys()
{
return MapKeys(OriginalKeys);
return GetMappedOriginalKeys(false);
}

public bool IsRunProgram
Expand All @@ -193,6 +242,14 @@ public bool IsOpenURIOrIsRunProgram
}
}

public bool HasChord
{
get
{
return SecondKeyOfChord > 0;
}
}

public bool IsConfirmingDelete
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,26 @@
<ItemsControl
IsTabStop="False"
ItemTemplate="{StaticResource OriginalKeyTemplate}"
ItemsSource="{x:Bind GetMappedOriginalKeys()}">
ItemsSource="{x:Bind GetMappedOriginalKeysWithoutChord()}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" Spacing="4" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>

<TextBlock
Text=","
Padding="6,0,6,6"
VerticalAlignment="Bottom"
Visibility="{x:Bind Path=HasChord, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
</TextBlock>

<ItemsControl
IsTabStop="False"
Visibility="{x:Bind Path=HasChord, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
ItemTemplate="{StaticResource OriginalKeyTemplate}"
ItemsSource="{x:Bind GetMappedOriginalKeysOnlyChord()}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" Spacing="4" />
Expand Down Expand Up @@ -219,7 +238,7 @@
HorizontalAlignment="Right"
Orientation="Horizontal"
Spacing="0">

<StackPanel Orientation="Horizontal"
Visibility="{x:Bind Path=IsConfirmingDelete, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
<Button
Expand Down Expand Up @@ -251,7 +270,7 @@

</Button>
</StackPanel>

<StackPanel Orientation="Horizontal"
Visibility="{x:Bind Path=IsConfirmingDelete, Mode=OneWay, Converter={StaticResource BoolToInvertedVisibilityConverter}}">
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ public static List<AppSpecificKeysDataModel> CombineShortcutLists(List<KeysDataM
}
else if (appSpecificShortcutList == null)
{
return globalShortcutList.ConvertAll(x => new AppSpecificKeysDataModel { OriginalKeys = x.OriginalKeys, NewRemapKeys = x.NewRemapKeys, NewRemapString = x.NewRemapString, RunProgramFilePath = x.RunProgramFilePath, OperationType = x.OperationType, OpenUri = x.OpenUri, RunProgramArgs = x.RunProgramArgs, TargetApp = allAppsDescription }).ToList();
return globalShortcutList.ConvertAll(x => new AppSpecificKeysDataModel { OriginalKeys = x.OriginalKeys, NewRemapKeys = x.NewRemapKeys, NewRemapString = x.NewRemapString, RunProgramFilePath = x.RunProgramFilePath, OperationType = x.OperationType, OpenUri = x.OpenUri, SecondKeyOfChord = x.SecondKeyOfChord, RunProgramArgs = x.RunProgramArgs, TargetApp = allAppsDescription }).ToList();
}
else
{
return globalShortcutList.ConvertAll(x => new AppSpecificKeysDataModel { OriginalKeys = x.OriginalKeys, NewRemapKeys = x.NewRemapKeys, NewRemapString = x.NewRemapString, RunProgramFilePath = x.RunProgramFilePath, OperationType = x.OperationType, OpenUri = x.OpenUri, RunProgramArgs = x.RunProgramArgs, TargetApp = allAppsDescription }).Concat(appSpecificShortcutList).ToList();
return globalShortcutList.ConvertAll(x => new AppSpecificKeysDataModel { OriginalKeys = x.OriginalKeys, NewRemapKeys = x.NewRemapKeys, NewRemapString = x.NewRemapString, RunProgramFilePath = x.RunProgramFilePath, OperationType = x.OperationType, OpenUri = x.OpenUri, SecondKeyOfChord = x.SecondKeyOfChord, RunProgramArgs = x.RunProgramArgs, TargetApp = allAppsDescription }).Concat(appSpecificShortcutList).ToList();
}
}

Expand Down

1 comment on commit f66aa43

@github-actions
Copy link

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 (62)
actio
ALLOWCHORDS
ALREADYRUNNINGCLOSE
ALREADYRUNNINGCLOSEANDTERMINATE
ALREADYRUNNINGDONOTHING
ALREADYRUNNINGSHOWWINDOW
ALREADYRUNNINGSTARTANOTHER
ALREADYRUNNINGTERMINATE
ARGSFORPROGRAM
BADKEY
BIF
BROWSEINFO
CKBH
CLOSE'ing
cmdow
commdlg
CRTL
EDITSINGLESHORTCUT
EDITTHISSHORTCUT
ELEVATIONTYPEDIFFERENTUSER
ELEVATIONTYPEELEVATED
ELEVATIONTYPENORMAL
FILEMUSTEXIST
IUse
LABELACTION
LABELAPPNOTRUNNINGSOUND
LABELAPPRUNNINGSOUND
LABELARGS
LABELELEVATION
LABELIFRUNNING
LABELKEYS
LABELPATHURI
LABELPROGRAM
LABELSHORTCUT
LABELSTARTAS
LABELSTARTIN
Lencode
LPITEMIDLIST
lpstr
NEWDIALOGSTYLE
ofn
OPENFILENAME
PATHMUSTEXIST
PATHTOPROGRAM
pids
PROCESSENTRY
Procses
RETURNONLYFSDIRS
ritchielawrence
rowx
runasuser
SNAPPROCESS
STARTINDIRFORPROGRAM
tlhelp
Toolhelp
URIEXAMPLE
URIOr
urlmon
VIZHIDDEN
VIZNORMAL
wcsicmp
WHATCANIUSELINK
Previously acknowledged words that are now absent applicationframehost qps TKey TValue unescape 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the git@github.com:jefflord/PowerToys.git repository
on the launch-apps-3350 branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/jefflord/PowerToys/actions/runs/7483537076/attempts/1'
Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary

This includes both expected items (1849) from .github/actions/spell-check/expect.txt and unrecognized words (62)

Dictionary Entries Covers Uniquely
cspell:r/src/r.txt 543 1 1
cspell:cpp/src/people.txt 23 1
cspell:cpp/src/ecosystem.txt 51 1

Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

      with:
        extra_dictionaries:
          cspell:r/src/r.txt
          cspell:cpp/src/people.txt
          cspell:cpp/src/ecosystem.txt

To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

check_extra_dictionaries: ''
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.

Please sign in to comment.