mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Store plugin hotkey info
This commit is contained in:
parent
089c0fd892
commit
2a52c28bdd
2 changed files with 47 additions and 13 deletions
|
|
@ -46,6 +46,7 @@ namespace Flow.Launcher.Core.Plugin
|
||||||
private static List<PluginMetadata> _metadatas;
|
private static List<PluginMetadata> _metadatas;
|
||||||
private static readonly List<string> _modifiedPlugins = new();
|
private static readonly List<string> _modifiedPlugins = new();
|
||||||
|
|
||||||
|
private static readonly Dictionary<PluginPair, List<BasePluginHotkey>> _pluginHotkeyInfo = new();
|
||||||
private static readonly Dictionary<HotkeyModel, List<(PluginMetadata, SearchWindowPluginHotkey)>> _windowPluginHotkeys = new();
|
private static readonly Dictionary<HotkeyModel, List<(PluginMetadata, SearchWindowPluginHotkey)>> _windowPluginHotkeys = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -263,9 +264,9 @@ namespace Flow.Launcher.Core.Plugin
|
||||||
|
|
||||||
await Task.WhenAll(InitTasks);
|
await Task.WhenAll(InitTasks);
|
||||||
|
|
||||||
var pluginHotkeyInfo = GetPluginHotkeyInfo();
|
InitializePluginHotkeyInfo();
|
||||||
Settings.UpdatePluginHotkeyInfo(pluginHotkeyInfo);
|
Settings.UpdatePluginHotkeyInfo(GetPluginHotkeyInfo());
|
||||||
InitializeWindowPluginHotkeys(pluginHotkeyInfo);
|
InitializeWindowPluginHotkeys();
|
||||||
|
|
||||||
foreach (var plugin in AllPlugins)
|
foreach (var plugin in AllPlugins)
|
||||||
{
|
{
|
||||||
|
|
@ -478,14 +479,7 @@ namespace Flow.Launcher.Core.Plugin
|
||||||
|
|
||||||
public static Dictionary<PluginPair, List<BasePluginHotkey>> GetPluginHotkeyInfo()
|
public static Dictionary<PluginPair, List<BasePluginHotkey>> GetPluginHotkeyInfo()
|
||||||
{
|
{
|
||||||
var hotkeyPluginInfos = new Dictionary<PluginPair, List<BasePluginHotkey>>();
|
return _pluginHotkeyInfo;
|
||||||
foreach (var plugin in _hotkeyPlugins)
|
|
||||||
{
|
|
||||||
var hotkeys = ((IPluginHotkey)plugin.Plugin).GetPuginHotkeys();
|
|
||||||
hotkeyPluginInfos.Add(plugin, hotkeys);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hotkeyPluginInfos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<HotkeyModel, List<(PluginMetadata Metadata, SearchWindowPluginHotkey SearchWindowPluginHotkey)>> GetWindowPluginHotkeys()
|
public static Dictionary<HotkeyModel, List<(PluginMetadata Metadata, SearchWindowPluginHotkey SearchWindowPluginHotkey)>> GetWindowPluginHotkeys()
|
||||||
|
|
@ -493,9 +487,45 @@ namespace Flow.Launcher.Core.Plugin
|
||||||
return _windowPluginHotkeys;
|
return _windowPluginHotkeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void InitializeWindowPluginHotkeys(Dictionary<PluginPair, List<BasePluginHotkey>> pluginHotkeyInfo)
|
public static void UpdatePluginHotkeyInfoTranslations()
|
||||||
{
|
{
|
||||||
foreach (var info in pluginHotkeyInfo)
|
foreach (var plugin in _hotkeyPlugins)
|
||||||
|
{
|
||||||
|
var newHotkeys = ((IPluginHotkey)plugin.Plugin).GetPuginHotkeys();
|
||||||
|
if (_pluginHotkeyInfo.TryGetValue(plugin, out var oldHotkeys))
|
||||||
|
{
|
||||||
|
foreach (var newHotkey in newHotkeys)
|
||||||
|
{
|
||||||
|
if (oldHotkeys.FirstOrDefault(h => h.Id == newHotkey.Id) is BasePluginHotkey pluginHotkey)
|
||||||
|
{
|
||||||
|
pluginHotkey.Name = newHotkey.Name;
|
||||||
|
pluginHotkey.Description = newHotkey.Description;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oldHotkeys.Add(newHotkey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_pluginHotkeyInfo.Add(plugin, newHotkeys);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void InitializePluginHotkeyInfo()
|
||||||
|
{
|
||||||
|
foreach (var plugin in _hotkeyPlugins)
|
||||||
|
{
|
||||||
|
var hotkeys = ((IPluginHotkey)plugin.Plugin).GetPuginHotkeys();
|
||||||
|
_pluginHotkeyInfo.Add(plugin, hotkeys);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void InitializeWindowPluginHotkeys()
|
||||||
|
{
|
||||||
|
foreach (var info in GetPluginHotkeyInfo())
|
||||||
{
|
{
|
||||||
var pluginPair = info.Key;
|
var pluginPair = info.Key;
|
||||||
var hotkeyInfo = info.Value;
|
var hotkeyInfo = info.Value;
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,7 @@ namespace Flow.Launcher.Core.Resource
|
||||||
|
|
||||||
private void UpdatePluginMetadataTranslations()
|
private void UpdatePluginMetadataTranslations()
|
||||||
{
|
{
|
||||||
|
// Update plugin metadata name & description
|
||||||
foreach (var p in PluginManager.GetTranslationPlugins())
|
foreach (var p in PluginManager.GetTranslationPlugins())
|
||||||
{
|
{
|
||||||
if (p.Plugin is not IPluginI18n pluginI18N) return;
|
if (p.Plugin is not IPluginI18n pluginI18N) return;
|
||||||
|
|
@ -292,6 +293,9 @@ namespace Flow.Launcher.Core.Resource
|
||||||
API.LogException(ClassName, $"Failed for <{p.Metadata.Name}>", e);
|
API.LogException(ClassName, $"Failed for <{p.Metadata.Name}>", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update plugin hotkey name & description
|
||||||
|
PluginManager.UpdatePluginHotkeyInfoTranslations();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string LanguageFile(string folder, string language)
|
private static string LanguageFile(string folder, string language)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue