diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs
index fc6c5d185..ea79386b3 100644
--- a/Flow.Launcher.Plugin/Result.cs
+++ b/Flow.Launcher.Plugin/Result.cs
@@ -204,7 +204,7 @@ namespace Flow.Launcher.Plugin
Score = Score,
TitleHighlightData = TitleHighlightData,
OriginQuery = OriginQuery,
- PluginDirectory = PluginDirectory
+ PluginDirectory = PluginDirectory,
};
}
@@ -258,7 +258,7 @@ namespace Flow.Launcher.Plugin
public string ProgressBarColor { get; set; } = "#26a0da";
///
- /// Contains data used to populate the the preview section of this result.
+ /// Contains data used to populate the preview section of this result.
///
public PreviewInfo Preview { get; set; } = PreviewInfo.Default;
diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml
index 633b84b19..070c290cd 100644
--- a/Flow.Launcher/Languages/en.xaml
+++ b/Flow.Launcher/Languages/en.xaml
@@ -417,4 +417,8 @@
sn
Sticky Notes
+
+ File Size
+ Created
+ Last Modified
diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml
index 2315d99ec..a8dfefb2a 100644
--- a/Flow.Launcher/MainWindow.xaml
+++ b/Flow.Launcher/MainWindow.xaml
@@ -7,6 +7,7 @@
xmlns:flowlauncher="clr-namespace:Flow.Launcher"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
+ xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
Name="FlowMainWindow"
@@ -514,4 +515,4 @@
-
\ No newline at end of file
+
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
index f2491d928..52daf20fb 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
@@ -29,6 +29,12 @@
Customise Action Keywords
Quick Access Links
Everything Setting
+ Preview Panel
+ Size
+ Creation date
+ Modification date
+ Display File Info
+ Date and time format
Sort Option:
Everything Path:
Launch Hidden
@@ -105,10 +111,11 @@
Open With
Select a program to open with
-
+
{0} free of {1}
Open in Default File Manager
- Use '>' to search in this directory, '*' to search for file extensions or '>*' to combine both searches.
+
+ Use '>' to search in this directory, '*' to search for file extensions or '>*' to combine both searches.
Failed to load Everything SDK
@@ -133,7 +140,7 @@
Warning: This is not a Fast Sort option, searches may be slow
Search Full Path
-
+
Click to launch or install Everything
Everything Installation
Installing Everything service. Please wait...
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
index a87f766a1..34f80f552 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
@@ -8,11 +8,15 @@ using System.Threading.Tasks;
using System.Windows;
using Flow.Launcher.Plugin.Explorer.Search.Everything;
using System.Windows.Input;
+using Path = System.IO.Path;
+using System.Windows.Controls;
+using Flow.Launcher.Plugin.Explorer.Views;
namespace Flow.Launcher.Plugin.Explorer.Search
{
public static class ResultManager
{
+ private static readonly string[] SizeUnits = { "B", "KB", "MB", "GB", "TB" };
private static PluginInitContext Context;
private static Settings Settings { get; set; }
@@ -172,36 +176,28 @@ namespace Flow.Launcher.Plugin.Explorer.Search
};
}
- private static string ToReadableSize(long pDrvSize, int pi)
+ internal static string ToReadableSize(long sizeOnDrive, int pi)
{
- int mok = 0;
- double drvSize = pDrvSize;
- string uom = "Byte"; // Unit Of Measurement
+ var unitIndex = 0;
+ double readableSize = sizeOnDrive;
- while (drvSize > 1024.0)
+ while (readableSize > 1024.0 && unitIndex < SizeUnits.Length - 1)
{
- drvSize /= 1024.0;
- mok++;
+ readableSize /= 1024.0;
+ unitIndex++;
}
- if (mok == 1)
- uom = "KB";
- else if (mok == 2)
- uom = " MB";
- else if (mok == 3)
- uom = " GB";
- else if (mok == 4)
- uom = " TB";
+ var unit = SizeUnits[unitIndex] ?? "";
- var returnStr = $"{Convert.ToInt32(drvSize)}{uom}";
- if (mok != 0)
+ var returnStr = $"{Convert.ToInt32(readableSize)} {unit}";
+ if (unitIndex != 0)
{
returnStr = pi switch
{
- 1 => $"{drvSize:F1}{uom}",
- 2 => $"{drvSize:F2}{uom}",
- 3 => $"{drvSize:F3}{uom}",
- _ => $"{Convert.ToInt32(drvSize)}{uom}"
+ 1 => $"{readableSize:F1} {unit}",
+ 2 => $"{readableSize:F2} {unit}",
+ 3 => $"{readableSize:F3} {unit}",
+ _ => $"{Convert.ToInt32(readableSize)} {unit}"
};
}
@@ -239,6 +235,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search
var title = Path.GetFileName(filePath);
+
+ /* Preview Detail */
+
var result = new Result
{
Title = title,
@@ -249,6 +248,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
Score = score,
CopyText = filePath,
+ PreviewPanel = new Lazy(() => new PreviewPanel(Settings, filePath)),
Action = c =>
{
try
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
index 137ba2f19..088bcf5d6 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
@@ -55,6 +55,16 @@ namespace Flow.Launcher.Plugin.Explorer
public bool WarnWindowsSearchServiceOff { get; set; } = true;
+ public bool ShowFileSizeInPreviewPanel { get; set; } = true;
+
+ public bool ShowCreatedDateInPreviewPanel { get; set; } = true;
+
+ public bool ShowModifiedDateInPreviewPanel { get; set; } = true;
+
+ public string PreviewPanelDateFormat { get; set; } = "yyyy-MM-dd";
+
+ public string PreviewPanelTimeFormat { get; set; } = "HH:mm";
+
private EverythingSearchManager _everythingManagerInstance;
private WindowsIndexSearchManager _windowsIndexSearchManager;
@@ -137,7 +147,7 @@ namespace Flow.Launcher.Plugin.Explorer
ContentSearchEngine == ContentIndexSearchEngineOption.Everything;
public bool EverythingSearchFullPath { get; set; } = false;
-
+
#endregion
internal enum ActionKeyword
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
index 02199fb5a..064795b43 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
@@ -8,6 +8,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows;
@@ -101,7 +102,107 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
#endregion
+ #region Preview Panel
+ public bool ShowFileSizeInPreviewPanel
+ {
+ get => Settings.ShowFileSizeInPreviewPanel;
+ set
+ {
+ Settings.ShowFileSizeInPreviewPanel = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public bool ShowCreatedDateInPreviewPanel
+ {
+ get => Settings.ShowCreatedDateInPreviewPanel;
+ set
+ {
+ Settings.ShowCreatedDateInPreviewPanel = value;
+ OnPropertyChanged();
+ OnPropertyChanged(nameof(ShowPreviewPanelDateTimeChoices));
+ OnPropertyChanged(nameof(PreviewPanelDateTimeChoicesVisibility));
+ }
+ }
+
+ public bool ShowModifiedDateInPreviewPanel
+ {
+ get => Settings.ShowModifiedDateInPreviewPanel;
+ set
+ {
+ Settings.ShowModifiedDateInPreviewPanel = value;
+ OnPropertyChanged();
+ OnPropertyChanged(nameof(ShowPreviewPanelDateTimeChoices));
+ OnPropertyChanged(nameof(PreviewPanelDateTimeChoicesVisibility));
+ }
+ }
+
+ public string PreviewPanelDateFormat
+ {
+ get => Settings.PreviewPanelDateFormat;
+ set
+ {
+ Settings.PreviewPanelDateFormat = value;
+ OnPropertyChanged();
+ OnPropertyChanged(nameof(PreviewPanelDateFormatDemo));
+ }
+ }
+
+ public string PreviewPanelTimeFormat
+ {
+ get => Settings.PreviewPanelTimeFormat;
+ set
+ {
+ Settings.PreviewPanelTimeFormat = value;
+ OnPropertyChanged();
+ OnPropertyChanged(nameof(PreviewPanelTimeFormatDemo));
+ }
+ }
+
+ public string PreviewPanelDateFormatDemo => DateTime.Now.ToString(PreviewPanelDateFormat, CultureInfo.CurrentCulture);
+ public string PreviewPanelTimeFormatDemo => DateTime.Now.ToString(PreviewPanelTimeFormat, CultureInfo.CurrentCulture);
+
+ public bool ShowPreviewPanelDateTimeChoices => ShowCreatedDateInPreviewPanel || ShowModifiedDateInPreviewPanel;
+
+ public Visibility PreviewPanelDateTimeChoicesVisibility => ShowCreatedDateInPreviewPanel || ShowModifiedDateInPreviewPanel ? Visibility.Visible : Visibility.Collapsed;
+
+
+ public List TimeFormatList { get; } = new()
+ {
+ "h:mm",
+ "hh:mm",
+ "H:mm",
+ "HH:mm",
+ "tt h:mm",
+ "tt hh:mm",
+ "h:mm tt",
+ "hh:mm tt",
+ "hh:mm:ss tt",
+ "HH:mm:ss"
+ };
+
+
+ public List DateFormatList { get; } = new()
+ {
+ "dd/MM/yyyy",
+ "dd/MM/yyyy ddd",
+ "dd/MM/yyyy, dddd",
+ "dd-MM-yyyy",
+ "dd-MM-yyyy ddd",
+ "dd-MM-yyyy, dddd",
+ "dd.MM.yyyy",
+ "dd.MM.yyyy ddd",
+ "dd.MM.yyyy, dddd",
+ "MM/dd/yyyy",
+ "MM/dd/yyyy ddd",
+ "MM/dd/yyyy, dddd",
+ "yyyy-MM-dd",
+ "yyyy-MM-dd ddd",
+ "yyyy-MM-dd, dddd",
+ };
+
+ #endregion
#region ActionKeyword
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
index b0708b793..5c92fc271 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
@@ -348,6 +348,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml
new file mode 100644
index 000000000..b5cfd1a5d
--- /dev/null
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs
new file mode 100644
index 000000000..878832e4f
--- /dev/null
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs
@@ -0,0 +1,101 @@
+using System.ComponentModel;
+using System.Globalization;
+using System.IO;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using Flow.Launcher.Infrastructure.Image;
+using Flow.Launcher.Plugin.Explorer.Search;
+
+namespace Flow.Launcher.Plugin.Explorer.Views;
+
+#nullable enable
+
+public partial class PreviewPanel : UserControl, INotifyPropertyChanged
+{
+ private string FilePath { get; }
+ public string FileSize { get; } = "";
+ public string CreatedAt { get; } = "";
+ public string LastModifiedAt { get; } = "";
+ private ImageSource _previewImage = new BitmapImage();
+ private Settings Settings { get; }
+
+ public ImageSource PreviewImage
+ {
+ get => _previewImage;
+ private set
+ {
+ _previewImage = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public Visibility FileSizeVisibility => Settings.ShowFileSizeInPreviewPanel
+ ? Visibility.Visible
+ : Visibility.Collapsed;
+ public Visibility CreatedAtVisibility => Settings.ShowCreatedDateInPreviewPanel
+ ? Visibility.Visible
+ : Visibility.Collapsed;
+ public Visibility LastModifiedAtVisibility => Settings.ShowModifiedDateInPreviewPanel
+ ? Visibility.Visible
+ : Visibility.Collapsed;
+
+ public Visibility FileInfoVisibility =>
+ Settings.ShowFileSizeInPreviewPanel ||
+ Settings.ShowCreatedDateInPreviewPanel ||
+ Settings.ShowModifiedDateInPreviewPanel
+ ? Visibility.Visible
+ : Visibility.Collapsed;
+
+ public PreviewPanel(Settings settings, string filePath)
+ {
+ InitializeComponent();
+
+ Settings = settings;
+
+ FilePath = filePath;
+
+ if (Settings.ShowFileSizeInPreviewPanel)
+ {
+ var fileSize = new FileInfo(filePath).Length;
+ FileSize = ResultManager.ToReadableSize(fileSize, 2);
+ }
+
+ if (Settings.ShowCreatedDateInPreviewPanel)
+ {
+ CreatedAt = File
+ .GetCreationTime(filePath)
+ .ToString(
+ $"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}",
+ CultureInfo.CurrentCulture
+ );
+ }
+
+ if (Settings.ShowModifiedDateInPreviewPanel)
+ {
+ LastModifiedAt = File
+ .GetLastWriteTime(filePath)
+ .ToString(
+ $"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}",
+ CultureInfo.CurrentCulture
+ );
+ }
+
+ _ = LoadImageAsync();
+ }
+
+ private async Task LoadImageAsync()
+ {
+ PreviewImage = await ImageLoader.LoadAsync(FilePath, true).ConfigureAwait(false);
+ }
+
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+}