From f485e8605a14361bdd6417eba0b5bf2d6a92b0cc Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 29 Mar 2025 13:10:06 +0800 Subject: [PATCH 01/13] Support placeholder text --- .../UserSettings/Settings.cs | 11 +++++ Flow.Launcher/Languages/en.xaml | 4 +- Flow.Launcher/MainWindow.xaml | 8 ++++ Flow.Launcher/MainWindow.xaml.cs | 43 +++++++++++++++++++ .../ViewModels/SettingsPaneThemeViewModel.cs | 6 +++ .../SettingPages/Views/SettingsPaneTheme.xaml | 15 +++++-- 6 files changed, 83 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 63debfb474c..38c4fbe114d 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -113,6 +113,17 @@ public string Theme public double? SettingWindowLeft { get; set; } = null; public System.Windows.WindowState SettingWindowState { get; set; } = WindowState.Normal; + bool _showPlaceholder { get; set; } = true; + public bool ShowPlaceholder + { + get => _showPlaceholder; + set + { + _showPlaceholder = value; + OnPropertyChanged(); + } + } + public int CustomExplorerIndex { get; set; } = 0; [JsonIgnore] diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index f0454b49633..f4e2d88afff 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -39,7 +39,7 @@ Game Mode Suspend the use of Hotkeys. Position Reset - Reset search window position + Type here to search Settings @@ -202,6 +202,8 @@ Date This theme supports two(light/dark) modes. This theme supports Blur Transparent Background. + Placeholder Text + Display placeholder text when query is empty Hotkey diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 533819d1730..b9e355e2f99 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -218,6 +218,14 @@ + Settings.SoundVolume = value; } + public bool ShowPlaceholder + { + get => Settings.ShowPlaceholder; + set => Settings.ShowPlaceholder = value; + } + public bool UseClock { get => Settings.UseClock; diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml index 6142371469d..5b92ee9b961 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml @@ -477,7 +477,6 @@ - - - + + + + + From a4dac91093960175e48aec20f9186f545ec7c228 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 29 Mar 2025 13:25:00 +0800 Subject: [PATCH 02/13] Support resize window --- .../UserSettings/Settings.cs | 13 ++++++++++++- Flow.Launcher/Languages/en.xaml | 12 +++++++----- Flow.Launcher/MainWindow.xaml.cs | 15 +++++++++++++++ .../ViewModels/SettingsPaneThemeViewModel.cs | 6 ++++++ .../SettingPages/Views/SettingsPaneTheme.xaml | 19 +++++++++++++++++-- 5 files changed, 57 insertions(+), 8 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 38c4fbe114d..cae5d977f6e 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -113,7 +113,18 @@ public string Theme public double? SettingWindowLeft { get; set; } = null; public System.Windows.WindowState SettingWindowState { get; set; } = WindowState.Normal; - bool _showPlaceholder { get; set; } = true; + bool _resizeWindow { get; set; } = true; + public bool ResizeWindow + { + get => _resizeWindow; + set + { + _resizeWindow = value; + OnPropertyChanged(); + } + } + + bool _showPlaceholder { get; set; } = false; public bool ShowPlaceholder { get => _showPlaceholder; diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index f4e2d88afff..656431e786d 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -104,11 +104,6 @@ Always Preview Always open preview panel when Flow activates. Press {0} to toggle preview. Shadow effect is not allowed while current theme has blur effect enabled - Backdrop Type - None - Acrylic - Mica - Mica Alt Search Plugin @@ -200,10 +195,17 @@ Custom Clock Date + Backdrop Type + None + Acrylic + Mica + Mica Alt This theme supports two(light/dark) modes. This theme supports Blur Transparent Background. Placeholder Text Display placeholder text when query is empty + Allow window size change + Allow dragging the search window edges to change its size Hotkey diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 85eff3a576e..097ce7df4fa 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -115,6 +115,9 @@ private async void OnLoaded(object sender, RoutedEventArgs _) welcomeWindow.Show(); } + // Initialize resize mode + SetupResizeMode(); + // Initialize place holder SetupPlaceholderText(); @@ -243,6 +246,9 @@ private async void OnLoaded(object sender, RoutedEventArgs _) case nameof(Settings.ShowPlaceholder): SetupPlaceholderText(); break; + case nameof(Settings.ResizeWindow): + SetupResizeMode(); + break; } }; @@ -1071,6 +1077,15 @@ private void SetPlaceholderText() #endregion + #region Resize Mode + + private void SetupResizeMode() + { + ResizeMode = _settings.ResizeWindow ? ResizeMode.CanResize : ResizeMode.NoResize; + } + + #endregion + #region IDisposable protected virtual void Dispose(bool disposing) diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs index 6e83d487a94..9c32e9bb94a 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs @@ -259,6 +259,12 @@ public double SoundEffectVolume set => Settings.SoundVolume = value; } + public bool ResizeWindow + { + get => Settings.ResizeWindow; + set => Settings.ResizeWindow = value; + } + public bool ShowPlaceholder { get => Settings.ShowPlaceholder; diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml index 5b92ee9b961..3abf46f09ee 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml @@ -30,6 +30,7 @@ VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.ScrollUnit="Pixel"> + + @@ -260,7 +262,8 @@ - + + - + + + + + + Date: Sat, 29 Mar 2025 14:15:24 +0800 Subject: [PATCH 03/13] Support change resize boarder thinkness --- Flow.Launcher.Core/Resource/Theme.cs | 41 +++++++++++++++++++--------- Flow.Launcher/MainWindow.xaml.cs | 14 +++++++--- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index 48900261730..44802aa916e 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -24,7 +24,7 @@ public class Theme { #region Properties & Fields - public bool BlurEnabled { get; set; } + public bool BlurEnabled { get; private set; } private const string ThemeMetadataNamePrefix = "Name:"; private const string ThemeMetadataIsDarkPrefix = "IsDark:"; @@ -42,6 +42,8 @@ public class Theme private static string DirectoryPath => Path.Combine(Constant.ProgramDirectory, Folder); private static string UserDirectoryPath => Path.Combine(DataLocation.DataDirectory(), Folder); + private Thickness _themeResizeBorderThickness; + #endregion #region Constructor @@ -463,7 +465,7 @@ public void AddDropShadowEffectToCurrentTheme() var effectSetter = new Setter { - Property = Border.EffectProperty, + Property = UIElement.EffectProperty, Value = new DropShadowEffect { Opacity = 0.3, @@ -473,12 +475,12 @@ public void AddDropShadowEffectToCurrentTheme() } }; - if (windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == Border.MarginProperty) is not Setter marginSetter) + if (windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == FrameworkElement.MarginProperty) is not Setter marginSetter) { var margin = new Thickness(ShadowExtraMargin, 12, ShadowExtraMargin, ShadowExtraMargin); marginSetter = new Setter() { - Property = Border.MarginProperty, + Property = FrameworkElement.MarginProperty, Value = margin, }; windowBorderStyle.Setters.Add(marginSetter); @@ -508,12 +510,12 @@ public void RemoveDropShadowEffectFromCurrentTheme() var dict = GetCurrentResourceDictionary(); var windowBorderStyle = dict["WindowBorderStyle"] as Style; - if (windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == Border.EffectProperty) is Setter effectSetter) + if (windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == UIElement.EffectProperty) is Setter effectSetter) { windowBorderStyle.Setters.Remove(effectSetter); } - if (windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == Border.MarginProperty) is Setter marginSetter) + if (windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == FrameworkElement.MarginProperty) is Setter marginSetter) { var currentMargin = (Thickness)marginSetter.Value; var newMargin = new Thickness( @@ -529,28 +531,41 @@ public void RemoveDropShadowEffectFromCurrentTheme() UpdateResourceDictionary(dict); } + public void SetResizeBoarderThickness(WindowChrome windowChrome, bool resizeWindow) + { + if (resizeWindow) + { + windowChrome.ResizeBorderThickness = _themeResizeBorderThickness; + } + else + { + windowChrome.ResizeBorderThickness = new Thickness(0); + } + } + // because adding drop shadow effect will change the margin of the window, // we need to update the window chrome thickness to correct set the resize border - private static void SetResizeBoarderThickness(Thickness? effectMargin) + private void SetResizeBoarderThickness(Thickness? effectMargin) { var window = Application.Current.MainWindow; if (WindowChrome.GetWindowChrome(window) is WindowChrome windowChrome) { - Thickness thickness; + // Save the theme resize border thickness so that we can restore it if we change ResizeWindow setting if (effectMargin == null) { - thickness = SystemParameters.WindowResizeBorderThickness; + _themeResizeBorderThickness = SystemParameters.WindowResizeBorderThickness; } else { - thickness = new Thickness( + _themeResizeBorderThickness = new Thickness( effectMargin.Value.Left + SystemParameters.WindowResizeBorderThickness.Left, effectMargin.Value.Top + SystemParameters.WindowResizeBorderThickness.Top, effectMargin.Value.Right + SystemParameters.WindowResizeBorderThickness.Right, effectMargin.Value.Bottom + SystemParameters.WindowResizeBorderThickness.Bottom); } - windowChrome.ResizeBorderThickness = thickness; + // Apply the resize border thickness to the window chrome + SetResizeBoarderThickness(windowChrome, _settings.ResizeWindow); } } @@ -582,7 +597,7 @@ await Application.Current.Dispatcher.InvokeAsync(() => { AutoDropShadow(useDropShadowEffect); } - }, DispatcherPriority.Normal); + }, DispatcherPriority.Render); } /// @@ -596,7 +611,7 @@ await Application.Current.Dispatcher.InvokeAsync(() => var (backdropType, _) = GetActualValue(); SetBlurForWindow(GetCurrentTheme(), backdropType); - }, DispatcherPriority.Normal); + }, DispatcherPriority.Render); } /// diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 097ce7df4fa..ce34aef1f74 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -11,6 +11,7 @@ using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; +using System.Windows.Shell; using System.Windows.Threading; using CommunityToolkit.Mvvm.DependencyInjection; using Flow.Launcher.Core.Plugin; @@ -115,9 +116,6 @@ private async void OnLoaded(object sender, RoutedEventArgs _) welcomeWindow.Show(); } - // Initialize resize mode - SetupResizeMode(); - // Initialize place holder SetupPlaceholderText(); @@ -152,13 +150,17 @@ private async void OnLoaded(object sender, RoutedEventArgs _) UpdatePosition(); // Refresh frame - await Ioc.Default.GetRequiredService().RefreshFrameAsync(); + await _theme.RefreshFrameAsync(); + + // Initialize resize mode after refreshing frame + SetupResizeMode(); // Reset preview _viewModel.ResetPreview(); // Since the default main window visibility is visible, so we need set focus during startup QueryTextBox.Focus(); + // Set the initial state of the QueryTextBoxCursorMovedToEnd property // Without this part, when shown for the first time, switching the context menu does not move the cursor to the end. _viewModel.QueryTextCursorMovedToEnd = false; @@ -1082,6 +1084,10 @@ private void SetPlaceholderText() private void SetupResizeMode() { ResizeMode = _settings.ResizeWindow ? ResizeMode.CanResize : ResizeMode.NoResize; + if (WindowChrome.GetWindowChrome(this) is WindowChrome windowChrome) + { + _theme.SetResizeBoarderThickness(windowChrome, _settings.ResizeWindow); + } } #endregion From c74dd200886b809c709f63e13a83e52098b93b1f Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 29 Mar 2025 14:15:35 +0800 Subject: [PATCH 04/13] Remove ThemeManager.Instance --- Flow.Launcher.Core/Resource/ThemeManager.cs | 12 ------------ Flow.Launcher/App.xaml.cs | 1 - 2 files changed, 13 deletions(-) delete mode 100644 Flow.Launcher.Core/Resource/ThemeManager.cs diff --git a/Flow.Launcher.Core/Resource/ThemeManager.cs b/Flow.Launcher.Core/Resource/ThemeManager.cs deleted file mode 100644 index 3cbe8319ad3..00000000000 --- a/Flow.Launcher.Core/Resource/ThemeManager.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using CommunityToolkit.Mvvm.DependencyInjection; - -namespace Flow.Launcher.Core.Resource -{ - [Obsolete("ThemeManager.Instance is obsolete. Use Ioc.Default.GetRequiredService() instead.")] - public class ThemeManager - { - public static Theme Instance - => Ioc.Default.GetRequiredService(); - } -} diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 833c63ddff8..7b1d113fbdc 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -177,7 +177,6 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () => HotKeyMapper.Initialize(); // main windows needs initialized before theme change because of blur settings - // TODO: Clean ThemeManager.Instance in future Ioc.Default.GetRequiredService().ChangeTheme(); Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); From 84f2686710e937621ecdc7a864ad944fa4f89fe8 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 29 Mar 2025 15:08:49 +0800 Subject: [PATCH 05/13] Support placeholder size change --- .../UserSettings/Settings.cs | 10 ++++++ Flow.Launcher/Languages/en.xaml | 6 ++-- Flow.Launcher/MainWindow.xaml | 2 +- Flow.Launcher/MainWindow.xaml.cs | 4 +++ .../ViewModels/SettingsPaneThemeViewModel.cs | 6 ++++ .../SettingPages/Views/SettingsPaneTheme.xaml | 32 +++++++++++++------ Flow.Launcher/ViewModel/MainViewModel.cs | 18 +++++++++++ 7 files changed, 65 insertions(+), 13 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index cae5d977f6e..7c747ae3626 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -134,6 +134,16 @@ public bool ShowPlaceholder OnPropertyChanged(); } } + string _placeholderText { get; set; } = string.Empty; + public string PlaceholderText + { + get => _placeholderText; + set + { + _placeholderText = value; + OnPropertyChanged(); + } + } public int CustomExplorerIndex { get; set; } = 0; diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 656431e786d..a9c5ab49fcc 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -202,8 +202,10 @@ Mica Alt This theme supports two(light/dark) modes. This theme supports Blur Transparent Background. - Placeholder Text - Display placeholder text when query is empty + Show placeholder + Display placeholder when query is empty + Placeholder text + Change placeholder text. Input empty will use: Type here to search Allow window size change Allow dragging the search window edges to change its size diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index b9e355e2f99..82ac63b7da6 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -224,7 +224,7 @@ FontSize="{Binding QueryBoxFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="False" Style="{DynamicResource QuerySuggestionBoxStyle}" - Text="{DynamicResource queryTextBoxSuggestion}" + Text="{Binding PlaceholderText, Mode=OneWay}" Visibility="Collapsed" /> Settings.ShowPlaceholder = value; } + public string PlaceholderText + { + get => Settings.PlaceholderText; + set => Settings.PlaceholderText = value; + } + public bool UseClock { get => Settings.UseClock; diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml index 3abf46f09ee..462ea799e8d 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml @@ -70,6 +70,7 @@ + - - - + + + + + + + + + diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index c69fc4484a2..ec5b52c9dd0 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -765,6 +765,24 @@ private ResultsViewModel SelectedResults public double ClockPanelOpacity { get; set; } = 1; public double SearchIconOpacity { get; set; } = 1; + private string _placeholderText; + public string PlaceholderText + { + get => _placeholderText; + set + { + if (string.IsNullOrEmpty(value)) + { + _placeholderText = App.API.GetTranslation("queryTextBoxSuggestion"); + } + else + { + _placeholderText = value; + } + OnPropertyChanged(); + } + } + public double MainWindowWidth { get => Settings.WindowSize; From 91c5e84ca0f89d5ab0714ddcae86541c51b89778 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 29 Mar 2025 15:27:25 +0800 Subject: [PATCH 06/13] Integrate resize window to fixed window height --- Flow.Launcher.Core/Resource/Theme.cs | 10 ++-- .../UserSettings/Settings.cs | 56 +++++++++++-------- Flow.Launcher/Languages/en.xaml | 6 +- Flow.Launcher/MainWindow.xaml.cs | 6 +- .../ViewModels/SettingsPaneThemeViewModel.cs | 6 -- .../SettingPages/Views/SettingsPaneTheme.xaml | 22 +++----- 6 files changed, 51 insertions(+), 55 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index 44802aa916e..a1b2c3e0ed2 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -531,15 +531,15 @@ public void RemoveDropShadowEffectFromCurrentTheme() UpdateResourceDictionary(dict); } - public void SetResizeBoarderThickness(WindowChrome windowChrome, bool resizeWindow) + public void SetResizeBoarderThickness(WindowChrome windowChrome, bool fixedWindowSize) { - if (resizeWindow) + if (fixedWindowSize) { - windowChrome.ResizeBorderThickness = _themeResizeBorderThickness; + windowChrome.ResizeBorderThickness = new Thickness(0); } else { - windowChrome.ResizeBorderThickness = new Thickness(0); + windowChrome.ResizeBorderThickness = _themeResizeBorderThickness; } } @@ -565,7 +565,7 @@ private void SetResizeBoarderThickness(Thickness? effectMargin) } // Apply the resize border thickness to the window chrome - SetResizeBoarderThickness(windowChrome, _settings.ResizeWindow); + SetResizeBoarderThickness(windowChrome, _settings.KeepMaxResults); } } diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 7c747ae3626..bd146f49a0b 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -68,11 +68,12 @@ public string Theme get => _theme; set { - if (value == _theme) - return; - _theme = value; - OnPropertyChanged(); - OnPropertyChanged(nameof(MaxResultsToShow)); + if (value != _theme) + { + _theme = value; + OnPropertyChanged(); + OnPropertyChanged(nameof(MaxResultsToShow)); + } } } public bool UseDropShadowEffect { get; set; } = true; @@ -113,25 +114,17 @@ public string Theme public double? SettingWindowLeft { get; set; } = null; public System.Windows.WindowState SettingWindowState { get; set; } = WindowState.Normal; - bool _resizeWindow { get; set; } = true; - public bool ResizeWindow - { - get => _resizeWindow; - set - { - _resizeWindow = value; - OnPropertyChanged(); - } - } - bool _showPlaceholder { get; set; } = false; public bool ShowPlaceholder { get => _showPlaceholder; set { - _showPlaceholder = value; - OnPropertyChanged(); + if (_showPlaceholder != value) + { + _showPlaceholder = value; + OnPropertyChanged(); + } } } string _placeholderText { get; set; } = string.Empty; @@ -140,8 +133,11 @@ public string PlaceholderText get => _placeholderText; set { - _placeholderText = value; - OnPropertyChanged(); + if (_placeholderText != value) + { + _placeholderText = value; + OnPropertyChanged(); + } } } @@ -273,10 +269,26 @@ public SearchPrecisionScore QuerySearchPrecision /// public double CustomWindowTop { get; set; } = 0; - public bool KeepMaxResults { get; set; } = false; + /// + /// Fixed window size + /// + private bool _keepMaxResults { get; set; } = false; + public bool KeepMaxResults + { + get => _keepMaxResults; + set + { + if (_keepMaxResults != value) + { + _keepMaxResults = value; + OnPropertyChanged(); + } + } + } + public int MaxResultsToShow { get; set; } = 5; - public int ActivateTimes { get; set; } + public int ActivateTimes { get; set; } public ObservableCollection CustomPluginHotkeys { get; set; } = new ObservableCollection(); diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index a9c5ab49fcc..6d890dfba29 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -72,8 +72,6 @@ Empty last Query Preserve Last Action Keyword Select Last Action Keyword - Fixed Window Height - The window height is not adjustable by dragging. Maximum results shown You can also quickly adjust this by using CTRL+Plus and CTRL+Minus. Ignore hotkeys in fullscreen mode @@ -206,8 +204,8 @@ Display placeholder when query is empty Placeholder text Change placeholder text. Input empty will use: Type here to search - Allow window size change - Allow dragging the search window edges to change its size + Fixed Window Size + The window size is not adjustable by dragging. Hotkey diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 6ffc010a6d1..3f0dcc3e190 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -252,7 +252,7 @@ private async void OnLoaded(object sender, RoutedEventArgs _) case nameof(Settings.PlaceholderText): _viewModel.PlaceholderText = _settings.PlaceholderText; break; - case nameof(Settings.ResizeWindow): + case nameof(Settings.KeepMaxResults): SetupResizeMode(); break; } @@ -1087,10 +1087,10 @@ private void SetPlaceholderText() private void SetupResizeMode() { - ResizeMode = _settings.ResizeWindow ? ResizeMode.CanResize : ResizeMode.NoResize; + ResizeMode = _settings.KeepMaxResults ? ResizeMode.NoResize : ResizeMode.CanResize; if (WindowChrome.GetWindowChrome(this) is WindowChrome windowChrome) { - _theme.SetResizeBoarderThickness(windowChrome, _settings.ResizeWindow); + _theme.SetResizeBoarderThickness(windowChrome, _settings.KeepMaxResults); } } diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs index 64fe351fa91..099be496bb8 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs @@ -259,12 +259,6 @@ public double SoundEffectVolume set => Settings.SoundVolume = value; } - public bool ResizeWindow - { - get => Settings.ResizeWindow; - set => Settings.ResizeWindow = value; - } - public bool ShowPlaceholder { get => Settings.ShowPlaceholder; diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml index 462ea799e8d..f9eef892437 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml @@ -499,28 +499,20 @@ Text="{DynamicResource browserMoreThemes}" Uri="{Binding LinkThemeGallery}" /> - - - - - - + - + Date: Sat, 29 Mar 2025 15:38:44 +0800 Subject: [PATCH 07/13] Code quality & Fix --- Flow.Launcher/MainWindow.xaml | 2 +- Flow.Launcher/MainWindow.xaml.cs | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 82ac63b7da6..2e6133df035 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -10,7 +10,7 @@ xmlns:vm="clr-namespace:Flow.Launcher.ViewModel" Name="FlowMainWindow" Title="Flow Launcher" - Width="{Binding MainWindowWidth, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" + Width="{Binding MainWindowWidth, Mode=OneWay}" MinWidth="400" MinHeight="30" d:DataContext="{d:DesignInstance Type=vm:MainViewModel}" diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 3f0dcc3e190..5df1b318f39 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -455,23 +455,25 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b { _initialWidth = (int)Width; _initialHeight = (int)Height; + handled = true; } else if (msg == Win32Helper.WM_EXITSIZEMOVE) { if (_initialHeight != (int)Height) { - var shadowMargin = 0; - var (_, useDropShadowEffect) = _theme.GetActualValue(); - if (useDropShadowEffect) - { - shadowMargin = 32; - } - if (!_settings.KeepMaxResults) { - var itemCount = (Height - (_settings.WindowHeightSize + 14) - shadowMargin) / _settings.ItemHeightSize; + // Get shadow margin + var shadowMargin = 0; + var (_, useDropShadowEffect) = _theme.GetActualValue(); + if (useDropShadowEffect) + { + shadowMargin = 32; + } + // Calculate max results to show + var itemCount = (Height - (_settings.WindowHeightSize + 14) - shadowMargin) / _settings.ItemHeightSize; if (itemCount < 2) { _settings.MaxResultsToShow = 2; @@ -483,11 +485,16 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b } SizeToContent = SizeToContent.Height; - _viewModel.MainWindowWidth = Width; } if (_initialWidth != (int)Width) { + if (!_settings.KeepMaxResults) + { + // Update width + _viewModel.MainWindowWidth = Width; + } + SizeToContent = SizeToContent.Height; } From 6f32a6f098851cf3af741b394b6a91c17db0c67a Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 29 Mar 2025 15:48:52 +0800 Subject: [PATCH 08/13] Fix placeholder text issue --- Flow.Launcher/ViewModel/MainViewModel.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index ec5b52c9dd0..a8425a456a1 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -768,17 +768,10 @@ private ResultsViewModel SelectedResults private string _placeholderText; public string PlaceholderText { - get => _placeholderText; + get => string.IsNullOrEmpty(_placeholderText) ? App.API.GetTranslation("queryTextBoxPlaceholder") : _placeholderText; set { - if (string.IsNullOrEmpty(value)) - { - _placeholderText = App.API.GetTranslation("queryTextBoxSuggestion"); - } - else - { - _placeholderText = value; - } + _placeholderText = value; OnPropertyChanged(); } } From 78b661733d46353381af8fe25dd578a9dd7f8613 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 29 Mar 2025 15:49:22 +0800 Subject: [PATCH 09/13] Improve placeholder text tooltip --- Flow.Launcher/Languages/en.xaml | 4 ++-- .../SettingPages/ViewModels/SettingsPaneThemeViewModel.cs | 5 +++++ Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 6d890dfba29..c170c44e422 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -39,7 +39,7 @@ Game Mode Suspend the use of Hotkeys. Position Reset - Type here to search + Type here to search Settings @@ -203,7 +203,7 @@ Show placeholder Display placeholder when query is empty Placeholder text - Change placeholder text. Input empty will use: Type here to search + Change placeholder text. Input empty will use: {0} Fixed Window Size The window size is not adjustable by dragging. diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs index 099be496bb8..e35c978ede7 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs @@ -265,6 +265,11 @@ public bool ShowPlaceholder set => Settings.ShowPlaceholder = value; } + public string PlaceholderTextTip + { + get => string.Format(App.API.GetTranslation("PlaceholderTextTip"), App.API.GetTranslation("queryTextBoxPlaceholder")); + } + public string PlaceholderText { get => Settings.PlaceholderText; diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml index f9eef892437..5e1ba24ea96 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml @@ -549,9 +549,9 @@ + Sub="{Binding PlaceholderTextTip}"> From 714860e416831cbdebdd7f636e3a9ecb13cae0a5 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 29 Mar 2025 16:03:41 +0800 Subject: [PATCH 10/13] Fix hotkey size change issue --- Flow.Launcher/MainWindow.xaml | 2 +- Flow.Launcher/ViewModel/MainViewModel.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 2e6133df035..82ac63b7da6 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -10,7 +10,7 @@ xmlns:vm="clr-namespace:Flow.Launcher.ViewModel" Name="FlowMainWindow" Title="Flow Launcher" - Width="{Binding MainWindowWidth, Mode=OneWay}" + Width="{Binding MainWindowWidth, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="400" MinHeight="30" d:DataContext="{d:DesignInstance Type=vm:MainViewModel}" diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index a8425a456a1..56de70b4785 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -584,7 +584,7 @@ public string QueryText [RelayCommand] private void IncreaseWidth() { - Settings.WindowSize += 100; + MainWindowWidth += 100; Settings.WindowLeft -= 50; OnPropertyChanged(nameof(MainWindowWidth)); } @@ -592,14 +592,14 @@ private void IncreaseWidth() [RelayCommand] private void DecreaseWidth() { - if (MainWindowWidth - 100 < 400 || Settings.WindowSize == 400) + if (MainWindowWidth - 100 < 400 || MainWindowWidth == 400) { - Settings.WindowSize = 400; + MainWindowWidth = 400; } else { + MainWindowWidth -= 100; Settings.WindowLeft += 50; - Settings.WindowSize -= 100; } OnPropertyChanged(nameof(MainWindowWidth)); From f160670d4f33068074f15a6301289ee78539fd11 Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 29 Mar 2025 17:24:47 +0900 Subject: [PATCH 11/13] Remove QuerySuggestionBoxStyle background --- Flow.Launcher/Themes/Discord Dark.xaml | 1 - Flow.Launcher/Themes/League.xaml | 1 - Flow.Launcher/Themes/Pink.xaml | 1 - 3 files changed, 3 deletions(-) diff --git a/Flow.Launcher/Themes/Discord Dark.xaml b/Flow.Launcher/Themes/Discord Dark.xaml index 9e39ee5bdaf..fb88da31353 100644 --- a/Flow.Launcher/Themes/Discord Dark.xaml +++ b/Flow.Launcher/Themes/Discord Dark.xaml @@ -28,7 +28,6 @@ BasedOn="{StaticResource BaseQuerySuggestionBoxStyle}" TargetType="{x:Type TextBox}"> - diff --git a/Flow.Launcher/Themes/League.xaml b/Flow.Launcher/Themes/League.xaml index f1c8ba19222..ffecf3fcbb4 100644 --- a/Flow.Launcher/Themes/League.xaml +++ b/Flow.Launcher/Themes/League.xaml @@ -24,7 +24,6 @@ x:Key="QuerySuggestionBoxStyle" BasedOn="{StaticResource BaseQuerySuggestionBoxStyle}" TargetType="{x:Type TextBox}"> - diff --git a/Flow.Launcher/Themes/Pink.xaml b/Flow.Launcher/Themes/Pink.xaml index d7de4e2467d..5bbfa26d6e8 100644 --- a/Flow.Launcher/Themes/Pink.xaml +++ b/Flow.Launcher/Themes/Pink.xaml @@ -22,7 +22,6 @@ x:Key="QuerySuggestionBoxStyle" BasedOn="{StaticResource BaseQuerySuggestionBoxStyle}" TargetType="{x:Type TextBox}"> - From 356f229fd44e65f0975ca3f700df3e96b4a87a5c Mon Sep 17 00:00:00 2001 From: Jack Ye <1160210343@qq.com> Date: Sat, 29 Mar 2025 16:38:54 +0800 Subject: [PATCH 12/13] Update Flow.Launcher.Core/Resource/Theme.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Flow.Launcher.Core/Resource/Theme.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index a1b2c3e0ed2..a4cca2a1df6 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -531,7 +531,7 @@ public void RemoveDropShadowEffectFromCurrentTheme() UpdateResourceDictionary(dict); } - public void SetResizeBoarderThickness(WindowChrome windowChrome, bool fixedWindowSize) + public void SetResizeBorderThickness(WindowChrome windowChrome, bool fixedWindowSize) { if (fixedWindowSize) { From cd01260ee91686e0ae2ca051c834bbe2a7c6e5f6 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 29 Mar 2025 16:41:11 +0800 Subject: [PATCH 13/13] Fix typos --- Flow.Launcher.Core/Resource/Theme.cs | 2 +- Flow.Launcher/MainWindow.xaml.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index a4cca2a1df6..e5980b62fa3 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -565,7 +565,7 @@ private void SetResizeBoarderThickness(Thickness? effectMargin) } // Apply the resize border thickness to the window chrome - SetResizeBoarderThickness(windowChrome, _settings.KeepMaxResults); + SetResizeBorderThickness(windowChrome, _settings.KeepMaxResults); } } diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 5df1b318f39..8f22d64b8d6 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -1097,7 +1097,7 @@ private void SetupResizeMode() ResizeMode = _settings.KeepMaxResults ? ResizeMode.NoResize : ResizeMode.CanResize; if (WindowChrome.GetWindowChrome(this) is WindowChrome windowChrome) { - _theme.SetResizeBoarderThickness(windowChrome, _settings.KeepMaxResults); + _theme.SetResizeBorderThickness(windowChrome, _settings.KeepMaxResults); } }