From 80b77754125da1db6da8d8fadf872dd0c01ec1c5 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 4 Jul 2025 10:50:50 +0800 Subject: [PATCH 1/4] Return results when query is empty for program --- Plugins/Flow.Launcher.Plugin.Program/Main.cs | 2 +- Plugins/Flow.Launcher.Plugin.Program/Programs/UWPPackage.cs | 3 +-- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs index d28845994..fd687bfae 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs @@ -104,7 +104,7 @@ namespace Flow.Launcher.Plugin.Program .Where(p => HideDuplicatedWindowsAppFilter(p, uwpsDirectories)) .Where(p => p.Enabled) .Select(p => p.Result(query.Search, Context.API)) - .Where(r => r?.Score > 0) + .Where(r => string.IsNullOrEmpty(query.Search) || r?.Score > 0) .ToList(); } catch (OperationCanceledException) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWPPackage.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWPPackage.cs index cb33250e1..f67111b4e 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWPPackage.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWPPackage.cs @@ -424,7 +424,7 @@ namespace Flow.Launcher.Plugin.Program.Programs } } - if (!matchResult.IsSearchPrecisionScoreMet()) + if (!matchResult.IsSearchPrecisionScoreMet() && !string.IsNullOrEmpty(query)) return null; var result = new Result @@ -468,7 +468,6 @@ namespace Flow.Launcher.Plugin.Program.Programs } }; - return result; } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index a87b002d4..7aca8f3b6 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -136,7 +136,7 @@ namespace Flow.Launcher.Plugin.Program.Programs List candidates = new List(); - if (!matchResult.IsSearchPrecisionScoreMet()) + if (!matchResult.IsSearchPrecisionScoreMet() && !string.IsNullOrEmpty(query)) { if (ExecutableName != null) // only lnk program will need this one { From 5b2b272f7665993a03dc58264b513136008f9736 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 5 Jul 2025 13:35:02 +0800 Subject: [PATCH 2/4] Add ActualApplicationThemeChanged in MainViewModel --- Flow.Launcher.Plugin/EventHandler.cs | 20 +++++++++++++++++++- Flow.Launcher/ViewModel/MainViewModel.cs | 15 +++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher.Plugin/EventHandler.cs b/Flow.Launcher.Plugin/EventHandler.cs index 893b0ba80..47ab24757 100644 --- a/Flow.Launcher.Plugin/EventHandler.cs +++ b/Flow.Launcher.Plugin/EventHandler.cs @@ -39,7 +39,14 @@ namespace Flow.Launcher.Plugin /// /// public delegate void VisibilityChangedEventHandler(object sender, VisibilityChangedEventArgs args); - + + /// + /// A delegate for when the actual application theme is changed + /// + /// + /// + public delegate void ActualApplicationThemeChangedEventHandler(object sender, ActualApplicationThemeChangedEventArgs args); + /// /// The event args for /// @@ -77,4 +84,15 @@ namespace Flow.Launcher.Plugin /// public Query Query { get; set; } } + + /// + /// The event args for + /// + public class ActualApplicationThemeChangedEventArgs : EventArgs + { + /// + /// if the application has changed actual theme + /// + public bool IsDark { get; init; } + } } diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 64a39fa62..49f7ea6c5 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -22,6 +22,7 @@ using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.Storage; using Microsoft.VisualStudio.Threading; +using ModernWpf; namespace Flow.Launcher.ViewModel { @@ -195,6 +196,18 @@ namespace Flow.Launcher.ViewModel RegisterViewUpdate(); _ = RegisterClockAndDateUpdateAsync(); + + ThemeManager.Current.ActualApplicationThemeChanged += ThemeManager_ActualApplicationThemeChanged; + } + + private void ThemeManager_ActualApplicationThemeChanged(ThemeManager sender, object args) + { + ActualApplicationThemeChanged?.Invoke( + Application.Current, + new ActualApplicationThemeChangedEventArgs() + { + IsDark = sender.ActualApplicationTheme == ApplicationTheme.Dark + }); } private void RegisterViewUpdate() @@ -821,6 +834,7 @@ namespace Flow.Launcher.ViewModel public bool MainWindowVisibilityStatus { get; set; } = true; public event VisibilityChangedEventHandler VisibilityChanged; + public event ActualApplicationThemeChangedEventHandler ActualApplicationThemeChanged; public Visibility ClockPanelVisibility { get; set; } public Visibility SearchIconVisibility { get; set; } @@ -1975,6 +1989,7 @@ namespace Flow.Launcher.ViewModel { _resultsViewUpdateTask.Dispose(); } + ThemeManager.Current.ActualApplicationThemeChanged -= ThemeManager_ActualApplicationThemeChanged; _disposed = true; } } From d7d17a93cd82578bec27ac712d073243b427e4f8 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 5 Jul 2025 13:35:17 +0800 Subject: [PATCH 3/4] Use ActualApplicationThemeChanged in MainWindow --- Flow.Launcher/MainWindow.xaml.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index f4d7ad8eb..aa5040dac 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -20,6 +20,7 @@ using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Hotkey; using Flow.Launcher.Infrastructure.Image; using Flow.Launcher.Infrastructure.UserSettings; +using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.ViewModel; using Microsoft.Win32; @@ -91,8 +92,8 @@ namespace Flow.Launcher InitSoundEffects(); DataObject.AddPastingHandler(QueryTextBox, QueryTextBox_OnPaste); - ModernWpf.ThemeManager.Current.ActualApplicationThemeChanged += ThemeManager_ActualApplicationThemeChanged; SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; + _viewModel.ActualApplicationThemeChanged += ViewModel_ActualApplicationThemeChanged; } #endregion @@ -101,7 +102,7 @@ namespace Flow.Launcher #pragma warning disable VSTHRD100 // Avoid async void methods - private void ThemeManager_ActualApplicationThemeChanged(ModernWpf.ThemeManager sender, object args) + private void ViewModel_ActualApplicationThemeChanged(object sender, ActualApplicationThemeChangedEventArgs args) { _ = _theme.RefreshFrameAsync(); } @@ -1351,7 +1352,7 @@ namespace Flow.Launcher _notifyIcon?.Dispose(); animationSoundWMP?.Close(); animationSoundWPF?.Dispose(); - ModernWpf.ThemeManager.Current.ActualApplicationThemeChanged -= ThemeManager_ActualApplicationThemeChanged; + _viewModel.ActualApplicationThemeChanged -= ViewModel_ActualApplicationThemeChanged; SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged; } From d1a5cc8e843b32a094a03d5aa157c1989ee39fcb Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 5 Jul 2025 13:35:28 +0800 Subject: [PATCH 4/4] Add theme mode api functions --- Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 11 +++++++++++ Flow.Launcher/PublicAPIInstance.cs | 18 +++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index f47ee5e11..1827354d0 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -595,5 +595,16 @@ namespace Flow.Launcher.Plugin /// /// The time taken to execute the method in milliseconds public Task StopwatchLogInfoAsync(string className, string message, Func action, [CallerMemberName] string methodName = ""); + + /// + /// Representing whether the application is using a dark theme + /// + /// + bool IsApplicationDarkTheme(); + + /// + /// Invoked when the actual theme of the application has changed. Currently, the plugin will continue to be subscribed even if it is turned off. + /// + event ActualApplicationThemeChangedEventHandler ActualApplicationThemeChanged; } } diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 6e82032ff..a2e5f1f85 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -14,23 +14,24 @@ using System.Windows; using System.Windows.Media; using CommunityToolkit.Mvvm.DependencyInjection; using Flow.Launcher.Core; +using Flow.Launcher.Core.ExternalPlugins; using Flow.Launcher.Core.Plugin; using Flow.Launcher.Core.Resource; -using Flow.Launcher.Core.ExternalPlugins; using Flow.Launcher.Core.Storage; using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure; -using Flow.Launcher.Infrastructure.Http; using Flow.Launcher.Infrastructure.Hotkey; +using Flow.Launcher.Infrastructure.Http; using Flow.Launcher.Infrastructure.Image; using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Storage; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; -using Flow.Launcher.Plugin.SharedModels; using Flow.Launcher.Plugin.SharedCommands; +using Flow.Launcher.Plugin.SharedModels; using Flow.Launcher.ViewModel; using JetBrains.Annotations; +using ModernWpf; using Squirrel; using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch; @@ -587,6 +588,17 @@ namespace Flow.Launcher public Task StopwatchLogInfoAsync(string className, string message, Func action, [CallerMemberName] string methodName = "") => Stopwatch.InfoAsync(className, message, action, methodName); + public bool IsApplicationDarkTheme() + { + return ThemeManager.Current.ActualApplicationTheme == ApplicationTheme.Dark; + } + + public event ActualApplicationThemeChangedEventHandler ActualApplicationThemeChanged + { + add => _mainVM.ActualApplicationThemeChanged += value; + remove => _mainVM.ActualApplicationThemeChanged -= value; + } + #endregion #region Private Methods