From ea7cee1363ba59a24c8a6b9d30f30f9e2834ff29 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 22:54:03 +0000 Subject: [PATCH 1/2] Bump NHotkey.Wpf from 2.1.1 to 3.0.0 Bumps [NHotkey.Wpf](https://github.com/thomaslevesque/NHotkey) from 2.1.1 to 3.0.0. - [Release notes](https://github.com/thomaslevesque/NHotkey/releases) - [Commits](https://github.com/thomaslevesque/NHotkey/compare/2.1.1...3.0.0) --- updated-dependencies: - dependency-name: NHotkey.Wpf dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Flow.Launcher/Flow.Launcher.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/Flow.Launcher.csproj b/Flow.Launcher/Flow.Launcher.csproj index 53c1bafc7..1569409a4 100644 --- a/Flow.Launcher/Flow.Launcher.csproj +++ b/Flow.Launcher/Flow.Launcher.csproj @@ -93,7 +93,7 @@ - + From 79ce5057c247ddac5bf478fdca52db18a5f700c3 Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Thu, 20 Jun 2024 09:54:01 +0600 Subject: [PATCH 2/2] Settings: fix creating/editing custom shortcuts --- Flow.Launcher/CustomShortcutSetting.xaml.cs | 17 ++++++++++------- .../ViewModels/SettingsPaneHotkeyViewModel.cs | 13 ++++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Flow.Launcher/CustomShortcutSetting.xaml.cs b/Flow.Launcher/CustomShortcutSetting.xaml.cs index 82efb4869..531b29d50 100644 --- a/Flow.Launcher/CustomShortcutSetting.xaml.cs +++ b/Flow.Launcher/CustomShortcutSetting.xaml.cs @@ -1,31 +1,34 @@ using Flow.Launcher.Core.Resource; -using Flow.Launcher.ViewModel; using System; using System.Windows; using System.Windows.Input; +using Flow.Launcher.SettingPages.ViewModels; namespace Flow.Launcher { public partial class CustomShortcutSetting : Window { + private readonly SettingsPaneHotkeyViewModel _hotkeyVm; public string Key { get; set; } = String.Empty; public string Value { get; set; } = String.Empty; - private string originalKey { get; init; } = null; - private string originalValue { get; init; } = null; - private bool update { get; init; } = false; + private string originalKey { get; } = null; + private string originalValue { get; } = null; + private bool update { get; } = false; - public CustomShortcutSetting(SettingWindowViewModel vm) + public CustomShortcutSetting(SettingsPaneHotkeyViewModel vm) { + _hotkeyVm = vm; InitializeComponent(); } - public CustomShortcutSetting(string key, string value) + public CustomShortcutSetting(string key, string value, SettingsPaneHotkeyViewModel vm) { Key = key; Value = value; originalKey = key; originalValue = value; update = true; + _hotkeyVm = vm; InitializeComponent(); } @@ -43,7 +46,7 @@ namespace Flow.Launcher return; } // Check if key is modified or adding a new one - if ((update && originalKey != Key) || !update) + if (((update && originalKey != Key) || !update) && _hotkeyVm.DoesShortcutExist(Key)) { MessageBox.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut")); return; diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs index 7eb05d945..a4488a037 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs @@ -1,4 +1,5 @@ -using System.Windows; +using System.Linq; +using System.Windows; using CommunityToolkit.Mvvm.Input; using Flow.Launcher.Core.Resource; using Flow.Launcher.Helper; @@ -114,7 +115,7 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel return; } - var window = new CustomShortcutSetting(item.Key, item.Value); + var window = new CustomShortcutSetting(item.Key, item.Value, this); if (window.ShowDialog() is not true) return; var index = Settings.CustomShortcuts.IndexOf(item); @@ -124,11 +125,17 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel [RelayCommand] private void CustomShortcutAdd() { - var window = new CustomShortcutSetting(null); + var window = new CustomShortcutSetting(this); if (window.ShowDialog() is true) { var shortcut = new CustomShortcutModel(window.Key, window.Value); Settings.CustomShortcuts.Add(shortcut); } } + + internal bool DoesShortcutExist(string key) + { + return Settings.CustomShortcuts.Any(v => v.Key == key) || + Settings.BuiltinShortcuts.Any(v => v.Key == key); + } }