Skip to content

Commit d04f493

Browse files
authored
Merge pull request #3631 from Flow-Launcher/file_tooltip
Support More Information for Files, Folders and Volumes Tooltips & Add Custom Preview Panel Support for Folder Results
2 parents 2a4b4de + a04829b commit d04f493

File tree

7 files changed

+329
-49
lines changed

7 files changed

+329
-49
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<system:String x:Key="plugin_explorer_shell_path">Shell Path</system:String>
4747
<system:String x:Key="plugin_explorer_indexsearchexcludedpaths_header">Index Search Excluded Paths</system:String>
4848
<system:String x:Key="plugin_explorer_use_location_as_working_dir">Use search result's location as the working directory of the executable</system:String>
49+
<system:String x:Key="plugin_explorer_display_more_info_in_tooltip">Display more information like size and age in tooltips</system:String>
4950
<system:String x:Key="plugin_explorer_default_open_in_file_manager">Hit Enter to open folder in Default File Manager</system:String>
5051
<system:String x:Key="plugin_explorer_usewindowsindexfordirectorysearch">Use Index Search For Path Search</system:String>
5152
<system:String x:Key="plugin_explorer_manageindexoptions">Indexing Options</system:String>
@@ -82,6 +83,9 @@
8283
<!-- Plugin Tooltip -->
8384
<system:String x:Key="plugin_explorer_plugin_ToolTipOpenDirectory">Ctrl + Enter to open the directory</system:String>
8485
<system:String x:Key="plugin_explorer_plugin_ToolTipOpenContainingFolder">Ctrl + Enter to open the containing folder</system:String>
86+
<system:String x:Key="plugin_explorer_plugin_tooltip_more_info">{0}{4}Size: {1}{4}Date created: {2}{4}Date modified: {3}</system:String>
87+
<system:String x:Key="plugin_explorer_plugin_tooltip_more_info_unknown">Unknown</system:String>
88+
<system:String x:Key="plugin_explorer_plugin_tooltip_more_info_volume">{0}{3}Space free: {1}{3}Total size: {2}</system:String>
8589

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

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

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public class Settings
3737

3838
public bool DefaultOpenFolderInFileManager { get; set; } = false;
3939

40+
public bool DisplayMoreInformationInToolTip { get; set; } = false;
41+
4042
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
4143

4244
public bool SearchActionKeywordEnabled { get; set; } = true;

Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,21 @@ public string PreviewPanelTimeFormat
244244
"yyyy-MM-dd",
245245
"yyyy-MM-dd ddd",
246246
"yyyy-MM-dd, dddd",
247+
"dd/MMM/yyyy",
248+
"dd/MMM/yyyy ddd",
249+
"dd/MMM/yyyy, dddd",
250+
"dd-MMM-yyyy",
251+
"dd-MMM-yyyy ddd",
252+
"dd-MMM-yyyy, dddd",
253+
"dd.MMM.yyyy",
254+
"dd.MMM.yyyy ddd",
255+
"dd.MMM.yyyy, dddd",
256+
"MMM/dd/yyyy",
257+
"MMM/dd/yyyy ddd",
258+
"MMM/dd/yyyy, dddd",
259+
"yyyy-MMM-dd",
260+
"yyyy-MMM-dd ddd",
261+
"yyyy-MMM-dd, dddd",
247262
};
248263

249264
#endregion

Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
<RowDefinition Height="Auto" />
206206
<RowDefinition Height="Auto" />
207207
<RowDefinition Height="Auto" />
208+
<RowDefinition Height="Auto" />
208209
</Grid.RowDefinitions>
209210
<Grid.ColumnDefinitions>
210211
<ColumnDefinition Width="Auto" />
@@ -228,16 +229,25 @@
228229
Content="{DynamicResource plugin_explorer_default_open_in_file_manager}"
229230
IsChecked="{Binding Settings.DefaultOpenFolderInFileManager}" />
230231

231-
<TextBlock
232+
<CheckBox
232233
Grid.Row="2"
233234
Grid.Column="0"
235+
Grid.ColumnSpan="2"
236+
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
237+
HorizontalAlignment="Left"
238+
Content="{DynamicResource plugin_explorer_display_more_info_in_tooltip}"
239+
IsChecked="{Binding Settings.DisplayMoreInformationInToolTip}" />
240+
241+
<TextBlock
242+
Grid.Row="3"
243+
Grid.Column="0"
234244
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
235245
HorizontalAlignment="Left"
236246
VerticalAlignment="Center"
237247
Foreground="{DynamicResource Color05B}"
238248
Text="{DynamicResource plugin_explorer_file_editor_path}" />
239249
<StackPanel
240-
Grid.Row="2"
250+
Grid.Row="3"
241251
Grid.Column="1"
242252
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
243253
Orientation="Horizontal">
@@ -256,15 +266,15 @@
256266
</StackPanel>
257267

