Skip to content

Commit d8965c5

Browse files
Merge pull request #2042 from VictoriousRaptor/ProgramOpenFolderHotkey
Add open parent folder hotkey for program plugin
2 parents 274052e + be35ff0 commit d8965c5

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@
348348
<system:String x:Key="HotkeyUpDownDesc">Back / Context Menu</system:String>
349349
<system:String x:Key="HotkeyLeftRightDesc">Item Navigation</system:String>
350350
<system:String x:Key="HotkeyShiftEnterDesc">Open Context Menu</system:String>
351-
<system:String x:Key="HotkeyCtrlEnterDesc">Open A File/Folder's Containing Folder</system:String>
351+
<system:String x:Key="HotkeyCtrlEnterDesc">Open Containing Folder</system:String>
352352
<system:String x:Key="HotkeyCtrlShiftEnterDesc">Run as Admin / Open Folder in Default File Manager</system:String>
353353
<system:String x:Key="HotkeyCtrlHDesc">Query History</system:String>
354354
<system:String x:Key="HotkeyESCDesc">Back to Result in Context Menu</system:String>

Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.Threading.Channels;
1515
using System.Xml;
1616
using Windows.ApplicationModel.Core;
17+
using System.Windows.Input;
1718

1819
namespace Flow.Launcher.Plugin.Program.Programs
1920
{
@@ -422,12 +423,16 @@ public Result Result(string query, IPublicAPI api)
422423
ContextData = this,
423424
Action = e =>
424425
{
425-
var elevated = (
426-
e.SpecialKeyState.CtrlPressed &&
427-
e.SpecialKeyState.ShiftPressed &&
428-
!e.SpecialKeyState.AltPressed &&
429-
!e.SpecialKeyState.WinPressed
430-
);
426+
// Ctrl + Enter to open containing folder
427+
bool openFolder = e.SpecialKeyState.ToModifierKeys() == ModifierKeys.Control;
428+
if (openFolder)
429+
{
430+
Main.Context.API.OpenDirectory(Location);
431+
return true;
432+
}
433+
434+
// Ctrl + Shift + Enter to run elevated
435+
bool elevated = e.SpecialKeyState.ToModifierKeys() == (ModifierKeys.Control | ModifierKeys.Shift);
431436

432437
bool shouldRunElevated = elevated && CanRunElevated;
433438
_ = Task.Run(() => Launch(shouldRunElevated)).ConfigureAwait(false);
@@ -459,7 +464,8 @@ public List<Result> ContextMenus(IPublicAPI api)
459464

460465
return true;
461466
},
462-
IcoPath = "Images/folder.png"
467+
IcoPath = "Images/folder.png",
468+
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe838"),
463469
}
464470
};
465471

@@ -473,7 +479,8 @@ public List<Result> ContextMenus(IPublicAPI api)
473479
Task.Run(() => Launch(true)).ConfigureAwait(false);
474480
return true;
475481
},
476-
IcoPath = "Images/cmd.png"
482+
IcoPath = "Images/cmd.png",
483+
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe7ef")
477484
});
478485
}
479486

Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using System.Threading.Channels;
1717
using Flow.Launcher.Plugin.Program.Views.Models;
1818
using IniParser;
19+
using System.Windows.Input;
1920

2021
namespace Flow.Launcher.Plugin.Program.Programs
2122
{
@@ -169,12 +170,16 @@ public Result Result(string query, IPublicAPI api)
169170
ContextData = this,
170171
Action = c =>
171172
{
172-
var runAsAdmin = (
173-
c.SpecialKeyState.CtrlPressed &&
174-
c.SpecialKeyState.ShiftPressed &&
175-
!c.SpecialKeyState.AltPressed &&
176-
!c.SpecialKeyState.WinPressed
177-
);
173+
// Ctrl + Enter to open containing folder
174+
bool openFolder = c.SpecialKeyState.ToModifierKeys() == ModifierKeys.Control;
175+
if (openFolder)
176+
{
177+
Main.Context.API.OpenDirectory(ParentDirectory, FullPath);
178+
return true;
179+
}
180+
181+
// Ctrl + Shift + Enter to run as admin
182+
bool runAsAdmin = c.SpecialKeyState.ToModifierKeys() == (ModifierKeys.Control | ModifierKeys.Shift);
178183

179184
var info = new ProcessStartInfo
180185
{

0 commit comments

Comments
 (0)