Skip to content

Commit 4c7a4fe

Browse files
committed
Add more info tooltip support for volumes
1 parent 1a95632 commit 4c7a4fe

File tree

2 files changed

+44
-36
lines changed

2 files changed

+44
-36
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
<system:String x:Key="plugin_explorer_plugin_ToolTipOpenContainingFolder">Ctrl + Enter to open the containing folder</system:String>
8383
<system:String x:Key="plugin_explorer_plugin_tooltip_more_info">{0}{4}Size: {1}{4}Date created: {2}{4}Date modified: {3}</system:String>
8484
<system:String x:Key="plugin_explorer_plugin_tooltip_more_info_unknown">Unknown</system:String>
85+
<system:String x:Key="plugin_explorer_plugin_tooltip_more_info_volume">{0}{3}Space free: {1}{3}Total size: {2}</system:String>
8586

8687
<!-- Context menu items -->
8788
<system:String x:Key="plugin_explorer_copypath">Copy path</system:String>

Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
162162
},
163163
Score = score,
164164
TitleToolTip = Main.Context.API.GetTranslation("plugin_explorer_plugin_ToolTipOpenDirectory"),
165-
SubTitleToolTip = Settings.DisplayMoreInformationInToolTip ? GetMoreInfoToolTip(path, ResultType.Folder) : path,
165+
SubTitleToolTip = Settings.DisplayMoreInformationInToolTip ? GetFolderMoreInfoTooltip(path) : path,
166166
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = path, WindowsIndexed = windowsIndexed }
167167
};
168168
}
@@ -183,6 +183,10 @@ internal static Result CreateDriveSpaceDisplayResult(string path, string actionK
183183
if (progressValue >= 90)
184184
progressBarColor = "#da2626";
185185

186+
var tooltip = Settings.DisplayMoreInformationInToolTip
187+
? GetVolumeMoreInfoTooltip(path, freespace, totalspace)
188+
: path;
189+
186190
return new Result
187191
{
188192
Title = title,
@@ -201,8 +205,8 @@ internal static Result CreateDriveSpaceDisplayResult(string path, string actionK
201205
OpenFolder(path);
202206
return true;
203207
},
204-
TitleToolTip = path,
205-
SubTitleToolTip = path,
208+
TitleToolTip = tooltip,
209+
SubTitleToolTip = tooltip,
206210
ContextData = new SearchResult { Type = ResultType.Volume, FullPath = path, WindowsIndexed = windowsIndexed }
207211
};
208212
}
@@ -316,7 +320,7 @@ internal static Result CreateFileResult(string filePath, Query query, int score
316320
return true;
317321
},
318322
TitleToolTip = Main.Context.API.GetTranslation("plugin_explorer_plugin_ToolTipOpenContainingFolder"),
319-
SubTitleToolTip = Settings.DisplayMoreInformationInToolTip ? GetMoreInfoToolTip(filePath, ResultType.File) : filePath,
323+
SubTitleToolTip = Settings.DisplayMoreInformationInToolTip ? GetFileMoreInfoTooltip(filePath) : filePath,
320324
ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath, WindowsIndexed = windowsIndexed }
321325
};
322326
return result;
@@ -347,43 +351,46 @@ private static void IncrementEverythingRunCounterIfNeeded(string fileOrFolder)
347351
_ = Task.Run(() => EverythingApi.IncrementRunCounterAsync(fileOrFolder));
348352
}
349353

350-
private static string GetMoreInfoToolTip(string filePath, ResultType type)
354+
private static string GetFileMoreInfoTooltip(string filePath)
351355
{
352-
switch (type)
356+
try
353357
{
354-
case ResultType.Folder:
355-
try
356-
{
357-
var folderSize = PreviewPanel.GetFolderSize(filePath);
358-
var folderCreatedAt = PreviewPanel.GetFolderCreatedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
359-
var folderModifiedAt = PreviewPanel.GetFolderLastModifiedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
360-
return string.Format(Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info"),
361-
filePath, folderSize, folderCreatedAt, folderModifiedAt, Environment.NewLine);
362-
}
363-
catch (Exception e)
364-
{
365-
Context.API.LogException(ClassName, $"Failed to load tooltip for {filePath}", e);
366-
return filePath;
367-
}
368-
case ResultType.File:
369-
try
370-
{
371-
var fileSize = PreviewPanel.GetFileSize(filePath);
372-
var fileCreatedAt = PreviewPanel.GetFileCreatedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
373-
var fileModifiedAt = PreviewPanel.GetFileLastModifiedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
374-
return string.Format(Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info"),
375-
filePath, fileSize, fileCreatedAt, fileModifiedAt, Environment.NewLine);
376-
}
377-
catch (Exception e)
378-
{
379-
Context.API.LogException(ClassName, $"Failed to load tooltip for {filePath}", e);
380-
return filePath;
381-
}
382-
default:
383-
return filePath;
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;
384368
}
385369
}
386370

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+
387394
private static readonly string[] MediaExtensions = { ".jpg", ".png", ".avi", ".mkv", ".bmp", ".gif", ".wmv", ".mp3", ".flac", ".mp4" };
388395
}
389396

0 commit comments

Comments
 (0)