From dfacb6b38543cbbb897361b908fdaefe4fd69f4b Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Wed, 3 Apr 2024 02:27:52 +0900 Subject: [PATCH 1/3] Init --- src/Files.App/Data/Commands/HotKey/HotKey.cs | 4 +- .../Data/Items/NavigationBarSuggestionItem.cs | 7 + .../UserControls/AddressToolbar.xaml | 31 +++- .../KeyboardShortcut.Properties.cs | 65 +++++++ .../KeyboardShortcut/KeyboardShortcut.cs | 103 +++++++++++ .../KeyboardShortcut/KeyboardShortcut.xaml | 161 ++++++++++++++++++ .../KeyboardShortcutItem.Properties.cs | 65 +++++++ .../KeyboardShortcut/KeyboardShortcutItem.cs | 46 +++++ .../KeyboardShortcutItemKind.cs | 14 ++ .../KeyboardShortcutItemSize.cs | 14 ++ .../KeyboardShortcutItemStyleSelector.cs | 33 ++++ .../UserControls/AddressToolbarViewModel.cs | 10 +- 12 files changed, 539 insertions(+), 14 deletions(-) create mode 100644 src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.Properties.cs create mode 100644 src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.cs create mode 100644 src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.xaml create mode 100644 src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItem.Properties.cs create mode 100644 src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItem.cs create mode 100644 src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemKind.cs create mode 100644 src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemSize.cs create mode 100644 src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemStyleSelector.cs diff --git a/src/Files.App/Data/Commands/HotKey/HotKey.cs b/src/Files.App/Data/Commands/HotKey/HotKey.cs index 424e9bbe73e4..8b90f42fc04e 100644 --- a/src/Files.App/Data/Commands/HotKey/HotKey.cs +++ b/src/Files.App/Data/Commands/HotKey/HotKey.cs @@ -11,7 +11,7 @@ namespace Files.App.Data.Commands [DebuggerDisplay("{Code}")] public readonly struct HotKey : IEquatable { - private static readonly FrozenDictionary modifiers = new Dictionary() + public static readonly FrozenDictionary modifiers = new Dictionary() { [KeyModifiers.Menu] = GetKeyString("Menu"), [KeyModifiers.Ctrl] = GetKeyString("Control"), @@ -19,7 +19,7 @@ namespace Files.App.Data.Commands [KeyModifiers.Win] = GetKeyString("Windows"), }.ToFrozenDictionary(); - private static readonly FrozenDictionary keys = new Dictionary() + public static readonly FrozenDictionary keys = new Dictionary() { [Keys.Enter] = GetKeyString("Enter"), [Keys.Space] = GetKeyString("Space"), diff --git a/src/Files.App/Data/Items/NavigationBarSuggestionItem.cs b/src/Files.App/Data/Items/NavigationBarSuggestionItem.cs index f78dd6673e94..90ff2a4a4df5 100644 --- a/src/Files.App/Data/Items/NavigationBarSuggestionItem.cs +++ b/src/Files.App/Data/Items/NavigationBarSuggestionItem.cs @@ -69,6 +69,13 @@ public string? SupplementaryDisplay set => SetProperty(ref _SupplementaryDisplay, value); } + private HotKeyCollection _HotKeys = new(); + public HotKeyCollection HotKeys + { + get => _HotKeys; + set => SetProperty(ref _HotKeys, value); + } + private void UpdatePrimaryDisplay() { if (SearchText is null || PrimaryDisplay is null) diff --git a/src/Files.App/UserControls/AddressToolbar.xaml b/src/Files.App/UserControls/AddressToolbar.xaml index f60185b763b4..492245059864 100644 --- a/src/Files.App/UserControls/AddressToolbar.xaml +++ b/src/Files.App/UserControls/AddressToolbar.xaml @@ -12,6 +12,7 @@ xmlns:extensions="using:CommunityToolkit.WinUI.UI" xmlns:helpers="using:Files.App.Helpers" xmlns:items="using:Files.App.Data.Items" + xmlns:keyboard="using:Files.App.UserControls.KeyboardShortcut" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:triggers="using:CommunityToolkit.WinUI.UI.Triggers" xmlns:uc="using:Files.App.UserControls" @@ -28,6 +29,8 @@ + + @@ -313,7 +316,7 @@ - + @@ -321,26 +324,38 @@ - + + - - - + HotKeys="{x:Bind HotKeys, Mode=OneWay}" /> + + + diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.Properties.cs b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.Properties.cs new file mode 100644 index 000000000000..1886379394ba --- /dev/null +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.Properties.cs @@ -0,0 +1,65 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +namespace Files.App.UserControls.KeyboardShortcut +{ + public sealed partial class KeyboardShortcut + { + public static readonly DependencyProperty ItemTypeProperty = + DependencyProperty.Register( + nameof(ItemType), + typeof(KeyboardShortcutItemKind), + typeof(KeyboardShortcutItem), + new PropertyMetadata(defaultValue: KeyboardShortcutItemKind.Default, (d, e) => ((KeyboardShortcutItem)d).OnItemTypePropertyChanged())); + + public KeyboardShortcutItemKind ItemType + { + get => (KeyboardShortcutItemKind)GetValue(ItemTypeProperty); + set => SetValue(ItemTypeProperty, value); + } + + public static readonly DependencyProperty SizeProperty = + DependencyProperty.Register( + nameof(Size), + typeof(KeyboardShortcutItemSize), + typeof(KeyboardShortcutItem), + new PropertyMetadata(defaultValue: KeyboardShortcutItemSize.Small, (d, e) => ((KeyboardShortcutItem)d).OnSizePropertyChanged())); + + public KeyboardShortcutItemSize Size + { + get => (KeyboardShortcutItemSize)GetValue(SizeProperty); + set => SetValue(SizeProperty, value); + } + + public static readonly DependencyProperty HotKeysProperty = + DependencyProperty.Register( + nameof(HotKeys), + typeof(HotKeyCollection), + typeof(KeyboardShortcut), + new PropertyMetadata(defaultValue: new(), (d, e) => ((KeyboardShortcut)d).OnHotKeysPropertyChanged())); + + public HotKeyCollection HotKeys + { + get => (HotKeyCollection)GetValue(HotKeysProperty); + set => SetValue(HotKeysProperty, value); + } + + public void OnItemTypePropertyChanged() + { + OnItemTypeChanged(); + } + + public void OnSizePropertyChanged() + { + OnSizeChanged(); + } + + private void OnHotKeysPropertyChanged() + { + OnHotKeysChanged(); + } + } +} diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.cs b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.cs new file mode 100644 index 000000000000..bf7f1e0d78da --- /dev/null +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.cs @@ -0,0 +1,103 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +using CommunityToolkit.WinUI.UI; +using Microsoft.UI.Input; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Automation; +using Microsoft.UI.Xaml.Automation.Peers; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; + +namespace Files.App.UserControls.KeyboardShortcut +{ + public sealed partial class KeyboardShortcut : Control + { + internal const string KeyboardShortcutItemsControl = "PART_KeyboardShortcutItemsControl"; + + public KeyboardShortcut() + { + DefaultStyleKey = typeof(KeyboardShortcut); + } + + private void OnItemTypeChanged() + { + } + + private void OnSizeChanged() + { + } + + private void OnHotKeysChanged() + { + if (HotKeys.IsEmpty) + return; + + List items = new(); + + foreach (var item in HotKeys) + { + if (items.Any()) + { + items.Add(new() { Text = ",", ItemType = KeyboardShortcutItemKind.Reveal, Size = Size }); + } + + switch(item.Key, item.Modifier) + { + // No keys or modifiers specified + case (Keys.None, KeyModifiers.None): + break; + + // Key modifiers only + case (Keys.None, _): + GetModifierCode(item.Modifier); + items.RemoveAt(items.Count - 1); + break; + + // Keys only + case (_, KeyModifiers.None): + var key = HotKey.keys[item.Key]; + items.Add(new() { Text = key, ItemType = ItemType, Size = Size }); + break; + + // Others + default: + GetModifierCode(item.Modifier); + key = HotKey.keys[item.Key]; + items.Add(new() { Text = key, ItemType = ItemType, Size = Size }); + break; + } + + void GetModifierCode(KeyModifiers modifier) + { + if (modifier.HasFlag(KeyModifiers.Menu)) + { + items.Add(new() { Text = HotKey.modifiers[KeyModifiers.Menu], ItemType = ItemType, Size = Size }); + items.Add(new() { Text = "+", ItemType = KeyboardShortcutItemKind.Reveal, Size = Size }); + } + if (modifier.HasFlag(KeyModifiers.Ctrl)) + { + items.Add(new() { Text = HotKey.modifiers[KeyModifiers.Ctrl], ItemType = ItemType, Size = Size }); + items.Add(new() { Text = "+", ItemType = KeyboardShortcutItemKind.Reveal, Size = Size }); + } + if (modifier.HasFlag(KeyModifiers.Shift)) + { + items.Add(new() { Text = HotKey.modifiers[KeyModifiers.Shift], ItemType = ItemType, Size = Size }); + items.Add(new() { Text = "+", ItemType = KeyboardShortcutItemKind.Reveal, Size = Size }); + } + if (modifier.HasFlag(KeyModifiers.Win)) + { + items.Add(new() { Text = HotKey.modifiers[KeyModifiers.Win], ItemType = ItemType, Size = Size }); + items.Add(new() { Text = "+", ItemType = KeyboardShortcutItemKind.Reveal, Size = Size }); + } + } + } + + // Set value + if (GetTemplateChild(KeyboardShortcutItemsControl) is ItemsControl keyboardShortcutItemsControl) + { + keyboardShortcutItemsControl.ItemsSource = items; + } + } + } +} diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.xaml b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.xaml new file mode 100644 index 000000000000..91d60c207812 --- /dev/null +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.xaml @@ -0,0 +1,161 @@ + + + + + + + + + + + + + diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItem.Properties.cs b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItem.Properties.cs new file mode 100644 index 000000000000..b9f497efdf1c --- /dev/null +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItem.Properties.cs @@ -0,0 +1,65 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +namespace Files.App.UserControls.KeyboardShortcut +{ + public sealed partial class KeyboardShortcutItem + { + public static readonly DependencyProperty ItemTypeProperty = + DependencyProperty.Register( + nameof(ItemType), + typeof(KeyboardShortcutItemKind), + typeof(KeyboardShortcutItem), + new PropertyMetadata(defaultValue: KeyboardShortcutItemKind.Default, (d, e) => ((KeyboardShortcutItem)d).OnItemTypePropertyChanged())); + + public KeyboardShortcutItemKind ItemType + { + get => (KeyboardShortcutItemKind)GetValue(ItemTypeProperty); + set => SetValue(ItemTypeProperty, value); + } + + public static readonly DependencyProperty SizeProperty = + DependencyProperty.Register( + nameof(Size), + typeof(KeyboardShortcutItemSize), + typeof(KeyboardShortcutItem), + new PropertyMetadata(defaultValue: KeyboardShortcutItemSize.Small, (d, e) => ((KeyboardShortcutItem)d).OnSizePropertyChanged())); + + public KeyboardShortcutItemSize Size + { + get => (KeyboardShortcutItemSize)GetValue(SizeProperty); + set => SetValue(SizeProperty, value); + } + + public static readonly DependencyProperty TextProperty = + DependencyProperty.Register( + nameof(Text), + typeof(string), + typeof(KeyboardShortcutItem), + new PropertyMetadata(defaultValue: string.Empty, (d, e) => ((KeyboardShortcutItem)d).OnTextPropertyChanged())); + + public string Text + { + get => (string)GetValue(TextProperty); + set => SetValue(TextProperty, value); + } + + public void OnItemTypePropertyChanged() + { + OnItemTypeChanged(); + } + + public void OnSizePropertyChanged() + { + OnSizeChanged(); + } + + public void OnTextPropertyChanged() + { + OnTextChanged(); + } + } +} diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItem.cs b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItem.cs new file mode 100644 index 000000000000..fb174fceda9a --- /dev/null +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItem.cs @@ -0,0 +1,46 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +namespace Files.App.UserControls.KeyboardShortcut +{ + public sealed partial class KeyboardShortcutItem : Control + { + internal const string SmallState = "Small"; + internal const string MediumState = "Medium"; + internal const string LargeState = "Large"; + + internal const string MainTextTextBlock = "PART_MainTextTextBlock"; + + public KeyboardShortcutItem() + { + DefaultStyleKey = typeof(KeyboardShortcutItem); + } + + private void OnItemTypeChanged() + { + } + + private void OnSizeChanged() + { + switch (Size) + { + case KeyboardShortcutItemSize.Small: + VisualStateManager.GoToState(this, SmallState, true); + break; + case KeyboardShortcutItemSize.Medium: + VisualStateManager.GoToState(this, MediumState, true); + break; + case KeyboardShortcutItemSize.Large: + VisualStateManager.GoToState(this, LargeState, true); + break; + } + } + + private void OnTextChanged() + { + } + } +} diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemKind.cs b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemKind.cs new file mode 100644 index 000000000000..3e440eb0ed72 --- /dev/null +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemKind.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.App.UserControls.KeyboardShortcut +{ + public enum KeyboardShortcutItemKind + { + Default, + + Accent, + + Reveal, + } +} diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemSize.cs b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemSize.cs new file mode 100644 index 000000000000..80a629d00421 --- /dev/null +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemSize.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.App.UserControls.KeyboardShortcut +{ + public enum KeyboardShortcutItemSize + { + Small, + + Medium, + + Large, + } +} diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemStyleSelector.cs b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemStyleSelector.cs new file mode 100644 index 000000000000..56c4ec5ff91b --- /dev/null +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemStyleSelector.cs @@ -0,0 +1,33 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +namespace Files.App.UserControls.KeyboardShortcut +{ + public class KeyboardShortcutItemStyleSelector : StyleSelector + { + public Style DefaultItemStyle { get; set; } + + public Style AccentItemStyle { get; set; } + + public Style RevealItemStyle { get; set; } + + protected override Style SelectStyleCore(object item, DependencyObject container) + { + if (container is KeyboardShortcutItem keyboardShortcutItem) + { + return keyboardShortcutItem.ItemType switch + { + KeyboardShortcutItemKind.Default => DefaultItemStyle, + KeyboardShortcutItemKind.Accent => AccentItemStyle, + KeyboardShortcutItemKind.Reveal => RevealItemStyle, + _ => DefaultItemStyle, + }; + } + + return DefaultItemStyle; + } + } +} diff --git a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs index f1e5f86af0e5..c097040aa162 100644 --- a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs @@ -838,14 +838,16 @@ public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPag { IsCommandPaletteOpen = true; var searchText = sender.Text.Substring(1).Trim(); - suggestions = Commands.Where(command => command.IsExecutable && - (command.Description.Contains(searchText, StringComparison.OrdinalIgnoreCase) - || command.Code.ToString().Contains(searchText, StringComparison.OrdinalIgnoreCase))) + suggestions = Commands.Where(command => + command.IsExecutable && + (command.Description.Contains(searchText, StringComparison.OrdinalIgnoreCase) || + command.Code.ToString().Contains(searchText, StringComparison.OrdinalIgnoreCase))) .Select(command => new NavigationBarSuggestionItem() { Text = ">" + command.Code, PrimaryDisplay = command.Description, - SupplementaryDisplay = command.HotKeyText, + //SupplementaryDisplay = command.HotKeyText, + HotKeys = command.HotKeys, SearchText = searchText, }).ToList(); } From 9bc9acdc14e92ca1bb40dc037df1a8ac5ea55101 Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:11:04 +0900 Subject: [PATCH 2/3] Update --- .../UserControls/AddressToolbar.xaml | 31 +++++++------------ .../KeyboardShortcut/KeyboardShortcut.xaml | 29 ++++++----------- .../UserControls/AddressToolbarViewModel.cs | 1 - 3 files changed, 22 insertions(+), 39 deletions(-) diff --git a/src/Files.App/UserControls/AddressToolbar.xaml b/src/Files.App/UserControls/AddressToolbar.xaml index 492245059864..89f8b2a05a19 100644 --- a/src/Files.App/UserControls/AddressToolbar.xaml +++ b/src/Files.App/UserControls/AddressToolbar.xaml @@ -322,40 +322,33 @@ - - + - + + + + - - - - - diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.xaml b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.xaml index 91d60c207812..42ed7486f8cf 100644 --- a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.xaml +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.xaml @@ -36,12 +36,11 @@ - - + - - + - - + @@ -86,7 +82,6 @@ CornerRadius="2"> - - + - - + - - + @@ -127,7 +119,6 @@ - + - + - + diff --git a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs index c097040aa162..8da23354620b 100644 --- a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs @@ -846,7 +846,6 @@ public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPag { Text = ">" + command.Code, PrimaryDisplay = command.Description, - //SupplementaryDisplay = command.HotKeyText, HotKeys = command.HotKeys, SearchText = searchText, }).ToList(); From ea2ba08a1ad11d9a2bde48c56ed653e092409694 Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Thu, 4 Apr 2024 02:38:31 +0900 Subject: [PATCH 3/3] Update --- .../KeyboardShortcut.Properties.cs | 2 +- .../KeyboardShortcut/KeyboardShortcut.cs | 10 ++-- .../KeyboardShortcut/KeyboardShortcut.xaml | 47 +++++++++++++------ .../KeyboardShortcutItem.Properties.cs | 2 +- .../KeyboardShortcutItemKind.cs | 6 +-- .../KeyboardShortcutItemStyleSelector.cs | 16 +++---- 6 files changed, 51 insertions(+), 32 deletions(-) diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.Properties.cs b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.Properties.cs index 1886379394ba..3194cdf177ba 100644 --- a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.Properties.cs +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.Properties.cs @@ -13,7 +13,7 @@ public sealed partial class KeyboardShortcut nameof(ItemType), typeof(KeyboardShortcutItemKind), typeof(KeyboardShortcutItem), - new PropertyMetadata(defaultValue: KeyboardShortcutItemKind.Default, (d, e) => ((KeyboardShortcutItem)d).OnItemTypePropertyChanged())); + new PropertyMetadata(defaultValue: KeyboardShortcutItemKind.Outlined, (d, e) => ((KeyboardShortcutItem)d).OnItemTypePropertyChanged())); public KeyboardShortcutItemKind ItemType { diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.cs b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.cs index bf7f1e0d78da..a1398e9b8cbd 100644 --- a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.cs +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.cs @@ -39,7 +39,7 @@ private void OnHotKeysChanged() { if (items.Any()) { - items.Add(new() { Text = ",", ItemType = KeyboardShortcutItemKind.Reveal, Size = Size }); + items.Add(new() { Text = ",", ItemType = KeyboardShortcutItemKind.TextOnly, Size = Size }); } switch(item.Key, item.Modifier) @@ -73,22 +73,22 @@ void GetModifierCode(KeyModifiers modifier) if (modifier.HasFlag(KeyModifiers.Menu)) { items.Add(new() { Text = HotKey.modifiers[KeyModifiers.Menu], ItemType = ItemType, Size = Size }); - items.Add(new() { Text = "+", ItemType = KeyboardShortcutItemKind.Reveal, Size = Size }); + items.Add(new() { Text = "+", ItemType = KeyboardShortcutItemKind.TextOnly, Size = Size }); } if (modifier.HasFlag(KeyModifiers.Ctrl)) { items.Add(new() { Text = HotKey.modifiers[KeyModifiers.Ctrl], ItemType = ItemType, Size = Size }); - items.Add(new() { Text = "+", ItemType = KeyboardShortcutItemKind.Reveal, Size = Size }); + items.Add(new() { Text = "+", ItemType = KeyboardShortcutItemKind.TextOnly, Size = Size }); } if (modifier.HasFlag(KeyModifiers.Shift)) { items.Add(new() { Text = HotKey.modifiers[KeyModifiers.Shift], ItemType = ItemType, Size = Size }); - items.Add(new() { Text = "+", ItemType = KeyboardShortcutItemKind.Reveal, Size = Size }); + items.Add(new() { Text = "+", ItemType = KeyboardShortcutItemKind.TextOnly, Size = Size }); } if (modifier.HasFlag(KeyModifiers.Win)) { items.Add(new() { Text = HotKey.modifiers[KeyModifiers.Win], ItemType = ItemType, Size = Size }); - items.Add(new() { Text = "+", ItemType = KeyboardShortcutItemKind.Reveal, Size = Size }); + items.Add(new() { Text = "+", ItemType = KeyboardShortcutItemKind.TextOnly, Size = Size }); } } } diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.xaml b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.xaml index 42ed7486f8cf..1cc08525a54e 100644 --- a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.xaml +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcut.xaml @@ -4,18 +4,23 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Files.App.UserControls.KeyboardShortcut"> - + + + + + + + + + + + - - - + diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItem.Properties.cs b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItem.Properties.cs index b9f497efdf1c..7b694933119d 100644 --- a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItem.Properties.cs +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItem.Properties.cs @@ -13,7 +13,7 @@ public sealed partial class KeyboardShortcutItem nameof(ItemType), typeof(KeyboardShortcutItemKind), typeof(KeyboardShortcutItem), - new PropertyMetadata(defaultValue: KeyboardShortcutItemKind.Default, (d, e) => ((KeyboardShortcutItem)d).OnItemTypePropertyChanged())); + new PropertyMetadata(defaultValue: KeyboardShortcutItemKind.Outlined, (d, e) => ((KeyboardShortcutItem)d).OnItemTypePropertyChanged())); public KeyboardShortcutItemKind ItemType { diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemKind.cs b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemKind.cs index 3e440eb0ed72..2233a13cccb9 100644 --- a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemKind.cs +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemKind.cs @@ -5,10 +5,10 @@ namespace Files.App.UserControls.KeyboardShortcut { public enum KeyboardShortcutItemKind { - Default, + Outlined, - Accent, + Filled, - Reveal, + TextOnly, } } diff --git a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemStyleSelector.cs b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemStyleSelector.cs index 56c4ec5ff91b..132e916c11c0 100644 --- a/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemStyleSelector.cs +++ b/src/Files.App/UserControls/KeyboardShortcut/KeyboardShortcutItemStyleSelector.cs @@ -8,11 +8,11 @@ namespace Files.App.UserControls.KeyboardShortcut { public class KeyboardShortcutItemStyleSelector : StyleSelector { - public Style DefaultItemStyle { get; set; } + public Style OutlinedItemStyle { get; set; } = null!; - public Style AccentItemStyle { get; set; } + public Style FilledItemStyle { get; set; } = null!; - public Style RevealItemStyle { get; set; } + public Style TextOnlyItemStyle { get; set; } = null!; protected override Style SelectStyleCore(object item, DependencyObject container) { @@ -20,14 +20,14 @@ protected override Style SelectStyleCore(object item, DependencyObject container { return keyboardShortcutItem.ItemType switch { - KeyboardShortcutItemKind.Default => DefaultItemStyle, - KeyboardShortcutItemKind.Accent => AccentItemStyle, - KeyboardShortcutItemKind.Reveal => RevealItemStyle, - _ => DefaultItemStyle, + KeyboardShortcutItemKind.Outlined => OutlinedItemStyle, + KeyboardShortcutItemKind.Filled => FilledItemStyle, + KeyboardShortcutItemKind.TextOnly => TextOnlyItemStyle, + _ => OutlinedItemStyle, }; } - return DefaultItemStyle; + return OutlinedItemStyle; } } }