From 7854cf348b4c754b42c05433514b48375023c480 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Sun, 6 Jun 2021 11:01:50 +0800 Subject: [PATCH] Finishing editing logic, and add a few interactive for ActionKeywordSetting.xaml 1. It will automatically focus on the textbox 2. Enter will trigger the done button --- .../ViewModels/SettingsViewModel.cs | 22 +--- .../Views/ActionKeywordSetting.xaml | 8 +- .../Views/ActionKeywordSetting.xaml.cs | 103 ++++++++++++------ .../Views/ExplorerSettings.xaml.cs | 2 +- 4 files changed, 75 insertions(+), 60 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index 0fed15fc4..77ec5457b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -44,30 +44,10 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels internal void UpdateActionKeyword(Settings.ActionKeyword modifiedActionKeyword, string newActionKeyword, string oldActionKeyword) { PluginManager.ReplaceActionKeyword(Context.CurrentPluginMetadata.ID, oldActionKeyword, newActionKeyword); - - switch (modifiedActionKeyword) - { - case Settings.ActionKeyword.SearchActionKeyword: - Settings.SearchActionKeyword = newActionKeyword; - break; - case Settings.ActionKeyword.PathSearchActionKeyword: - Settings.PathSearchActionKeyword = newActionKeyword; - break; - case Settings.ActionKeyword.FileContentSearchActionKeyword: - Settings.FileContentSearchActionKeyword = newActionKeyword; - break; - case Settings.ActionKeyword.IndexSearchActionKeyword: - Settings.IndexSearchActionKeyword = newActionKeyword; - break; - } } - internal bool IsActionKeywordAlreadyAssigned(string newActionKeyword, string oldActionKeyword) + internal bool IsActionKeywordAlreadyAssigned(string newActionKeyword) { - // PluginManager.ActionKeywordRegistered does not check global action keyword ('*'), so use this logic instead - if (newActionKeyword == Query.GlobalPluginWildcardSign) - return newActionKeyword == oldActionKeyword; - return PluginManager.ActionKeywordRegistered(newActionKeyword); } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml index af67f1727..19ff624b0 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml @@ -25,13 +25,15 @@ Margin="10" Grid.Row="0" Width="105" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" - Text="{Binding CurrentActionKeyword.Keyword}" /> + Text="{Binding ActionKeyword}" + PreviewKeyDown="TxtCurrentActionKeyword_OnKeyDown"/> -