From dcf72bca5be1ede3fb2629e9841fc436ed005843 Mon Sep 17 00:00:00 2001 From: DB p Date: Tue, 30 Apr 2024 07:57:39 +0900 Subject: [PATCH 1/8] Add FileSize/Created/LastModified Info for Preview --- Flow.Launcher.Plugin/Result.cs | 22 ++++++++++++++++++- Flow.Launcher/MainWindow.xaml | 12 ++++++++++ .../Search/ResultManager.cs | 15 +++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index fc6c5d185d8..2d3757ddc5a 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -129,6 +129,21 @@ public string IcoPath /// default: 0 public int Score { get; set; } + /// + /// File Size + /// + public string FileSize { get; set; } = string.Empty; + + /// + /// Created + /// + public string FileCreated { get; set; } = string.Empty; + + /// + /// Last Modified Date File + /// + public string LastModifed { get; set; } = string.Empty; + /// /// A list of indexes for the characters to be highlighted in Title /// @@ -204,7 +219,10 @@ public Result Clone() Score = Score, TitleHighlightData = TitleHighlightData, OriginQuery = OriginQuery, - PluginDirectory = PluginDirectory + PluginDirectory = PluginDirectory, + FileCreated = FileCreated, + FileSize = FileSize, + LastModifed = LastModifed }; } @@ -300,6 +318,8 @@ public record PreviewInfo IsMedia = false, PreviewDelegate = null, }; + + } } } diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 2e6e973a720..c8a40c7aec3 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -490,6 +490,18 @@ x:Name="PreviewSubTitle" Style="{DynamicResource PreviewItemSubTitleStyle}" Text="{Binding Result.SubTitle}" /> + + + + + + + + + + + + diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index a87f766a1f9..b2839231ed0 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -8,6 +8,8 @@ using System.Windows; using Flow.Launcher.Plugin.Explorer.Search.Everything; using System.Windows.Input; +using System.Windows.Shapes; +using Path = System.IO.Path; namespace Flow.Launcher.Plugin.Explorer.Search { @@ -239,6 +241,16 @@ internal static Result CreateFileResult(string filePath, Query query, int score var title = Path.GetFileName(filePath); + /* Preview Detail */ + long fileSize = new System.IO.FileInfo(filePath).Length; + string fileSizStr = fileSize.ToString(); + + DateTime created = System.IO.File.GetCreationTime(filePath); + string createdStr = created.ToString("yyyy-MM-dd HH:mm:ss"); + DateTime lastModified = System.IO.File.GetLastWriteTime(filePath); + string lastModifiedStr = lastModified.ToString("yyyy-MM-dd HH:mm:ss"); + + var result = new Result { Title = title, @@ -248,6 +260,9 @@ internal static Result CreateFileResult(string filePath, Query query, int score AutoCompleteText = GetAutoCompleteText(title, query, filePath, ResultType.File), TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData, Score = score, + FileSize = fileSizStr, + FileCreated = createdStr, + LastModifed = lastModifiedStr, CopyText = filePath, Action = c => { From 588e814e50ef76e128c4b254b61ac674cf25029b Mon Sep 17 00:00:00 2001 From: DB p Date: Tue, 30 Apr 2024 11:10:22 +0900 Subject: [PATCH 2/8] - Add style for hiding when non-filesize - Add Strings --- Flow.Launcher/Languages/en.xaml | 4 + Flow.Launcher/MainWindow.xaml | 87 ++++++++++++++++--- .../Search/ResultManager.cs | 15 ++-- 3 files changed, 89 insertions(+), 17 deletions(-) diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index bda86e481ec..04ecd03a293 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -413,4 +413,8 @@ sn Sticky Notes + + File Size + Created + Last Modified diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index c8a40c7aec3..9f04b145660 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -7,6 +7,7 @@ xmlns:flowlauncher="clr-namespace:Flow.Launcher" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:svgc="http://sharpvectors.codeplex.com/svgc/" + xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:ui="http://schemas.modernwpf.com/2019" xmlns:vm="clr-namespace:Flow.Launcher.ViewModel" Name="FlowMainWindow" @@ -490,17 +491,81 @@ x:Name="PreviewSubTitle" Style="{DynamicResource PreviewItemSubTitleStyle}" Text="{Binding Result.SubTitle}" /> - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index b2839231ed0..60e4a31b493 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -10,6 +10,7 @@ using System.Windows.Input; using System.Windows.Shapes; using Path = System.IO.Path; +using System.Globalization; namespace Flow.Launcher.Plugin.Explorer.Search { @@ -189,11 +190,11 @@ private static string ToReadableSize(long pDrvSize, int pi) if (mok == 1) uom = "KB"; else if (mok == 2) - uom = " MB"; + uom = "MB"; else if (mok == 3) - uom = " GB"; + uom = "GB"; else if (mok == 4) - uom = " TB"; + uom = "TB"; var returnStr = $"{Convert.ToInt32(drvSize)}{uom}"; if (mok != 0) @@ -241,14 +242,16 @@ internal static Result CreateFileResult(string filePath, Query query, int score var title = Path.GetFileName(filePath); + /* Preview Detail */ long fileSize = new System.IO.FileInfo(filePath).Length; - string fileSizStr = fileSize.ToString(); + string fileSizStr = ToReadableSize(fileSize, 2); DateTime created = System.IO.File.GetCreationTime(filePath); - string createdStr = created.ToString("yyyy-MM-dd HH:mm:ss"); + string createdStr = created.ToString("yy-M-dd ddd hh:mm", CultureInfo.CurrentCulture); DateTime lastModified = System.IO.File.GetLastWriteTime(filePath); - string lastModifiedStr = lastModified.ToString("yyyy-MM-dd HH:mm:ss"); + string lastModifiedStr = lastModified.ToString("yy-M-dd ddd hh:mm", CultureInfo.CurrentCulture); + var result = new Result From a337163d9e6748b4067e5611ca8f5f050c930dc0 Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Wed, 1 May 2024 11:29:43 +0800 Subject: [PATCH 3/8] fix typo --- Flow.Launcher.Plugin/Result.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index 2d3757ddc5a..87b9a8b180c 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -276,7 +276,7 @@ public ValueTask ExecuteAsync(ActionContext context) public string ProgressBarColor { get; set; } = "#26a0da"; /// - /// Contains data used to populate the the preview section of this result. + /// Contains data used to populate the preview section of this result. /// public PreviewInfo Preview { get; set; } = PreviewInfo.Default; From 696ae7e20d11faf141708f90ce41730a8bee363b Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Mon, 20 May 2024 23:03:19 +0600 Subject: [PATCH 4/8] Move the additional explorer plugin functionality into the explorer plugin itself --- Flow.Launcher.Plugin/Result.cs | 20 --- Flow.Launcher/MainWindow.xaml | 78 +--------- .../Search/ResultManager.cs | 56 +++---- .../Views/PreviewPanel.xaml | 137 ++++++++++++++++++ .../Views/PreviewPanel.xaml.cs | 64 ++++++++ 5 files changed, 221 insertions(+), 134 deletions(-) create mode 100644 Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml create mode 100644 Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index 87b9a8b180c..ea79386b3dd 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -129,21 +129,6 @@ public string IcoPath /// default: 0 public int Score { get; set; } - /// - /// File Size - /// - public string FileSize { get; set; } = string.Empty; - - /// - /// Created - /// - public string FileCreated { get; set; } = string.Empty; - - /// - /// Last Modified Date File - /// - public string LastModifed { get; set; } = string.Empty; - /// /// A list of indexes for the characters to be highlighted in Title /// @@ -220,9 +205,6 @@ public Result Clone() TitleHighlightData = TitleHighlightData, OriginQuery = OriginQuery, PluginDirectory = PluginDirectory, - FileCreated = FileCreated, - FileSize = FileSize, - LastModifed = LastModifed }; } @@ -318,8 +300,6 @@ public record PreviewInfo IsMedia = false, PreviewDelegate = null, }; - - } } } diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index a234ea4be4a..7abeb47c165 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -492,82 +492,6 @@ x:Name="PreviewSubTitle" Style="{DynamicResource PreviewItemSubTitleStyle}" Text="{Binding Result.SubTitle}" /> - - - - - - - - - - - - - - - - - - - - - - - - @@ -583,4 +507,4 @@ - \ No newline at end of file + diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index 60e4a31b493..a1cd67fe432 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -8,14 +8,15 @@ using System.Windows; using Flow.Launcher.Plugin.Explorer.Search.Everything; using System.Windows.Input; -using System.Windows.Shapes; using Path = System.IO.Path; -using System.Globalization; +using System.Windows.Controls; +using Flow.Launcher.Plugin.Explorer.Views; namespace Flow.Launcher.Plugin.Explorer.Search { public static class ResultManager { + private static readonly string[] SizeUnits = { "B", "KB", "MB", "GB", "TB" }; private static PluginInitContext Context; private static Settings Settings { get; set; } @@ -175,36 +176,28 @@ internal static Result CreateDriveSpaceDisplayResult(string path, string actionK }; } - private static string ToReadableSize(long pDrvSize, int pi) + internal static string ToReadableSize(long sizeOnDrive, int pi) { - int mok = 0; - double drvSize = pDrvSize; - string uom = "Byte"; // Unit Of Measurement + var unitIndex = 0; + double readableSize = sizeOnDrive; - while (drvSize > 1024.0) + while (readableSize > 1024.0 && unitIndex < SizeUnits.Length - 1) { - drvSize /= 1024.0; - mok++; + readableSize /= 1024.0; + unitIndex++; } - if (mok == 1) - uom = "KB"; - else if (mok == 2) - uom = "MB"; - else if (mok == 3) - uom = "GB"; - else if (mok == 4) - uom = "TB"; - - var returnStr = $"{Convert.ToInt32(drvSize)}{uom}"; - if (mok != 0) + var unit = SizeUnits[unitIndex] ?? ""; + + var returnStr = $"{Convert.ToInt32(readableSize)} {unit}"; + if (unitIndex != 0) { returnStr = pi switch { - 1 => $"{drvSize:F1}{uom}", - 2 => $"{drvSize:F2}{uom}", - 3 => $"{drvSize:F3}{uom}", - _ => $"{Convert.ToInt32(drvSize)}{uom}" + 1 => $"{readableSize:F1} {unit}", + 2 => $"{readableSize:F2} {unit}", + 3 => $"{readableSize:F3} {unit}", + _ => $"{Convert.ToInt32(readableSize)} {unit}" }; } @@ -242,17 +235,8 @@ internal static Result CreateFileResult(string filePath, Query query, int score var title = Path.GetFileName(filePath); - - /* Preview Detail */ - long fileSize = new System.IO.FileInfo(filePath).Length; - string fileSizStr = ToReadableSize(fileSize, 2); - - DateTime created = System.IO.File.GetCreationTime(filePath); - string createdStr = created.ToString("yy-M-dd ddd hh:mm", CultureInfo.CurrentCulture); - DateTime lastModified = System.IO.File.GetLastWriteTime(filePath); - string lastModifiedStr = lastModified.ToString("yy-M-dd ddd hh:mm", CultureInfo.CurrentCulture); - + /* Preview Detail */ var result = new Result { @@ -263,10 +247,8 @@ internal static Result CreateFileResult(string filePath, Query query, int score AutoCompleteText = GetAutoCompleteText(title, query, filePath, ResultType.File), TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData, Score = score, - FileSize = fileSizStr, - FileCreated = createdStr, - LastModifed = lastModifiedStr, CopyText = filePath, + PreviewPanel = new Lazy(() => new PreviewPanel(filePath)), Action = c => { try diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml new file mode 100644 index 00000000000..ded9a97ab71 --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs new file mode 100644 index 00000000000..aa9d33fe126 --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs @@ -0,0 +1,64 @@ +using System; +using System.ComponentModel; +using System.Globalization; +using System.IO; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using Flow.Launcher.Infrastructure.Image; +using Flow.Launcher.Plugin.Explorer.Search; + +namespace Flow.Launcher.Plugin.Explorer.Views; + +#nullable enable + +public partial class PreviewPanel : UserControl, INotifyPropertyChanged +{ + private string FilePath { get; } + public string FileSize { get; } + public string CreatedAt { get; } + public string LastModifiedAt { get; } + private ImageSource _previewImage = new BitmapImage(); + + public ImageSource PreviewImage + { + get => _previewImage; + private set + { + _previewImage = value; + OnPropertyChanged(); + } + } + + public PreviewPanel(string filePath) + { + InitializeComponent(); + + FilePath = filePath; + + var fileSize = new FileInfo(filePath).Length; + FileSize = ResultManager.ToReadableSize(fileSize, 2); + + DateTime created = File.GetCreationTime(filePath); + CreatedAt = created.ToString("yy-M-dd ddd hh:mm", CultureInfo.CurrentCulture); + + DateTime lastModified = File.GetLastWriteTime(filePath); + LastModifiedAt = lastModified.ToString("yy-M-dd ddd hh:mm", CultureInfo.CurrentCulture); + + _ = LoadImageAsync(); + } + + private async Task LoadImageAsync() + { + PreviewImage = await ImageLoader.LoadAsync(FilePath, true).ConfigureAwait(false); + } + + public event PropertyChangedEventHandler? PropertyChanged; + + protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } +} From 5b561f4dce0862ce6063cff83aae1a169528ed3f Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Fri, 24 May 2024 09:51:24 +0600 Subject: [PATCH 5/8] Add settings for file size and date/time in explorer plugin --- .../Languages/en.xaml | 7 +- .../Search/ResultManager.cs | 2 +- .../Flow.Launcher.Plugin.Explorer/Settings.cs | 12 ++- .../ViewModels/SettingsViewModel.cs | 101 ++++++++++++++++++ .../Views/ExplorerSettings.xaml | 51 +++++++++ .../Views/PreviewPanel.xaml | 13 ++- .../Views/PreviewPanel.xaml.cs | 54 +++++++--- 7 files changed, 222 insertions(+), 18 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index f2491d928ea..d5d3518a713 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -29,6 +29,11 @@ Customise Action Keywords Quick Access Links Everything Setting + Preview Panel + Display file size + Display file creation date + Display file modification date + Date and time format: Sort Option: Everything Path: Launch Hidden @@ -133,7 +138,7 @@ Warning: This is not a Fast Sort option, searches may be slow Search Full Path - + Click to launch or install Everything Everything Installation Installing Everything service. Please wait... diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index a1cd67fe432..34f80f55294 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -248,7 +248,7 @@ internal static Result CreateFileResult(string filePath, Query query, int score TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData, Score = score, CopyText = filePath, - PreviewPanel = new Lazy(() => new PreviewPanel(filePath)), + PreviewPanel = new Lazy(() => new PreviewPanel(Settings, filePath)), Action = c => { try diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 137ba2f1982..088bcf5d60b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -55,6 +55,16 @@ public class Settings public bool WarnWindowsSearchServiceOff { get; set; } = true; + public bool ShowFileSizeInPreviewPanel { get; set; } = true; + + public bool ShowCreatedDateInPreviewPanel { get; set; } = true; + + public bool ShowModifiedDateInPreviewPanel { get; set; } = true; + + public string PreviewPanelDateFormat { get; set; } = "yyyy-MM-dd"; + + public string PreviewPanelTimeFormat { get; set; } = "HH:mm"; + private EverythingSearchManager _everythingManagerInstance; private WindowsIndexSearchManager _windowsIndexSearchManager; @@ -137,7 +147,7 @@ public enum ContentIndexSearchEngineOption ContentSearchEngine == ContentIndexSearchEngineOption.Everything; public bool EverythingSearchFullPath { get; set; } = false; - + #endregion internal enum ActionKeyword diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index 02199fb5aef..064795b430a 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.IO; using System.Linq; using System.Windows; @@ -101,7 +102,107 @@ private void InitializeEngineSelection() #endregion + #region Preview Panel + public bool ShowFileSizeInPreviewPanel + { + get => Settings.ShowFileSizeInPreviewPanel; + set + { + Settings.ShowFileSizeInPreviewPanel = value; + OnPropertyChanged(); + } + } + + public bool ShowCreatedDateInPreviewPanel + { + get => Settings.ShowCreatedDateInPreviewPanel; + set + { + Settings.ShowCreatedDateInPreviewPanel = value; + OnPropertyChanged(); + OnPropertyChanged(nameof(ShowPreviewPanelDateTimeChoices)); + OnPropertyChanged(nameof(PreviewPanelDateTimeChoicesVisibility)); + } + } + + public bool ShowModifiedDateInPreviewPanel + { + get => Settings.ShowModifiedDateInPreviewPanel; + set + { + Settings.ShowModifiedDateInPreviewPanel = value; + OnPropertyChanged(); + OnPropertyChanged(nameof(ShowPreviewPanelDateTimeChoices)); + OnPropertyChanged(nameof(PreviewPanelDateTimeChoicesVisibility)); + } + } + + public string PreviewPanelDateFormat + { + get => Settings.PreviewPanelDateFormat; + set + { + Settings.PreviewPanelDateFormat = value; + OnPropertyChanged(); + OnPropertyChanged(nameof(PreviewPanelDateFormatDemo)); + } + } + + public string PreviewPanelTimeFormat + { + get => Settings.PreviewPanelTimeFormat; + set + { + Settings.PreviewPanelTimeFormat = value; + OnPropertyChanged(); + OnPropertyChanged(nameof(PreviewPanelTimeFormatDemo)); + } + } + + public string PreviewPanelDateFormatDemo => DateTime.Now.ToString(PreviewPanelDateFormat, CultureInfo.CurrentCulture); + public string PreviewPanelTimeFormatDemo => DateTime.Now.ToString(PreviewPanelTimeFormat, CultureInfo.CurrentCulture); + + public bool ShowPreviewPanelDateTimeChoices => ShowCreatedDateInPreviewPanel || ShowModifiedDateInPreviewPanel; + + public Visibility PreviewPanelDateTimeChoicesVisibility => ShowCreatedDateInPreviewPanel || ShowModifiedDateInPreviewPanel ? Visibility.Visible : Visibility.Collapsed; + + + public List TimeFormatList { get; } = new() + { + "h:mm", + "hh:mm", + "H:mm", + "HH:mm", + "tt h:mm", + "tt hh:mm", + "h:mm tt", + "hh:mm tt", + "hh:mm:ss tt", + "HH:mm:ss" + }; + + + public List DateFormatList { get; } = new() + { + "dd/MM/yyyy", + "dd/MM/yyyy ddd", + "dd/MM/yyyy, dddd", + "dd-MM-yyyy", + "dd-MM-yyyy ddd", + "dd-MM-yyyy, dddd", + "dd.MM.yyyy", + "dd.MM.yyyy ddd", + "dd.MM.yyyy, dddd", + "MM/dd/yyyy", + "MM/dd/yyyy ddd", + "MM/dd/yyyy, dddd", + "yyyy-MM-dd", + "yyyy-MM-dd ddd", + "yyyy-MM-dd, dddd", + }; + + #endregion #region ActionKeyword diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index b0708b793b6..9fea2da2a53 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -348,6 +348,57 @@ + + + + + + + + + + + + + + + + + + + + + + Settings.ShowFileSizeInPreviewPanel + ? Visibility.Visible + : Visibility.Collapsed; + public Visibility CreatedAtVisibility => Settings.ShowCreatedDateInPreviewPanel + ? Visibility.Visible + : Visibility.Collapsed; + public Visibility LastModifiedAtVisibility => Settings.ShowModifiedDateInPreviewPanel + ? Visibility.Visible + : Visibility.Collapsed; + + public PreviewPanel(Settings settings, string filePath) { InitializeComponent(); + Settings = settings; + FilePath = filePath; - var fileSize = new FileInfo(filePath).Length; - FileSize = ResultManager.ToReadableSize(fileSize, 2); + if (Settings.ShowFileSizeInPreviewPanel) + { + var fileSize = new FileInfo(filePath).Length; + FileSize = ResultManager.ToReadableSize(fileSize, 2); + } - DateTime created = File.GetCreationTime(filePath); - CreatedAt = created.ToString("yy-M-dd ddd hh:mm", CultureInfo.CurrentCulture); + if (Settings.ShowCreatedDateInPreviewPanel) + { + CreatedAt = File + .GetCreationTime(filePath) + .ToString( + $"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}", + CultureInfo.CurrentCulture + ); + } - DateTime lastModified = File.GetLastWriteTime(filePath); - LastModifiedAt = lastModified.ToString("yy-M-dd ddd hh:mm", CultureInfo.CurrentCulture); + if (Settings.ShowModifiedDateInPreviewPanel) + { + LastModifiedAt = File + .GetLastWriteTime(filePath) + .ToString( + $"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}", + CultureInfo.CurrentCulture + ); + } _ = LoadImageAsync(); } From abb0c02dfe69e7ad89f481bb552c195ac86a785b Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Fri, 24 May 2024 10:12:34 +0600 Subject: [PATCH 6/8] Fix file info in preview panel of explorer plugin disappearing when file size display is disabled --- .../Views/PreviewPanel.xaml | 20 ++++++------------- .../Views/PreviewPanel.xaml.cs | 7 +++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml index a88acc6d168..4d7343fc521 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml @@ -54,20 +54,12 @@ - - - - + + - + + @@ -77,6 +69,7 @@ + + Settings.ShowFileSizeInPreviewPanel || + Settings.ShowCreatedDateInPreviewPanel || + Settings.ShowModifiedDateInPreviewPanel + ? Visibility.Visible + : Visibility.Collapsed; + public PreviewPanel(Settings settings, string filePath) { InitializeComponent(); From 5ffe0917866d72dfb110e70f496d9b84396d0642 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 24 May 2024 16:04:05 +0900 Subject: [PATCH 7/8] Adjust Exploer Setting Panel --- .../Languages/en.xaml | 14 +++++++------ .../Views/ExplorerSettings.xaml | 20 +++++++++---------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index d5d3518a713..52daf20fbb5 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -30,10 +30,11 @@ Quick Access Links Everything Setting Preview Panel - Display file size - Display file creation date - Display file modification date - Date and time format: + Size + Creation date + Modification date + Display File Info + Date and time format Sort Option: Everything Path: Launch Hidden @@ -110,10 +111,11 @@ Open With Select a program to open with - + {0} free of {1} Open in Default File Manager - Use '>' to search in this directory, '*' to search for file extensions or '>*' to combine both searches. + + Use '>' to search in this directory, '*' to search for file extensions or '>*' to combine both searches. Failed to load Everything SDK diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index 9fea2da2a53..5c92fc271d8 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -353,7 +353,9 @@ Header="{DynamicResource plugin_explorer_previewpanel_setting_header}" Style="{DynamicResource ExplorerTabItem}"> + @@ -371,10 +373,8 @@ Margin="0,20,0,0" IsEnabled="{Binding ShowPreviewPanelDateTimeChoices}" Visibility="{Binding PreviewPanelDateTimeChoicesVisibility}"> - - + + + Foreground="{DynamicResource Color05B}" + Text="{Binding PreviewPanelDateFormatDemo}" /> - + + Foreground="{DynamicResource Color05B}" + Text="{Binding PreviewPanelTimeFormatDemo}" /> @@ -454,7 +454,7 @@ From 72f0a746a959602feb049e777aab1c4480038af7 Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 25 May 2024 08:45:21 +0900 Subject: [PATCH 8/8] Fix Binding --- .../Views/PreviewPanel.xaml | 69 +++++++++---------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml index 4d7343fc521..b5cfd1a5d1f 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml @@ -1,12 +1,17 @@ - - + + @@ -14,8 +19,8 @@ @@ -42,23 +47,15 @@ - - - - - - + + + @@ -74,61 +71,61 @@ Grid.Row="0" Grid.Column="0" Margin="0 0 8 0" - Visibility="{Binding FileSizeVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" VerticalAlignment="Top" Style="{DynamicResource PreviewItemSubTitleStyle}" Text="{DynamicResource FileSize}" - TextWrapping="Wrap" /> + TextWrapping="Wrap" + Visibility="{Binding FileSizeVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" /> + TextWrapping="Wrap" + Visibility="{Binding FileSizeVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" /> + TextWrapping="Wrap" + Visibility="{Binding CreatedAtVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" /> + TextWrapping="Wrap" + Visibility="{Binding CreatedAtVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" /> + TextWrapping="Wrap" + Visibility="{Binding LastModifiedAtVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" /> + TextWrapping="Wrap" + Visibility="{Binding LastModifiedAtVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />