@@ -14,6 +14,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
1414{
1515 public static class ResultManager
1616 {
17+ private static readonly string ClassName = nameof ( ResultManager ) ;
18+
1719 private static readonly string [ ] SizeUnits = { "B" , "KB" , "MB" , "GB" , "TB" } ;
1820 private static PluginInitContext Context ;
1921 private static Settings Settings { get ; set ; }
@@ -99,10 +101,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
99101 AutoCompleteText = GetAutoCompleteText ( title , query , path , ResultType . Folder ) ,
100102 TitleHighlightData = Context . API . FuzzySearch ( query . Search , title ) . MatchData ,
101103 CopyText = path ,
102- Preview = new Result . PreviewInfo
103- {
104- FilePath = path ,
105- } ,
104+ PreviewPanel = new Lazy < UserControl > ( ( ) => new PreviewPanel ( Settings , path , ResultType . Folder ) ) ,
106105 Action = c =>
107106 {
108107 if ( c . SpecialKeyState . ToModifierKeys ( ) == ModifierKeys . Alt )
@@ -163,7 +162,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
163162 } ,
164163 Score = score ,
165164 TitleToolTip = Main . Context . API . GetTranslation ( "plugin_explorer_plugin_ToolTipOpenDirectory" ) ,
166- SubTitleToolTip = path ,
165+ SubTitleToolTip = Settings . DisplayMoreInformationInToolTip ? GetFolderMoreInfoTooltip ( path ) : path ,
167166 ContextData = new SearchResult { Type = ResultType . Folder , FullPath = path , WindowsIndexed = windowsIndexed }
168167 } ;
169168 }
@@ -184,6 +183,10 @@ internal static Result CreateDriveSpaceDisplayResult(string path, string actionK
184183 if ( progressValue >= 90 )
185184 progressBarColor = "#da2626" ;
186185
186+ var tooltip = Settings . DisplayMoreInformationInToolTip
187+ ? GetVolumeMoreInfoTooltip ( path , freespace , totalspace )
188+ : path ;
189+
187190 return new Result
188191 {
189192 Title = title ,
@@ -202,8 +205,8 @@ internal static Result CreateDriveSpaceDisplayResult(string path, string actionK
202205 OpenFolder ( path ) ;
203206 return true ;
204207 } ,
205- TitleToolTip = path ,
206- SubTitleToolTip = path ,
208+ TitleToolTip = tooltip ,
209+ SubTitleToolTip = tooltip ,
207210 ContextData = new SearchResult { Type = ResultType . Volume , FullPath = path , WindowsIndexed = windowsIndexed }
208211 } ;
209212 }
@@ -269,7 +272,6 @@ internal static Result CreateFileResult(string filePath, Query query, int score
269272 bool isMedia = IsMedia ( Path . GetExtension ( filePath ) ) ;
270273 var title = Path . GetFileName ( filePath ) ;
271274
272-
273275 /* Preview Detail */
274276
275277 var result = new Result
@@ -287,7 +289,7 @@ internal static Result CreateFileResult(string filePath, Query query, int score
287289 TitleHighlightData = Context . API . FuzzySearch ( query . Search , title ) . MatchData ,
288290 Score = score ,
289291 CopyText = filePath ,
290- PreviewPanel = new Lazy < UserControl > ( ( ) => new PreviewPanel ( Settings , filePath ) ) ,
292+ PreviewPanel = new Lazy < UserControl > ( ( ) => new PreviewPanel ( Settings , filePath , ResultType . File ) ) ,
291293 Action = c =>
292294 {
293295 if ( c . SpecialKeyState . ToModifierKeys ( ) == ModifierKeys . Alt )
@@ -318,7 +320,7 @@ internal static Result CreateFileResult(string filePath, Query query, int score
318320 return true ;
319321 } ,
320322 TitleToolTip = Main . Context . API . GetTranslation ( "plugin_explorer_plugin_ToolTipOpenContainingFolder" ) ,
321- SubTitleToolTip = filePath ,
323+ SubTitleToolTip = Settings . DisplayMoreInformationInToolTip ? GetFileMoreInfoTooltip ( filePath ) : filePath ,
322324 ContextData = new SearchResult { Type = ResultType . File , FullPath = filePath , WindowsIndexed = windowsIndexed }
323325 } ;
324326 return result ;
@@ -349,6 +351,46 @@ private static void IncrementEverythingRunCounterIfNeeded(string fileOrFolder)
349351 _ = Task . Run ( ( ) => EverythingApi . IncrementRunCounterAsync ( fileOrFolder ) ) ;
350352 }
351353
354+ private static string GetFileMoreInfoTooltip ( string filePath )
355+ {
356+ try
357+ {
358+ var fileSize = PreviewPanel . GetFileSize ( filePath ) ;
359+ var fileCreatedAt = PreviewPanel . GetFileCreatedAt ( filePath , Settings . PreviewPanelDateFormat , Settings . PreviewPanelTimeFormat , Settings . ShowFileAgeInPreviewPanel ) ;
360+ var fileModifiedAt = PreviewPanel . GetFileLastModifiedAt ( filePath , Settings . PreviewPanelDateFormat , Settings . PreviewPanelTimeFormat , Settings . ShowFileAgeInPreviewPanel ) ;
361+ return string . Format ( Context . API . GetTranslation ( "plugin_explorer_plugin_tooltip_more_info" ) ,
362+ filePath , fileSize , fileCreatedAt , fileModifiedAt , Environment . NewLine ) ;
363+ }
364+ catch ( Exception e )
365+ {
366+ Context . API . LogException ( ClassName , $ "Failed to load tooltip for { filePath } ", e ) ;
367+ return filePath ;
368+ }
369+ }
370+
371+ private static string GetFolderMoreInfoTooltip ( string folderPath )
372+ {
373+ try
374+ {
375+ var folderSize = PreviewPanel . GetFolderSize ( folderPath ) ;
376+ var folderCreatedAt = PreviewPanel . GetFolderCreatedAt ( folderPath , Settings . PreviewPanelDateFormat , Settings . PreviewPanelTimeFormat , Settings . ShowFileAgeInPreviewPanel ) ;
377+ var folderModifiedAt = PreviewPanel . GetFolderLastModifiedAt ( folderPath , Settings . PreviewPanelDateFormat , Settings . PreviewPanelTimeFormat , Settings . ShowFileAgeInPreviewPanel ) ;
378+ return string . Format ( Context . API . GetTranslation ( "plugin_explorer_plugin_tooltip_more_info" ) ,
379+ folderPath , folderSize , folderCreatedAt , folderModifiedAt , Environment . NewLine ) ;
380+ }
381+ catch ( Exception e )
382+ {
383+ Context . API . LogException ( ClassName , $ "Failed to load tooltip for { folderPath } ", e ) ;
384+ return folderPath ;
385+ }
386+ }
387+
388+ private static string GetVolumeMoreInfoTooltip ( string volumePath , string freespace , string totalspace )
389+ {
390+ return string . Format ( Context . API . GetTranslation ( "plugin_explorer_plugin_tooltip_more_info_volume" ) ,
391+ volumePath , freespace , totalspace , Environment . NewLine ) ;
392+ }
393+
352394 private static readonly string [ ] MediaExtensions = { ".jpg" , ".png" , ".avi" , ".mkv" , ".bmp" , ".gif" , ".wmv" , ".mp3" , ".flac" , ".mp4" } ;
353395 }
354396
0 commit comments