Skip to content

Commit db5bc41

Browse files
authored
Merge branch 'dev' into processkiller_orderby_windowtitle
2 parents b2532fc + 424b575 commit db5bc41

File tree

161 files changed

+3091
-1839
lines changed

Some content is hidden

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

161 files changed

+3091
-1839
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ updates:
88
- package-ecosystem: "nuget" # See documentation for possible values
99
directory: "/" # Location of package manifests
1010
schedule:
11-
interval: "weekly"
11+
interval: "daily"
12+
open-pull-requests-limit: 3
1213
ignore:
1314
- dependency-name: "squirrel-windows"
1415
reviewers:

Flow.Launcher.Core/Configuration/Portable.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99
using Flow.Launcher.Infrastructure.UserSettings;
1010
using Flow.Launcher.Plugin.SharedCommands;
1111
using System.Linq;
12+
using CommunityToolkit.Mvvm.DependencyInjection;
13+
using Flow.Launcher.Plugin;
1214

1315
namespace Flow.Launcher.Core.Configuration
1416
{
1517
public class Portable : IPortable
1618
{
19+
private readonly IPublicAPI API = Ioc.Default.GetRequiredService<IPublicAPI>();
20+
1721
/// <summary>
1822
/// As at Squirrel.Windows version 1.5.2, UpdateManager needs to be disposed after finish
1923
/// </summary>
@@ -40,7 +44,7 @@ public void DisablePortableMode()
4044
#endif
4145
IndicateDeletion(DataLocation.PortableDataPath);
4246

43-
MessageBoxEx.Show("Flow Launcher needs to restart to finish disabling portable mode, " +
47+
API.ShowMsgBox("Flow Launcher needs to restart to finish disabling portable mode, " +
4448
"after the restart your portable data profile will be deleted and roaming data profile kept");
4549

4650
UpdateManager.RestartApp(Constant.ApplicationFileName);
@@ -64,7 +68,7 @@ public void EnablePortableMode()
6468
#endif
6569
IndicateDeletion(DataLocation.RoamingDataPath);
6670

67-
MessageBoxEx.Show("Flow Launcher needs to restart to finish enabling portable mode, " +
71+
API.ShowMsgBox("Flow Launcher needs to restart to finish enabling portable mode, " +
6872
"after the restart your roaming data profile will be deleted and portable data profile kept");
6973

7074
UpdateManager.RestartApp(Constant.ApplicationFileName);
@@ -95,13 +99,13 @@ public void RemoveUninstallerEntry()
9599

96100
public void MoveUserDataFolder(string fromLocation, string toLocation)
97101
{
98-
FilesFolders.CopyAll(fromLocation, toLocation, MessageBoxEx.Show);
102+
FilesFolders.CopyAll(fromLocation, toLocation, (s) => API.ShowMsgBox(s));
99103
VerifyUserDataAfterMove(fromLocation, toLocation);
100104
}
101105

102106
public void VerifyUserDataAfterMove(string fromLocation, string toLocation)
103107
{
104-
FilesFolders.VerifyBothFolderFilesEqual(fromLocation, toLocation, MessageBoxEx.Show);
108+
FilesFolders.VerifyBothFolderFilesEqual(fromLocation, toLocation, (s) => API.ShowMsgBox(s));
105109
}
106110

107111
public void CreateShortcuts()
@@ -157,13 +161,13 @@ public void PreStartCleanUpAfterPortabilityUpdate()
157161
// delete it and prompt the user to pick the portable data location
158162
if (File.Exists(roamingDataDeleteFilePath))
159163
{
160-
FilesFolders.RemoveFolderIfExists(roamingDataDir, MessageBoxEx.Show);
164+
FilesFolders.RemoveFolderIfExists(roamingDataDir, (s) => API.ShowMsgBox(s));
161165

162-
if (MessageBoxEx.Show("Flow Launcher has detected you enabled portable mode, " +
166+
if (API.ShowMsgBox("Flow Launcher has detected you enabled portable mode, " +
163167
"would you like to move it to a different location?", string.Empty,
164168
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
165169
{
166-
FilesFolders.OpenPath(Constant.RootDirectory, MessageBoxEx.Show);
170+
FilesFolders.OpenPath(Constant.RootDirectory, (s) => API.ShowMsgBox(s));
167171

168172
Environment.Exit(0);
169173
}
@@ -172,9 +176,9 @@ public void PreStartCleanUpAfterPortabilityUpdate()
172176
// delete it and notify the user about it.
173177
else if (File.Exists(portableDataDeleteFilePath))
174178
{
175-
FilesFolders.RemoveFolderIfExists(portableDataDir, MessageBoxEx.Show);
179+
FilesFolders.RemoveFolderIfExists(portableDataDir, (s) => API.ShowMsgBox(s));
176180

177-
MessageBoxEx.Show("Flow Launcher has detected you disabled portable mode, " +
181+
API.ShowMsgBox("Flow Launcher has detected you disabled portable mode, " +
178182
"the relevant shortcuts and uninstaller entry have been created");
179183
}
180184
}
@@ -186,7 +190,7 @@ public bool CanUpdatePortability()
186190

187191
if (roamingLocationExists && portableLocationExists)
188192
{
189-
MessageBoxEx.Show(string.Format("Flow Launcher detected your user data exists both in {0} and " +
193+
API.ShowMsgBox(string.Format("Flow Launcher detected your user data exists both in {0} and " +
190194
"{1}. {2}{2}Please delete {1} in order to proceed. No changes have occurred.",
191195
DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine));
192196

Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
using System.Windows;
99
using System.Windows.Forms;
1010
using Flow.Launcher.Core.Resource;
11+
using CommunityToolkit.Mvvm.DependencyInjection;
1112

1213
namespace Flow.Launcher.Core.ExternalPlugins.Environments
1314
{
1415
public abstract class AbstractPluginEnvironment
1516
{
17+
protected readonly IPublicAPI API = Ioc.Default.GetRequiredService<IPublicAPI>();
18+
1619
internal abstract string Language { get; }
1720

1821
internal abstract string EnvName { get; }
@@ -25,7 +28,7 @@ public abstract class AbstractPluginEnvironment
2528

2629
internal virtual string FileDialogFilter => string.Empty;
2730

28-
internal abstract string PluginsSettingsFilePath { get; set; }
31+
internal abstract string PluginsSettingsFilePath { get; set; }
2932

3033
internal List<PluginMetadata> PluginMetadataList;
3134

@@ -57,7 +60,7 @@ internal IEnumerable<PluginPair> Setup()
5760
EnvName,
5861
Environment.NewLine
5962
);
60-
if (MessageBoxEx.Show(noRuntimeMessage, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
63+
if (API.ShowMsgBox(noRuntimeMessage, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
6164
{
6265
var msg = string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginChooseRuntimeExecutable"), EnvName);
6366
string selectedFile;
@@ -82,7 +85,7 @@ internal IEnumerable<PluginPair> Setup()
8285
}
8386
else
8487
{
85-
MessageBoxEx.Show(string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language));
88+
API.ShowMsgBox(string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language));
8689
Log.Error("PluginsLoader",
8790
$"Not able to successfully set {EnvName} path, setting's plugin executable path variable is still an empty string.",
8891
$"{Language}Environment");
@@ -98,7 +101,7 @@ private void EnsureLatestInstalled(string expectedPath, string currentPath, stri
98101
if (expectedPath == currentPath)
99102
return;
100103

101-
FilesFolders.RemoveFolderIfExists(installedDirPath, MessageBoxEx.Show);
104+
FilesFolders.RemoveFolderIfExists(installedDirPath, (s) => API.ShowMsgBox(s));
102105

103106
InstallEnvironment();
104107

Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal PythonEnvironment(List<PluginMetadata> pluginMetadataList, PluginsSetti
2828

2929
internal override void InstallEnvironment()
3030
{
31-
FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
31+
FilesFolders.RemoveFolderIfExists(InstallPath, (s) => API.ShowMsgBox(s));
3232

3333
// Python 3.11.4 is no longer Windows 7 compatible. If user is on Win 7 and
3434
// uses Python plugin they need to custom install and use v3.8.9

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal TypeScriptEnvironment(List<PluginMetadata> pluginMetadataList, PluginsS
2525

2626
internal override void InstallEnvironment()
2727
{
28-
FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
28+
FilesFolders.RemoveFolderIfExists(InstallPath, (s) => API.ShowMsgBox(s));
2929

3030
DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath).Wait();
3131

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal TypeScriptV2Environment(List<PluginMetadata> pluginMetadataList, Plugin
2525

2626
internal override void InstallEnvironment()
2727
{
28-
FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
28+
FilesFolders.RemoveFolderIfExists(InstallPath, (s) => API.ShowMsgBox(s));
2929

3030
DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath).Wait();
3131

Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Flow.Launcher.Infrastructure.Logger;
1+
using Flow.Launcher.Infrastructure.Logger;
22
using System;
33
using System.Collections.Generic;
44
using System.Threading;
@@ -21,7 +21,7 @@ public static class PluginsManifest
2121

2222
public static List<UserPlugin> UserPlugins { get; private set; }
2323

24-
public static async Task UpdateManifestAsync(CancellationToken token = default, bool usePrimaryUrlOnly = false)
24+
public static async Task<bool> UpdateManifestAsync(CancellationToken token = default, bool usePrimaryUrlOnly = false)
2525
{
2626
try
2727
{
@@ -31,8 +31,14 @@ public static async Task UpdateManifestAsync(CancellationToken token = default,
3131
{
3232
var results = await mainPluginStore.FetchAsync(token, usePrimaryUrlOnly).ConfigureAwait(false);
3333

34-
UserPlugins = results;
35-
lastFetchedAt = DateTime.Now;
34+
// If the results are empty, we shouldn't update the manifest because the results are invalid.
35+
if (results.Count != 0)
36+
{
37+
UserPlugins = results;
38+
lastFetchedAt = DateTime.Now;
39+
40+
return true;
41+
}
3642
}
3743
}
3844
catch (Exception e)
@@ -43,6 +49,8 @@ public static async Task UpdateManifestAsync(CancellationToken token = default,
4349
{
4450
manifestUpdateLock.Release();
4551
}
52+
53+
return false;
4654
}
4755
}
4856
}

Flow.Launcher.Core/Flow.Launcher.Core.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@
5454

5555
<ItemGroup>
5656
<PackageReference Include="Droplex" Version="1.7.0" />
57-
<PackageReference Include="FSharp.Core" Version="9.0.100" />
57+
<PackageReference Include="FSharp.Core" Version="9.0.201" />
5858
<PackageReference Include="Meziantou.Framework.Win32.Jobs" Version="3.4.0" />
5959
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
6060
<PackageReference Include="squirrel.windows" Version="1.5.2" NoWarn="NU1701" />
61-
<PackageReference Include="StreamJsonRpc" Version="2.20.20" />
61+
<PackageReference Include="StreamJsonRpc" Version="2.21.10" />
6262
</ItemGroup>
6363

6464
<ItemGroup>

Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace Flow.Launcher.Core.Plugin
3434
/// Represent the plugin that using JsonPRC
3535
/// every JsonRPC plugin should has its own plugin instance
3636
/// </summary>
37-
internal abstract class JsonRPCPluginBase : IAsyncPlugin, IContextMenu, ISettingProvider, ISavable
37+
public abstract class JsonRPCPluginBase : IAsyncPlugin, IContextMenu, ISettingProvider, ISavable
3838
{
3939
protected PluginInitContext Context;
4040
public const string JsonRPC = "JsonRPC";
@@ -44,8 +44,10 @@ internal abstract class JsonRPCPluginBase : IAsyncPlugin, IContextMenu, ISetting
4444
private string SettingConfigurationPath =>
4545
Path.Combine(Context.CurrentPluginMetadata.PluginDirectory, "SettingsTemplate.yaml");
4646

47-
private string SettingPath => Path.Combine(DataLocation.PluginSettingsDirectory,
48-
Context.CurrentPluginMetadata.Name, "Settings.json");
47+
private string SettingDirectory => Path.Combine(DataLocation.PluginSettingsDirectory,
48+
Context.CurrentPluginMetadata.Name);
49+
50+
private string SettingPath => Path.Combine(SettingDirectory, "Settings.json");
4951

5052
public abstract List<Result> LoadContextMenus(Result selectedResult);
5153

@@ -155,9 +157,22 @@ public void Save()
155157
Settings?.Save();
156158
}
157159

160+
public bool NeedCreateSettingPanel()
161+
{
162+
return Settings.NeedCreateSettingPanel();
163+
}
164+
158165
public Control CreateSettingPanel()
159166
{
160167
return Settings.CreateSettingPanel();
161168
}
169+
170+
public void DeletePluginSettingsDirectory()
171+
{
172+
if (Directory.Exists(SettingDirectory))
173+
{
174+
Directory.Delete(SettingDirectory, true);
175+
}
176+
}
162177
}
163178
}

Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,15 @@ public void Save()
109109
_storage.Save();
110110
}
111111

112+
public bool NeedCreateSettingPanel()
113+
{
114+
// If there are no settings or the settings configuration is empty, return null
115+
return Settings != null && Configuration != null && Configuration.Body.Count != 0;
116+
}
117+
112118
public Control CreateSettingPanel()
113119
{
114-
if (Settings == null || Settings.Count == 0)
115-
return new();
120+
// No need to check if NeedCreateSettingPanel is true because CreateSettingPanel will only be called if it's true
116121

117122
var settingWindow = new UserControl();
118123
var mainPanel = new Grid { Margin = settingPanelMargin, VerticalAlignment = VerticalAlignment.Center };

0 commit comments

Comments
 (0)