mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use IPluginHotkey for program plugin
This commit is contained in:
parent
854f8082b1
commit
9f404aa92c
3 changed files with 55 additions and 17 deletions
|
|
@ -16,7 +16,7 @@ using Path = System.IO.Path;
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin.Program
|
namespace Flow.Launcher.Plugin.Program
|
||||||
{
|
{
|
||||||
public class Main : ISettingProvider, IAsyncPlugin, IPluginI18n, IContextMenu, IAsyncReloadable, IDisposable
|
public class Main : ISettingProvider, IAsyncPlugin, IPluginI18n, IContextMenu, IAsyncReloadable, IDisposable, IPluginHotkey
|
||||||
{
|
{
|
||||||
private static readonly string ClassName = nameof(Main);
|
private static readonly string ClassName = nameof(Main);
|
||||||
|
|
||||||
|
|
@ -459,5 +459,59 @@ namespace Flow.Launcher.Plugin.Program
|
||||||
{
|
{
|
||||||
Win32.Dispose();
|
Win32.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<BasePluginHotkey> GetPuginHotkeys()
|
||||||
|
{
|
||||||
|
return new List<BasePluginHotkey>
|
||||||
|
{
|
||||||
|
new SearchWindowPluginHotkey()
|
||||||
|
{
|
||||||
|
Id = 0,
|
||||||
|
Name = Context.API.GetTranslation("flowlauncher_plugin_program_open_containing_folder"),
|
||||||
|
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue838"),
|
||||||
|
DefaultHotkey = "Ctrl+Enter",
|
||||||
|
Editable = false,
|
||||||
|
Visible = true,
|
||||||
|
Action = (r) =>
|
||||||
|
{
|
||||||
|
if (r.ContextData is UWPPackage uwp)
|
||||||
|
{
|
||||||
|
Context.API.OpenDirectory(uwp.Location);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (r.ContextData is Win32 win32)
|
||||||
|
{
|
||||||
|
Context.API.OpenDirectory(win32.ParentDirectory, win32.FullPath);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// TODO: Do it after administrator mode PR
|
||||||
|
/*new SearchWindowPluginHotkey()
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Name = Context.API.GetTranslation("flowlauncher_plugin_program_run_as_administrator"),
|
||||||
|
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE7EF"),
|
||||||
|
DefaultHotkey = "Ctrl+Shift+Enter",
|
||||||
|
Editable = false,
|
||||||
|
Visible = true,
|
||||||
|
Action = (r) =>
|
||||||
|
{
|
||||||
|
if (r.ContextData is UWPPackage uwp)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (r.ContextData is Win32 win32)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},*/
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -442,14 +442,6 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
||||||
ContextData = this,
|
ContextData = this,
|
||||||
Action = e =>
|
Action = e =>
|
||||||
{
|
{
|
||||||
// Ctrl + Enter to open containing folder
|
|
||||||
bool openFolder = e.SpecialKeyState.ToModifierKeys() == ModifierKeys.Control;
|
|
||||||
if (openFolder)
|
|
||||||
{
|
|
||||||
Main.Context.API.OpenDirectory(Location);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ctrl + Shift + Enter to run elevated
|
// Ctrl + Shift + Enter to run elevated
|
||||||
bool elevated = e.SpecialKeyState.ToModifierKeys() == (ModifierKeys.Control | ModifierKeys.Shift);
|
bool elevated = e.SpecialKeyState.ToModifierKeys() == (ModifierKeys.Control | ModifierKeys.Shift);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,14 +185,6 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
||||||
TitleToolTip = $"{title}\n{ExecutablePath}",
|
TitleToolTip = $"{title}\n{ExecutablePath}",
|
||||||
Action = c =>
|
Action = c =>
|
||||||
{
|
{
|
||||||
// Ctrl + Enter to open containing folder
|
|
||||||
bool openFolder = c.SpecialKeyState.ToModifierKeys() == ModifierKeys.Control;
|
|
||||||
if (openFolder)
|
|
||||||
{
|
|
||||||
Main.Context.API.OpenDirectory(ParentDirectory, FullPath);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ctrl + Shift + Enter to run as admin
|
// Ctrl + Shift + Enter to run as admin
|
||||||
bool runAsAdmin = c.SpecialKeyState.ToModifierKeys() == (ModifierKeys.Control | ModifierKeys.Shift);
|
bool runAsAdmin = c.SpecialKeyState.ToModifierKeys() == (ModifierKeys.Control | ModifierKeys.Shift);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue