diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Command.cs b/Plugins/Flow.Launcher.Plugin.Sys/Command.cs
new file mode 100644
index 00000000000..6c3a99f3e20
--- /dev/null
+++ b/Plugins/Flow.Launcher.Plugin.Sys/Command.cs
@@ -0,0 +1,44 @@
+using System.Text.Json.Serialization;
+
+namespace Flow.Launcher.Plugin.Sys
+{
+ public class Command : BaseModel
+ {
+ public string Key { get; set; }
+
+ private string name;
+ [JsonIgnore]
+ public string Name
+ {
+ get => name;
+ set
+ {
+ name = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private string description;
+ [JsonIgnore]
+ public string Description
+ {
+ get => description;
+ set
+ {
+ description = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private string keyword;
+ public string Keyword
+ {
+ get => keyword;
+ set
+ {
+ keyword = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+}
diff --git a/Plugins/Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml b/Plugins/Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml
new file mode 100644
index 00000000000..a848f2f1f52
--- /dev/null
+++ b/Plugins/Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml.cs
new file mode 100644
index 00000000000..8797bf2201e
--- /dev/null
+++ b/Plugins/Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml.cs
@@ -0,0 +1,45 @@
+using System.Windows;
+
+namespace Flow.Launcher.Plugin.Sys
+{
+ public partial class CommandKeywordSettingWindow
+ {
+ private readonly Command _oldSearchSource;
+ private readonly PluginInitContext _context;
+
+ public CommandKeywordSettingWindow(PluginInitContext context, Command old)
+ {
+ _context = context;
+ _oldSearchSource = old;
+ InitializeComponent();
+ CommandKeyword.Text = old.Keyword;
+ CommandKeywordTips.Text = string.Format(_context.API.GetTranslation("flowlauncher_plugin_sys_custom_command_keyword_tip"), old.Name);
+ }
+
+ private void OnCancelButtonClick(object sender, RoutedEventArgs e)
+ {
+ Close();
+ }
+
+ private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
+ {
+ var keyword = CommandKeyword.Text;
+ if (string.IsNullOrEmpty(keyword))
+ {
+ var warning = _context.API.GetTranslation("flowlauncher_plugin_sys_input_command_keyword");
+ _context.API.ShowMsgBox(warning);
+ }
+ else
+ {
+ _oldSearchSource.Keyword = keyword;
+ Close();
+ }
+ }
+
+ private void OnResetButtonClick(object sender, RoutedEventArgs e)
+ {
+ // Key is the default value of this command
+ CommandKeyword.Text = _oldSearchSource.Key;
+ }
+ }
+}
diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml
index 2a266f8f651..ad3f8553bab 100644
--- a/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml
@@ -4,8 +4,9 @@
xmlns:system="clr-namespace:System;assembly=mscorlib">
- Command
+ Name
Description
+ Command
Shutdown
Restart
@@ -29,6 +30,8 @@
Toggle Game Mode
Set the Flow Launcher Theme
+ Edit
+
Shutdown Computer
Restart Computer
@@ -61,6 +64,15 @@
Are you sure you want to restart the computer with Advanced Boot Options?
Are you sure you want to log off?
+ Command Keyword Setting
+ Custom Command Keyword
+ Enter a keyword to search for command: {0}. This keyword is used to match your query.
+ Command Keyword
+ Reset
+ Confirm
+ Cancel
+ Please enter a non-empty command keyword
+
System Commands
Provides System related commands. e.g. shutdown, lock, settings etc.
diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs
index 28747cc7cf1..77f3b56a6e2 100644
--- a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Globalization;
using System.IO;
+using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
using Flow.Launcher.Infrastructure;
@@ -18,43 +20,81 @@ namespace Flow.Launcher.Plugin.Sys
{
public class Main : IPlugin, ISettingProvider, IPluginI18n
{
- private PluginInitContext context;
- private ThemeSelector themeSelector;
- private Dictionary KeywordTitleMappings = new Dictionary();
-
- // SHTDN_REASON_MAJOR_OTHER indicates a generic shutdown reason that isn't categorized under hardware failure, software updates, or other predefined reasons.
+ private readonly Dictionary KeywordTitleMappings = new()
+ {
+ {"Shutdown", "flowlauncher_plugin_sys_shutdown_computer_cmd"},
+ {"Restart", "flowlauncher_plugin_sys_restart_computer_cmd"},
+ {"Restart With Advanced Boot Options", "flowlauncher_plugin_sys_restart_advanced_cmd"},
+ {"Log Off/Sign Out", "flowlauncher_plugin_sys_log_off_cmd"},
+ {"Lock", "flowlauncher_plugin_sys_lock_cmd"},
+ {"Sleep", "flowlauncher_plugin_sys_sleep_cmd"},
+ {"Hibernate", "flowlauncher_plugin_sys_hibernate_cmd"},
+ {"Index Option", "flowlauncher_plugin_sys_indexoption_cmd"},
+ {"Empty Recycle Bin", "flowlauncher_plugin_sys_emptyrecyclebin_cmd"},
+ {"Open Recycle Bin", "flowlauncher_plugin_sys_openrecyclebin_cmd"},
+ {"Exit", "flowlauncher_plugin_sys_exit_cmd"},
+ {"Save Settings", "flowlauncher_plugin_sys_save_all_settings_cmd"},
+ {"Restart Flow Launcher", "flowlauncher_plugin_sys_restart_cmd"},
+ {"Settings", "flowlauncher_plugin_sys_setting_cmd"},
+ {"Reload Plugin Data", "flowlauncher_plugin_sys_reload_plugin_data_cmd"},
+ {"Check For Update", "flowlauncher_plugin_sys_check_for_update_cmd"},
+ {"Open Log Location", "flowlauncher_plugin_sys_open_log_location_cmd"},
+ {"Flow Launcher Tips", "flowlauncher_plugin_sys_open_docs_tips_cmd"},
+ {"Flow Launcher UserData Folder", "flowlauncher_plugin_sys_open_userdata_location_cmd"},
+ {"Toggle Game Mode", "flowlauncher_plugin_sys_toggle_game_mode_cmd"},
+ {"Set Flow Launcher Theme", "flowlauncher_plugin_sys_theme_selector_cmd"}
+ };
+ private readonly Dictionary KeywordDescriptionMappings = new();
+
+ // SHTDN_REASON_MAJOR_OTHER indicates a generic shutdown reason that isn't categorized under hardware failure,
+ // software updates, or other predefined reasons.
// SHTDN_REASON_FLAG_PLANNED marks the shutdown as planned rather than an unexpected shutdown or failure
- private const SHUTDOWN_REASON REASON = SHUTDOWN_REASON.SHTDN_REASON_MAJOR_OTHER | SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED;
+ private const SHUTDOWN_REASON REASON = SHUTDOWN_REASON.SHTDN_REASON_MAJOR_OTHER |
+ SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED;
+
+ private PluginInitContext _context;
+ private Settings _settings;
+ private ThemeSelector _themeSelector;
+ private SettingsViewModel _viewModel;
public Control CreateSettingPanel()
{
- var results = Commands();
- return new SysSettings(results);
+ UpdateLocalizedNameDescription(false);
+ return new SysSettings(_context, _viewModel);
}
public List Query(Query query)
{
if(query.Search.StartsWith(ThemeSelector.Keyword))
{
- return themeSelector.Query(query);
+ return _themeSelector.Query(query);
}
var commands = Commands();
var results = new List();
foreach (var c in commands)
{
- c.Title = GetDynamicTitle(query, c);
+ var command = _settings.Commands.First(x => x.Key == c.Title);
+ c.Title = command.Name;
+ c.SubTitle = command.Description;
- var titleMatch = StringMatcher.FuzzySearch(query.Search, c.Title);
- var subTitleMatch = StringMatcher.FuzzySearch(query.Search, c.SubTitle);
+ // Match from localized title & localized subtitle & keyword
+ var titleMatch = _context.API.FuzzySearch(query.Search, c.Title);
+ var subTitleMatch = _context.API.FuzzySearch(query.Search, c.SubTitle);
+ var keywordMatch = _context.API.FuzzySearch(query.Search, command.Keyword);
+ // Get the largest score from them
var score = Math.Max(titleMatch.Score, subTitleMatch.Score);
- if (score > 0)
+ var finalScore = Math.Max(score, keywordMatch.Score);
+ if (finalScore > 0)
{
- c.Score = score;
+ c.Score = finalScore;
- if (score == titleMatch.Score)
+ // If title match has the highest score, highlight title
+ if (finalScore == titleMatch.Score)
+ {
c.TitleHighlightData = titleMatch.MatchData;
+ }
results.Add(c);
}
@@ -63,54 +103,51 @@ public List Query(Query query)
return results;
}
- private string GetDynamicTitle(Query query, Result result)
+ private string GetTitle(string key)
{
- if (!KeywordTitleMappings.TryGetValue(result.Title, out var translationKey))
+ if (!KeywordTitleMappings.TryGetValue(key, out var translationKey))
{
- Log.Error("Flow.Launcher.Plugin.Sys.Main", $"Dynamic Title not found for: {result.Title}");
+ Log.Error("Flow.Launcher.Plugin.Sys.Main", $"Title not found for: {key}");
return "Title Not Found";
}
- var translatedTitle = context.API.GetTranslation(translationKey);
+ return _context.API.GetTranslation(translationKey);
+ }
- if (result.Title == translatedTitle)
+ private string GetDescription(string key)
+ {
+ if (!KeywordDescriptionMappings.TryGetValue(key, out var translationKey))
{
- return result.Title;
+ Log.Error("Flow.Launcher.Plugin.Sys.Main", $"Description not found for: {key}");
+ return "Description Not Found";
}
- var englishTitleMatch = StringMatcher.FuzzySearch(query.Search, result.Title);
- var translatedTitleMatch = StringMatcher.FuzzySearch(query.Search, translatedTitle);
-
- return englishTitleMatch.Score >= translatedTitleMatch.Score ? result.Title : translatedTitle;
+ return _context.API.GetTranslation(translationKey);
}
public void Init(PluginInitContext context)
{
- this.context = context;
- themeSelector = new ThemeSelector(context);
- KeywordTitleMappings = new Dictionary{
- {"Shutdown", "flowlauncher_plugin_sys_shutdown_computer_cmd"},
- {"Restart", "flowlauncher_plugin_sys_restart_computer_cmd"},
- {"Restart With Advanced Boot Options", "flowlauncher_plugin_sys_restart_advanced_cmd"},
- {"Log Off/Sign Out", "flowlauncher_plugin_sys_log_off_cmd"},
- {"Lock", "flowlauncher_plugin_sys_lock_cmd"},
- {"Sleep", "flowlauncher_plugin_sys_sleep_cmd"},
- {"Hibernate", "flowlauncher_plugin_sys_hibernate_cmd"},
- {"Index Option", "flowlauncher_plugin_sys_indexoption_cmd"},
- {"Empty Recycle Bin", "flowlauncher_plugin_sys_emptyrecyclebin_cmd"},
- {"Open Recycle Bin", "flowlauncher_plugin_sys_openrecyclebin_cmd"},
- {"Exit", "flowlauncher_plugin_sys_exit_cmd"},
- {"Save Settings", "flowlauncher_plugin_sys_save_all_settings_cmd"},
- {"Restart Flow Launcher", "flowlauncher_plugin_sys_restart_cmd"},
- {"Settings", "flowlauncher_plugin_sys_setting_cmd"},
- {"Reload Plugin Data", "flowlauncher_plugin_sys_reload_plugin_data_cmd"},
- {"Check For Update", "flowlauncher_plugin_sys_check_for_update_cmd"},
- {"Open Log Location", "flowlauncher_plugin_sys_open_log_location_cmd"},
- {"Flow Launcher Tips", "flowlauncher_plugin_sys_open_docs_tips_cmd"},
- {"Flow Launcher UserData Folder", "flowlauncher_plugin_sys_open_userdata_location_cmd"},
- {"Toggle Game Mode", "flowlauncher_plugin_sys_toggle_game_mode_cmd"},
- {"Set Flow Launcher Theme", "flowlauncher_plugin_sys_theme_selector_cmd"}
- };
+ _context = context;
+ _settings = context.API.LoadSettingJsonStorage();
+ _viewModel = new SettingsViewModel(_settings);
+ _themeSelector = new ThemeSelector(context);
+ foreach (string key in KeywordTitleMappings.Keys)
+ {
+ // Remove _cmd in the last of the strings
+ KeywordDescriptionMappings[key] = KeywordTitleMappings[key][..^4];
+ }
+ }
+
+ private void UpdateLocalizedNameDescription(bool force)
+ {
+ if (string.IsNullOrEmpty(_settings.Commands[0].Name) || force)
+ {
+ foreach (var c in _settings.Commands)
+ {
+ c.Name = GetTitle(c.Key);
+ c.Description = GetDescription(c.Key);
+ }
+ }
}
private static unsafe bool EnableShutdownPrivilege()
@@ -162,14 +199,13 @@ private List Commands()
new Result
{
Title = "Shutdown",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_shutdown_computer"),
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe7e8"),
IcoPath = "Images\\shutdown.png",
Action = c =>
{
- var result = context.API.ShowMsgBox(
- context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_shutdown_computer"),
- context.API.GetTranslation("flowlauncher_plugin_sys_shutdown_computer"),
+ var result = _context.API.ShowMsgBox(
+ _context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_shutdown_computer"),
+ _context.API.GetTranslation("flowlauncher_plugin_sys_shutdown_computer"),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes)
@@ -184,14 +220,13 @@ private List Commands()
new Result
{
Title = "Restart",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"),
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe777"),
IcoPath = "Images\\restart.png",
Action = c =>
{
- var result = context.API.ShowMsgBox(
- context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_restart_computer"),
- context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"),
+ var result = _context.API.ShowMsgBox(
+ _context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_restart_computer"),
+ _context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes)
@@ -206,14 +241,13 @@ private List Commands()
new Result
{
Title = "Restart With Advanced Boot Options",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_restart_advanced"),
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xecc5"),
IcoPath = "Images\\restart_advanced.png",
Action = c =>
{
- var result = context.API.ShowMsgBox(
- context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_restart_computer_advanced"),
- context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"),
+ var result = _context.API.ShowMsgBox(
+ _context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_restart_computer_advanced"),
+ _context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes)
@@ -228,14 +262,13 @@ private List Commands()
new Result
{
Title = "Log Off/Sign Out",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_log_off"),
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe77b"),
IcoPath = "Images\\logoff.png",
Action = c =>
{
- var result = context.API.ShowMsgBox(
- context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_logoff_computer"),
- context.API.GetTranslation("flowlauncher_plugin_sys_log_off"),
+ var result = _context.API.ShowMsgBox(
+ _context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_logoff_computer"),
+ _context.API.GetTranslation("flowlauncher_plugin_sys_log_off"),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes)
@@ -247,7 +280,6 @@ private List Commands()
new Result
{
Title = "Lock",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_lock"),
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe72e"),
IcoPath = "Images\\lock.png",
Action = c =>
@@ -259,7 +291,6 @@ private List Commands()
new Result
{
Title = "Sleep",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_sleep"),
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xec46"),
IcoPath = "Images\\sleep.png",
Action = c =>
@@ -271,7 +302,6 @@ private List Commands()
new Result
{
Title = "Hibernate",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_hibernate"),
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe945"),
IcoPath = "Images\\hibernate.png",
Action= c =>
@@ -283,7 +313,6 @@ private List Commands()
new Result
{
Title = "Index Option",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_indexoption"),
IcoPath = "Images\\indexoption.png",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe773"),
Action = c =>
@@ -295,7 +324,6 @@ private List Commands()
new Result
{
Title = "Empty Recycle Bin",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_emptyrecyclebin"),
IcoPath = "Images\\recyclebin.png",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe74d"),
Action = c =>
@@ -306,7 +334,7 @@ private List Commands()
var result = PInvoke.SHEmptyRecycleBin(new(), string.Empty, 0);
if (result != HRESULT.S_OK && result != HRESULT.E_UNEXPECTED)
{
- context.API.ShowMsgBox("Failed to empty the recycle bin. This might happen if:\n" +
+ _context.API.ShowMsgBox("Failed to empty the recycle bin. This might happen if:\n" +
"- A file in the recycle bin is in use\n" +
"- You don't have permission to delete some items\n" +
"Please close any applications that might be using these files and try again.",
@@ -320,7 +348,6 @@ private List Commands()
new Result
{
Title = "Open Recycle Bin",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_openrecyclebin"),
IcoPath = "Images\\openrecyclebin.png",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe74d"),
CopyText = recycleBinFolder,
@@ -333,7 +360,6 @@ private List Commands()
new Result
{
Title = "Exit",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_exit"),
IcoPath = "Images\\app.png",
Action = c =>
{
@@ -344,52 +370,48 @@ private List Commands()
new Result
{
Title = "Save Settings",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_save_all_settings"),
IcoPath = "Images\\app.png",
Action = c =>
{
- context.API.SaveAppAllSettings();
- context.API.ShowMsg(context.API.GetTranslation("flowlauncher_plugin_sys_dlgtitle_success"),
- context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_all_settings_saved"));
+ _context.API.SaveAppAllSettings();
+ _context.API.ShowMsg(_context.API.GetTranslation("flowlauncher_plugin_sys_dlgtitle_success"),
+ _context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_all_settings_saved"));
return true;
}
},
new Result
{
Title = "Restart Flow Launcher",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_restart"),
IcoPath = "Images\\app.png",
Action = c =>
{
- context.API.RestartApp();
+ _context.API.RestartApp();
return false;
}
},
new Result
{
Title = "Settings",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_setting"),
IcoPath = "Images\\app.png",
Action = c =>
{
- context.API.OpenSettingDialog();
+ _context.API.OpenSettingDialog();
return true;
}
},
new Result
{
Title = "Reload Plugin Data",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_reload_plugin_data"),
IcoPath = "Images\\app.png",
Action = c =>
{
// Hide the window first then show msg after done because sometimes the reload could take a while, so not to make user think it's frozen.
- context.API.HideMainWindow();
+ _context.API.HideMainWindow();
- _ = context.API.ReloadAllPluginData().ContinueWith(_ =>
- context.API.ShowMsg(
- context.API.GetTranslation("flowlauncher_plugin_sys_dlgtitle_success"),
- context.API.GetTranslation(
+ _ = _context.API.ReloadAllPluginData().ContinueWith(_ =>
+ _context.API.ShowMsg(
+ _context.API.GetTranslation("flowlauncher_plugin_sys_dlgtitle_success"),
+ _context.API.GetTranslation(
"flowlauncher_plugin_sys_dlgtext_all_applicableplugins_reloaded")),
System.Threading.Tasks.TaskScheduler.Current);
@@ -399,75 +421,69 @@ private List Commands()
new Result
{
Title = "Check For Update",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_check_for_update"),
IcoPath = "Images\\checkupdate.png",
Action = c =>
{
- context.API.HideMainWindow();
- context.API.CheckForNewUpdate();
+ _context.API.HideMainWindow();
+ _context.API.CheckForNewUpdate();
return true;
}
},
new Result
{
Title = "Open Log Location",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_open_log_location"),
IcoPath = "Images\\app.png",
CopyText = logPath,
AutoCompleteText = logPath,
Action = c =>
{
- context.API.OpenDirectory(logPath);
+ _context.API.OpenDirectory(logPath);
return true;
}
},
new Result
{
Title = "Flow Launcher Tips",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_open_docs_tips"),
IcoPath = "Images\\app.png",
CopyText = Constant.Documentation,
AutoCompleteText = Constant.Documentation,
Action = c =>
{
- context.API.OpenUrl(Constant.Documentation);
+ _context.API.OpenUrl(Constant.Documentation);
return true;
}
},
new Result
{
Title = "Flow Launcher UserData Folder",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_open_userdata_location"),
IcoPath = "Images\\app.png",
CopyText = userDataPath,
AutoCompleteText = userDataPath,
Action = c =>
{
- context.API.OpenDirectory(userDataPath);
+ _context.API.OpenDirectory(userDataPath);
return true;
}
},
new Result
{
Title = "Toggle Game Mode",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_toggle_game_mode"),
IcoPath = "Images\\app.png",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\ue7fc"),
Action = c =>
{
- context.API.ToggleGameMode();
+ _context.API.ToggleGameMode();
return true;
}
},
new Result
{
Title = "Set Flow Launcher Theme",
- SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_theme_selector"),
IcoPath = "Images\\app.png",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\ue7fc"),
Action = c =>
{
- context.API.ChangeQuery($"{ThemeSelector.Keyword} ");
+ _context.API.ChangeQuery($"{ThemeSelector.Keyword} ");
return false;
}
}
@@ -478,12 +494,17 @@ private List Commands()
public string GetTranslatedPluginTitle()
{
- return context.API.GetTranslation("flowlauncher_plugin_sys_plugin_name");
+ return _context.API.GetTranslation("flowlauncher_plugin_sys_plugin_name");
}
public string GetTranslatedPluginDescription()
{
- return context.API.GetTranslation("flowlauncher_plugin_sys_plugin_description");
+ return _context.API.GetTranslation("flowlauncher_plugin_sys_plugin_description");
+ }
+
+ public void OnCultureInfoChanged(CultureInfo _)
+ {
+ UpdateLocalizedNameDescription(true);
}
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Settings.cs b/Plugins/Flow.Launcher.Plugin.Sys/Settings.cs
new file mode 100644
index 00000000000..f39e6d65fe0
--- /dev/null
+++ b/Plugins/Flow.Launcher.Plugin.Sys/Settings.cs
@@ -0,0 +1,127 @@
+using System.Collections.ObjectModel;
+using System.Text.Json.Serialization;
+
+namespace Flow.Launcher.Plugin.Sys;
+
+public class Settings : BaseModel
+{
+ public Settings()
+ {
+ if (Commands.Count > 0)
+ {
+ SelectedCommand = Commands[0];
+ }
+ }
+
+ public ObservableCollection Commands { get; set; } = new ObservableCollection
+ {
+ new()
+ {
+ Key = "Shutdown",
+ Keyword = "Shutdown"
+ },
+ new()
+ {
+ Key = "Restart",
+ Keyword = "Restart"
+ },
+ new()
+ {
+ Key = "Restart With Advanced Boot Options",
+ Keyword = "Restart With Advanced Boot Options"
+ },
+ new()
+ {
+ Key = "Log Off/Sign Out",
+ Keyword = "Log Off/Sign Out"
+ },
+ new()
+ {
+ Key = "Lock",
+ Keyword = "Lock"
+ },
+ new()
+ {
+ Key = "Sleep",
+ Keyword = "Sleep"
+ },
+ new()
+ {
+ Key = "Hibernate",
+ Keyword = "Hibernate"
+ },
+ new()
+ {
+ Key = "Index Option",
+ Keyword = "Index Option"
+ },
+ new()
+ {
+ Key = "Empty Recycle Bin",
+ Keyword = "Empty Recycle Bin"
+ },
+ new()
+ {
+ Key = "Open Recycle Bin",
+ Keyword = "Open Recycle Bin"
+ },
+ new()
+ {
+ Key = "Exit",
+ Keyword = "Exit"
+ },
+ new()
+ {
+ Key = "Save Settings",
+ Keyword = "Save Settings"
+ },
+ new()
+ {
+ Key = "Restart Flow Launcher",
+ Keyword = "Restart Flow Launcher"
+ },
+ new()
+ {
+ Key = "Settings",
+ Keyword = "Settings"
+ },
+ new()
+ {
+ Key = "Reload Plugin Data",
+ Keyword = "Reload Plugin Data"
+ },
+ new()
+ {
+ Key = "Check For Update",
+ Keyword = "Check For Update"
+ },
+ new()
+ {
+ Key = "Open Log Location",
+ Keyword = "Open Log Location"
+ },
+ new()
+ {
+ Key = "Flow Launcher Tips",
+ Keyword = "Flow Launcher Tips"
+ },
+ new()
+ {
+ Key = "Flow Launcher UserData Folder",
+ Keyword = "Flow Launcher UserData Folder"
+ },
+ new()
+ {
+ Key = "Toggle Game Mode",
+ Keyword = "Toggle Game Mode"
+ },
+ new()
+ {
+ Key = "Set Flow Launcher Theme",
+ Keyword = "Set Flow Launcher Theme"
+ }
+ };
+
+ [JsonIgnore]
+ public Command SelectedCommand { get; set; }
+}
diff --git a/Plugins/Flow.Launcher.Plugin.Sys/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Sys/SettingsViewModel.cs
new file mode 100644
index 00000000000..0755dffa923
--- /dev/null
+++ b/Plugins/Flow.Launcher.Plugin.Sys/SettingsViewModel.cs
@@ -0,0 +1,12 @@
+namespace Flow.Launcher.Plugin.Sys
+{
+ public class SettingsViewModel
+ {
+ public SettingsViewModel(Settings settings)
+ {
+ Settings = settings;
+ }
+
+ public Settings Settings { get; }
+ }
+}
diff --git a/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml b/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml
index f806900dedc..67e840e5358 100644
--- a/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml
@@ -4,36 +4,66 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:vm="clr-namespace:Flow.Launcher.Plugin.Sys"
+ d:DataContext="{d:DesignInstance vm:SettingsViewModel}"
d:DesignHeight="300"
d:DesignWidth="300"
mc:Ignorable="d">
-
+
+
+
+
+
+
-
+
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs
index feb30821a55..0a38fda0432 100644
--- a/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs
@@ -1,28 +1,30 @@
-using System.Collections.Generic;
-using System.Windows;
+using System.Windows;
using System.Windows.Controls;
namespace Flow.Launcher.Plugin.Sys
{
public partial class SysSettings : UserControl
{
- public SysSettings(List Results)
+ private readonly PluginInitContext _context;
+ private readonly Settings _settings;
+
+ public SysSettings(PluginInitContext context, SettingsViewModel viewModel)
{
InitializeComponent();
-
- foreach (var Result in Results)
- {
- lbxCommands.Items.Add(Result);
- }
+ _context = context;
+ _settings = viewModel.Settings;
+ DataContext = viewModel;
}
+
private void ListView_SizeChanged(object sender, SizeChangedEventArgs e)
{
ListView listView = sender as ListView;
GridView gView = listView.View as GridView;
var workingWidth = listView.ActualWidth - SystemParameters.VerticalScrollBarWidth; // take into account vertical scrollbar
- var col1 = 0.3;
- var col2 = 0.7;
+ var col1 = 0.2;
+ var col2 = 0.6;
+ var col3 = 0.2;
if (workingWidth <= 0)
{
@@ -31,6 +33,22 @@ private void ListView_SizeChanged(object sender, SizeChangedEventArgs e)
gView.Columns[0].Width = workingWidth * col1;
gView.Columns[1].Width = workingWidth * col2;
+ gView.Columns[2].Width = workingWidth * col3;
+ }
+
+ public void OnEditCommandKeywordClick(object sender, RoutedEventArgs e)
+ {
+ var commandKeyword = new CommandKeywordSettingWindow(_context, _settings.SelectedCommand);
+ commandKeyword.ShowDialog();
+ }
+
+ private void MouseDoubleClickItem(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ if (((FrameworkElement)e.OriginalSource).DataContext is Command && _settings.SelectedCommand != null)
+ {
+ var commandKeyword = new CommandKeywordSettingWindow(_context, _settings.SelectedCommand);
+ commandKeyword.ShowDialog();
+ }
}
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs b/Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs
index 38619cbbc2c..e67b4e5c5c8 100644
--- a/Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs
+++ b/Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs
@@ -2,7 +2,7 @@
using System.Linq;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.Core.Resource;
-using Flow.Launcher.Infrastructure.UserSettings;
+using FLSettings = Flow.Launcher.Infrastructure.UserSettings.Settings;
namespace Flow.Launcher.Plugin.Sys
{
@@ -10,7 +10,7 @@ public class ThemeSelector
{
public const string Keyword = "fltheme";
- private readonly Settings _settings;
+ private readonly FLSettings _settings;
private readonly Theme _theme;
private readonly PluginInitContext _context;
@@ -43,7 +43,7 @@ public ThemeSelector(PluginInitContext context)
{
_context = context;
_theme = Ioc.Default.GetRequiredService();
- _settings = Ioc.Default.GetRequiredService();
+ _settings = Ioc.Default.GetRequiredService();
}
public List Query(Query query)
diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsViewModel.cs
index a2538893bc9..e07e30cb2b6 100644
--- a/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsViewModel.cs
+++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsViewModel.cs
@@ -1,21 +1,12 @@
-using Flow.Launcher.Infrastructure.Storage;
-
-namespace Flow.Launcher.Plugin.WebSearch
+namespace Flow.Launcher.Plugin.WebSearch
{
public class SettingsViewModel
{
- private readonly PluginJsonStorage _storage;
-
public SettingsViewModel(Settings settings)
{
Settings = settings;
}
public Settings Settings { get; }
-
- public void Save()
- {
- _storage.Save();
- }
}
-}
\ No newline at end of file
+}