diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
index 79f8a5848ec..eefd6f4eb53 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
@@ -33,6 +33,7 @@
Size
Date Created
Date Modified
+ File Age
Display File Info
Date and time format
Sort Option:
@@ -166,4 +167,12 @@
Display native context menu (experimental)
Below you can specify items you want to include in the context menu, they can be partial (e.g. 'pen wit') or complete ('Open with').
Below you can specify items you want to exclude from context menu, they can be partial (e.g. 'pen wit') or complete ('Open with').
+
+
+ Today
+ {0} days ago
+ 1 month ago
+ {0} months ago
+ 1 year ago
+ {0} years ago
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
index 3d30bcf29e5..4f83fc72e5b 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
@@ -27,7 +27,6 @@ public class Settings
public string ExcludedFileTypes { get; set; } = "";
-
public bool UseLocationAsWorkingDir { get; set; } = false;
public bool ShowInlinedWindowsContextMenu { get; set; } = false;
@@ -66,6 +65,9 @@ public class Settings
public bool ShowCreatedDateInPreviewPanel { get; set; } = true;
public bool ShowModifiedDateInPreviewPanel { get; set; } = true;
+
+ public bool ShowFileAgeInPreviewPanel { get; set; } = false;
+
public string PreviewPanelDateFormat { get; set; } = "yyyy-MM-dd";
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
index cf9ebd33fee..fb33dacab01 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
@@ -169,6 +169,18 @@ public bool ShowModifiedDateInPreviewPanel
}
}
+ public bool ShowFileAgeInPreviewPanel
+ {
+ get => Settings.ShowFileAgeInPreviewPanel;
+ set
+ {
+ Settings.ShowFileAgeInPreviewPanel = value;
+ OnPropertyChanged();
+ OnPropertyChanged(nameof(ShowPreviewPanelDateTimeChoices));
+ OnPropertyChanged(nameof(PreviewPanelDateTimeChoicesVisibility));
+ }
+ }
+
public string PreviewPanelDateFormat
{
get => Settings.PreviewPanelDateFormat;
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
index e5999da4166..4302e721a51 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
@@ -505,6 +505,11 @@
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
Content="{DynamicResource plugin_explorer_previewpanel_display_file_modification_checkbox}"
IsChecked="{Binding ShowModifiedDateInPreviewPanel}" />
+
+
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs
index aaf1efdc1fd..e1a957199a5 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs
@@ -1,4 +1,5 @@
-using System.ComponentModel;
+using System;
+using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
@@ -65,22 +66,27 @@ public PreviewPanel(Settings settings, string filePath)
if (Settings.ShowCreatedDateInPreviewPanel)
{
- CreatedAt = File
- .GetCreationTime(filePath)
- .ToString(
- $"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}",
- CultureInfo.CurrentCulture
- );
+ DateTime createdDate = File.GetCreationTime(filePath);
+ string formattedDate = createdDate.ToString(
+ $"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}",
+ CultureInfo.CurrentCulture
+ );
+
+ string result = formattedDate;
+ if (Settings.ShowFileAgeInPreviewPanel) result = $"{GetFileAge(createdDate)} - {formattedDate}";
+ CreatedAt = result;
}
if (Settings.ShowModifiedDateInPreviewPanel)
{
- LastModifiedAt = File
- .GetLastWriteTime(filePath)
- .ToString(
- $"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}",
- CultureInfo.CurrentCulture
- );
+ DateTime lastModifiedDate = File.GetLastWriteTime(filePath);
+ string formattedDate = lastModifiedDate.ToString(
+ $"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}",
+ CultureInfo.CurrentCulture
+ );
+ string result = formattedDate;
+ if (Settings.ShowFileAgeInPreviewPanel) result = $"{GetFileAge(lastModifiedDate)} - {formattedDate}";
+ LastModifiedAt = result;
}
_ = LoadImageAsync();
@@ -90,6 +96,30 @@ private async Task LoadImageAsync()
{
PreviewImage = await Main.Context.API.LoadImageAsync(FilePath, true).ConfigureAwait(false);
}
+
+ private static string GetFileAge(DateTime fileDateTime)
+ {
+ var now = DateTime.Now;
+ var difference = now - fileDateTime;
+
+ if (difference.TotalDays < 1)
+ return Main.Context.API.GetTranslation("Today");
+ if (difference.TotalDays < 30)
+ return string.Format(Main.Context.API.GetTranslation("DaysAgo"), (int)difference.TotalDays);
+
+ var monthsDiff = (now.Year - fileDateTime.Year) * 12 + now.Month - fileDateTime.Month;
+ if (monthsDiff == 1)
+ return Main.Context.API.GetTranslation("OneMonthAgo");
+ if (monthsDiff < 12)
+ return string.Format(Main.Context.API.GetTranslation("MonthsAgo"), monthsDiff);
+
+ var yearsDiff = now.Year - fileDateTime.Year;
+ if (now.Month < fileDateTime.Month || (now.Month == fileDateTime.Month && now.Day < fileDateTime.Day))
+ yearsDiff--;
+
+ return yearsDiff == 1 ? Main.Context.API.GetTranslation("OneYearAgo") :
+ string.Format(Main.Context.API.GetTranslation("YearsAgo"), yearsDiff);
+ }
public event PropertyChangedEventHandler? PropertyChanged;