mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Support custom preview panel for folder results
This commit is contained in:
parent
f069ee9094
commit
85c038719e
2 changed files with 11 additions and 11 deletions
|
|
@ -99,10 +99,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<UserControl>(() => new PreviewPanel(Settings, path, ResultType.Folder)),
|
||||
Action = c =>
|
||||
{
|
||||
if (c.SpecialKeyState.ToModifierKeys() == ModifierKeys.Alt)
|
||||
|
|
@ -286,7 +283,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
TitleHighlightData = Context.API.FuzzySearch(query.Search, title).MatchData,
|
||||
Score = score,
|
||||
CopyText = filePath,
|
||||
PreviewPanel = new Lazy<UserControl>(() => new PreviewPanel(Settings, filePath)),
|
||||
PreviewPanel = new Lazy<UserControl>(() => new PreviewPanel(Settings, filePath, ResultType.File)),
|
||||
Action = c =>
|
||||
{
|
||||
if (c.SpecialKeyState.ToModifierKeys() == ModifierKeys.Alt)
|
||||
|
|
@ -354,7 +351,6 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
{
|
||||
case ResultType.Folder:
|
||||
var folderSize = PreviewPanel.GetFolderSize(filePath);
|
||||
if (string.IsNullOrEmpty(folderSize)) folderSize = Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown");
|
||||
var folderCreatedAt = PreviewPanel.GetFolderCreatedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
|
||||
var folderModifiedAt = PreviewPanel.GetFolderLastModifiedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
|
||||
return string.Format(Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info"),
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public partial class PreviewPanel : UserControl, INotifyPropertyChanged
|
|||
? Visibility.Visible
|
||||
: Visibility.Collapsed;
|
||||
|
||||
public PreviewPanel(Settings settings, string filePath)
|
||||
public PreviewPanel(Settings settings, string filePath, ResultType type)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
|
@ -60,17 +60,21 @@ public partial class PreviewPanel : UserControl, INotifyPropertyChanged
|
|||
|
||||
if (Settings.ShowFileSizeInPreviewPanel)
|
||||
{
|
||||
FileSize = GetFileSize(filePath);
|
||||
FileSize = type == ResultType.File ? GetFileSize(filePath) : GetFolderSize(filePath);
|
||||
}
|
||||
|
||||
if (Settings.ShowCreatedDateInPreviewPanel)
|
||||
{
|
||||
CreatedAt = GetFileCreatedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
|
||||
CreatedAt = type == ResultType.File ?
|
||||
GetFileCreatedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel) :
|
||||
GetFolderCreatedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
|
||||
}
|
||||
|
||||
if (Settings.ShowModifiedDateInPreviewPanel)
|
||||
{
|
||||
LastModifiedAt = GetFileLastModifiedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
|
||||
LastModifiedAt = type == ResultType.File ?
|
||||
GetFileLastModifiedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel) :
|
||||
GetFolderLastModifiedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
|
||||
}
|
||||
|
||||
_ = LoadImageAsync();
|
||||
|
|
@ -126,7 +130,7 @@ public partial class PreviewPanel : UserControl, INotifyPropertyChanged
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return string.Empty;
|
||||
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown");
|
||||
}
|
||||
return ResultManager.ToReadableSize(size, 2);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue