Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
920162f
Use Flow.Launcher.Localization to improve code quality
Jack251970 Sep 21, 2025
343b65c
Merge dev branch
Jack251970 Sep 21, 2025
62abf67
Code cleanup
Jack251970 Sep 23, 2025
6b5e20b
Improve code quality
Jack251970 Sep 23, 2025
071914e
Improve code quality
Jack251970 Sep 23, 2025
479d665
Use internal static Context & Improve code quality
Jack251970 Sep 23, 2025
a3ee3ec
Use Flow.Launcher.Localization to improve code quality
Jack251970 Sep 23, 2025
26ec51c
Code cleanup
Jack251970 Sep 23, 2025
e286143
Use Flow.Launcher.Localization to improve code quality
Jack251970 Sep 23, 2025
5c1c6e9
Improve code quality
Jack251970 Sep 23, 2025
a9364cb
Improve code quality
Jack251970 Sep 23, 2025
41200b8
Use Flow.Launcher.Localization to improve code quality
Jack251970 Sep 23, 2025
2234ed1
Merge branch 'dev' into flow_launcher_localization
Jack251970 Sep 23, 2025
d20dacc
Fix logic issue
Jack251970 Sep 23, 2025
163af5c
Fix the variable name typo
Jack251970 Sep 23, 2025
dad5f5a
Fix redundant boolean cast and ensure consistent default value handling
Jack251970 Sep 23, 2025
af1d11a
Use Flow.Launcher.Localization to improve code quality
Jack251970 Sep 23, 2025
017e1bd
Revert namespace styles
Jack251970 Sep 23, 2025
979f75e
Fix indent format
Jack251970 Sep 23, 2025
d73dedc
Revert namespace style
Jack251970 Sep 23, 2025
0fbfad0
Fix indent format
Jack251970 Sep 23, 2025
e4b8f12
Fix namespace style
Jack251970 Sep 23, 2025
087a169
Fix indent format
Jack251970 Sep 23, 2025
14a0a17
Fix indent format
Jack251970 Sep 23, 2025
742caf2
Merge branch 'dev' into flow_launcher_localization
VictoriousRaptor Sep 27, 2025
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
6 changes: 3 additions & 3 deletions Plugins/Flow.Launcher.Plugin.Calculator/DecimalSeparator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public enum DecimalSeparator
{
[EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_calculator_decimal_separator_use_system_locale))]
UseSystemLocale,

[EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_calculator_decimal_separator_dot))]
Dot,
Dot,

[EnumLocalizeKey(nameof(Localize.flowlauncher_plugin_calculator_decimal_separator_comma))]
Comma
}
Expand Down
20 changes: 10 additions & 10 deletions Plugins/Flow.Launcher.Plugin.Calculator/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Windows.Controls;
using Mages.Core;
using Flow.Launcher.Plugin.Calculator.Views;
using Flow.Launcher.Plugin.Calculator.ViewModels;
using Flow.Launcher.Plugin.Calculator.Views;
using Mages.Core;

namespace Flow.Launcher.Plugin.Calculator
{
Expand All @@ -26,7 +26,7 @@ public class Main : IPlugin, IPluginI18n, ISettingProvider
private const string IcoPath = "Images/calculator.png";
private static readonly List<Result> EmptyResults = [];

internal static PluginInitContext Context { get; set; } = null!;
internal static PluginInitContext Context { get; private set; } = null!;

private Settings _settings;
private SettingsViewModel _viewModel;
Expand Down Expand Up @@ -57,10 +57,10 @@ public List<Result> Query(Query query)
{
var search = query.Search;
bool isFunctionPresent = FunctionRegex.IsMatch(search);

// Mages is case sensitive, so we need to convert all function names to lower case.
search = FunctionRegex.Replace(search, m => m.Value.ToLowerInvariant());

var decimalSep = GetDecimalSeparator();
var groupSep = GetGroupSeparator(decimalSep);
var expression = NumberRegex.Replace(search, m => NormalizeNumber(m.Value, isFunctionPresent, decimalSep, groupSep));
Expand Down Expand Up @@ -292,7 +292,7 @@ private static string NormalizeNumber(string numberStr, bool isFunctionPresent,
{
processedStr = processedStr.Replace(decimalSep, ".");
}

return processedStr;
}
else
Expand All @@ -310,7 +310,7 @@ private static string NormalizeNumber(string numberStr, bool isFunctionPresent,
return processedStr;
}
}

private static bool IsValidGrouping(string[] parts, int[] groupSizes)
{
if (parts.Length <= 1) return true;
Expand All @@ -326,7 +326,7 @@ private static bool IsValidGrouping(string[] parts, int[] groupSizes)

var lastGroupSize = groupSizes.Last();
var canRepeatLastGroup = lastGroupSize != 0;

int groupIndex = 0;
for (int i = parts.Length - 1; i > 0; i--)
{
Expand All @@ -335,7 +335,7 @@ private static bool IsValidGrouping(string[] parts, int[] groupSizes)
{
expectedSize = groupSizes[groupIndex];
}
else if(canRepeatLastGroup)
else if (canRepeatLastGroup)
{
expectedSize = lastGroupSize;
}
Expand All @@ -345,7 +345,7 @@ private static bool IsValidGrouping(string[] parts, int[] groupSizes)
}

if (parts[i].Length != expectedSize) return false;

groupIndex++;
}

Expand Down
3 changes: 1 addition & 2 deletions Plugins/Flow.Launcher.Plugin.Calculator/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

namespace Flow.Launcher.Plugin.Calculator;
namespace Flow.Launcher.Plugin.Calculator;

public class Settings
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<NoWarn>$(NoWarn);FLSG0007</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -54,5 +55,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Flow.Launcher.Localization" Version="0.0.6" />
</ItemGroup>

</Project>
30 changes: 15 additions & 15 deletions Plugins/Flow.Launcher.Plugin.PluginIndicator/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ namespace Flow.Launcher.Plugin.PluginIndicator
{
public class Main : IPlugin, IPluginI18n, IHomeQuery
{
internal PluginInitContext Context { get; private set; }
internal static PluginInitContext Context { get; private set; }

public List<Result> Query(Query query)
public void Init(PluginInitContext context)
{
return QueryResults(query);
Context = context;
}

public List<Result> HomeQuery()
public List<Result> Query(Query query)
{
return QueryResults();
return QueryResults(query);
}

private List<Result> QueryResults(Query query = null)
private static List<Result> QueryResults(Query query = null)
{
var nonGlobalPlugins = GetNonGlobalPlugins();
var querySearch = query?.Search ?? string.Empty;
Expand All @@ -34,7 +34,7 @@ from keyword in nonGlobalPlugins.Keys
select new Result
{
Title = keyword,
SubTitle = string.Format(Context.API.GetTranslation("flowlauncher_plugin_pluginindicator_result_subtitle"), plugin.Name),
SubTitle = Localize.flowlauncher_plugin_pluginindicator_result_subtitle(plugin.Name),
Score = score,
IcoPath = plugin.IcoPath,
AutoCompleteText = $"{keyword}{Plugin.Query.TermSeparator}",
Expand All @@ -44,10 +44,10 @@ from keyword in nonGlobalPlugins.Keys
return false;
}
};
return results.ToList();
return [.. results];
}

private Dictionary<string, PluginPair> GetNonGlobalPlugins()
private static Dictionary<string, PluginPair> GetNonGlobalPlugins()
{
var nonGlobalPlugins = new Dictionary<string, PluginPair>();
foreach (var plugin in Context.API.GetAllPlugins())
Expand All @@ -66,19 +66,19 @@ private Dictionary<string, PluginPair> GetNonGlobalPlugins()
return nonGlobalPlugins;
}

public void Init(PluginInitContext context)
public string GetTranslatedPluginTitle()
{
Context = context;
return Localize.flowlauncher_plugin_pluginindicator_plugin_name();
}

public string GetTranslatedPluginTitle()
public string GetTranslatedPluginDescription()
{
return Context.API.GetTranslation("flowlauncher_plugin_pluginindicator_plugin_name");
return Localize.flowlauncher_plugin_pluginindicator_plugin_description();
}

public string GetTranslatedPluginDescription()
public List<Result> HomeQuery()
{
return Context.API.GetTranslation("flowlauncher_plugin_pluginindicator_plugin_description");
return QueryResults();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<NoWarn>$(NoWarn);FLSG0007</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -52,6 +53,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Flow.Launcher.Localization" Version="0.0.6" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.205">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
62 changes: 31 additions & 31 deletions Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
{
public class Main : IPlugin, IPluginI18n, IContextMenu, ISettingProvider
{
private readonly ProcessHelper processHelper = new();
internal static PluginInitContext Context { get; private set; }

private static PluginInitContext _context;
private Settings _settings;

internal Settings Settings;
private readonly ProcessHelper processHelper = new();

private SettingsViewModel _viewModel;

public void Init(PluginInitContext context)
{
_context = context;
Settings = context.API.LoadSettingJsonStorage<Settings>();
_viewModel = new SettingsViewModel(Settings);
Context = context;
_settings = context.API.LoadSettingJsonStorage<Settings>();
_viewModel = new SettingsViewModel(_settings);
}

public List<Result> Query(Query query)
Expand All @@ -31,12 +31,12 @@

public string GetTranslatedPluginTitle()
{
return _context.API.GetTranslation("flowlauncher_plugin_processkiller_plugin_name");
return Localize.flowlauncher_plugin_processkiller_plugin_name();
}

public string GetTranslatedPluginDescription()
{
return _context.API.GetTranslation("flowlauncher_plugin_processkiller_plugin_description");
return Localize.flowlauncher_plugin_processkiller_plugin_description();

Check warning on line 39 in Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`processkiller` is not a recognized word. (unrecognized-spelling)
}

public List<Result> LoadContextMenus(Result result)
Expand All @@ -51,13 +51,13 @@
{
menuOptions.Add(new Result
{
Title = _context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_instances"),
Title = Localize.flowlauncher_plugin_processkiller_kill_instances(),

Check warning on line 54 in Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`processkiller` is not a recognized word. (unrecognized-spelling)
SubTitle = processPath,
Action = _ =>
{
foreach (var p in similarProcesses)
{
processHelper.TryKill(_context, p);
ProcessHelper.TryKill(p);
}

return true;
Expand All @@ -72,8 +72,8 @@
private List<Result> CreateResultsFromQuery(Query query)
{
// Get all non-system processes
var allPocessList = processHelper.GetMatchingProcesses();
if (!allPocessList.Any())
var allProcessList = processHelper.GetMatchingProcesses();
if (allProcessList.Count == 0)
{
return null;
}
Expand All @@ -82,12 +82,12 @@
var searchTerm = query.Search;
var processlist = new List<ProcessResult>();
var processWindowTitle =
Settings.ShowWindowTitle || Settings.PutVisibleWindowProcessesTop ?
_settings.ShowWindowTitle || _settings.PutVisibleWindowProcessesTop ?
ProcessHelper.GetProcessesWithNonEmptyWindowTitle() :
new Dictionary<int, string>();
[];
if (string.IsNullOrWhiteSpace(searchTerm))
{
foreach (var p in allPocessList)
foreach (var p in allProcessList)
{
var progressNameIdTitle = ProcessHelper.GetProcessNameIdTitle(p);

Expand All @@ -95,16 +95,16 @@
{
// Add score to prioritize processes with visible windows
// Use window title for those processes if enabled
processlist.Add(new ProcessResult(

Check warning on line 98 in Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`processlist` is not a recognized word. (unrecognized-spelling)
p,
Settings.PutVisibleWindowProcessesTop ? 200 : 0,
Settings.ShowWindowTitle ? windowTitle : progressNameIdTitle,
_settings.PutVisibleWindowProcessesTop ? 200 : 0,
_settings.ShowWindowTitle ? windowTitle : progressNameIdTitle,
null,
progressNameIdTitle));
}
else
{
processlist.Add(new ProcessResult(

Check warning on line 107 in Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`processlist` is not a recognized word. (unrecognized-spelling)
p,
0,
progressNameIdTitle,
Expand All @@ -115,39 +115,39 @@
}
else
{
foreach (var p in allPocessList)
foreach (var p in allProcessList)
{
var progressNameIdTitle = ProcessHelper.GetProcessNameIdTitle(p);

if (processWindowTitle.TryGetValue(p.Id, out var windowTitle))
{
// Get max score from searching process name, window title and process id
var windowTitleMatch = _context.API.FuzzySearch(searchTerm, windowTitle);
var processNameIdMatch = _context.API.FuzzySearch(searchTerm, progressNameIdTitle);
var windowTitleMatch = Context.API.FuzzySearch(searchTerm, windowTitle);
var processNameIdMatch = Context.API.FuzzySearch(searchTerm, progressNameIdTitle);
var score = Math.Max(windowTitleMatch.Score, processNameIdMatch.Score);
if (score > 0)
{
// Add score to prioritize processes with visible windows
// Use window title for those processes
if (Settings.PutVisibleWindowProcessesTop)
if (_settings.PutVisibleWindowProcessesTop)
{
score += 200;
}
processlist.Add(new ProcessResult(

Check warning on line 136 in Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`processlist` is not a recognized word. (unrecognized-spelling)
p,
score,
Settings.ShowWindowTitle ? windowTitle : progressNameIdTitle,
_settings.ShowWindowTitle ? windowTitle : progressNameIdTitle,
score == windowTitleMatch.Score ? windowTitleMatch : null,
progressNameIdTitle));
}
}
else
{
var processNameIdMatch = _context.API.FuzzySearch(searchTerm, progressNameIdTitle);
var processNameIdMatch = Context.API.FuzzySearch(searchTerm, progressNameIdTitle);
var score = processNameIdMatch.Score;
if (score > 0)
{
processlist.Add(new ProcessResult(

Check warning on line 150 in Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`processlist` is not a recognized word. (unrecognized-spelling)
p,
score,
progressNameIdTitle,
Expand All @@ -162,7 +162,7 @@
foreach (var pr in processlist)
{
var p = pr.Process;
var path = processHelper.TryGetProcessFilename(p);
var path = ProcessHelper.TryGetProcessFilename(p);
results.Add(new Result()
{
IcoPath = path,
Expand All @@ -172,12 +172,12 @@
TitleHighlightData = pr.TitleMatch?.MatchData,
Score = pr.Score,
ContextData = p.ProcessName,
AutoCompleteText = $"{_context.CurrentPluginMetadata.ActionKeyword}{Plugin.Query.TermSeparator}{p.ProcessName}",
AutoCompleteText = $"{Context.CurrentPluginMetadata.ActionKeyword}{Plugin.Query.TermSeparator}{p.ProcessName}",
Action = (c) =>
{
processHelper.TryKill(_context, p);
ProcessHelper.TryKill(p);
// Re-query to refresh process list
_context.API.ReQuery();
Context.API.ReQuery();
return true;
}
});
Expand All @@ -194,17 +194,17 @@
sortedResults.Insert(1, new Result()
{
IcoPath = firstResult?.IcoPath,
Title = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all"), firstResult?.ContextData),
SubTitle = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all_count"), processlist.Count),
Title = Localize.flowlauncher_plugin_processkiller_kill_all(firstResult?.ContextData),

Check warning on line 197 in Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`processkiller` is not a recognized word. (unrecognized-spelling)
SubTitle = Localize.flowlauncher_plugin_processkiller_kill_all_count(processlist.Count),

Check warning on line 198 in Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`processkiller` is not a recognized word. (unrecognized-spelling)
Score = 200,
Action = (c) =>
{
foreach (var p in processlist)
{
processHelper.TryKill(_context, p.Process);
ProcessHelper.TryKill(p.Process);
}
// Re-query to refresh process list
_context.API.ReQuery();
Context.API.ReQuery();
return true;
}
});
Expand Down
Loading
Loading