258268
<TextBlock
259-
Grid.Row="3"
269+
Grid.Row="4"
260270
Grid.Column="0"
261271
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
262272
HorizontalAlignment="Left"
263273
VerticalAlignment="Center"
264274
Foreground="{DynamicResource Color05B}"
265275
Text="{DynamicResource plugin_explorer_folder_editor_path}" />
266276
<StackPanel
267-
Grid.Row="3"
277+
Grid.Row="4"
268278
Grid.Column="1"
269279
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
270280
Orientation="Horizontal">
@@ -283,15 +293,15 @@
283293
</StackPanel>
284294

285295
<TextBlock
286-
Grid.Row="4"
296+
Grid.Row="5"
287297
Grid.Column="0"
288298
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
289299
HorizontalAlignment="Left"
290300
VerticalAlignment="Center"
291301
Foreground="{DynamicResource Color05B}"
292302
Text="{DynamicResource plugin_explorer_shell_path}" />
293303
<StackPanel
294-
Grid.Row="4"
304+
Grid.Row="5"
295305
Grid.Column="1"
296306
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
297307
Orientation="Horizontal">
@@ -310,14 +320,14 @@
310320
</StackPanel>
311321

312322
<TextBlock
313-
Grid.Row="5"
323+
Grid.Row="6"
314324
Grid.Column="0"
315325
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
316326
VerticalAlignment="Center"
317327
Foreground="{DynamicResource Color05B}"
318328
Text="{DynamicResource plugin_explorer_Index_Search_Engine}" />
319329
<ComboBox
320-
Grid.Row="5"
330+
Grid.Row="6"
321331
Grid.Column="1"
322332
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
323333
HorizontalAlignment="Left"
@@ -327,14 +337,14 @@
327337
SelectedItem="{Binding SelectedIndexSearchEngine}" />
328338

329339
<TextBlock
330-
Grid.Row="6"
340+
Grid.Row="7"
331341
Grid.Column="0"
332342
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
333343
VerticalAlignment="Center"
334344
Foreground="{DynamicResource Color05B}"
335345
Text="{DynamicResource plugin_explorer_Content_Search_Engine}" />
336346
<ComboBox
337-
Grid.Row="6"
347+
Grid.Row="7"
338348
Grid.Column="1"
339349
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
340350
HorizontalAlignment="Left"
@@ -344,14 +354,14 @@
344354
SelectedItem="{Binding SelectedContentSearchEngine}" />
345355

346356
<TextBlock
347-
Grid.Row="7"
357+
Grid.Row="8"
348358
Grid.Column="0"
349359
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
350360
VerticalAlignment="Center"
351361
Foreground="{DynamicResource Color05B}"
352362
Text="{DynamicResource plugin_explorer_Directory_Recursive_Search_Engine}" />
353363
<ComboBox
354-
Grid.Row="7"
364+
Grid.Row="8"
355365
Grid.Column="1"
356366
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
357367
HorizontalAlignment="Left"
@@ -361,14 +371,14 @@
361371
SelectedItem="{Binding SelectedPathEnumerationEngine}" />
362372

363373
<TextBlock
364-
Grid.Row="8"
374+
Grid.Row="9"
365375
Grid.Column="0"
366376
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
367377
VerticalAlignment="Center"
368378
Foreground="{DynamicResource Color05B}"
369379
Text="{DynamicResource plugin_explorer_Excluded_File_Types}" />
370380
<TextBox
371-
Grid.Row="8"
381+
Grid.Row="9"
372382
Grid.Column="1"
373383
MinWidth="{StaticResource SettingPanelTextBoxMinWidth}"
374384
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
@@ -377,14 +387,14 @@
377387
ToolTip="{DynamicResource plugin_explorer_Excluded_File_Types_Tooltip}" />
378388

379389
<TextBlock
380-
Grid.Row="9"
390+
Grid.Row="10"
381391
Grid.Column="0"
382392
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
383393
VerticalAlignment="Center"
384394
Foreground="{DynamicResource Color05B}"
385395
Text="{DynamicResource plugin_explorer_Maximum_Results}" />
386396
<TextBox
387-
Grid.Row="9"
397+
Grid.Row="10"
388398
Grid.Column="1"
389399
MinWidth="{StaticResource SettingPanelTextBoxMinWidth}"
390400
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
@@ -396,7 +406,7 @@
396406
ToolTip="{DynamicResource plugin_explorer_Maximum_Results_Tooltip}" />
397407

398408
<Button
399-
Grid.Row="10"
409+
Grid.Row="11"
400410
Grid.Column="0"
401411
Grid.ColumnSpan="2"
402412
Margin="{StaticResource SettingPanelItemTopBottomMargin}"

Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
HorizontalAlignment="Right"
118118
VerticalAlignment="Top"
119119
Style="{DynamicResource PreviewItemSubTitleStyle}"
120-
Text="{Binding FileSize, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"
120+
Text="{Binding FileSize, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Mode=OneWay}"
121121
TextWrapping="Wrap"
122122
Visibility="{Binding FileSizeVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
123123

0 commit comments

Comments
 (0)