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
4 changes: 2 additions & 2 deletions Flow.Launcher.Plugin/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public Result Clone()
Score = Score,
TitleHighlightData = TitleHighlightData,
OriginQuery = OriginQuery,
PluginDirectory = PluginDirectory
PluginDirectory = PluginDirectory,
};
}

Expand Down Expand Up @@ -258,7 +258,7 @@ public ValueTask<bool> ExecuteAsync(ActionContext context)
public string ProgressBarColor { get; set; } = "#26a0da";

/// <summary>
/// Contains data used to populate the the preview section of this result.
/// Contains data used to populate the preview section of this result.
/// </summary>
public PreviewInfo Preview { get; set; } = PreviewInfo.Default;

Expand Down
4 changes: 4 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,8 @@
<system:String x:Key="RecommendAcronyms">sn</system:String>
<system:String x:Key="RecommendAcronymsDesc">Sticky Notes</system:String>

<!-- Preview Area -->
<system:String x:Key="FileSize">File Size</system:String>
<system:String x:Key="Created">Created</system:String>
<system:String x:Key="LastModified">Last Modified</system:String>
</ResourceDictionary>
3 changes: 2 additions & 1 deletion Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:flowlauncher="clr-namespace:Flow.Launcher"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
Name="FlowMainWindow"
Expand Down Expand Up @@ -514,4 +515,4 @@
</StackPanel>
</Border>
</Grid>
</Window>
</Window>
13 changes: 10 additions & 3 deletions Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
<system:String x:Key="plugin_explorer_manageactionkeywords_header">Customise Action Keywords</system:String>
<system:String x:Key="plugin_explorer_quickaccesslinks_header">Quick Access Links</system:String>
<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">Size</system:String>
<system:String x:Key="plugin_explorer_previewpanel_display_file_creation_checkbox">Creation date</system:String>
<system:String x:Key="plugin_explorer_previewpanel_display_file_modification_checkbox">Modification 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>
<system:String x:Key="plugin_explorer_everything_installed_path">Everything Path:</system:String>
<system:String x:Key="plugin_explorer_launch_hidden">Launch Hidden</system:String>
Expand Down Expand Up @@ -105,10 +111,11 @@
<system:String x:Key="plugin_explorer_openwith">Open With</system:String>
<system:String x:Key="plugin_explorer_openwith_subtitle">Select a program to open with</system:String>

<!-- Special Results-->
<!-- Special Results -->
<system:String x:Key="plugin_explorer_diskfreespace">{0} free of {1}</system:String>
<system:String x:Key="plugin_explorer_openresultfolder">Open in Default File Manager</system:String>
<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>
<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 All @@ -133,7 +140,7 @@
<system:String x:Key="flowlauncher_plugin_everything_nonfastsort_warning">Warning: This is not a Fast Sort option, searches may be slow</system:String>

<system:String x:Key="flowlauncher_plugin_everything_search_fullpath">Search Full Path</system:String>

<system:String x:Key="flowlauncher_plugin_everything_click_to_launch_or_install">Click to launch or install Everything</system:String>
<system:String x:Key="flowlauncher_plugin_everything_installing_title">Everything Installation</system:String>
<system:String x:Key="flowlauncher_plugin_everything_installing_subtitle">Installing Everything service. Please wait...</system:String>
Expand Down
44 changes: 22 additions & 22 deletions Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
using System.Windows;
using Flow.Launcher.Plugin.Explorer.Search.Everything;
using System.Windows.Input;
using Path = System.IO.Path;
using System.Windows.Controls;
using Flow.Launcher.Plugin.Explorer.Views;

