Skip to content

Commit 8f4d914

Browse files
authored
Merge branch 'dev' into ui_wpf_modern
2 parents ec13be9 + 1415df2 commit 8f4d914

File tree

132 files changed

+2991
-801
lines changed

Some content is hidden

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

132 files changed

+2991
-801
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: 33 additions & 9 deletions
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";
@@ -60,16 +59,20 @@ public string Language
6059
get => _language;
6160
set
6261
{
63-
_language = value;
64-
OnPropertyChanged();
62+
if (_language != value)
63+
{
64+
_language = value;
65+
OnPropertyChanged();
66+
}
6567
}
6668
}
69+
private string _theme = Constant.DefaultTheme;
6770
public string Theme
6871
{
6972
get => _theme;
7073
set
7174
{
72-
if (value != _theme)
75+
if (_theme != value)
7376
{
7477
_theme = value;
7578
OnPropertyChanged();
@@ -79,6 +82,7 @@ public string Theme
7982
}
8083
public bool UseDropShadowEffect { get; set; } = true;
8184
public BackdropTypes BackdropType{ get; set; } = BackdropTypes.None;
85+
public string ReleaseNotesVersion { get; set; } = string.Empty;
8286

8387
/* Appearance Settings. It should be separated from the setting later.*/
8488
public double WindowHeightSize { get; set; } = 42;
@@ -297,9 +301,12 @@ public SearchPrecisionScore QuerySearchPrecision
297301
get => _querySearchPrecision;
298302
set
299303
{
300-
_querySearchPrecision = value;
301-
if (_stringMatcher != null)
302-
_stringMatcher.UserSettingSearchPrecision = value;
304+
if (_querySearchPrecision != value)
305+
{
306+
_querySearchPrecision = value;
307+
if (_stringMatcher != null)
308+
_stringMatcher.UserSettingSearchPrecision = value;
309+
}
303310
}
304311
}
305312

@@ -366,13 +373,30 @@ public bool HideNotifyIcon
366373
get => _hideNotifyIcon;
367374
set
368375
{
369-
_hideNotifyIcon = value;
370-
OnPropertyChanged();
376+
if (_hideNotifyIcon != value)
377+
{
378+
_hideNotifyIcon = value;
379+
OnPropertyChanged();
380+
}
371381
}
372382
}
373383
public bool LeaveCmdOpen { get; set; }
374384
public bool HideWhenDeactivated { get; set; } = true;
375385

386+
private bool _showAtTopmost = true;
387+
public bool ShowAtTopmost
388+
{
389+
get => _showAtTopmost;
390+
set
391+
{
392+
if (_showAtTopmost != value)
393+
{
394+
_showAtTopmost = value;
395+
OnPropertyChanged();
396+
}
397+
}
398+
}
399+
376400
public bool SearchQueryResultsWithDelay { get; set; }
377401
public int SearchDelayTime { get; set; } = 150;
378402

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
@@ -171,6 +171,8 @@ await API.StopwatchLogInfoAsync(ClassName, "Startup cost", async () =>
171171
Current.Resources["SettingWindowFont"] = new FontFamily(_settings.SettingWindowFont);
172172
Current.Resources["ContentControlThemeFontFamily"] = new FontFamily(_settings.SettingWindowFont);
173173

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

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

0 commit comments

Comments
 (0)