From 29be50478984e0b70f12f89e477188a581131ab8 Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Thu, 30 May 2024 20:49:36 +0600 Subject: [PATCH] Implement temporary result list height increase when preview is on --- Flow.Launcher/ViewModel/MainViewModel.cs | 16 +++++++++++--- Flow.Launcher/ViewModel/ResultsViewModel.cs | 23 +++++++++++++++++++-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index dcca3fb1a..90f1070b4 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -143,15 +143,21 @@ namespace Flow.Launcher.ViewModel ContextMenu = new ResultsViewModel(Settings) { - LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand + LeftClickResultCommand = OpenResultCommand, + RightClickResultCommand = LoadContextMenuCommand, + IsPreviewOn = Settings.AlwaysPreview }; Results = new ResultsViewModel(Settings) { - LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand + LeftClickResultCommand = OpenResultCommand, + RightClickResultCommand = LoadContextMenuCommand, + IsPreviewOn = Settings.AlwaysPreview }; History = new ResultsViewModel(Settings) { - LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand + LeftClickResultCommand = OpenResultCommand, + RightClickResultCommand = LoadContextMenuCommand, + IsPreviewOn = Settings.AlwaysPreview }; _selectedResults = Results; @@ -586,6 +592,10 @@ namespace Flow.Launcher.ViewModel { HidePreview(); } + + ContextMenu.IsPreviewOn = PreviewVisible; + History.IsPreviewOn = PreviewVisible; + Results.IsPreviewOn = PreviewVisible; } private void ShowPreview() diff --git a/Flow.Launcher/ViewModel/ResultsViewModel.cs b/Flow.Launcher/ViewModel/ResultsViewModel.cs index 68e59009f..107372e01 100644 --- a/Flow.Launcher/ViewModel/ResultsViewModel.cs +++ b/Flow.Launcher/ViewModel/ResultsViewModel.cs @@ -1,4 +1,5 @@ -using Flow.Launcher.Infrastructure.UserSettings; +using System; +using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using System.Collections.Generic; using System.Collections.Specialized; @@ -49,7 +50,25 @@ namespace Flow.Launcher.ViewModel #region Properties - public double MaxHeight => MaxResults * _settings.ItemHeightSize; + public bool IsPreviewOn { get; set; } + + public double MaxHeight + { + get + { + var newResultsCount = MaxResults; + if (IsPreviewOn) + { + newResultsCount = (int)Math.Ceiling(380 / _settings.ItemHeightSize); + if (newResultsCount < MaxResults) + { + newResultsCount = MaxResults; + } + } + return newResultsCount * _settings.ItemHeightSize; + } + } + public double ItemHeightSize { get => _settings.ItemHeightSize;