Skip to content

Commit 002c27f

Browse files
committed
Merge remote-tracking branch 'origin/dev' into ExplorerPathActionkeyword
2 parents 9d7ff08 + 04536c4 commit 002c27f

File tree

12 files changed

+44
-32
lines changed

12 files changed

+44
-32
lines changed

Flow.Launcher.Core/Plugin/JsonPRCModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ public class JsonRPCQueryResponseModel : JsonRPCResponseModel
5151

5252
public class JsonRPCRequestModel : JsonRPCModelBase
5353
{
54+
[JsonPropertyName("method")]
5455
public string Method { get; set; }
5556

57+
[JsonPropertyName("parameters")]
5658
public object[] Parameters { get; set; }
5759

5860
public override string ToString()

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public static class PluginManager
2121
private static IEnumerable<PluginPair> _contextMenuPlugins;
2222

2323
public static List<PluginPair> AllPlugins { get; private set; }
24-
public static readonly List<PluginPair> GlobalPlugins = new List<PluginPair>();
25-
public static readonly Dictionary<string, PluginPair> NonGlobalPlugins = new Dictionary<string, PluginPair>();
24+
public static readonly HashSet<PluginPair> GlobalPlugins = new();
25+
public static readonly Dictionary<string, PluginPair> NonGlobalPlugins = new ();
2626

2727
public static IPublicAPI API { private set; get; }
2828

@@ -118,7 +118,9 @@ public static async Task InitializePlugins(IPublicAPI api)
118118
_contextMenuPlugins = GetPluginsForInterface<IContextMenu>();
119119
foreach (var plugin in AllPlugins)
120120
{
121-
foreach (var actionKeyword in plugin.Metadata.ActionKeywords)
121+
// set distinct on each plugin's action keywords helps only firing global(*) and action keywords once where a plugin
122+
// has multiple global and action keywords because we will only add them here once.
123+
foreach (var actionKeyword in plugin.Metadata.ActionKeywords.Distinct())
122124
{
123125
switch (actionKeyword)
124126
{
@@ -141,7 +143,7 @@ public static async Task InitializePlugins(IPublicAPI api)
141143
}
142144
}
143145

144-
public static List<PluginPair> ValidPluginsForQuery(Query query)
146+
public static ICollection<PluginPair> ValidPluginsForQuery(Query query)
145147
{
146148
if (NonGlobalPlugins.ContainsKey(query.ActionKeyword))
147149
{
@@ -283,9 +285,7 @@ public static void RemoveActionKeyword(string id, string oldActionkeyword)
283285
if (oldActionkeyword == Query.GlobalPluginWildcardSign
284286
&& // Plugins may have multiple ActionKeywords that are global, eg. WebSearch
285287
plugin.Metadata.ActionKeywords
286-
.Where(x => x == Query.GlobalPluginWildcardSign)
287-
.ToList()
288-
.Count == 1)
288+
.Count(x => x == Query.GlobalPluginWildcardSign) == 1)
289289
{
290290
GlobalPlugins.Remove(plugin);
291291
}

Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public void UpdatePluginSettings(List<PluginMetadata> metadatas)
3030
metadata.ActionKeywords = settings.ActionKeywords;
3131
metadata.ActionKeyword = settings.ActionKeywords[0];
3232
}
33+
else
34+
{
35+
metadata.ActionKeywords = new List<string>();
36+
metadata.ActionKeyword = string.Empty;
37+
}
3338
metadata.Disabled = settings.Disabled;
3439
metadata.Priority = settings.Priority;
3540
}

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -494,21 +494,16 @@ private void QueryResults()
494494
}
495495
}, currentCancellationToken);
496496

497-
Task[] tasks = new Task[plugins.Count];
498-
try
497+
// plugins is ICollection, meaning LINQ will get the Count and preallocate Array
498+
499+
Task[] tasks = plugins.Select(plugin => plugin.Metadata.Disabled switch
499500
{
500-
for (var i = 0; i < plugins.Count; i++)
501-
{
502-
if (!plugins[i].Metadata.Disabled)
503-
{
504-
tasks[i] = QueryTask(plugins[i]);
505-
}
506-
else
507-
{
508-
tasks[i] = Task.CompletedTask; // Avoid Null
509-
}
510-
}
501+
false => QueryTask(plugin),
502+
true => Task.CompletedTask
503+
}).ToArray();
511504

505+
try
506+
{
512507
// Check the code, WhenAll will translate all type of IEnumerable or Collection to Array, so make an array at first
513508
await Task.WhenAll(tasks);
514509
}

Flow.Launcher/ViewModel/PluginViewModel.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Windows;
22
using System.Windows.Media;
33
using Flow.Launcher.Plugin;
4-
using Flow.Launcher.Core.Resource;
54
using Flow.Launcher.Infrastructure.Image;
65
using Flow.Launcher.Core.Plugin;
76

