Skip to content

Commit 4d712a1

Browse files
authored
Merge pull request #1519 from Flow-Launcher/pluginlist_unselected_item
2 parents 03ba623 + 9edfa37 commit 4d712a1

File tree

6 files changed

+45
-77
lines changed

6 files changed

+45
-77
lines changed

Flow.Launcher/ActionKeywords.xaml.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,17 @@
88

99
namespace Flow.Launcher
1010
{
11-
public partial class ActionKeywords : Window
11+
public partial class ActionKeywords
1212
{
1313
private readonly PluginPair plugin;
14-
private Settings settings;
1514
private readonly Internationalization translater = InternationalizationManager.Instance;
1615
private readonly PluginViewModel pluginViewModel;
1716

18-
public ActionKeywords(string pluginId, Settings settings, PluginViewModel pluginViewModel)
17+
public ActionKeywords(PluginViewModel pluginViewModel)
1918
{
2019
InitializeComponent();
21-
plugin = PluginManager.GetPluginForId(pluginId);
22-
this.settings = settings;
20+
plugin = pluginViewModel.PluginPair;
2321
this.pluginViewModel = pluginViewModel;
24-
if (plugin == null)
25-
{
26-
MessageBox.Show(translater.GetTranslation("cannotFindSpecifiedPlugin"));
27-
Close();
28-
}
2922
}
3023

3124
private void ActionKeyword_OnLoaded(object sender, RoutedEventArgs e)

Flow.Launcher/PriorityChangeWindow.xaml.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Flow.Launcher.Core.Plugin;
22
using Flow.Launcher.Core.Resource;
3-
using Flow.Launcher.Infrastructure.UserSettings;
43
using Flow.Launcher.Plugin;
54
using Flow.Launcher.ViewModel;
65
using System;
@@ -23,14 +22,12 @@ namespace Flow.Launcher
2322
public partial class PriorityChangeWindow : Window
2423
{
2524
private readonly PluginPair plugin;
26-
private Settings settings;
2725
private readonly Internationalization translater = InternationalizationManager.Instance;
2826
private readonly PluginViewModel pluginViewModel;
29-
public PriorityChangeWindow(string pluginId, Settings settings, PluginViewModel pluginViewModel)
27+
public PriorityChangeWindow(string pluginId, PluginViewModel pluginViewModel)
3028
{
3129
InitializeComponent();
3230
plugin = PluginManager.GetPluginForId(pluginId);
33-
this.settings = settings;
3431
this.pluginViewModel = pluginViewModel;
3532
if (plugin == null)
3633
{
@@ -74,4 +71,4 @@ private void PriorityChangeWindow_Loaded(object sender, RoutedEventArgs e)
7471
}
7572
}
7673
}
77-
}
74+
}

Flow.Launcher/SettingWindow.xaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@
11271127
x:Name="PriorityButton"
11281128
Margin="0,0,22,0"
11291129
VerticalAlignment="Center"
1130-
Click="OnPluginPriorityClick"
1130+
Command="{Binding EditPluginPriorityCommand}"
11311131
Content="{Binding Priority, UpdateSourceTrigger=PropertyChanged}"
11321132
Cursor="Hand"
11331133
ToolTip="{DynamicResource priorityToolTip}">
@@ -1205,8 +1205,8 @@
12051205
Height="34"
12061206
Margin="5,0,0,0"
12071207
HorizontalAlignment="Right"
1208-
Click="OnPluginActionKeywordsClick"
12091208
Content="{Binding ActionKeywordsText}"
1209+
Command="{Binding SetActionKeywordsCommand}"
12101210
Cursor="Hand"
12111211
DockPanel.Dock="Right"
12121212
FontWeight="Bold"
@@ -1355,9 +1355,14 @@
13551355
Cursor="Hand"
13561356
FontSize="11"
13571357
Foreground="{DynamicResource PluginInfoColor}"
1358-
MouseUp="OnPluginDirecotyClick"
13591358
Text="{DynamicResource pluginDirectory}"
1360-
TextDecorations="Underline" />
1359+
TextDecorations="Underline" >
1360+
<TextBlock.InputBindings>
1361+
<MouseBinding
1362+
Command="{Binding OpenPluginDirectoryCommand}"
1363+
MouseAction="LeftClick"/>
1364+
</TextBlock.InputBindings>
1365+
</TextBlock>
13611366
</StackPanel>
13621367

13631368
</ItemsControl>

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Flow.Launcher.Infrastructure.Hotkey;
66
using Flow.Launcher.Infrastructure.UserSettings;
77
using Flow.Launcher.Plugin;
8-
using Flow.Launcher.Plugin.SharedCommands;
98
using Flow.Launcher.ViewModel;
109
using ModernWpf;
1110
using ModernWpf.Controls;
@@ -18,7 +17,6 @@
1817
using System.Windows.Forms;
1918
using System.Windows.Input;
2019
using System.Windows.Interop;
21-
using System.Windows.Media;
2220
using System.Windows.Navigation;
2321
using Button = System.Windows.Controls.Button;
2422
using Control = System.Windows.Controls.Control;
@@ -189,44 +187,11 @@ private void OnPluginPriorityClick(object sender, RoutedEventArgs e)
189187
{
190188
if (sender is Control { DataContext: PluginViewModel pluginViewModel })
191189
{
192-
PriorityChangeWindow priorityChangeWindow = new PriorityChangeWindow(pluginViewModel.PluginPair.Metadata.ID, settings, pluginViewModel);
190+
PriorityChangeWindow priorityChangeWindow = new PriorityChangeWindow(pluginViewModel.PluginPair.Metadata.ID, pluginViewModel);
193191
priorityChangeWindow.ShowDialog();
194192
}
195193
}
196194

