Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<system:String x:Key="plugin_explorer_previewpanel_display_file_size_checkbox">Size</system:String>
<system:String x:Key="plugin_explorer_previewpanel_display_file_creation_checkbox">Date Created</system:String>
<system:String x:Key="plugin_explorer_previewpanel_display_file_modification_checkbox">Date Modified</system:String>
<system:String x:Key="plugin_explorer_previewpanel_display_file_age_checkbox">File Age</system:String>
<system:String x:Key="plugin_explorer_previewpanel_file_info_label">Display File Info</system:String>
<system:String x:Key="plugin_explorer_previewpanel_date_and_time_format_label">Date and time format</system:String>
<system:String x:Key="plugin_explorer_everything_sort_option">Sort Option:</system:String>
Expand Down Expand Up @@ -166,4 +167,12 @@
<system:String x:Key="plugin_explorer_native_context_menu_display_context_menu">Display native context menu (experimental)</system:String>
<system:String x:Key="plugin_explorer_native_context_menu_include_patterns_guide">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').</system:String>
<system:String x:Key="plugin_explorer_native_context_menu_exclude_patterns_guide">Below you can specify items you want to exclude from context menu, they can be partial (e.g. 'pen wit') or complete ('Open with').</system:String>

<!-- Preview Info -->
<system:String x:Key="Today">Today</system:String>
<system:String x:Key="DaysAgo">{0} days ago</system:String>
<system:String x:Key="OneMonthAgo">1 month ago</system:String>
<system:String x:Key="MonthsAgo">{0} months ago</system:String>
<system:String x:Key="OneYearAgo">1 year ago</system:String>
<system:String x:Key="YearsAgo">{0} years ago</system:String>
</ResourceDictionary>
4 changes: 3 additions & 1 deletion Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class Settings

public string ExcludedFileTypes { get; set; } = "";


public bool UseLocationAsWorkingDir { get; set; } = false;

public bool ShowInlinedWindowsContextMenu { get; set; } = false;
Expand Down Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@
}
}

public bool ShowFileAgeInPreviewPanel
{
get => Settings.ShowFileAgeInPreviewPanel;
set
{
Settings.ShowFileAgeInPreviewPanel = value;
OnPropertyChanged();
OnPropertyChanged(nameof(ShowPreviewPanelDateTimeChoices));
OnPropertyChanged(nameof(PreviewPanelDateTimeChoicesVisibility));
}
}

public string PreviewPanelDateFormat
{
get => Settings.PreviewPanelDateFormat;
Expand Down Expand Up @@ -245,13 +257,13 @@
new(Settings.ActionKeyword.SearchActionKeyword,
"plugin_explorer_actionkeywordview_search"),
new(Settings.ActionKeyword.FileContentSearchActionKeyword,
"plugin_explorer_actionkeywordview_filecontentsearch"),

Check warning on line 260 in Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`actionkeywordview` is not a recognized word. (unrecognized-spelling)
new(Settings.ActionKeyword.PathSearchActionKeyword,
"plugin_explorer_actionkeywordview_pathsearch"),

Check warning on line 262 in Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`actionkeywordview` is not a recognized word. (unrecognized-spelling)
new(Settings.ActionKeyword.IndexSearchActionKeyword,
"plugin_explorer_actionkeywordview_indexsearch"),

Check warning on line 264 in Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`actionkeywordview` is not a recognized word. (unrecognized-spelling)
new(Settings.ActionKeyword.QuickAccessActionKeyword,
"plugin_explorer_actionkeywordview_quickaccess")

Check warning on line 266 in Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`actionkeywordview` is not a recognized word. (unrecognized-spelling)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,23 +488,28 @@
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
VerticalAlignment="Center"
Foreground="{DynamicResource Color05B}"
Text="{DynamicResource plugin_explorer_previewpanel_file_info_label}" />

Check warning on line 491 in Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml

View workflow job for this annotation

GitHub Actions / Check Spelling

`previewpanel` is not a recognized word. (unrecognized-spelling)
<WrapPanel
Width="Auto"
HorizontalAlignment="Right"
DockPanel.Dock="Right">
<CheckBox
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
Content="{DynamicResource plugin_explorer_previewpanel_display_file_size_checkbox}"

Check warning on line 498 in Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml

View workflow job for this annotation

GitHub Actions / Check Spelling

`previewpanel` is not a recognized word. (unrecognized-spelling)
IsChecked="{Binding ShowFileSizeInPreviewPanel}" />
<CheckBox
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
Content="{DynamicResource plugin_explorer_previewpanel_display_file_creation_checkbox}"

Check warning on line 502 in Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml

View workflow job for this annotation

GitHub Actions / Check Spelling

`previewpanel` is not a recognized word. (unrecognized-spelling)
IsChecked="{Binding ShowCreatedDateInPreviewPanel}" />
<CheckBox
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
Content="{DynamicResource plugin_explorer_previewpanel_display_file_modification_checkbox}"

Check warning on line 506 in Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml

View workflow job for this annotation

GitHub Actions / Check Spelling

`previewpanel` is not a recognized word. (unrecognized-spelling)
IsChecked="{Binding ShowModifiedDateInPreviewPanel}" />

<CheckBox
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
Content="{DynamicResource plugin_explorer_previewpanel_display_file_age_checkbox}"
IsChecked="{Binding ShowFileAgeInPreviewPanel}" />
</WrapPanel>
</DockPanel>

Expand Down Expand Up @@ -711,7 +716,7 @@
Height="200"
AllowDrop="True"
BorderThickness="1"
DragEnter="lbxAccessLinks_DragEnter"

Check warning on line 719 in Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml

View workflow job for this annotation

GitHub Actions / Check Spelling

`lbx` is not a recognized word. (unrecognized-spelling)
Drop="LbxAccessLinks_OnDrop"
ItemTemplate="{StaticResource ListViewTemplateAccessLinks}"
ItemsSource="{Binding Settings.QuickAccessLinks}"
Expand Down Expand Up @@ -768,7 +773,7 @@
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
BorderThickness="1">
<ListView
Name="lbxExcludedPaths"

Check warning on line 776 in Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml

View workflow job for this annotation

GitHub Actions / Check Spelling

`lbx` is not a recognized word. (unrecognized-spelling)
Height="200"
AllowDrop="True"
DragEnter="lbxAccessLinks_DragEnter"
Expand Down
56 changes: 43 additions & 13 deletions Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -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();
Expand All @@ -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;

Expand Down
Loading