@@ -11,8 +10,6 @@ public class PluginViewModel : BaseModel
1110
{
1211
public PluginPair PluginPair { get; set; }
1312

14-
private readonly Internationalization _translator = InternationalizationManager.Instance;
15-
1613
public ImageSource Image => ImageLoader.Load(PluginPair.Metadata.IcoPath);
1714
public bool PluginState
1815
{
@@ -22,7 +19,7 @@ public bool PluginState
2219
PluginPair.Metadata.Disabled = !value;
2320
}
2421
}
25-
public Visibility ActionKeywordsVisibility => PluginPair.Metadata.ActionKeywords.Count > 1 ? Visibility.Collapsed : Visibility.Visible;
22+
public Visibility ActionKeywordsVisibility => PluginPair.Metadata.ActionKeywords.Count == 1 ? Visibility.Visible : Visibility.Collapsed;
2623
public string InitilizaTime => PluginPair.Metadata.InitTime.ToString() + "ms";
2724
public string QueryTime => PluginPair.Metadata.AvgQueryTime + "ms";
2825
public string ActionKeywordsText => string.Join(Query.ActionKeywordSeperater, PluginPair.Metadata.ActionKeywords);

Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
<system:String x:Key="flowlauncher_plugin_program_reindex">Reindex</system:String>
1414
<system:String x:Key="flowlauncher_plugin_program_indexing">Indexing</system:String>
1515
<system:String x:Key="flowlauncher_plugin_program_index_start">Index Start Menu</system:String>
16+
<system:String x:Key="flowlauncher_plugin_program_index_start_tooltip">When enabled, Flow will load programs from the start menu</system:String>
1617
<system:String x:Key="flowlauncher_plugin_program_index_registry">Index Registry</system:String>
18+
<system:String x:Key="flowlauncher_plugin_program_index_registry_tooltip">When enabled, Flow will load programs from the registry</system:String>
1719
<system:String x:Key="flowlauncher_plugin_program_enable_description">Enable Program Description</system:String>
20+
<system:String x:Key="flowlauncher_plugin_program_enable_description_tooltip">Disabling this will also stop Flow from searching via the program desciption</system:String>
1821
<system:String x:Key="flowlauncher_plugin_program_suffixes_header">Suffixes</system:String>
1922
<system:String x:Key="flowlauncher_plugin_program_max_depth_header">Max Depth</system:String>
2023

Plugins/Flow.Launcher.Plugin.Program/Languages/sk.xaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
<system:String x:Key="flowlauncher_plugin_program_suffixes">Prípony súborov</system:String>
1313
<system:String x:Key="flowlauncher_plugin_program_reindex">Reindexovať</system:String>
1414
<system:String x:Key="flowlauncher_plugin_program_indexing">Indexovanie</system:String>
15-
<system:String x:Key="flowlauncher_plugin_program_index_start">Indexovať Ponuku Štart</system:String>
16-
<system:String x:Key="flowlauncher_plugin_program_index_registry">Indexovať Registry</system:String>
15+
<system:String x:Key="flowlauncher_plugin_program_index_start">Indexovať ponuku Štart</system:String>
16+
<system:String x:Key="flowlauncher_plugin_program_index_start_tooltip">Ak je povolené, Flow načíta programy z ponuky Štart</system:String>
17+
<system:String x:Key="flowlauncher_plugin_program_index_registry">Indexovať databázu Registry</system:String>
18+
<system:String x:Key="flowlauncher_plugin_program_index_registry_tooltip">Ak je povolené, Flow načíta programy z databázy Registry</system:String>
19+
<system:String x:Key="flowlauncher_plugin_program_enable_description">Povoliť popis programu</system:String>
20+
<system:String x:Key="flowlauncher_plugin_program_enable_description_tooltip">Zakázaním tejto funkcie sa tiež zastaví vyhľadávanie popisu programu cez Flow</system:String>
1721
<system:String x:Key="flowlauncher_plugin_program_suffixes_header">Prípony</system:String>
1822
<system:String x:Key="flowlauncher_plugin_program_max_depth_header">Max. hĺbka</system:String>
1923

Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Flow.Launcher.Plugin.Program.Logger;
1818
using Rect = System.Windows.Rect;
1919
using Flow.Launcher.Plugin.SharedModels;
20+
using Flow.Launcher.Infrastructure.Logger;
2021

2122
namespace Flow.Launcher.Plugin.Program.Programs
2223
{
@@ -81,6 +82,11 @@ private void InitializeAppInfo()
8182

8283
Apps = new List<Application>().ToArray();
8384
}
85+
86+
if (Marshal.ReleaseComObject(stream) > 0)
87+
{
88+
Log.Error("Flow.Launcher.Plugin.Program.Programs.UWP", "AppxManifest.xml was leaked");
89+
}
8490
}
8591

8692

Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
</Grid.RowDefinitions>
1717
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Stretch">
1818
<StackPanel Orientation="Vertical" Width="250">
19-
<CheckBox Name="StartMenuEnabled" IsChecked="{Binding EnableStartMenuSource}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_start}" />
20-
<CheckBox Name="RegistryEnabled" IsChecked="{Binding EnableRegistrySource}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_registry}" />
21-
<CheckBox Name="DescriptionEnabled" IsChecked="{Binding EnableDescription}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_enable_description}" />
19+
<CheckBox Name="StartMenuEnabled" IsChecked="{Binding EnableStartMenuSource}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_start}" ToolTip="{DynamicResource flowlauncher_plugin_program_index_start_tooltip}" />
20+
<CheckBox Name="RegistryEnabled" IsChecked="{Binding EnableRegistrySource}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_registry}" ToolTip="{DynamicResource flowlauncher_plugin_program_index_registry_tooltip}" />
21+
<CheckBox Name="DescriptionEnabled" IsChecked="{Binding EnableDescription}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_enable_description}" ToolTip="{DynamicResource flowlauncher_plugin_program_enable_description_tooltip}" />
2222
</StackPanel>
2323
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
2424
<Button Height="31" HorizontalAlignment="Right" Margin="10" Width="100" x:Name="btnLoadAllProgramSource" Click="btnLoadAllProgramSource_OnClick" Content="{DynamicResource flowlauncher_plugin_program_all_programs}" />

Plugins/Flow.Launcher.Plugin.Program/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "Program",
55
"Description": "Search programs in Flow.Launcher",
66
"Author": "qianlifeng",
7-
"Version": "1.5.0",
7+
"Version": "1.5.3",
88
"Language": "csharp",
99
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1010
"ExecuteFileName": "Flow.Launcher.Plugin.Program.dll",

0 commit comments

Comments
 (0)