197-
private void OnPluginActionKeywordsClick(object sender, RoutedEventArgs e)
198-
{
199-
var id = viewModel.SelectedPlugin.PluginPair.Metadata.ID;
200-
ActionKeywords changeKeywordsWindow = new ActionKeywords(id, settings, viewModel.SelectedPlugin);
201-
changeKeywordsWindow.ShowDialog();
202-
}
203-
204-
private void OnPluginNameClick(object sender, MouseButtonEventArgs e)
205-
{
206-
if (e.ChangedButton == MouseButton.Left)
207-
{
208-
var website = viewModel.SelectedPlugin.PluginPair.Metadata.Website;
209-
if (!string.IsNullOrEmpty(website))
210-
{
211-
var uri = new Uri(website);
212-
if (Uri.CheckSchemeName(uri.Scheme))
213-
{
214-
website.OpenInBrowserTab();
215-
}
216-
}
217-
}
218-
}
219-
220-
private void OnPluginDirecotyClick(object sender, MouseButtonEventArgs e)
221-
{
222-
if (e.ChangedButton == MouseButton.Left)
223-
{
224-
var directory = viewModel.SelectedPlugin.PluginPair.Metadata.PluginDirectory;
225-
if (!string.IsNullOrEmpty(directory))
226-
PluginManager.API.OpenDirectory(directory);
227-
}
228-
}
229-
230195
#endregion
231196

232197
#region Proxy
@@ -297,22 +262,6 @@ private void ClearLogFolder(object sender, RoutedEventArgs e)
297262
}
298263
}
299264

300-
private static T FindParent<T>(DependencyObject child) where T : DependencyObject
301-
{
302-
//get parent item
303-
DependencyObject parentObject = VisualTreeHelper.GetParent(child);
304-
305-
//we've reached the end of the tree
306-
if (parentObject == null) return null;
307-
308-
//check if the parent matches the type we're looking for
309-
T parent = parentObject as T;
310-
if (parent != null)
311-
return parent;
312-
else
313-
return FindParent<T>(parentObject);
314-
}
315-
316265
private void OnExternalPluginInstallClick(object sender, RoutedEventArgs e)
317266
{
318267
if (sender is not Button { DataContext: PluginStoreItemViewModel plugin } button)
@@ -335,8 +284,6 @@ private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs
335284
var name = viewModel.SelectedPlugin.PluginPair.Metadata.Name;
336285
viewModel.DisplayPluginQuery($"uninstall {name}", PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7"));
337286
}
338-
339-
340287
}
341288

342289
private void OnExternalPluginUninstallClick(object sender, RoutedEventArgs e)

Flow.Launcher/ViewModel/PluginViewModel.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
using Flow.Launcher.Infrastructure.Image;
66
using Flow.Launcher.Core.Plugin;
77
using System.Windows.Controls;
8+
using CommunityToolkit.Mvvm.Input;
89

910
namespace Flow.Launcher.ViewModel
1011
{
11-
public class PluginViewModel : BaseModel
12+
public partial class PluginViewModel : BaseModel
1213
{
1314
private readonly PluginPair _pluginPair;
1415
public PluginPair PluginPair
@@ -53,19 +54,20 @@ public bool IsExpanded
5354
set
5455
{
5556
_isExpanded = value;
57+
5658
OnPropertyChanged();
5759
OnPropertyChanged(nameof(SettingControl));
5860
}
5961
}
6062

6163
private Control _settingControl;
6264
private bool _isExpanded;
63-
public Control SettingControl
65+
public Control SettingControl
6466
=> IsExpanded
6567
? _settingControl
6668
??= PluginPair.Plugin is not ISettingProvider settingProvider
67-
? new Control()
68-
: settingProvider.CreateSettingPanel()
69+
? new Control()
70+
: settingProvider.CreateSettingPanel()
6971
: null;
7072
private ImageSource _image = ImageLoader.DefaultImage;
7173

@@ -87,7 +89,29 @@ public void ChangePriority(int newPriority)
8789
OnPropertyChanged(nameof(Priority));
8890
}
8991

92+
[RelayCommand]
93+
private void EditPluginPriority()
94+
{
95+
PriorityChangeWindow priorityChangeWindow = new PriorityChangeWindow(PluginPair.Metadata.ID, this);
96+
priorityChangeWindow.ShowDialog();
97+
}
98+
99+
[RelayCommand]
100+
private void OpenPluginDirectory()
101+
{
102+
var directory = PluginPair.Metadata.PluginDirectory;
103+
if (!string.IsNullOrEmpty(directory))
104+
PluginManager.API.OpenDirectory(directory);
105+
}
106+
90107
public static bool IsActionKeywordRegistered(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword);
108+
109+
[RelayCommand]
110+
private void SetActionKeywords()
111+
{
112+
ActionKeywords changeKeywordsWindow = new ActionKeywords(this);
113+
changeKeywordsWindow.ShowDialog();
114+
}
91115
}
92116

93117
}

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ private async Task RefreshExternalPluginsAsync()
356356
await PluginsManifest.UpdateManifestAsync();
357357
OnPropertyChanged(nameof(ExternalPlugins));
358358
}
359+
360+
359361

360362
internal void DisplayPluginQuery(string queryToDisplay, PluginPair plugin, int actionKeywordPosition = 0)
361363
{

0 commit comments

Comments
 (0)