From 155eecd86fa5fc35220cf2fc7b7f4e8fcca4fc63 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 4 Jun 2025 16:17:14 +0800 Subject: [PATCH 01/19] Expose part functions to helper --- .../Views/PreviewPanel.xaml.cs | 56 ++++++++++++------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs index e1a957199a5..d8715530ca7 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs @@ -60,33 +60,17 @@ public PreviewPanel(Settings settings, string filePath) if (Settings.ShowFileSizeInPreviewPanel) { - var fileSize = new FileInfo(filePath).Length; - FileSize = ResultManager.ToReadableSize(fileSize, 2); + FileSize = GetFileSize(filePath); } if (Settings.ShowCreatedDateInPreviewPanel) { - DateTime createdDate = File.GetCreationTime(filePath); - string formattedDate = createdDate.ToString( - $"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}", - CultureInfo.CurrentCulture - ); - - string result = formattedDate; - if (Settings.ShowFileAgeInPreviewPanel) result = $"{GetFileAge(createdDate)} - {formattedDate}"; - CreatedAt = result; + CreatedAt = GetCreatedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel); } if (Settings.ShowModifiedDateInPreviewPanel) { - DateTime lastModifiedDate = File.GetLastWriteTime(filePath); - string formattedDate = lastModifiedDate.ToString( - $"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}", - CultureInfo.CurrentCulture - ); - string result = formattedDate; - if (Settings.ShowFileAgeInPreviewPanel) result = $"{GetFileAge(lastModifiedDate)} - {formattedDate}"; - LastModifiedAt = result; + LastModifiedAt = GetLastModifiedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel); } _ = LoadImageAsync(); @@ -96,7 +80,39 @@ private async Task LoadImageAsync() { PreviewImage = await Main.Context.API.LoadImageAsync(FilePath, true).ConfigureAwait(false); } - + + public static string GetFileSize(string filePath) + { + var fileInfo = new FileInfo(filePath); + return ResultManager.ToReadableSize(fileInfo.Length, 2); + } + + public static string GetCreatedAt(string filePath, string previewPanelDateFormat, string previewPanelTimeFormat, bool showFileAgeInPreviewPanel) + { + var createdDate = File.GetCreationTime(filePath); + var formattedDate = createdDate.ToString( + $"{previewPanelDateFormat} {previewPanelTimeFormat}", + CultureInfo.CurrentCulture + ); + + var result = formattedDate; + if (showFileAgeInPreviewPanel) result = $"{GetFileAge(createdDate)} - {formattedDate}"; + return result; + } + + public static string GetLastModifiedAt(string filePath, string previewPanelDateFormat, string previewPanelTimeFormat, bool showFileAgeInPreviewPanel) + { + var lastModifiedDate = File.GetLastWriteTime(filePath); + var formattedDate = lastModifiedDate.ToString( + $"{previewPanelDateFormat} {previewPanelTimeFormat}", + CultureInfo.CurrentCulture + ); + + var result = formattedDate; + if (showFileAgeInPreviewPanel) result = $"{GetFileAge(lastModifiedDate)} - {formattedDate}"; + return result; + } + private static string GetFileAge(DateTime fileDateTime) { var now = DateTime.Now; From 16551396b985337901cf4ced1e20545fb2812678 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 4 Jun 2025 17:01:15 +0800 Subject: [PATCH 02/19] Add ui for new setting --- .../Languages/en.xaml | 3 ++ .../Flow.Launcher.Plugin.Explorer/Settings.cs | 2 + .../Views/ExplorerSettings.xaml | 46 +++++++++++-------- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index eefd6f4eb53..1cb050e64df 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -43,6 +43,7 @@ Shell Path Index Search Excluded Paths Use search result's location as the working directory of the executable + Display more information like size and age in tooltips Hit Enter to open folder in Default File Manager Use Index Search For Path Search Indexing Options @@ -79,6 +80,8 @@ Ctrl + Enter to open the directory Ctrl + Enter to open the containing folder + {0}{4}Size: {1}{4}Date created: {2}{4}Date modified: {3} + Unknown Copy path diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 4f83fc72e5b..77540f3a87b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -37,6 +37,8 @@ public class Settings public bool DefaultOpenFolderInFileManager { get; set; } = false; + public bool DisplayMoreInformationInToolTip { get; set; } = false; + public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; public bool SearchActionKeywordEnabled { get; set; } = true; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index 4302e721a51..50151d0b018 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -198,6 +198,7 @@ + @@ -222,16 +223,25 @@ Content="{DynamicResource plugin_explorer_default_open_in_file_manager}" IsChecked="{Binding Settings.DefaultOpenFolderInFileManager}" /> - + + @@ -250,7 +260,7 @@ @@ -277,7 +287,7 @@ @@ -304,14 +314,14 @@