From d394d86201521e3368412dcb46cd256c9105e2ef Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:42:05 +0800 Subject: [PATCH] Bugfix --- .../UserSettings/CustomShortcutModel.cs | 2 +- Flow.Launcher.Infrastructure/UserSettings/Settings.cs | 1 + Flow.Launcher/CustomShortcutSetting.xaml.cs | 5 +++-- Flow.Launcher/SettingWindow.xaml | 4 ++-- Flow.Launcher/SettingWindow.xaml.cs | 2 +- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 7 +++---- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/CustomShortcutModel.cs b/Flow.Launcher.Infrastructure/UserSettings/CustomShortcutModel.cs index d4dab8461..11f30d2f6 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/CustomShortcutModel.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/CustomShortcutModel.cs @@ -46,7 +46,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings public void Deconstruct(out string key, out string value) { key = Key; - value = Expand(); + value = Value; } public static implicit operator (string Key, string Value)(CustomShortcutModel shortcut) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index cdbcf23ff..a9a69687c 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -8,6 +8,7 @@ using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedModels; using Flow.Launcher; using Flow.Launcher.ViewModel; + namespace Flow.Launcher.Infrastructure.UserSettings { public class Settings : BaseModel diff --git a/Flow.Launcher/CustomShortcutSetting.xaml.cs b/Flow.Launcher/CustomShortcutSetting.xaml.cs index 292288473..f3d1895a1 100644 --- a/Flow.Launcher/CustomShortcutSetting.xaml.cs +++ b/Flow.Launcher/CustomShortcutSetting.xaml.cs @@ -20,9 +20,10 @@ namespace Flow.Launcher InitializeComponent(); } - public CustomShortcutSetting((string, string) shortcut, Settings settings) + public CustomShortcutSetting(CustomShortcutModel shortcut, Settings settings) { - (Key, Value) = shortcut; + Key = shortcut.Key; + Value = shortcut.Value; _settings = settings; update = true; InitializeComponent(); diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index f15de6afe..907a6aa6d 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2131,7 +2131,8 @@ - + @@ -2184,7 +2185,6 @@ BorderThickness="1" ItemsSource="{Binding ShortCuts}" SelectedItem="{Binding SelectedCustomShortcut}" - SelectedIndex="{Binding SelectCustomShortcutIndex}" Style="{StaticResource {x:Static GridView.GridViewStyleKey}}"> diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index d765e35a9..261903da6 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -411,7 +411,7 @@ namespace Flow.Launcher var shortcutSettingWindow = new CustomShortcutSetting(item, settings); if (shortcutSettingWindow.ShowDialog() == true) { - viewModel.EditShortcut(item); + viewModel.EditShortcut(item, shortcutSettingWindow.ShortCut); } } else diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 678e23ec0..53dad8cbd 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -543,7 +543,6 @@ namespace Flow.Launcher.ViewModel public CustomPluginHotkey SelectedCustomPluginHotkey { get; set; } public CustomShortcutModel? SelectedCustomShortcut { get; set; } - public int? SelectCustomShortcutIndex { get; set; } public void AddShortcut(CustomShortcutModel shortcut) { @@ -551,10 +550,10 @@ namespace Flow.Launcher.ViewModel ShortCuts.Add(shortcut); } - public void EditShortcut(CustomShortcutModel shortcut) + public void EditShortcut(CustomShortcutModel oldShortcut, CustomShortcutModel newShortcut) { - Settings.CustomShortcuts[ShortCuts.IndexOf(shortcut)] = shortcut; - ShortCuts[ShortCuts.IndexOf(shortcut)] = shortcut; + RemoveShortcut(oldShortcut); + AddShortcut(newShortcut); } public void RemoveShortcut(CustomShortcutModel shortcut)