Skip to content

Commit 35e71c6

Browse files
committed
Relative Date checkbox
1 parent 90ad72c commit 35e71c6

File tree

6 files changed

+34
-5
lines changed

6 files changed

+34
-5
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<system:String x:Key="plugin_explorer_previewpanel_display_file_size_checkbox">Size</system:String>
3434
<system:String x:Key="plugin_explorer_previewpanel_display_file_creation_checkbox">Date Created</system:String>
3535
<system:String x:Key="plugin_explorer_previewpanel_display_file_modification_checkbox">Date Modified</system:String>
36+
<system:String x:Key="plugin_explorer_previewpanel_display_file_relative_date_checkbox">Relative Date</system:String>
3637
<system:String x:Key="plugin_explorer_previewpanel_file_info_label">Display File Info</system:String>
3738
<system:String x:Key="plugin_explorer_previewpanel_date_and_time_format_label">Date and time format</system:String>
3839
<system:String x:Key="plugin_explorer_everything_sort_option">Sort Option:</system:String>
@@ -125,6 +126,8 @@
125126
<system:String x:Key="plugin_explorer_openresultfolder_subtitle">
126127
Use '>' to search in this directory, '*' to search for file extensions or '>*' to combine both searches.
127128
</system:String>
129+
130+
128131

129132
<!-- Everything -->
130133
<system:String x:Key="flowlauncher_plugin_everything_sdk_issue">Failed to load Everything SDK</system:String>

Plugins/Flow.Launcher.Plugin.Explorer/Languages/pt-br.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
<system:String x:Key="plugin_explorer_everything_setting_header">Everything Setting</system:String>
3030
<system:String x:Key="plugin_explorer_previewpanel_setting_header">Preview Panel</system:String>
3131
<system:String x:Key="plugin_explorer_previewpanel_display_file_size_checkbox">Tamanho</system:String>
32-
<system:String x:Key="plugin_explorer_previewpanel_display_file_creation_checkbox">Date Created</system:String>
33-
<system:String x:Key="plugin_explorer_previewpanel_display_file_modification_checkbox">Date Modified</system:String>
32+
<system:String x:Key="plugin_explorer_previewpanel_display_file_creation_checkbox">Data Criação</system:String>
33+
<system:String x:Key="plugin_explorer_previewpanel_display_file_modification_checkbox">Data Modificação</system:String>
34+
<system:String x:Key="plugin_explorer_previewpanel_display_file_relative_date_checkbox">Data Relativa</system:String>
3435
<system:String x:Key="plugin_explorer_previewpanel_file_info_label">Display File Info</system:String>
3536
<system:String x:Key="plugin_explorer_previewpanel_date_and_time_format_label">Date and time format</system:String>
3637
<system:String x:Key="plugin_explorer_everything_sort_option">Sort Option:</system:String>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ public class Settings
6666
public bool ShowCreatedDateInPreviewPanel { get; set; } = true;
6767

6868
public bool ShowModifiedDateInPreviewPanel { get; set; } = true;
69+
70+
public bool ShowRelativeDateInPreviewPanel { get; set; } = true;
71+
6972

7073
public string PreviewPanelDateFormat { get; set; } = "yyyy-MM-dd";
7174

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,18 @@ public bool ShowModifiedDateInPreviewPanel
169169
}
170170
}
171171

172+
public bool ShowRelativeDateInPreviewPanel
173+
{
174+
get => Settings.ShowRelativeDateInPreviewPanel;
175+
set
176+
{
177+
Settings.ShowRelativeDateInPreviewPanel = value;
178+
OnPropertyChanged();
179+
OnPropertyChanged(nameof(ShowPreviewPanelDateTimeChoices));
180+
OnPropertyChanged(nameof(PreviewPanelDateTimeChoicesVisibility));
181+
}
182+
}
183+
172184
public string PreviewPanelDateFormat
173185
{
174186
get => Settings.PreviewPanelDateFormat;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,11 @@
505505
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
506506
Content="{DynamicResource plugin_explorer_previewpanel_display_file_modification_checkbox}"
507507
IsChecked="{Binding ShowModifiedDateInPreviewPanel}" />
508+
509+
<CheckBox
510+
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
511+
Content="{DynamicResource plugin_explorer_previewpanel_display_file_relative_date_checkbox}"
512+
IsChecked="{Binding ShowRelativeDateInPreviewPanel}" />
508513
</WrapPanel>
509514
</DockPanel>
510515

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ public PreviewPanel(Settings settings, string filePath)
7171
$"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}",
7272
CultureInfo.CurrentCulture
7373
);
74-
CreatedAt = $"{GetDiffTimeString(createdDate)} - {formattedDate}";
74+
75+
string result = formattedDate;
76+
if (Settings.ShowRelativeDateInPreviewPanel) result = $"{GetFileAge(createdDate)} - {formattedDate}";
77+
CreatedAt = result;
7578
}
7679

7780
if (Settings.ShowModifiedDateInPreviewPanel)
@@ -81,7 +84,9 @@ public PreviewPanel(Settings settings, string filePath)
8184
$"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}",
8285
CultureInfo.CurrentCulture
8386
);
84-
LastModifiedAt = $"{GetDiffTimeString(lastModifiedDate)} - {formattedDate}";
87+
string result = formattedDate;
88+
if (Settings.ShowRelativeDateInPreviewPanel) result = $"{GetFileAge(lastModifiedDate)} - {formattedDate}";
89+
LastModifiedAt = result;
8590
}
8691

8792
_ = LoadImageAsync();
@@ -92,7 +97,7 @@ private async Task LoadImageAsync()
9297
PreviewImage = await Main.Context.API.LoadImageAsync(FilePath, true).ConfigureAwait(false);
9398
}
9499

95-
private string GetDiffTimeString(DateTime fileDateTime)
100+
private string GetFileAge(DateTime fileDateTime)
96101
{
97102
DateTime now = DateTime.Now;
98103
TimeSpan difference = now - fileDateTime;

0 commit comments

Comments
 (0)