Skip to content

Commit 7868703

Browse files
authored
Merge branch 'dev' into welcome_backspace_issue
2 parents 8ce4bd9 + 424b575 commit 7868703

File tree

24 files changed

+257
-26
lines changed

24 files changed

+257
-26
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/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.101" />
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: 6 additions & 1 deletion
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";
@@ -157,6 +157,11 @@ public void Save()
157157
Settings?.Save();
158158
}
159159

160+
public bool NeedCreateSettingPanel()
161+
{
162+
return Settings.NeedCreateSettingPanel();
163+
}
164+
160165
public Control CreateSettingPanel()
161166
{
162167
return Settings.CreateSettingPanel();

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 null;
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 };

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using Flow.Launcher.Infrastructure;
1313
using Flow.Launcher.Infrastructure.Logger;
1414
using Flow.Launcher.Infrastructure.UserSettings;
15-
using CommunityToolkit.Mvvm.DependencyInjection;
1615
using Flow.Launcher.Plugin;
1716

1817
namespace Flow.Launcher.Core.Resource
@@ -35,6 +34,8 @@ public class Theme
3534
private string DirectoryPath => Path.Combine(Constant.ProgramDirectory, Folder);
3635
private string UserDirectoryPath => Path.Combine(DataLocation.DataDirectory(), Folder);
3736

37+
public string CurrentTheme => _settings.Theme;
38+
3839
public bool BlurEnabled { get; set; }
3940

4041
private double mainWindowWidth;

Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<PrivateAssets>all</PrivateAssets>
6060
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6161
</PackageReference>
62-
<PackageReference Include="MemoryPack" Version="1.21.3" />
62+
<PackageReference Include="MemoryPack" Version="1.21.4" />
6363
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="17.12.19" />
6464
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.106">
6565
<PrivateAssets>all</PrivateAssets>

Flow.Launcher.Infrastructure/Logger/Log.cs

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,45 @@ static Log()
4848
configuration.AddTarget("file", fileTargetASyncWrapper);
4949
configuration.AddTarget("debug", debugTarget);
5050

51+
var fileRule = new LoggingRule("*", LogLevel.Debug, fileTargetASyncWrapper)
52+
{
53+
RuleName = "file"
54+
};
5155
#if DEBUG
52-
var fileRule = new LoggingRule("*", LogLevel.Debug, fileTargetASyncWrapper);
53-
var debugRule = new LoggingRule("*", LogLevel.Debug, debugTarget);
56+
var debugRule = new LoggingRule("*", LogLevel.Debug, debugTarget)
57+
{
58+
RuleName = "debug"
59+
};
5460
configuration.LoggingRules.Add(debugRule);
55-
#else
56-
var fileRule = new LoggingRule("*", LogLevel.Info, fileTargetASyncWrapper);
5761
#endif
5862
configuration.LoggingRules.Add(fileRule);
5963
LogManager.Configuration = configuration;
6064
}
6165

66+
public static void SetLogLevel(LOGLEVEL level)
67+
{
68+
switch (level)
69+
{
70+
case LOGLEVEL.DEBUG:
71+
UseDebugLogLevel();
72+
break;
73+
default:
74+
UseInfoLogLevel();
75+
break;
76+
}
77+
Info(nameof(Logger), $"Using log level: {level}.");
78+
}
79+
80+
private static void UseDebugLogLevel()
81+
{
82+
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal);
83+
}
84+
85+
private static void UseInfoLogLevel()
86+
{
87+
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Info, LogLevel.Fatal);
88+
}
89+
6290
private static void LogFaultyFormat(string message)
6391
{
6492
var logger = LogManager.GetLogger("FaultyLogger");
@@ -206,4 +234,10 @@ public static void Warn(string message)
206234
LogInternal(message, LogLevel.Warn);
207235
}
208236
}
237+
238+
public enum LOGLEVEL
239+
{
240+
DEBUG,
241+
INFO
242+
}
209243
}

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Windows;
66
using CommunityToolkit.Mvvm.DependencyInjection;
77
using Flow.Launcher.Infrastructure.Hotkey;
8+
using Flow.Launcher.Infrastructure.Logger;
89
using Flow.Launcher.Infrastructure.Storage;
910
using Flow.Launcher.Plugin;
1011
using Flow.Launcher.Plugin.SharedModels;
@@ -199,6 +200,9 @@ public CustomBrowserViewModel CustomBrowser
199200
}
200201
};
201202

203+
[JsonConverter(typeof(JsonStringEnumConverter))]
204+
public LOGLEVEL LogLevel { get; set; } = LOGLEVEL.INFO;
205+
202206
/// <summary>
203207
/// when false Alphabet static service will always return empty results
204208
/// </summary>

Flow.Launcher/App.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ private async void OnStartupAsync(object sender, StartupEventArgs e)
113113
{
114114
await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
115115
{
116+
Log.SetLogLevel(_settings.LogLevel);
117+
116118
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
117119

118120
Log.Info("|App.OnStartup|Begin Flow Launcher startup ----------------------------------------------------");

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
<PackageReference Include="NHotkey.Wpf" Version="3.0.0" />
105105
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" />
106106
<PackageReference Include="SemanticVersioning" Version="3.0.0" />
107-
<PackageReference Include="Jack251970.TaskScheduler" Version="2.12.1" />
107+
<PackageReference Include="TaskScheduler" Version="2.12.1" />
108108
<PackageReference Include="VirtualizingWrapPanel" Version="2.1.1" />
109109
</ItemGroup>
110110

0 commit comments

Comments
 (0)