namespace Flow.Launcher.Plugin.Explorer.Search
{
public static class ResultManager
{
private static readonly string[] SizeUnits = { "B", "KB", "MB", "GB", "TB" };
private static PluginInitContext Context;
private static Settings Settings { get; set; }

Expand Down Expand Up @@ -172,36 +176,28 @@ internal static Result CreateDriveSpaceDisplayResult(string path, string actionK
};
}

private static string ToReadableSize(long pDrvSize, int pi)
internal static string ToReadableSize(long sizeOnDrive, int pi)
{
int mok = 0;
double drvSize = pDrvSize;
string uom = "Byte"; // Unit Of Measurement
var unitIndex = 0;
double readableSize = sizeOnDrive;

while (drvSize > 1024.0)
while (readableSize > 1024.0 && unitIndex < SizeUnits.Length - 1)
{
drvSize /= 1024.0;
mok++;
readableSize /= 1024.0;
unitIndex++;
}

if (mok == 1)
uom = "KB";
else if (mok == 2)
uom = " MB";
else if (mok == 3)
uom = " GB";
else if (mok == 4)
uom = " TB";

var returnStr = $"{Convert.ToInt32(drvSize)}{uom}";
if (mok != 0)
var unit = SizeUnits[unitIndex] ?? "";

var returnStr = $"{Convert.ToInt32(readableSize)} {unit}";
if (unitIndex != 0)
{
returnStr = pi switch
{
1 => $"{drvSize:F1}{uom}",
2 => $"{drvSize:F2}{uom}",
3 => $"{drvSize:F3}{uom}",
_ => $"{Convert.ToInt32(drvSize)}{uom}"
1 => $"{readableSize:F1} {unit}",
2 => $"{readableSize:F2} {unit}",
3 => $"{readableSize:F3} {unit}",
_ => $"{Convert.ToInt32(readableSize)} {unit}"
};
}

Expand Down Expand Up @@ -239,6 +235,9 @@ internal static Result CreateFileResult(string filePath, Query query, int score

var title = Path.GetFileName(filePath);


/* Preview Detail */

var result = new Result
{
Title = title,
Expand All @@ -249,6 +248,7 @@ internal static Result CreateFileResult(string filePath, Query query, int score
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
Score = score,
CopyText = filePath,
PreviewPanel = new Lazy<UserControl>(() => new PreviewPanel(Settings, filePath)),
Action = c =>
{
try
Expand Down
12 changes: 11 additions & 1 deletion Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ public class Settings

public bool WarnWindowsSearchServiceOff { get; set; } = true;

public bool ShowFileSizeInPreviewPanel { get; set; } = true;

public bool ShowCreatedDateInPreviewPanel { get; set; } = true;

public bool ShowModifiedDateInPreviewPanel { get; set; } = true;

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

public string PreviewPanelTimeFormat { get; set; } = "HH:mm";

private EverythingSearchManager _everythingManagerInstance;
private WindowsIndexSearchManager _windowsIndexSearchManager;

Expand Down Expand Up @@ -137,7 +147,7 @@ public enum ContentIndexSearchEngineOption
ContentSearchEngine == ContentIndexSearchEngineOption.Everything;

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

#endregion

internal enum ActionKeyword
Expand Down
101 changes: 101 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows;
Expand Down Expand Up @@ -101,7 +102,107 @@ private void InitializeEngineSelection()

#endregion

#region Preview Panel

public bool ShowFileSizeInPreviewPanel
{
get => Settings.ShowFileSizeInPreviewPanel;
set
{
Settings.ShowFileSizeInPreviewPanel = value;
OnPropertyChanged();
}
}

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

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

public string PreviewPanelDateFormat
{
get => Settings.PreviewPanelDateFormat;
set
{
Settings.PreviewPanelDateFormat = value;
OnPropertyChanged();
OnPropertyChanged(nameof(PreviewPanelDateFormatDemo));
}
}

public string PreviewPanelTimeFormat
{
get => Settings.PreviewPanelTimeFormat;
set
{
Settings.PreviewPanelTimeFormat = value;
OnPropertyChanged();
OnPropertyChanged(nameof(PreviewPanelTimeFormatDemo));
}
}

public string PreviewPanelDateFormatDemo => DateTime.Now.ToString(PreviewPanelDateFormat, CultureInfo.CurrentCulture);
public string PreviewPanelTimeFormatDemo => DateTime.Now.ToString(PreviewPanelTimeFormat, CultureInfo.CurrentCulture);

public bool ShowPreviewPanelDateTimeChoices => ShowCreatedDateInPreviewPanel || ShowModifiedDateInPreviewPanel;

public Visibility PreviewPanelDateTimeChoicesVisibility => ShowCreatedDateInPreviewPanel || ShowModifiedDateInPreviewPanel ? Visibility.Visible : Visibility.Collapsed;


public List<string> TimeFormatList { get; } = new()
{
"h:mm",
"hh:mm",
"H:mm",
"HH:mm",
"tt h:mm",
"tt hh:mm",
"h:mm tt",
"hh:mm tt",
"hh:mm:ss tt",
"HH:mm:ss"
};


public List<string> DateFormatList { get; } = new()
{
"dd/MM/yyyy",
"dd/MM/yyyy ddd",
"dd/MM/yyyy, dddd",
"dd-MM-yyyy",
"dd-MM-yyyy ddd",
"dd-MM-yyyy, dddd",
"dd.MM.yyyy",
"dd.MM.yyyy ddd",
"dd.MM.yyyy, dddd",
"MM/dd/yyyy",
"MM/dd/yyyy ddd",
"MM/dd/yyyy, dddd",
"yyyy-MM-dd",
"yyyy-MM-dd ddd",
"yyyy-MM-dd, dddd",
};

#endregion

#region ActionKeyword

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,57 @@
</StackPanel>
</StackPanel>
</TabItem>
<TabItem
Width="Auto"
Header="{DynamicResource plugin_explorer_previewpanel_setting_header}"
Style="{DynamicResource ExplorerTabItem}">
<StackPanel Margin="30,20,0,10">
<TextBlock Foreground="{DynamicResource Color05B}" Text="{DynamicResource plugin_explorer_previewpanel_file_info_label}" />
<CheckBox
Margin="0,10,0,0"
Content="{DynamicResource plugin_explorer_previewpanel_display_file_size_checkbox}"
IsChecked="{Binding ShowFileSizeInPreviewPanel}" />

<CheckBox
Margin="0,10,0,0"
Content="{DynamicResource plugin_explorer_previewpanel_display_file_creation_checkbox}"
IsChecked="{Binding ShowCreatedDateInPreviewPanel}" />

<CheckBox
Margin="0,10,0,0"
Content="{DynamicResource plugin_explorer_previewpanel_display_file_modification_checkbox}"
IsChecked="{Binding ShowModifiedDateInPreviewPanel}" />

<StackPanel
Margin="0,20,0,0"
IsEnabled="{Binding ShowPreviewPanelDateTimeChoices}"
Visibility="{Binding PreviewPanelDateTimeChoicesVisibility}">
<TextBlock Foreground="{DynamicResource Color05B}" Text="{DynamicResource plugin_explorer_previewpanel_date_and_time_format_label}" />
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<ComboBox
Width="200"
ItemsSource="{Binding DateFormatList}"
SelectedItem="{Binding PreviewPanelDateFormat}" />
<TextBlock
Margin="12,0,0,0"
VerticalAlignment="Center"
Foreground="{DynamicResource Color05B}"
Text="{Binding PreviewPanelDateFormatDemo}" />
</StackPanel>
<StackPanel Margin="0,10,0,10" Orientation="Horizontal">
<ComboBox
Width="200"
ItemsSource="{Binding TimeFormatList}"
SelectedItem="{Binding PreviewPanelTimeFormat}" />
<TextBlock
Margin="12,0,0,0"
VerticalAlignment="Center"
Foreground="{DynamicResource Color05B}"
Text="{Binding PreviewPanelTimeFormatDemo}" />
</StackPanel>
</StackPanel>
</StackPanel>
</TabItem>
<TabItem
Width="Auto"
Header="{DynamicResource plugin_explorer_everything_setting_header}"
Expand Down Expand Up @@ -403,7 +454,7 @@
<TextBox
Grid.Row="2"
Grid.Column="1"
Width="250"
MinWidth="350"
Margin="0,15,0,0"
Text="{Binding EverythingInstalledPath}" />
</Grid>
Expand Down
Loading