Skip to content

Commit e2a46ed

Browse files
Merge branch 'dev' into ImagePreview
2 parents 564721b + c56a275 commit e2a46ed

File tree

66 files changed

+4399
-1226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4399
-1226
lines changed

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ public interface IPublicAPI
183183
/// <param name="oldActionKeyword">The actionkeyword that is supposed to be removed</param>
184184
void RemoveActionKeyword(string pluginId, string oldActionKeyword);
185185

186+
/// <summary>
187+
/// Check whether specific ActionKeyword is assigned to any of the plugin
188+
/// </summary>
189+
/// <param name="actionKeyword">The actionkeyword for checking</param>
190+
/// <returns>True if the actionkeyword is already assigned, False otherwise</returns>
191+
bool ActionKeywordAssigned(string actionKeyword);
192+
186193
/// <summary>
187194
/// Log debug message
188195
/// Message will only be logged in Debug mode

Flow.Launcher.Test/Plugins/ExplorerTest.cs

Lines changed: 45 additions & 111 deletions
Large diffs are not rendered by default.

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/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public void Dispose()
183183

184184
public void OnSecondAppStarted()
185185
{
186-
Current.MainWindow.Show();
186+
_mainVM.Show();
187187
}
188188
}
189189
}

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ private void OnKeyDown(object sender, KeyEventArgs e)
610610
&& QueryTextBox.CaretIndex == QueryTextBox.Text.Length)
611611
{
612612
var queryWithoutActionKeyword =
613-
QueryBuilder.Build(QueryTextBox.Text.Trim(), PluginManager.NonGlobalPlugins).Search;
613+
QueryBuilder.Build(QueryTextBox.Text.Trim(), PluginManager.NonGlobalPlugins)?.Search;
614614

615615
if (FilesFolders.IsLocationPathString(queryWithoutActionKeyword))
616616
{

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/PublicAPIInstance.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ public Task HttpDownloadAsync([NotNull] string url, [NotNull] string filePath,
141141
public void AddActionKeyword(string pluginId, string newActionKeyword) =>
142142
PluginManager.AddActionKeyword(pluginId, newActionKeyword);
143143

144+
public bool ActionKeywordAssigned(string actionKeyword) => PluginManager.ActionKeywordRegistered(actionKeyword);
145+
144146
public void RemoveActionKeyword(string pluginId, string oldActionKeyword) =>
145147
PluginManager.RemoveActionKeyword(pluginId, oldActionKeyword);
146148

Flow.Launcher/SettingWindow.xaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@
11431143
x:Name="PriorityButton"
11441144
Margin="0,0,22,0"
11451145
VerticalAlignment="Center"
1146-
Click="OnPluginPriorityClick"
1146+
Command="{Binding EditPluginPriorityCommand}"
11471147
Content="{Binding Priority, UpdateSourceTrigger=PropertyChanged}"
11481148
Cursor="Hand"
11491149
ToolTip="{DynamicResource priorityToolTip}">
@@ -1221,8 +1221,8 @@
12211221
Height="34"
12221222
Margin="5,0,0,0"
12231223
HorizontalAlignment="Right"
1224-
Click="OnPluginActionKeywordsClick"
12251224
Content="{Binding ActionKeywordsText}"
1225+
Command="{Binding SetActionKeywordsCommand}"
12261226
Cursor="Hand"
12271227
DockPanel.Dock="Right"
12281228
FontWeight="Bold"
@@ -1371,9 +1371,14 @@
13711371
Cursor="Hand"
13721372
FontSize="11"
13731373
Foreground="{DynamicResource PluginInfoColor}"
1374-
MouseUp="OnPluginDirecotyClick"
13751374
Text="{DynamicResource pluginDirectory}"
1376-
TextDecorations="Underline" />
1375+
TextDecorations="Underline" >
1376+
<TextBlock.InputBindings>
1377+
<MouseBinding
1378+
Command="{Binding OpenPluginDirectoryCommand}"
1379+
MouseAction="LeftClick"/>
1380+
</TextBlock.InputBindings>
1381+
</TextBlock>
13771382
</StackPanel>
13781383

13791384
</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.MissingImage;
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
}

0 commit comments

Comments
 (0)