Skip to content

Commit f14f671

Browse files
authored
Merge branch 'dev' into quickswitch
2 parents d59ad87 + ba28621 commit f14f671

Some content is hidden

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

42 files changed

+1661
-178
lines changed

Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace Flow.Launcher.Core.Plugin
1414
{
15-
public class JsonRPCPluginSettings
15+
public class JsonRPCPluginSettings : ISavable
1616
{
1717
public required JsonRpcConfigurationModel? Configuration { get; init; }
1818

Flow.Launcher.Core/Resource/TranslationConverter.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

Flow.Launcher.Infrastructure/Http/Http.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,18 @@ public static async Task<HttpResponseMessage> SendAsync(HttpRequestMessage reque
220220
return new HttpResponseMessage(HttpStatusCode.InternalServerError);
221221
}
222222
}
223+
224+
public static async Task<string> GetStringAsync(string url, CancellationToken token = default)
225+
{
226+
try
227+
{
228+
Log.Debug(ClassName, $"Url <{url}>");
229+
return await client.GetStringAsync(url, token);
230+
}
231+
catch (System.Exception e)
232+
{
233+
return string.Empty;
234+
}
235+
}
223236
}
224237
}

Flow.Launcher.Infrastructure/Storage/FlowLauncherJsonStorage.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
using System.Threading.Tasks;
33
using Flow.Launcher.Infrastructure.Logger;
44
using Flow.Launcher.Infrastructure.UserSettings;
5+
using Flow.Launcher.Plugin;
56
using Flow.Launcher.Plugin.SharedCommands;
67

