Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
3 changes: 3 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 @@ -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>
Expand Down
5 changes: 3 additions & 2 deletions Plugins/Flow.Launcher.Plugin.Explorer/Languages/pt-br.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 de Criação</system:String>
<system:String x:Key="plugin_explorer_previewpanel_display_file_modification_checkbox">Data de Modificação</system:String>
<system:String x:Key="plugin_explorer_previewpanel_display_file_age_checkbox">Idade do Arquivo</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
3 changes: 3 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,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
52 changes: 39 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,7 +96,27 @@ private async Task LoadImageAsync()
{
PreviewImage = await Main.Context.API.LoadImageAsync(FilePath, true).ConfigureAwait(false);
}

private string GetFileAge(DateTime fileDateTime)
{
DateTime now = DateTime.Now;
TimeSpan difference = now - fileDateTime;

if (difference.TotalDays < 1)
return "Today";
if (difference.TotalDays < 30)
return $"{(int)difference.TotalDays} days ago";

int monthsDiff = (now.Year - fileDateTime.Year) * 12 + now.Month - fileDateTime.Month;
if (monthsDiff < 12)
return monthsDiff == 1 ? "1 month ago" : $"{monthsDiff} months ago";

int yearsDiff = now.Year - fileDateTime.Year;
if (now.Month < fileDateTime.Month || (now.Month == fileDateTime.Month && now.Day < fileDateTime.Day))
yearsDiff--;

return yearsDiff == 1 ? "1 year ago" : $"{yearsDiff} years ago";
}
public event PropertyChangedEventHandler? PropertyChanged;

protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
Expand Down
Loading