diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index 27d1bfeab..7d0a553a4 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -46,6 +46,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 @@ -82,6 +83,9 @@ 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 + {0}{3}Space free: {1}{3}Total size: {2} Copy path diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index 5c4accdc0..6bbdcbe0a 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -14,6 +14,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search { public static class ResultManager { + private static readonly string ClassName = nameof(ResultManager); + private static readonly string[] SizeUnits = { "B", "KB", "MB", "GB", "TB" }; private static PluginInitContext Context; private static Settings Settings { get; set; } @@ -99,10 +101,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search AutoCompleteText = GetAutoCompleteText(title, query, path, ResultType.Folder), TitleHighlightData = Context.API.FuzzySearch(query.Search, title).MatchData, CopyText = path, - Preview = new Result.PreviewInfo - { - FilePath = path, - }, + PreviewPanel = new Lazy(() => new PreviewPanel(Settings, path, ResultType.Folder)), Action = c => { if (c.SpecialKeyState.ToModifierKeys() == ModifierKeys.Alt) @@ -163,7 +162,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search }, Score = score, TitleToolTip = Main.Context.API.GetTranslation("plugin_explorer_plugin_ToolTipOpenDirectory"), - SubTitleToolTip = path, + SubTitleToolTip = Settings.DisplayMoreInformationInToolTip ? GetFolderMoreInfoTooltip(path) : path, ContextData = new SearchResult { Type = ResultType.Folder, FullPath = path, WindowsIndexed = windowsIndexed } }; } @@ -184,6 +183,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search if (progressValue >= 90) progressBarColor = "#da2626"; + var tooltip = Settings.DisplayMoreInformationInToolTip + ? GetVolumeMoreInfoTooltip(path, freespace, totalspace) + : path; + return new Result { Title = title, @@ -202,8 +205,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search OpenFolder(path); return true; }, - TitleToolTip = path, - SubTitleToolTip = path, + TitleToolTip = tooltip, + SubTitleToolTip = tooltip, ContextData = new SearchResult { Type = ResultType.Volume, FullPath = path, WindowsIndexed = windowsIndexed } }; } @@ -269,7 +272,6 @@ namespace Flow.Launcher.Plugin.Explorer.Search bool isMedia = IsMedia(Path.GetExtension(filePath)); var title = Path.GetFileName(filePath); - /* Preview Detail */ var result = new Result @@ -287,7 +289,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search TitleHighlightData = Context.API.FuzzySearch(query.Search, title).MatchData, Score = score, CopyText = filePath, - PreviewPanel = new Lazy(() => new PreviewPanel(Settings, filePath)), + PreviewPanel = new Lazy(() => new PreviewPanel(Settings, filePath, ResultType.File)), Action = c => { if (c.SpecialKeyState.ToModifierKeys() == ModifierKeys.Alt) @@ -318,7 +320,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search return true; }, TitleToolTip = Main.Context.API.GetTranslation("plugin_explorer_plugin_ToolTipOpenContainingFolder"), - SubTitleToolTip = filePath, + SubTitleToolTip = Settings.DisplayMoreInformationInToolTip ? GetFileMoreInfoTooltip(filePath) : filePath, ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath, WindowsIndexed = windowsIndexed } }; return result; @@ -349,6 +351,46 @@ namespace Flow.Launcher.Plugin.Explorer.Search _ = Task.Run(() => EverythingApi.IncrementRunCounterAsync(fileOrFolder)); } + private static string GetFileMoreInfoTooltip(string filePath) + { + try + { + var fileSize = PreviewPanel.GetFileSize(filePath); + var fileCreatedAt = PreviewPanel.GetFileCreatedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel); + var fileModifiedAt = PreviewPanel.GetFileLastModifiedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel); + return string.Format(Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info"), + filePath, fileSize, fileCreatedAt, fileModifiedAt, Environment.NewLine); + } + catch (Exception e) + { + Context.API.LogException(ClassName, $"Failed to load tooltip for {filePath}", e); + return filePath; + } + } + + private static string GetFolderMoreInfoTooltip(string folderPath) + { + try + { + var folderSize = PreviewPanel.GetFolderSize(folderPath); + var folderCreatedAt = PreviewPanel.GetFolderCreatedAt(folderPath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel); + var folderModifiedAt = PreviewPanel.GetFolderLastModifiedAt(folderPath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel); + return string.Format(Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info"), + folderPath, folderSize, folderCreatedAt, folderModifiedAt, Environment.NewLine); + } + catch (Exception e) + { + Context.API.LogException(ClassName, $"Failed to load tooltip for {folderPath}", e); + return folderPath; + } + } + + private static string GetVolumeMoreInfoTooltip(string volumePath, string freespace, string totalspace) + { + return string.Format(Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_volume"), + volumePath, freespace, totalspace, Environment.NewLine); + } + private static readonly string[] MediaExtensions = { ".jpg", ".png", ".avi", ".mkv", ".bmp", ".gif", ".wmv", ".mp3", ".flac", ".mp4" }; } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 4f83fc72e..77540f3a8 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -37,6 +37,8 @@ namespace Flow.Launcher.Plugin.Explorer 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/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index 59d3a5cfd..5aa6a13be 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -244,6 +244,21 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels "yyyy-MM-dd", "yyyy-MM-dd ddd", "yyyy-MM-dd, dddd", + "dd/MMM/yyyy", + "dd/MMM/yyyy ddd", + "dd/MMM/yyyy, dddd", + "dd-MMM-yyyy", + "dd-MMM-yyyy ddd", + "dd-MMM-yyyy, dddd", + "dd.MMM.yyyy", + "dd.MMM.yyyy ddd", + "dd.MMM.yyyy, dddd", + "MMM/dd/yyyy", + "MMM/dd/yyyy ddd", + "MMM/dd/yyyy, dddd", + "yyyy-MMM-dd", + "yyyy-MMM-dd ddd", + "yyyy-MMM-dd, dddd", }; #endregion diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index a05d43041..8f4b4d862 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -205,6 +205,7 @@ + @@ -228,16 +229,25 @@ Content="{DynamicResource plugin_explorer_default_open_in_file_manager}" IsChecked="{Binding Settings.DefaultOpenFolderInFileManager}" /> - + + @@ -256,7 +266,7 @@ @@ -283,7 +293,7 @@ @@ -310,14 +320,14 @@