78
namespace Flow.Launcher.Infrastructure.Storage
89
{
9-
public class FlowLauncherJsonStorage<T> : JsonStorage<T> where T : new()
10+
// Expose ISaveable interface in derived class to make sure we are calling the new version of Save method
11+
public class FlowLauncherJsonStorage<T> : JsonStorage<T>, ISavable where T : new()
1012
{
1113
private static readonly string ClassName = "FlowLauncherJsonStorage";
1214

Flow.Launcher.Infrastructure/Storage/PluginBinaryStorage.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using System.IO;
22
using System.Threading.Tasks;
33
using Flow.Launcher.Infrastructure.Logger;
4+
using Flow.Launcher.Plugin;
45
using Flow.Launcher.Plugin.SharedCommands;
56

67
namespace Flow.Launcher.Infrastructure.Storage
78
{
8-
public class PluginBinaryStorage<T> : BinaryStorage<T> where T : new()
9+
// Expose ISaveable interface in derived class to make sure we are calling the new version of Save method
10+
public class PluginBinaryStorage<T> : BinaryStorage<T>, ISavable where T : new()
911
{
1012
private static readonly string ClassName = "PluginBinaryStorage";
1113

Flow.Launcher.Infrastructure/Storage/PluginJsonStorage.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
using System.Threading.Tasks;
33
using Flow.Launcher.Infrastructure.Logger;
44
using Flow.Launcher.Infrastructure.UserSettings;
5+
using Flow.Launcher.Plugin;
56
using Flow.Launcher.Plugin.SharedCommands;
67

78
namespace Flow.Launcher.Infrastructure.Storage
89
{
9-
public class PluginJsonStorage<T> : JsonStorage<T> where T : new()
10+
// Expose ISaveable interface in derived class to make sure we are calling the new version of Save method
11+
public class PluginJsonStorage<T> : JsonStorage<T>, ISavable where T : new()
1012
{
1113
// Use assembly name to check which plugin is using this storage
1214
public readonly string AssemblyName;

Flow.Launcher.Infrastructure/UserSettings/CustomShortcutModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Text.Json.Serialization;
33
using System.Threading.Tasks;
4+
using CommunityToolkit.Mvvm.DependencyInjection;
5+
using Flow.Launcher.Plugin;
46

57
namespace Flow.Launcher.Infrastructure.UserSettings
68
{
@@ -53,6 +55,12 @@ public class BaseBuiltinShortcutModel : ShortcutBaseModel
5355
{
5456
public string Description { get; set; }
5557

58+
public string LocalizedDescription => API.GetTranslation(Description);
59+
60+
// We should not initialize API in static constructor because it will create another API instance
61+
private static IPublicAPI api = null;
62+
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
63+
5664
public BaseBuiltinShortcutModel(string key, string description)
5765
{
5866
Key = key;

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public void Save()
3333
_storage.Save();
3434
}
3535

36-
private string _theme = Constant.DefaultTheme;
3736
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
3837
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
3938
public string ColorScheme { get; set; } = "System";
@@ -65,6 +64,7 @@ public string Language
6564
OnPropertyChanged();
6665
}
6766
}
67+
private string _theme = Constant.DefaultTheme;
6868
public string Theme
6969
{
7070
get => _theme;
@@ -80,6 +80,7 @@ public string Theme
8080
}
8181
public bool UseDropShadowEffect { get; set; } = true;
8282
public BackdropTypes BackdropType { get; set; } = BackdropTypes.None;
83+
public string ReleaseNotesVersion { get; set; } = string.Empty;
8384

8485
/* Appearance Settings. It should be separated from the setting later.*/
8586
public double WindowHeightSize { get; set; } = 42;

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ public interface IPublicAPI
8484
/// <param name="subTitle">Optional message subtitle</param>
8585
void ShowMsgError(string title, string subTitle = "");
8686

87+
/// <summary>
88+
/// Show the error message using Flow's standard error icon.
89+
/// </summary>
90+
/// <param name="title">Message title</param>
91+
/// <param name="buttonText">Message button content</param>
92+
/// <param name="buttonAction">Message button action</param>
93+
/// <param name="subTitle">Optional message subtitle</param>
94+
void ShowMsgErrorWithButton(string title, string buttonText, Action buttonAction, string subTitle = "");
95+
8796
/// <summary>
8897
/// Show the MainWindow when hiding
8998
/// </summary>
@@ -127,6 +136,27 @@ public interface IPublicAPI
127136
/// <param name="useMainWindowAsOwner">when true will use main windows as the owner</param>
128137
void ShowMsg(string title, string subTitle, string iconPath, bool useMainWindowAsOwner = true);
129138

139+
/// <summary>
140+
/// Show message box with button
141+
/// </summary>
142+
/// <param name="title">Message title</param>
143+
/// <param name="buttonText">Message button content</param>
144+
/// <param name="buttonAction">Message button action</param>
145+
/// <param name="subTitle">Message subtitle</param>
146+
/// <param name="iconPath">Message icon path (relative path to your plugin folder)</param>
147+
void ShowMsgWithButton(string title, string buttonText, Action buttonAction, string subTitle = "", string iconPath = "");
148+
149+
/// <summary>
150+
/// Show message box with button
151+
/// </summary>
152+
/// <param name="title">Message title</param>
153+
/// <param name="buttonText">Message button content</param>
154+
/// <param name="buttonAction">Message button action</param>
155+
/// <param name="subTitle">Message subtitle</param>
156+
/// <param name="iconPath">Message icon path (relative path to your plugin folder)</param>
157+
/// <param name="useMainWindowAsOwner">when true will use main windows as the owner</param>
158+
void ShowMsgWithButton(string title, string buttonText, Action buttonAction, string subTitle, string iconPath, bool useMainWindowAsOwner = true);
159+
130160
/// <summary>
131161
/// Open setting dialog
132162
/// </summary>

Flow.Launcher/App.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ await API.StopwatchLogInfoAsync(ClassName, "Startup cost", async () =>
172172
Current.Resources["SettingWindowFont"] = new FontFamily(_settings.SettingWindowFont);
173173
Current.Resources["ContentControlThemeFontFamily"] = new FontFamily(_settings.SettingWindowFont);
174174

175+
Notification.Install();
176+
175177
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
176178

177179
API.LogInfo(ClassName, "Begin Flow Launcher startup ----------------------------------------------------");

0 commit comments

Comments
 (0)