From 24bbfcc4139596ac6d3929da44e353508f426974 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 7 Apr 2025 14:27:33 +0800 Subject: [PATCH] Support numerical box for priority --- Flow.Launcher/PriorityChangeWindow.xaml | 121 ------------------ Flow.Launcher/PriorityChangeWindow.xaml.cs | 67 ---------- .../Controls/InstalledPluginDisplay.xaml | 3 +- Flow.Launcher/ViewModel/PluginViewModel.cs | 20 +-- 4 files changed, 4 insertions(+), 207 deletions(-) delete mode 100644 Flow.Launcher/PriorityChangeWindow.xaml delete mode 100644 Flow.Launcher/PriorityChangeWindow.xaml.cs diff --git a/Flow.Launcher/PriorityChangeWindow.xaml b/Flow.Launcher/PriorityChangeWindow.xaml deleted file mode 100644 index 33ed54bb4..000000000 --- a/Flow.Launcher/PriorityChangeWindow.xaml +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Flow.Launcher/PriorityChangeWindow.xaml.cs b/Flow.Launcher/PriorityChangeWindow.xaml.cs deleted file mode 100644 index fbe2a941d..000000000 --- a/Flow.Launcher/PriorityChangeWindow.xaml.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Flow.Launcher.Core.Plugin; -using Flow.Launcher.Core.Resource; -using Flow.Launcher.Plugin; -using Flow.Launcher.ViewModel; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using Flow.Launcher.Core; - -namespace Flow.Launcher -{ - /// - /// Interaction Logic of PriorityChangeWindow.xaml - /// - public partial class PriorityChangeWindow : Window - { - private readonly PluginPair plugin; - private readonly Internationalization translater = InternationalizationManager.Instance; - private readonly PluginViewModel pluginViewModel; - public PriorityChangeWindow(string pluginId, PluginViewModel pluginViewModel) - { - InitializeComponent(); - plugin = PluginManager.GetPluginForId(pluginId); - this.pluginViewModel = pluginViewModel; - if (plugin == null) - { - App.API.ShowMsgBox(translater.GetTranslation("cannotFindSpecifiedPlugin")); - Close(); - } - } - - private void BtnCancel_OnClick(object sender, RoutedEventArgs e) - { - Close(); - } - - private void btnDone_OnClick(object sender, RoutedEventArgs e) - { - if (int.TryParse(tbAction.Text.Trim(), out var newPriority)) - { - pluginViewModel.ChangePriority(newPriority); - Close(); - } - else - { - string msg = translater.GetTranslation("invalidPriority"); - App.API.ShowMsgBox(msg); - } - - } - - private void PriorityChangeWindow_Loaded(object sender, RoutedEventArgs e) - { - tbAction.Text = pluginViewModel.Priority.ToString(); - tbAction.Focus(); - } - private void window_MouseDown(object sender, MouseButtonEventArgs e) /* for close hotkey popup */ - { - TextBox textBox = Keyboard.FocusedElement as TextBox; - if (textBox != null) - { - TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next); - textBox.MoveFocus(tRequest); - } - } - } -} diff --git a/Flow.Launcher/Resources/Controls/InstalledPluginDisplay.xaml b/Flow.Launcher/Resources/Controls/InstalledPluginDisplay.xaml index 5ba011fed..778f00160 100644 --- a/Flow.Launcher/Resources/Controls/InstalledPluginDisplay.xaml +++ b/Flow.Launcher/Resources/Controls/InstalledPluginDisplay.xaml @@ -70,7 +70,8 @@ Maximum="999" Minimum="-999" SpinButtonPlacementMode="Inline" - ToolTip="{DynamicResource priorityToolTip}" /> + ToolTip="{DynamicResource priorityToolTip}" + Value="{Binding Priority, Mode=TwoWay}" /> PluginPair.Metadata.Priority; set { - if (PluginPair.Metadata.Priority != value) - { - ChangePriority(value); - } + PluginPair.Metadata.Priority = value; + PluginSettingsObject.Priority = value; } } @@ -151,20 +149,6 @@ namespace Flow.Launcher.ViewModel OnPropertyChanged(nameof(SearchDelayTimeText)); } - public void ChangePriority(int newPriority) - { - PluginPair.Metadata.Priority = newPriority; - PluginSettingsObject.Priority = newPriority; - OnPropertyChanged(nameof(Priority)); - } - - [RelayCommand] - private void EditPluginPriority() - { - var priorityChangeWindow = new PriorityChangeWindow(PluginPair. Metadata.ID, this); - priorityChangeWindow.ShowDialog(); - } - [RelayCommand] private void OpenPluginDirectory() {