From ea4578f651862001aff967eb3f618254e035ae7c Mon Sep 17 00:00:00 2001 From: DB p Date: Sun, 26 May 2024 22:50:48 +0900 Subject: [PATCH] Add Keep Height (old behaiver) function --- .../UserSettings/Settings.cs | 1 + Flow.Launcher/Languages/en.xaml | 2 ++ Flow.Launcher/MainWindow.xaml.cs | 17 ++++++++++------- .../ViewModels/SettingsPaneGeneralViewModel.cs | 5 +++++ .../Views/SettingsPaneGeneral.xaml | 18 ++++++++++++++++++ 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index bf269ba12..aeb492162 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -232,6 +232,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings /// public double CustomWindowTop { get; set; } = 0; + public bool KeepMaxResults { get; set; } = false; public int MaxResultsToShow { get; set; } = 5; public int ActivateTimes { get; set; } diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 8a3cf1e80..d1b342751 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -56,6 +56,8 @@ Preserve Last Query Select last Query Empty last Query + Keeping Window Max Height + Window height will keep to fit the maximum number of results Maximum results shown You can also quickly adjust this by using CTRL+Plus and CTRL+Minus. Ignore hotkeys in fullscreen mode diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index c333b6b04..7b497f394 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -120,14 +120,17 @@ namespace Flow.Launcher shadowMargin = 32; } - if (System.Convert.ToInt32((Height - (_settings.WindowHeightSize + 14) - shadowMargin) / _settings.ItemHeightSize) < 1) - { - _settings.MaxResultsToShow = 2; - } - else - { - _settings.MaxResultsToShow = System.Convert.ToInt32(Math.Truncate((Height - (_settings.WindowHeightSize + 14) - shadowMargin) / _settings.ItemHeightSize)); + if (!_settings.KeepMaxResults) { + if (System.Convert.ToInt32((Height - (_settings.WindowHeightSize + 14) - shadowMargin) / _settings.ItemHeightSize) < 1) + { + _settings.MaxResultsToShow = 2; + } + else + { + _settings.MaxResultsToShow = System.Convert.ToInt32(Math.Truncate((Height - (_settings.WindowHeightSize + 14) - shadowMargin) / _settings.ItemHeightSize)); + } } + _settings.WindowSize = Width; FlowMainWindow.SizeToContent = SizeToContent.Height; } diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs index a9718a0ac..cb231d4f5 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs @@ -151,6 +151,11 @@ public partial class SettingsPaneGeneralViewModel : BaseModel public List Languages => InternationalizationManager.Instance.LoadAvailableLanguages(); public IEnumerable MaxResultsRange => Enumerable.Range(2, 16); + public bool KeepMaxResults + { + get => Settings.KeepMaxResults; + set => Settings.KeepMaxResults = value; + } public string AlwaysPreviewToolTip => string.Format( InternationalizationManager.Instance.GetTranslation("AlwaysPreviewToolTip"), diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml index c2b23a295..e983e77db 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml @@ -153,6 +153,24 @@ + + + + + + + + +