diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index f2491d928..d5d3518a7 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 a1cd67fe4..34f80f552 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -248,7 +248,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search 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 137ba2f19..088bcf5d6 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -55,6 +55,16 @@ namespace Flow.Launcher.Plugin.Explorer 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 @@ namespace Flow.Launcher.Plugin.Explorer 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 02199fb5a..064795b43 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; 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 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels #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 b0708b793..9fea2da2a 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(); }