From fe7985d5644a2c3b86ff369736fb461e7fc0fba4 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Mon, 23 Jun 2025 12:25:16 +0800
Subject: [PATCH 01/33] Use Flow.Launcher.Localization to improve code quality
---
.../DecimalSeparator.cs | 11 +++---
.../Flow.Launcher.Plugin.Calculator.csproj | 2 +-
.../Flow.Launcher.Plugin.Calculator/Main.cs | 35 +++++++++----------
.../ViewModels/SettingsViewModel.cs | 16 +++++++++
.../Views/CalculatorSettings.xaml | 19 +++-------
.../Views/CalculatorSettings.xaml.cs | 12 +++----
6 files changed, 48 insertions(+), 47 deletions(-)
diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/DecimalSeparator.cs b/Plugins/Flow.Launcher.Plugin.Calculator/DecimalSeparator.cs
index 81a68739b92..0ece36d54a9 100644
--- a/Plugins/Flow.Launcher.Plugin.Calculator/DecimalSeparator.cs
+++ b/Plugins/Flow.Launcher.Plugin.Calculator/DecimalSeparator.cs
@@ -1,18 +1,17 @@
-using System.ComponentModel;
-using Flow.Launcher.Core.Resource;
+using Flow.Launcher.Localization.Attributes;
namespace Flow.Launcher.Plugin.Calculator
{
- [TypeConverter(typeof(LocalizationConverter))]
+ [EnumLocalize]
public enum DecimalSeparator
{
- [LocalizedDescription("flowlauncher_plugin_calculator_decimal_seperator_use_system_locale")]
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_calculator_decimal_seperator_use_system_locale))]
UseSystemLocale,
- [LocalizedDescription("flowlauncher_plugin_calculator_decimal_seperator_dot")]
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_calculator_decimal_seperator_dot))]
Dot,
- [LocalizedDescription("flowlauncher_plugin_calculator_decimal_seperator_comma")]
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_calculator_decimal_seperator_comma))]
Comma
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Flow.Launcher.Plugin.Calculator.csproj b/Plugins/Flow.Launcher.Plugin.Calculator/Flow.Launcher.Plugin.Calculator.csproj
index 9cdef365d04..73dacf3d1da 100644
--- a/Plugins/Flow.Launcher.Plugin.Calculator/Flow.Launcher.Plugin.Calculator.csproj
+++ b/Plugins/Flow.Launcher.Plugin.Calculator/Flow.Launcher.Plugin.Calculator.csproj
@@ -42,7 +42,6 @@
-
@@ -63,6 +62,7 @@
+
diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs
index b1e4cd60601..f35e6423707 100644
--- a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs
@@ -5,7 +5,6 @@
using System.Text.RegularExpressions;
using System.Windows.Controls;
using Mages.Core;
-using Flow.Launcher.Plugin.Calculator.ViewModels;
using Flow.Launcher.Plugin.Calculator.Views;
namespace Flow.Launcher.Plugin.Calculator
@@ -24,19 +23,17 @@ public class Main : IPlugin, IPluginI18n, ISettingProvider
@")+$", RegexOptions.Compiled);
private static readonly Regex RegBrackets = new Regex(@"[\(\)\[\]]", RegexOptions.Compiled);
private static Engine MagesEngine;
- private const string comma = ",";
- private const string dot = ".";
+ private const string Comma = ",";
+ private const string Dot = ".";
- private PluginInitContext Context { get; set; }
+ internal static PluginInitContext Context { get; set; } = null!;
private static Settings _settings;
- private static SettingsViewModel _viewModel;
public void Init(PluginInitContext context)
{
Context = context;
_settings = context.API.LoadSettingJsonStorage();
- _viewModel = new SettingsViewModel(_settings);
MagesEngine = new Engine(new Configuration
{
@@ -72,10 +69,10 @@ public List Query(Query query)
var result = MagesEngine.Interpret(expression);
if (result?.ToString() == "NaN")
- result = Context.API.GetTranslation("flowlauncher_plugin_calculator_not_a_number");
+ result = Localize.flowlauncher_plugin_calculator_not_a_number();
if (result is Function)
- result = Context.API.GetTranslation("flowlauncher_plugin_calculator_expression_not_complete");
+ result = Localize.flowlauncher_plugin_calculator_expression_not_complete();
if (!string.IsNullOrEmpty(result?.ToString()))
{
@@ -89,7 +86,7 @@ public List Query(Query query)
Title = newResult,
IcoPath = "Images/calculator.png",
Score = 300,
- SubTitle = Context.API.GetTranslation("flowlauncher_plugin_calculator_copy_number_to_clipboard"),
+ SubTitle = Localize.flowlauncher_plugin_calculator_copy_number_to_clipboard(),
CopyText = newResult,
Action = c =>
{
@@ -134,16 +131,16 @@ private bool CanCalculate(Query query)
return false;
}
- if ((query.Search.Contains(dot) && GetDecimalSeparator() != dot) ||
- (query.Search.Contains(comma) && GetDecimalSeparator() != comma))
+ if ((query.Search.Contains(Dot) && GetDecimalSeparator() != Dot) ||
+ (query.Search.Contains(Comma) && GetDecimalSeparator() != Comma))
return false;
return true;
}
- private string ChangeDecimalSeparator(decimal value, string newDecimalSeparator)
+ private static string ChangeDecimalSeparator(decimal value, string newDecimalSeparator)
{
- if (String.IsNullOrEmpty(newDecimalSeparator))
+ if (string.IsNullOrEmpty(newDecimalSeparator))
{
return value.ToString();
}
@@ -161,13 +158,13 @@ private static string GetDecimalSeparator()
return _settings.DecimalSeparator switch
{
DecimalSeparator.UseSystemLocale => systemDecimalSeparator,
- DecimalSeparator.Dot => dot,
- DecimalSeparator.Comma => comma,
+ DecimalSeparator.Dot => Dot,
+ DecimalSeparator.Comma => Comma,
_ => systemDecimalSeparator,
};
}
- private bool IsBracketComplete(string query)
+ private static bool IsBracketComplete(string query)
{
var matchs = RegBrackets.Matches(query);
var leftBracketCount = 0;
@@ -188,17 +185,17 @@ private bool IsBracketComplete(string query)
public string GetTranslatedPluginTitle()
{
- return Context.API.GetTranslation("flowlauncher_plugin_caculator_plugin_name");
+ return Localize.flowlauncher_plugin_caculator_plugin_name();
}
public string GetTranslatedPluginDescription()
{
- return Context.API.GetTranslation("flowlauncher_plugin_caculator_plugin_description");
+ return Localize.flowlauncher_plugin_caculator_plugin_description();
}
public Control CreateSettingPanel()
{
- return new CalculatorSettings(_viewModel);
+ return new CalculatorSettings(_settings);
}
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Calculator/ViewModels/SettingsViewModel.cs
index 09f745669fc..a1f07bd17cf 100644
--- a/Plugins/Flow.Launcher.Plugin.Calculator/ViewModels/SettingsViewModel.cs
+++ b/Plugins/Flow.Launcher.Plugin.Calculator/ViewModels/SettingsViewModel.cs
@@ -8,10 +8,26 @@ public class SettingsViewModel : BaseModel
public SettingsViewModel(Settings settings)
{
Settings = settings;
+ DecimalSeparatorLocalized.UpdateLabels(AllDecimalSeparator);
}
public Settings Settings { get; init; }
public IEnumerable MaxDecimalPlacesRange => Enumerable.Range(1, 20);
+
+ public List AllDecimalSeparator { get; } = DecimalSeparatorLocalized.GetValues();
+
+ public DecimalSeparator SelectedDecimalSeparator
+ {
+ get => Settings.DecimalSeparator;
+ set
+ {
+ if (Settings.DecimalSeparator != value)
+ {
+ Settings.DecimalSeparator = value;
+ OnPropertyChanged();
+ }
+ }
+ }
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Views/CalculatorSettings.xaml b/Plugins/Flow.Launcher.Plugin.Calculator/Views/CalculatorSettings.xaml
index ceee3897c18..589f3ddcd64 100644
--- a/Plugins/Flow.Launcher.Plugin.Calculator/Views/CalculatorSettings.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Calculator/Views/CalculatorSettings.xaml
@@ -3,20 +3,15 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:calculator="clr-namespace:Flow.Launcher.Plugin.Calculator"
- xmlns:core="clr-namespace:Flow.Launcher.Core.Resource;assembly=Flow.Launcher.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:ui="clr-namespace:Flow.Launcher.Infrastructure.UI;assembly=Flow.Launcher.Infrastructure"
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Calculator.ViewModels"
+ d:DataContext="{d:DesignInstance Type=viewModels:SettingsViewModel}"
d:DesignHeight="450"
d:DesignWidth="800"
Loaded="CalculatorSettings_Loaded"
mc:Ignorable="d">
-
-
-
-
@@ -42,14 +37,10 @@
Margin="{StaticResource SettingPanelItemRightTopBottomMargin}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
- ItemsSource="{Binding Source={ui:EnumBindingSource {x:Type calculator:DecimalSeparator}}}"
- SelectedItem="{Binding Settings.DecimalSeparator}">
-
-
-
-
-
-
+ DisplayMemberPath="Display"
+ ItemsSource="{Binding AllDecimalSeparator}"
+ SelectedValue="{Binding SelectedDecimalSeparator, Mode=TwoWay}"
+ SelectedValuePath="Value" />
Date: Mon, 23 Jun 2025 12:37:58 +0800
Subject: [PATCH 02/33] Adjust indent
---
.../Flow.Launcher.Plugin.Calculator.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Flow.Launcher.Plugin.Calculator.csproj b/Plugins/Flow.Launcher.Plugin.Calculator/Flow.Launcher.Plugin.Calculator.csproj
index 73dacf3d1da..719b6c74fd4 100644
--- a/Plugins/Flow.Launcher.Plugin.Calculator/Flow.Launcher.Plugin.Calculator.csproj
+++ b/Plugins/Flow.Launcher.Plugin.Calculator/Flow.Launcher.Plugin.Calculator.csproj
@@ -62,7 +62,7 @@
-
+
From 1b05643b64acaa357bb5f3195f933d0d1210fbf7 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Mon, 23 Jun 2025 12:38:27 +0800
Subject: [PATCH 03/33] Use Flow.Launcher.Localization to improve code quality
---
.../ChromiumBookmarkLoader.cs | 8 ++---
.../Commands/BookmarkLoader.cs | 4 +--
.../FirefoxBookmarkLoader.cs | 10 +++---
...low.Launcher.Plugin.BrowserBookmark.csproj | 2 +-
.../Helper/FaviconHelper.cs | 10 +++---
.../Main.cs | 24 +++++++-------
.../Models/CustomBrowser.cs | 32 +++++++++++++++----
.../Views/CustomBrowserSetting.xaml | 7 ++--
8 files changed, 58 insertions(+), 39 deletions(-)
diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs
index 6e6b2e5f4ad..6dc0f7a9a33 100644
--- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs
+++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs
@@ -45,7 +45,7 @@ protected List LoadBookmarks(string browserDataPath, string name)
}
catch (Exception ex)
{
- Main._context.API.LogException(ClassName, $"Failed to register bookmark file monitoring: {bookmarkPath}", ex);
+ Main.Context.API.LogException(ClassName, $"Failed to register bookmark file monitoring: {bookmarkPath}", ex);
continue;
}
@@ -58,7 +58,7 @@ protected List LoadBookmarks(string browserDataPath, string name)
var faviconDbPath = Path.Combine(profile, "Favicons");
if (File.Exists(faviconDbPath))
{
- Main._context.API.StopwatchLogInfo(ClassName, $"Load {profileBookmarks.Count} favicons cost", () =>
+ Main.Context.API.StopwatchLogInfo(ClassName, $"Load {profileBookmarks.Count} favicons cost", () =>
{
LoadFaviconsFromDb(faviconDbPath, profileBookmarks);
});
@@ -125,7 +125,7 @@ private static void EnumerateFolderBookmark(JsonElement folderElement, ICollecti
}
else
{
- Main._context.API.LogError(ClassName, $"type property not found for {subElement.GetString()}");
+ Main.Context.API.LogError(ClassName, $"type property not found for {subElement.GetString()}");
}
}
}
@@ -190,7 +190,7 @@ ORDER BY b.width DESC
}
catch (Exception ex)
{
- Main._context.API.LogException(ClassName, $"Failed to extract bookmark favicon: {bookmark.Url}", ex);
+ Main.Context.API.LogException(ClassName, $"Failed to extract bookmark favicon: {bookmark.Url}", ex);
}
finally
{
diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/BookmarkLoader.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/BookmarkLoader.cs
index 758ce68ae78..b76adae93c3 100644
--- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/BookmarkLoader.cs
+++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/BookmarkLoader.cs
@@ -9,11 +9,11 @@ internal static class BookmarkLoader
{
internal static MatchResult MatchProgram(Bookmark bookmark, string queryString)
{
- var match = Main._context.API.FuzzySearch(queryString, bookmark.Name);
+ var match = Main.Context.API.FuzzySearch(queryString, bookmark.Name);
if (match.IsSearchPrecisionScoreMet())
return match;
- return Main._context.API.FuzzySearch(queryString, bookmark.Url);
+ return Main.Context.API.FuzzySearch(queryString, bookmark.Url);
}
internal static List LoadAllBookmarks(Settings setting)
diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs
index ec3b867ea81..68e5d5caadd 100644
--- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs
+++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs
@@ -49,7 +49,7 @@ protected List GetBookmarksFromPath(string placesPath)
}
catch (Exception ex)
{
- Main._context.API.LogException(ClassName, $"Failed to register Firefox bookmark file monitoring: {placesPath}", ex);
+ Main.Context.API.LogException(ClassName, $"Failed to register Firefox bookmark file monitoring: {placesPath}", ex);
return bookmarks;
}
@@ -84,7 +84,7 @@ protected List GetBookmarksFromPath(string placesPath)
var faviconDbPath = Path.Combine(Path.GetDirectoryName(placesPath), "favicons.sqlite");
if (File.Exists(faviconDbPath))
{
- Main._context.API.StopwatchLogInfo(ClassName, $"Load {bookmarks.Count} favicons cost", () =>
+ Main.Context.API.StopwatchLogInfo(ClassName, $"Load {bookmarks.Count} favicons cost", () =>
{
LoadFaviconsFromDb(faviconDbPath, bookmarks);
});
@@ -98,7 +98,7 @@ protected List GetBookmarksFromPath(string placesPath)
}
catch (Exception ex)
{
- Main._context.API.LogException(ClassName, $"Failed to load Firefox bookmarks: {placesPath}", ex);
+ Main.Context.API.LogException(ClassName, $"Failed to load Firefox bookmarks: {placesPath}", ex);
}
// Delete temporary file
@@ -111,7 +111,7 @@ protected List GetBookmarksFromPath(string placesPath)
}
catch (Exception ex)
{
- Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
+ Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
}
return bookmarks;
@@ -186,7 +186,7 @@ ORDER BY i.width DESC -- Select largest icon available
}
catch (Exception ex)
{
- Main._context.API.LogException(ClassName, $"Failed to extract Firefox favicon: {bookmark.Url}", ex);
+ Main.Context.API.LogException(ClassName, $"Failed to extract Firefox favicon: {bookmark.Url}", ex);
}
finally
{
diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj
index 3fb0fa46f64..bf558bc3152 100644
--- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj
+++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj
@@ -81,7 +81,6 @@
-
@@ -96,6 +95,7 @@
+
diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs
index a879dcefd1b..b88bd764042 100644
--- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs
+++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs
@@ -27,9 +27,9 @@ public static void LoadFaviconsFromDb(string faviconCacheDir, string dbPath, Act
}
catch (Exception ex1)
{
- Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex1);
+ Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex1);
}
- Main._context.API.LogException(ClassName, $"Failed to copy favicon DB: {dbPath}", ex);
+ Main.Context.API.LogException(ClassName, $"Failed to copy favicon DB: {dbPath}", ex);
return;
}
@@ -39,7 +39,7 @@ public static void LoadFaviconsFromDb(string faviconCacheDir, string dbPath, Act
}
catch (Exception ex)
{
- Main._context.API.LogException(ClassName, $"Failed to connect to SQLite: {tempDbPath}", ex);
+ Main.Context.API.LogException(ClassName, $"Failed to connect to SQLite: {tempDbPath}", ex);
}
// Delete temporary file
@@ -49,7 +49,7 @@ public static void LoadFaviconsFromDb(string faviconCacheDir, string dbPath, Act
}
catch (Exception ex)
{
- Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
+ Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
}
}
@@ -61,7 +61,7 @@ public static void SaveBitmapData(byte[] imageData, string outputPath)
}
catch (Exception ex)
{
- Main._context.API.LogException(ClassName, $"Failed to save image: {outputPath}", ex);
+ Main.Context.API.LogException(ClassName, $"Failed to save image: {outputPath}", ex);
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs
index 91ade206b67..3b67e6f18a4 100644
--- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs
@@ -19,7 +19,7 @@ public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContex
internal static string _faviconCacheDir;
- internal static PluginInitContext _context;
+ internal static PluginInitContext Context { get; set; }
internal static Settings _settings;
@@ -29,7 +29,7 @@ public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContex
public void Init(PluginInitContext context)
{
- _context = context;
+ Context = context;
_settings = context.API.LoadSettingJsonStorage();
@@ -42,7 +42,7 @@ public void Init(PluginInitContext context)
private static void LoadBookmarksIfEnabled()
{
- if (_context.CurrentPluginMetadata.Disabled)
+ if (Context.CurrentPluginMetadata.Disabled)
{
// Don't load or monitor files if disabled
return;
@@ -84,7 +84,7 @@ public List Query(Query query)
Score = BookmarkLoader.MatchProgram(c, param).Score,
Action = _ =>
{
- _context.API.OpenUrl(c.Url);
+ Context.API.OpenUrl(c.Url);
return true;
},
@@ -108,7 +108,7 @@ public List Query(Query query)
Score = 5,
Action = _ =>
{
- _context.API.OpenUrl(c.Url);
+ Context.API.OpenUrl(c.Url);
return true;
},
ContextData = new BookmarkAttributes { Url = c.Url }
@@ -192,12 +192,12 @@ public static void ReloadAllBookmarks(bool disposeFileWatchers = true)
public string GetTranslatedPluginTitle()
{
- return _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_plugin_name");
+ return Localize.flowlauncher_plugin_browserbookmark_plugin_name();
}
public string GetTranslatedPluginDescription()
{
- return _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_plugin_description");
+ return Localize.flowlauncher_plugin_browserbookmark_plugin_description();
}
public Control CreateSettingPanel()
@@ -211,22 +211,22 @@ public List LoadContextMenus(Result selectedResult)
{
new()
{
- Title = _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_title"),
- SubTitle = _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_subtitle"),
+ Title = Localize.flowlauncher_plugin_browserbookmark_copyurl_title(),
+ SubTitle = Localize.flowlauncher_plugin_browserbookmark_copyurl_subtitle(),
Action = _ =>
{
try
{
- _context.API.CopyToClipboard(((BookmarkAttributes)selectedResult.ContextData).Url);
+ Context.API.CopyToClipboard(((BookmarkAttributes)selectedResult.ContextData).Url);
return true;
}
catch (Exception e)
{
var message = "Failed to set url in clipboard";
- _context.API.LogException(ClassName, message, e);
+ Context.API.LogException(ClassName, message, e);
- _context.API.ShowMsg(message);
+ Context.API.ShowMsg(message);
return false;
}
diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Models/CustomBrowser.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Models/CustomBrowser.cs
index 74e0f299aff..af1e3fee496 100644
--- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Models/CustomBrowser.cs
+++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Models/CustomBrowser.cs
@@ -1,4 +1,7 @@
-namespace Flow.Launcher.Plugin.BrowserBookmark.Models;
+using System.Collections.Generic;
+using Flow.Launcher.Localization.Attributes;
+
+namespace Flow.Launcher.Plugin.BrowserBookmark.Models;
public class CustomBrowser : BaseModel
{
@@ -11,8 +14,11 @@ public string Name
get => _name;
set
{
- _name = value;
- OnPropertyChanged();
+ if (_name != value)
+ {
+ _name = value;
+ OnPropertyChanged();
+ }
}
}
@@ -21,24 +27,36 @@ public string DataDirectoryPath
get => _dataDirectoryPath;
set
{
- _dataDirectoryPath = value;
- OnPropertyChanged();
+ if (_dataDirectoryPath != value)
+ {
+ _dataDirectoryPath = value;
+ OnPropertyChanged();
+ }
}
}
+ public List AllBrowserTypes { get; } = BrowserTypeLocalized.GetValues();
+
public BrowserType BrowserType
{
get => _browserType;
set
{
- _browserType = value;
- OnPropertyChanged();
+ if (_browserType != value)
+ {
+ _browserType = value;
+ OnPropertyChanged();
+ }
}
}
}
+[EnumLocalize]
public enum BrowserType
{
+ [EnumLocalizeValue("Chromium")]
Chromium,
+
+ [EnumLocalizeValue("Firefox")]
Firefox,
}
diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml
index 80b004ff993..f67d359bffa 100644
--- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml
+++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml
@@ -5,7 +5,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Flow.Launcher.Plugin.BrowserBookmark.Models"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:ui="clr-namespace:Flow.Launcher.Infrastructure.UI;assembly=Flow.Launcher.Infrastructure"
Title="{DynamicResource flowlauncher_plugin_browserbookmark_bookmarkDataSetting}"
Width="550"
Background="{DynamicResource PopuBGColor}"
@@ -142,8 +141,10 @@
Margin="5 10 10 0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
- ItemsSource="{Binding Source={ui:EnumBindingSource {x:Type local:BrowserType}}}"
- SelectedItem="{Binding BrowserType}" />
+ DisplayMemberPath="Display"
+ ItemsSource="{Binding AllBrowserTypes}"
+ SelectedValue="{Binding BrowserType}"
+ SelectedValuePath="Value" />
Date: Mon, 23 Jun 2025 12:45:31 +0800
Subject: [PATCH 04/33] Use trick to get the cache directory path
---
.../Flow.Launcher.Plugin.Program.csproj | 1 -
Plugins/Flow.Launcher.Plugin.Program/Main.cs | 11 ++++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj b/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj
index 99c1a12e9b3..7e61f19b334 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj
+++ b/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj
@@ -58,7 +58,6 @@
-
diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs
index d2884599467..211afcfb08e 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs
@@ -6,7 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Controls;
-using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin.Program.Programs;
using Flow.Launcher.Plugin.Program.Views;
using Flow.Launcher.Plugin.Program.Views.Models;
@@ -234,11 +233,17 @@ static void MoveFile(string sourcePath, string destinationPath)
}
}
+ // If plugin cache directory is this: D:\\Data\\Cache\\Plugins\\Flow.Launcher.Plugin.Program
+ // then the parent directory is: D:\\Data\\Cache
+ // So we can use the parent of the parent directory to get the cache directory path
+ var directoryInfo = new DirectoryInfo(pluginCacheDirectory);
+ var cacheDirectory = directoryInfo.Parent.Parent.FullName;
+
// Move old cache files to the new cache directory
- var oldWin32CacheFile = Path.Combine(DataLocation.CacheDirectory, $"{Win32CacheName}.cache");
+ var oldWin32CacheFile = Path.Combine(cacheDirectory, $"{Win32CacheName}.cache");
var newWin32CacheFile = Path.Combine(pluginCacheDirectory, $"{Win32CacheName}.cache");
MoveFile(oldWin32CacheFile, newWin32CacheFile);
- var oldUWPCacheFile = Path.Combine(DataLocation.CacheDirectory, $"{UwpCacheName}.cache");
+ var oldUWPCacheFile = Path.Combine(cacheDirectory, $"{UwpCacheName}.cache");
var newUWPCacheFile = Path.Combine(pluginCacheDirectory, $"{UwpCacheName}.cache");
MoveFile(oldUWPCacheFile, newUWPCacheFile);
From 6143c9945497397c19ef3476c8a17ebd0c922bd1 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Mon, 23 Jun 2025 12:47:44 +0800
Subject: [PATCH 05/33] Remove useless class
---
.../UI/EnumBindingSource.cs | 58 -------------------
1 file changed, 58 deletions(-)
delete mode 100644 Flow.Launcher.Infrastructure/UI/EnumBindingSource.cs
diff --git a/Flow.Launcher.Infrastructure/UI/EnumBindingSource.cs b/Flow.Launcher.Infrastructure/UI/EnumBindingSource.cs
deleted file mode 100644
index f9504e6d926..00000000000
--- a/Flow.Launcher.Infrastructure/UI/EnumBindingSource.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using System;
-using System.Windows.Markup;
-
-namespace Flow.Launcher.Infrastructure.UI
-{
- [Obsolete("EnumBindingSourceExtension is obsolete. Use with Flow.Launcher.Localization NuGet package instead.")]
- public class EnumBindingSourceExtension : MarkupExtension
- {
- private Type _enumType;
- public Type EnumType
- {
- get { return _enumType; }
- set
- {
- if (value != _enumType)
- {
- if (value != null)
- {
- Type enumType = Nullable.GetUnderlyingType(value) ?? value;
- if (!enumType.IsEnum)
- {
- throw new ArgumentException("Type must represent an enum.");
- }
- }
-
- _enumType = value;
- }
- }
- }
-
- public EnumBindingSourceExtension() { }
-
- public EnumBindingSourceExtension(Type enumType)
- {
- EnumType = enumType;
- }
-
- public override object ProvideValue(IServiceProvider serviceProvider)
- {
- if (_enumType == null)
- {
- throw new InvalidOperationException("The EnumType must be specified.");
- }
-
- Type actualEnumType = Nullable.GetUnderlyingType(_enumType) ?? _enumType;
- Array enumValues = Enum.GetValues(actualEnumType);
-
- if (actualEnumType == _enumType)
- {
- return enumValues;
- }
-
- Array tempArray = Array.CreateInstance(actualEnumType, enumValues.Length + 1);
- enumValues.CopyTo(tempArray, 1);
- return tempArray;
- }
- }
-}
From 107da050a57dca45991be856cfba3c6640e8e9c8 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Mon, 23 Jun 2025 13:02:04 +0800
Subject: [PATCH 06/33] Fix build issue
---
.../Flow.Launcher.Plugin.Program.csproj | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj b/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj
index 7e61f19b334..16a8c03f4ae 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj
+++ b/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj
@@ -63,11 +63,13 @@
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
\ No newline at end of file
From 9be2ef092476727aaf9404e0a196165df4535fbc Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Mon, 23 Jun 2025 13:03:45 +0800
Subject: [PATCH 07/33] Remove unused class
---
.../Resource/LocalizationConverter.cs | 38 -------------------
1 file changed, 38 deletions(-)
delete mode 100644 Flow.Launcher.Core/Resource/LocalizationConverter.cs
diff --git a/Flow.Launcher.Core/Resource/LocalizationConverter.cs b/Flow.Launcher.Core/Resource/LocalizationConverter.cs
deleted file mode 100644
index fdda33926d5..00000000000
--- a/Flow.Launcher.Core/Resource/LocalizationConverter.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.Globalization;
-using System.Reflection;
-using System.Windows.Data;
-
-namespace Flow.Launcher.Core.Resource
-{
- [Obsolete("LocalizationConverter is obsolete. Use with Flow.Launcher.Localization NuGet package instead.")]
- public class LocalizationConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (targetType == typeof(string) && value != null)
- {
- FieldInfo fi = value.GetType().GetField(value.ToString());
- if (fi != null)
- {
- string localizedDescription = string.Empty;
- var attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
- if ((attributes.Length > 0) && (!String.IsNullOrEmpty(attributes[0].Description)))
- {
- localizedDescription = attributes[0].Description;
- }
-
- return (!String.IsNullOrEmpty(localizedDescription)) ? localizedDescription : value.ToString();
- }
- }
-
- return string.Empty;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
From c4cbf941cf4a681255a39c9fc38850b178be1fde Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Mon, 23 Jun 2025 13:13:45 +0800
Subject: [PATCH 08/33] Add directory null check
---
Plugins/Flow.Launcher.Plugin.Program/Main.cs | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs
index 211afcfb08e..b9187a801fc 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs
@@ -237,15 +237,17 @@ static void MoveFile(string sourcePath, string destinationPath)
// then the parent directory is: D:\\Data\\Cache
// So we can use the parent of the parent directory to get the cache directory path
var directoryInfo = new DirectoryInfo(pluginCacheDirectory);
- var cacheDirectory = directoryInfo.Parent.Parent.FullName;
-
- // Move old cache files to the new cache directory
- var oldWin32CacheFile = Path.Combine(cacheDirectory, $"{Win32CacheName}.cache");
- var newWin32CacheFile = Path.Combine(pluginCacheDirectory, $"{Win32CacheName}.cache");
- MoveFile(oldWin32CacheFile, newWin32CacheFile);
- var oldUWPCacheFile = Path.Combine(cacheDirectory, $"{UwpCacheName}.cache");
- var newUWPCacheFile = Path.Combine(pluginCacheDirectory, $"{UwpCacheName}.cache");
- MoveFile(oldUWPCacheFile, newUWPCacheFile);
+ var cacheDirectory = directoryInfo.Parent?.Parent?.FullName;
+ // Move old cache files to the new cache directory if cache directory exists
+ if (!string.IsNullOrEmpty(cacheDirectory))
+ {
+ var oldWin32CacheFile = Path.Combine(cacheDirectory, $"{Win32CacheName}.cache");
+ var newWin32CacheFile = Path.Combine(pluginCacheDirectory, $"{Win32CacheName}.cache");
+ MoveFile(oldWin32CacheFile, newWin32CacheFile);
+ var oldUWPCacheFile = Path.Combine(cacheDirectory, $"{UwpCacheName}.cache");
+ var newUWPCacheFile = Path.Combine(pluginCacheDirectory, $"{UwpCacheName}.cache");
+ MoveFile(oldUWPCacheFile, newUWPCacheFile);
+ }
await _win32sLock.WaitAsync();
_win32s = await context.API.LoadCacheBinaryStorageAsync(Win32CacheName, pluginCacheDirectory, new List());
From 3bf1887362513444a45bd48e5b6c19f37056807b Mon Sep 17 00:00:00 2001
From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com>
Date: Tue, 15 Jul 2025 23:56:03 +0800
Subject: [PATCH 09/33] Intoduce dependency
---
.../Flow.Launcher.Plugin.Explorer.csproj | 1 +
1 file changed, 1 insertion(+)
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj b/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj
index 93691814aee..6b1fcdd0d53 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj
@@ -47,6 +47,7 @@
+
From e116668ef9223ec24d3e4f8e1b26325ea9f9d4e7 Mon Sep 17 00:00:00 2001
From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com>
Date: Tue, 15 Jul 2025 23:57:21 +0800
Subject: [PATCH 10/33] Rename file
---
.../Search/Everything/{SortOption.cs => EverythingSortOption.cs} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/{SortOption.cs => EverythingSortOption.cs} (100%)
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/SortOption.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSortOption.cs
similarity index 100%
rename from Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/SortOption.cs
rename to Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSortOption.cs
From 30f7ae0d6726557bdd6d5878e240fe8817847bb6 Mon Sep 17 00:00:00 2001
From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com>
Date: Wed, 16 Jul 2025 21:28:17 +0800
Subject: [PATCH 11/33] Use Localization for Explorer plugin
---
.../Helper/SortOptionTranslationHelper.cs | 25 -----------
.../Languages/en.xaml | 41 ++++++++++++-------
Plugins/Flow.Launcher.Plugin.Explorer/Main.cs | 2 -
.../Search/Everything/EverythingAPI.cs | 7 ++--
.../Everything/EverythingApiDllImport.cs | 9 ++--
.../Everything/EverythingSearchOption.cs | 6 +--
.../Search/Everything/EverythingSortOption.cs | 32 ++++++++++++++-
.../Flow.Launcher.Plugin.Explorer/Settings.cs | 8 +---
.../ViewModels/SettingsViewModel.cs | 21 ++++++++--
.../Converters/EverythingEnumNameConverter.cs | 20 ---------
.../Views/ExplorerSettings.xaml | 21 +++-------
.../Views/ExplorerSettings.xaml.cs | 9 +---
12 files changed, 93 insertions(+), 108 deletions(-)
delete mode 100644 Plugins/Flow.Launcher.Plugin.Explorer/Helper/SortOptionTranslationHelper.cs
delete mode 100644 Plugins/Flow.Launcher.Plugin.Explorer/Views/Converters/EverythingEnumNameConverter.cs
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Helper/SortOptionTranslationHelper.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Helper/SortOptionTranslationHelper.cs
deleted file mode 100644
index 72f58f5b60c..00000000000
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Helper/SortOptionTranslationHelper.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using Flow.Launcher.Plugin.Everything.Everything;
-using JetBrains.Annotations;
-using System;
-
-namespace Flow.Launcher.Plugin.Explorer.Helper;
-
-public static class SortOptionTranslationHelper
-{
- [CanBeNull]
- public static IPublicAPI API { get; internal set; }
-
- public static string GetTranslatedName(this SortOption sortOption)
- {
- const string prefix = "flowlauncher_plugin_everything_sort_by_";
-
- ArgumentNullException.ThrowIfNull(API);
-
- var enumName = Enum.GetName(sortOption);
- var splited = enumName!.Split('_');
- var name = string.Join('_', splited[..^1]);
- var direction = splited[^1];
-
- return $"{API.GetTranslation(prefix + name.ToLower())} {API.GetTranslation(prefix + direction.ToLower())}";
- }
-}
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
index 2e0f6a67db3..6a28a5be838 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
@@ -143,20 +143,33 @@
Warning: Everything service is not running
Error while querying Everything
Sort By
- Name
- Path
- Size
- Extension
- Type Name
- Date Created
- Date Modified
- Attributes
- File List FileName
- Run Count
- Date Recently Changed
- Date Accessed
- Date Run
- ↑
+ Name ↑
+ Name ↓
+ Path ↑
+ Path ↓
+ Size ↑
+ Size ↓
+ Extension ↑
+ Extension ↓
+ Type Name ↑
+ Type Name ↓
+ Date Created ↑
+ Date Created ↓
+ Date Modified ↑
+ Date Modified ↓
+ Attributes ↑
+ Attributes ↓
+ File List FileName ↑
+ File List FileName ↓
+ Run Count ↑
+ Run Count ↓
+ Date Recently Changed ↑
+ Date Recently Changed ↓
+ Date Accessed ↑
+ Date Accessed ↓
+ Date Run ↑
+ Date Run ↓
+
↓
Warning: This is not a Fast Sort option, searches may be slow
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs
index f1aea98b4bf..54292d55044 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs
@@ -42,8 +42,6 @@ public Task InitAsync(PluginInitContext context)
contextMenu = new ContextMenu(Context, Settings, viewModel);
searchManager = new SearchManager(Settings, Context);
ResultManager.Init(Context, Settings);
-
- SortOptionTranslationHelper.API = context.API;
EverythingApiDllImport.Load(Path.Combine(Context.CurrentPluginMetadata.PluginDirectory, "EverythingSDK",
Environment.Is64BitProcess ? "x64" : "x86"));
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs
index 6159c93556a..fd62566d54e 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs
@@ -1,5 +1,4 @@
-using Flow.Launcher.Plugin.Everything.Everything;
-using Flow.Launcher.Plugin.Explorer.Search.Everything.Exceptions;
+using Flow.Launcher.Plugin.Explorer.Search.Everything.Exceptions;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
@@ -36,7 +35,7 @@ public enum StateCode
///
/// Checks whether the sort option is Fast Sort.
///
- public static bool IsFastSortOption(SortOption sortOption)
+ public static bool IsFastSortOption(EverythingSortOption sortOption)
{
var fastSortOptionEnabled = EverythingApiDllImport.Everything_IsFastSort(sortOption);
@@ -112,7 +111,7 @@ public static async IAsyncEnumerable SearchAsync(EverythingSearchO
EverythingApiDllImport.Everything_SetSort(option.SortOption);
EverythingApiDllImport.Everything_SetMatchPath(option.IsFullPathSearch);
- if (option.SortOption == SortOption.RUN_COUNT_DESCENDING)
+ if (option.SortOption == EverythingSortOption.RUN_COUNT_DESCENDING)
{
EverythingApiDllImport.Everything_SetRequestFlags(EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME | EVERYTHING_REQUEST_RUN_COUNT);
}
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingApiDllImport.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingApiDllImport.cs
index 5b80819faed..c952a980c47 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingApiDllImport.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingApiDllImport.cs
@@ -1,5 +1,4 @@
-using Flow.Launcher.Plugin.Everything.Everything;
-using System;
+using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
@@ -114,11 +113,11 @@ public static void Load(string directory)
// Everything 1.4
[DllImport(DLL)]
- public static extern void Everything_SetSort(SortOption dwSortType);
+ public static extern void Everything_SetSort(EverythingSortOption dwSortType);
[DllImport(DLL)]
- public static extern bool Everything_IsFastSort(SortOption dwSortType);
+ public static extern bool Everything_IsFastSort(EverythingSortOption dwSortType);
[DllImport(DLL)]
- public static extern SortOption Everything_GetSort();
+ public static extern EverythingSortOption Everything_GetSort();
[DllImport(DLL)]
public static extern uint Everything_GetResultListSort();
[DllImport(DLL)]
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchOption.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchOption.cs
index 92b8e96238e..d8b670a0895 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchOption.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchOption.cs
@@ -1,10 +1,8 @@
-using Flow.Launcher.Plugin.Everything.Everything;
-
-namespace Flow.Launcher.Plugin.Explorer.Search.Everything
+namespace Flow.Launcher.Plugin.Explorer.Search.Everything
{
public record struct EverythingSearchOption(
string Keyword,
- SortOption SortOption,
+ EverythingSortOption SortOption,
bool IsContentSearch = false,
string ContentSearchKeyword = default,
string ParentPath = default,
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSortOption.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSortOption.cs
index 3c2fc3660ad..6a3d7cb67bf 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSortOption.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSortOption.cs
@@ -1,31 +1,59 @@
-namespace Flow.Launcher.Plugin.Everything.Everything
+using Flow.Launcher.Localization.Attributes;
+
+namespace Flow.Launcher.Plugin.Explorer.Search.Everything
{
- public enum SortOption : uint
+ [EnumLocalize]
+ public enum EverythingSortOption : uint
{
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_name_ascending))]
NAME_ASCENDING = 1u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_name_descending))]
NAME_DESCENDING = 2u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_path_ascending))]
PATH_ASCENDING = 3u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_path_descending))]
PATH_DESCENDING = 4u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_size_ascending))]
SIZE_ASCENDING = 5u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_size_descending))]
SIZE_DESCENDING = 6u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_extension_ascending))]
EXTENSION_ASCENDING = 7u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_extension_descending))]
EXTENSION_DESCENDING = 8u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_type_name_ascending))]
TYPE_NAME_ASCENDING = 9u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_type_name_descending))]
TYPE_NAME_DESCENDING = 10u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_date_created_ascending))]
DATE_CREATED_ASCENDING = 11u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_date_created_descending))]
DATE_CREATED_DESCENDING = 12u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_date_modified_ascending))]
DATE_MODIFIED_ASCENDING = 13u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_date_modified_descending))]
DATE_MODIFIED_DESCENDING = 14u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_attributes_ascending))]
ATTRIBUTES_ASCENDING = 15u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_attributes_descending))]
ATTRIBUTES_DESCENDING = 16u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_file_list_filename_ascending))]
FILE_LIST_FILENAME_ASCENDING = 17u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_file_list_filename_descending))]
FILE_LIST_FILENAME_DESCENDING = 18u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_run_count_descending))]
RUN_COUNT_DESCENDING = 20u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_date_recently_changed_ascending))]
DATE_RECENTLY_CHANGED_ASCENDING = 21u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_date_recently_changed_descending))]
DATE_RECENTLY_CHANGED_DESCENDING = 22u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_date_accessed_ascending))]
DATE_ACCESSED_ASCENDING = 23u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_date_accessed_descending))]
DATE_ACCESSED_DESCENDING = 24u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_date_run_ascending))]
DATE_RUN_ASCENDING = 25u,
+ [EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_everything_sort_by_date_run_descending))]
DATE_RUN_DESCENDING = 26u
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
index 77540f3a87b..672e81d0386 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
@@ -1,5 +1,4 @@
-using Flow.Launcher.Plugin.Everything.Everything;
-using Flow.Launcher.Plugin.Explorer.Search;
+using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.Everything;
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex;
@@ -145,10 +144,7 @@ public enum ContentIndexSearchEngineOption
public string EverythingInstalledPath { get; set; }
- [JsonIgnore]
- public SortOption[] SortOptions { get; set; } = Enum.GetValues();
-
- public SortOption SortOption { get; set; } = SortOption.NAME_ASCENDING;
+ public EverythingSortOption SortOption { get; set; } = EverythingSortOption.NAME_ASCENDING;
public bool EnableEverythingContentSearch { get; set; } = false;
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
index 5aa6a13be49..efffb19e05a 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
@@ -35,6 +35,7 @@ public SettingsViewModel(PluginInitContext context, Settings settings)
InitializeEngineSelection();
InitializeActionKeywordModels();
+ EverythingSortOptionLocalized.UpdateLabels(AllEverythingSortOptions);
}
public void Save()
@@ -578,6 +579,20 @@ public int MaxResult
#region Everything FastSortWarning
+ public List AllEverythingSortOptions { get; } = EverythingSortOptionLocalized.GetValues();
+
+ public EverythingSortOption SelectedEverythingSortOption
+ {
+ get => Settings.SortOption;
+ set
+ {
+ Settings.SortOption = value;
+ OnPropertyChanged(nameof(SelectedEverythingSortOption));
+ OnPropertyChanged(nameof(FastSortWarningVisibility));
+ OnPropertyChanged(nameof(SortOptionWarningMessage));
+ }
+ }
+
public Visibility FastSortWarningVisibility
{
get
@@ -607,15 +622,15 @@ public string SortOptionWarningMessage
// this method is used to determine if Everything service is running because as at Everything v1.4.1
// the sdk does not provide a dedicated interface to determine if it is running.
return EverythingApi.IsFastSortOption(Settings.SortOption) ? string.Empty
- : Context.API.GetTranslation("flowlauncher_plugin_everything_nonfastsort_warning");
+ : Localize.flowlauncher_plugin_everything_nonfastsort_warning();
}
catch (IPCErrorException)
{
- return Context.API.GetTranslation("flowlauncher_plugin_everything_is_not_running");
+ return Localize.flowlauncher_plugin_everything_is_not_running();
}
catch (DllNotFoundException)
{
- return Context.API.GetTranslation("flowlauncher_plugin_everything_sdk_issue");
+ return Localize.flowlauncher_plugin_everything_sdk_issue();
}
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/Converters/EverythingEnumNameConverter.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/Converters/EverythingEnumNameConverter.cs
deleted file mode 100644
index e24b21dcd32..00000000000
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/Converters/EverythingEnumNameConverter.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using Flow.Launcher.Plugin.Everything.Everything;
-using Flow.Launcher.Plugin.Explorer.Helper;
-using System;
-using System.Globalization;
-using System.Windows.Data;
-
-namespace Flow.Launcher.Plugin.Explorer.Views.Converters;
-
-public class EnumNameConverter : IValueConverter
-{
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value is SortOption option ? option.GetTranslatedName() : value;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
-}
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
index 59373b4de3f..08abc3ba6d0 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
@@ -2,7 +2,6 @@
x:Class="Flow.Launcher.Plugin.Explorer.Views.ExplorerSettings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:converters="clr-namespace:Flow.Launcher.Plugin.Explorer.Views.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:qa="clr-namespace:Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks"
@@ -74,8 +73,6 @@
-
-