Relative Date checkbox

This commit is contained in:
01Dri 2025-05-24 00:12:56 -03:00
parent 90ad72ca30
commit 35e71c6f51
6 changed files with 34 additions and 5 deletions

View file

@ -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_relative_date_checkbox">Relative Date</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>
@ -125,6 +126,8 @@
<system:String x:Key="plugin_explorer_openresultfolder_subtitle">
Use '>' to search in this directory, '*' to search for file extensions or '>*' to combine both searches.
</system:String>
<!-- Everything -->
<system:String x:Key="flowlauncher_plugin_everything_sdk_issue">Failed to load Everything SDK</system:String>

View file

@ -29,8 +29,9 @@
<system:String x:Key="plugin_explorer_everything_setting_header">Everything Setting</system:String>
<system:String x:Key="plugin_explorer_previewpanel_setting_header">Preview Panel</system:String>
<system:String x:Key="plugin_explorer_previewpanel_display_file_size_checkbox">Tamanho</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_creation_checkbox">Data Criação</system:String>
<system:String x:Key="plugin_explorer_previewpanel_display_file_modification_checkbox">Data Modificação</system:String>
<system:String x:Key="plugin_explorer_previewpanel_display_file_relative_date_checkbox">Data Relativa</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>

View file

@ -66,6 +66,9 @@ namespace Flow.Launcher.Plugin.Explorer
public bool ShowCreatedDateInPreviewPanel { get; set; } = true;
public bool ShowModifiedDateInPreviewPanel { get; set; } = true;
public bool ShowRelativeDateInPreviewPanel { get; set; } = true;
public string PreviewPanelDateFormat { get; set; } = "yyyy-MM-dd";

View file

@ -169,6 +169,18 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
}
}
public bool ShowRelativeDateInPreviewPanel
{
get => Settings.ShowRelativeDateInPreviewPanel;
set
{
Settings.ShowRelativeDateInPreviewPanel = value;
OnPropertyChanged();
OnPropertyChanged(nameof(ShowPreviewPanelDateTimeChoices));
OnPropertyChanged(nameof(PreviewPanelDateTimeChoicesVisibility));
}
}
public string PreviewPanelDateFormat
{
get => Settings.PreviewPanelDateFormat;

View file

@ -505,6 +505,11 @@
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
Content="{DynamicResource plugin_explorer_previewpanel_display_file_modification_checkbox}"
IsChecked="{Binding ShowModifiedDateInPreviewPanel}" />
<CheckBox
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"
Content="{DynamicResource plugin_explorer_previewpanel_display_file_relative_date_checkbox}"
IsChecked="{Binding ShowRelativeDateInPreviewPanel}" />
</WrapPanel>
</DockPanel>

View file

@ -71,7 +71,10 @@ public partial class PreviewPanel : UserControl, INotifyPropertyChanged
$"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}",
CultureInfo.CurrentCulture
);
CreatedAt = $"{GetDiffTimeString(createdDate)} - {formattedDate}";
string result = formattedDate;
if (Settings.ShowRelativeDateInPreviewPanel) result = $"{GetFileAge(createdDate)} - {formattedDate}";
CreatedAt = result;
}
if (Settings.ShowModifiedDateInPreviewPanel)
@ -81,7 +84,9 @@ public partial class PreviewPanel : UserControl, INotifyPropertyChanged
$"{Settings.PreviewPanelDateFormat} {Settings.PreviewPanelTimeFormat}",
CultureInfo.CurrentCulture
);
LastModifiedAt = $"{GetDiffTimeString(lastModifiedDate)} - {formattedDate}";
string result = formattedDate;
if (Settings.ShowRelativeDateInPreviewPanel) result = $"{GetFileAge(lastModifiedDate)} - {formattedDate}";
LastModifiedAt = result;
}
_ = LoadImageAsync();
@ -92,7 +97,7 @@ public partial class PreviewPanel : UserControl, INotifyPropertyChanged
PreviewImage = await Main.Context.API.LoadImageAsync(FilePath, true).ConfigureAwait(false);
}
private string GetDiffTimeString(DateTime fileDateTime)
private string GetFileAge(DateTime fileDateTime)
{
DateTime now = DateTime.Now;
TimeSpan difference = now - fileDateTime;