diff --git a/Flow.Launcher/ActionKeywords.xaml.cs b/Flow.Launcher/ActionKeywords.xaml.cs
index e116e6f4d..012c9ff4e 100644
--- a/Flow.Launcher/ActionKeywords.xaml.cs
+++ b/Flow.Launcher/ActionKeywords.xaml.cs
@@ -8,24 +8,17 @@ using Flow.Launcher.ViewModel;
namespace Flow.Launcher
{
- public partial class ActionKeywords : Window
+ public partial class ActionKeywords
{
private readonly PluginPair plugin;
- private Settings settings;
private readonly Internationalization translater = InternationalizationManager.Instance;
private readonly PluginViewModel pluginViewModel;
- public ActionKeywords(string pluginId, Settings settings, PluginViewModel pluginViewModel)
+ public ActionKeywords(PluginViewModel pluginViewModel)
{
InitializeComponent();
- plugin = PluginManager.GetPluginForId(pluginId);
- this.settings = settings;
+ plugin = pluginViewModel.PluginPair;
this.pluginViewModel = pluginViewModel;
- if (plugin == null)
- {
- MessageBox.Show(translater.GetTranslation("cannotFindSpecifiedPlugin"));
- Close();
- }
}
private void ActionKeyword_OnLoaded(object sender, RoutedEventArgs e)
diff --git a/Flow.Launcher/PriorityChangeWindow.xaml.cs b/Flow.Launcher/PriorityChangeWindow.xaml.cs
index fe846e78b..e2fe46adc 100644
--- a/Flow.Launcher/PriorityChangeWindow.xaml.cs
+++ b/Flow.Launcher/PriorityChangeWindow.xaml.cs
@@ -1,6 +1,5 @@
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Core.Resource;
-using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using Flow.Launcher.ViewModel;
using System;
@@ -23,14 +22,12 @@ namespace Flow.Launcher
public partial class PriorityChangeWindow : Window
{
private readonly PluginPair plugin;
- private Settings settings;
private readonly Internationalization translater = InternationalizationManager.Instance;
private readonly PluginViewModel pluginViewModel;
- public PriorityChangeWindow(string pluginId, Settings settings, PluginViewModel pluginViewModel)
+ public PriorityChangeWindow(string pluginId, PluginViewModel pluginViewModel)
{
InitializeComponent();
plugin = PluginManager.GetPluginForId(pluginId);
- this.settings = settings;
this.pluginViewModel = pluginViewModel;
if (plugin == null)
{
@@ -74,4 +71,4 @@ namespace Flow.Launcher
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml
index 8d702fcf5..f7955dd22 100644
--- a/Flow.Launcher/SettingWindow.xaml
+++ b/Flow.Launcher/SettingWindow.xaml
@@ -1127,7 +1127,7 @@
x:Name="PriorityButton"
Margin="0,0,22,0"
VerticalAlignment="Center"
- Click="OnPluginPriorityClick"
+ Command="{Binding EditPluginPriorityCommand}"
Content="{Binding Priority, UpdateSourceTrigger=PropertyChanged}"
Cursor="Hand"
ToolTip="{DynamicResource priorityToolTip}">
@@ -1205,8 +1205,8 @@
Height="34"
Margin="5,0,0,0"
HorizontalAlignment="Right"
- Click="OnPluginActionKeywordsClick"
Content="{Binding ActionKeywordsText}"
+ Command="{Binding SetActionKeywordsCommand}"
Cursor="Hand"
DockPanel.Dock="Right"
FontWeight="Bold"
@@ -1355,9 +1355,14 @@
Cursor="Hand"
FontSize="11"
Foreground="{DynamicResource PluginInfoColor}"
- MouseUp="OnPluginDirecotyClick"
Text="{DynamicResource pluginDirectory}"
- TextDecorations="Underline" />
+ TextDecorations="Underline" >
+
+
+
+
diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs
index d178be77c..b9dbac0f9 100644
--- a/Flow.Launcher/SettingWindow.xaml.cs
+++ b/Flow.Launcher/SettingWindow.xaml.cs
@@ -5,7 +5,6 @@ using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
-using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.ViewModel;
using ModernWpf;
using ModernWpf.Controls;
@@ -18,7 +17,6 @@ using System.Windows.Data;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Interop;
-using System.Windows.Media;
using System.Windows.Navigation;
using Button = System.Windows.Controls.Button;
using Control = System.Windows.Controls.Control;
@@ -189,44 +187,11 @@ namespace Flow.Launcher
{
if (sender is Control { DataContext: PluginViewModel pluginViewModel })
{
- PriorityChangeWindow priorityChangeWindow = new PriorityChangeWindow(pluginViewModel.PluginPair.Metadata.ID, settings, pluginViewModel);
+ PriorityChangeWindow priorityChangeWindow = new PriorityChangeWindow(pluginViewModel.PluginPair.Metadata.ID, pluginViewModel);
priorityChangeWindow.ShowDialog();
}
}
- private void OnPluginActionKeywordsClick(object sender, RoutedEventArgs e)
- {
- var id = viewModel.SelectedPlugin.PluginPair.Metadata.ID;
- ActionKeywords changeKeywordsWindow = new ActionKeywords(id, settings, viewModel.SelectedPlugin);
- changeKeywordsWindow.ShowDialog();
- }
-
- private void OnPluginNameClick(object sender, MouseButtonEventArgs e)
- {
- if (e.ChangedButton == MouseButton.Left)
- {
- var website = viewModel.SelectedPlugin.PluginPair.Metadata.Website;
- if (!string.IsNullOrEmpty(website))
- {
- var uri = new Uri(website);
- if (Uri.CheckSchemeName(uri.Scheme))
- {
- website.OpenInBrowserTab();
- }
- }
- }
- }
-
- private void OnPluginDirecotyClick(object sender, MouseButtonEventArgs e)
- {
- if (e.ChangedButton == MouseButton.Left)
- {
- var directory = viewModel.SelectedPlugin.PluginPair.Metadata.PluginDirectory;
- if (!string.IsNullOrEmpty(directory))
- PluginManager.API.OpenDirectory(directory);
- }
- }
-
#endregion
#region Proxy
@@ -297,22 +262,6 @@ namespace Flow.Launcher
}
}
- private static T FindParent(DependencyObject child) where T : DependencyObject
- {
- //get parent item
- DependencyObject parentObject = VisualTreeHelper.GetParent(child);
-
- //we've reached the end of the tree
- if (parentObject == null) return null;
-
- //check if the parent matches the type we're looking for
- T parent = parentObject as T;
- if (parent != null)
- return parent;
- else
- return FindParent(parentObject);
- }
-
private void OnExternalPluginInstallClick(object sender, RoutedEventArgs e)
{
if (sender is not Button { DataContext: PluginStoreItemViewModel plugin } button)
@@ -335,8 +284,6 @@ namespace Flow.Launcher
var name = viewModel.SelectedPlugin.PluginPair.Metadata.Name;
viewModel.DisplayPluginQuery($"uninstall {name}", PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7"));
}
-
-
}
private void OnExternalPluginUninstallClick(object sender, RoutedEventArgs e)
diff --git a/Flow.Launcher/ViewModel/PluginViewModel.cs b/Flow.Launcher/ViewModel/PluginViewModel.cs
index 725857e2f..9871ceb93 100644
--- a/Flow.Launcher/ViewModel/PluginViewModel.cs
+++ b/Flow.Launcher/ViewModel/PluginViewModel.cs
@@ -5,10 +5,11 @@ using Flow.Launcher.Plugin;
using Flow.Launcher.Infrastructure.Image;
using Flow.Launcher.Core.Plugin;
using System.Windows.Controls;
+using CommunityToolkit.Mvvm.Input;
namespace Flow.Launcher.ViewModel
{
- public class PluginViewModel : BaseModel
+ public partial class PluginViewModel : BaseModel
{
private readonly PluginPair _pluginPair;
public PluginPair PluginPair
@@ -53,6 +54,7 @@ namespace Flow.Launcher.ViewModel
set
{
_isExpanded = value;
+
OnPropertyChanged();
OnPropertyChanged(nameof(SettingControl));
}
@@ -60,12 +62,12 @@ namespace Flow.Launcher.ViewModel
private Control _settingControl;
private bool _isExpanded;
- public Control SettingControl
+ public Control SettingControl
=> IsExpanded
? _settingControl
??= PluginPair.Plugin is not ISettingProvider settingProvider
- ? new Control()
- : settingProvider.CreateSettingPanel()
+ ? new Control()
+ : settingProvider.CreateSettingPanel()
: null;
private ImageSource _image = ImageLoader.DefaultImage;
@@ -87,7 +89,29 @@ namespace Flow.Launcher.ViewModel
OnPropertyChanged(nameof(Priority));
}
+ [RelayCommand]
+ private void EditPluginPriority()
+ {
+ PriorityChangeWindow priorityChangeWindow = new PriorityChangeWindow(PluginPair.Metadata.ID, this);
+ priorityChangeWindow.ShowDialog();
+ }
+
+ [RelayCommand]
+ private void OpenPluginDirectory()
+ {
+ var directory = PluginPair.Metadata.PluginDirectory;
+ if (!string.IsNullOrEmpty(directory))
+ PluginManager.API.OpenDirectory(directory);
+ }
+
public static bool IsActionKeywordRegistered(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword);
+
+ [RelayCommand]
+ private void SetActionKeywords()
+ {
+ ActionKeywords changeKeywordsWindow = new ActionKeywords(this);
+ changeKeywordsWindow.ShowDialog();
+ }
}
}
diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs
index f63a5e5bf..a97a328e6 100644
--- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs
+++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs
@@ -356,6 +356,8 @@ namespace Flow.Launcher.ViewModel
await PluginsManifest.UpdateManifestAsync();
OnPropertyChanged(nameof(ExternalPlugins));
}
+
+
internal void DisplayPluginQuery(string queryToDisplay, PluginPair plugin, int actionKeywordPosition = 0)
{