diff --git a/Flow.Launcher.Plugin/ActionContext.cs b/Flow.Launcher.Plugin/ActionContext.cs
index b9e499d2b..d898972da 100644
--- a/Flow.Launcher.Plugin/ActionContext.cs
+++ b/Flow.Launcher.Plugin/ActionContext.cs
@@ -1,4 +1,6 @@
-namespace Flow.Launcher.Plugin
+using System.Windows.Input;
+
+namespace Flow.Launcher.Plugin
{
public class ActionContext
{
@@ -11,5 +13,13 @@
public bool ShiftPressed { get; set; }
public bool AltPressed { get; set; }
public bool WinPressed { get; set; }
+
+ public ModifierKeys ToModifierKeys()
+ {
+ return (CtrlPressed ? ModifierKeys.Control : ModifierKeys.None) |
+ (ShiftPressed ? ModifierKeys.Shift : ModifierKeys.None) |
+ (AltPressed ? ModifierKeys.Alt : ModifierKeys.None) |
+ (WinPressed ? ModifierKeys.Windows : ModifierKeys.None);
+ }
}
-}
\ No newline at end of file
+}
diff --git a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs
index 6b7f0c2d3..dd4dcc7a4 100644
--- a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs
+++ b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs
@@ -170,6 +170,36 @@ namespace Flow.Launcher.Plugin.SharedCommands
}
}
+ ///
+ /// Open a file with associated application
+ ///
+ /// File path
+ /// Working directory
+ /// Open as Administrator
+ public static void OpenFile(string filePath, string workingDir = "", bool asAdmin = false)
+ {
+ var psi = new ProcessStartInfo
+ {
+ FileName = filePath,
+ UseShellExecute = true,
+ WorkingDirectory = workingDir,
+ Verb = asAdmin ? "runas" : string.Empty
+ };
+ try
+ {
+ if (FileExists(filePath))
+ Process.Start(psi);
+ }
+ catch (Exception)
+ {
+#if DEBUG
+ throw;
+#else
+ MessageBox.Show(string.Format("Unable to open the path {0}, please check if it exists", filePath));
+#endif
+ }
+ }
+
///
/// This checks whether a given string is a directory path or network location string.
/// It does not check if location actually exists.
diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml
index ad1c002e6..103d523a7 100644
--- a/Flow.Launcher/Languages/en.xaml
+++ b/Flow.Launcher/Languages/en.xaml
@@ -348,8 +348,8 @@
Back / Context Menu
Item Navigation
Open Context Menu
- Open Containing Folder
- Run as Admin
+ Open A File/Folder's Containing Folder
+ Run as Admin / Open Folder in Default File Manager
Query History
Back to Result in Context Menu
Autocomplete
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
index 58fe31dd6..d5352ef1e 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
@@ -18,6 +18,8 @@
The warning message has been switched off. As an alternative for searching files and folders, would you like to install Everything plugin?{0}{0}Select 'Yes' to install Everything plugin, or 'No' to return
Explorer Alternative
Error occurred during search: {0}
+ Could not open folder
+ Could not open file
Delete
@@ -34,6 +36,7 @@
Shell Path
Index Search Excluded Paths
Use search result's location as the working directory of the executable
+ Hit Enter to open folder in Default File Manager
Use Index Search For Path Search
Indexing Options
Search:
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
index 7147c348e..83c173ac6 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
@@ -8,6 +8,7 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using Flow.Launcher.Plugin.Explorer.Search.Everything;
+using System.Windows.Input;
namespace Flow.Launcher.Plugin.Explorer.Search
{
@@ -79,7 +80,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
Action = c =>
{
// open folder
- if (c.SpecialKeyState.CtrlPressed || (!Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled))
+ if (c.SpecialKeyState.ToModifierKeys() == (ModifierKeys.Control | ModifierKeys.Shift))
{
try
{
@@ -88,13 +89,44 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}
catch (Exception ex)
{
- MessageBox.Show(ex.Message, "Could not start " + path);
+ MessageBox.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
+ return false;
+ }
+ }
+ // Open containing folder
+ if (c.SpecialKeyState.ToModifierKeys() == ModifierKeys.Control)
+ {
+ try
+ {
+ Context.API.OpenDirectory(Path.GetDirectoryName(path), path);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
return false;
}
}
- // or make this folder the current query
- Context.API.ChangeQuery(GetPathWithActionKeyword(path, ResultType.Folder, query.ActionKeyword));
+ // If path search is disabled just open it in file manager
+ if (Settings.DefaultOpenFolderInFileManager || (!Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled))
+ {
+ try
+ {
+ OpenFolder(path);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
+ return false;
+ }
+ }
+ else
+ {
+ // or make this folder the current query
+ Context.API.ChangeQuery(GetPathWithActionKeyword(path, ResultType.Folder, query.ActionKeyword));
+ }
return false;
},
@@ -222,22 +254,22 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{
try
{
- if (c.SpecialKeyState.CtrlPressed && c.SpecialKeyState.ShiftPressed)
+ if (c.SpecialKeyState.ToModifierKeys() == (ModifierKeys.Control | ModifierKeys.Shift))
{
- OpenFileAsAdmin(filePath);
+ OpenFile(filePath, Settings.UseLocationAsWorkingDir ? Path.GetDirectoryName(filePath) : string.Empty, true);
}
- else if (c.SpecialKeyState.CtrlPressed)
+ else if (c.SpecialKeyState.ToModifierKeys() == ModifierKeys.Control)
{
OpenFolder(filePath, filePath);
}
else
{
- OpenFile(filePath);
+ OpenFile(filePath, Settings.UseLocationAsWorkingDir ? Path.GetDirectoryName(filePath) : string.Empty);
}
}
catch (Exception ex)
{
- MessageBox.Show(ex.Message, "Could not start " + filePath);
+ MessageBox.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_openfile_error"));
}
return true;
@@ -256,38 +288,16 @@ namespace Flow.Launcher.Plugin.Explorer.Search
return MediaExtensions.Contains(extension.ToLowerInvariant());
}
- private static void OpenFile(string filePath)
+ private static void OpenFile(string filePath, string workingDir = "", bool asAdmin = false)
{
IncrementEverythingRunCounterIfNeeded(filePath);
- FilesFolders.OpenPath(filePath);
+ FilesFolders.OpenFile(filePath, workingDir, asAdmin);
}
private static void OpenFolder(string folderPath, string fileNameOrFilePath = null)
{
IncrementEverythingRunCounterIfNeeded(folderPath);
- Context.API.OpenDirectory(Path.GetDirectoryName(folderPath), fileNameOrFilePath);
- }
-
- private static void OpenFileAsAdmin(string filePath)
- {
- _ = Task.Run(() =>
- {
- try
- {
- IncrementEverythingRunCounterIfNeeded(filePath);
- Process.Start(new ProcessStartInfo
- {
- FileName = filePath,
- UseShellExecute = true,
- WorkingDirectory = Settings.UseLocationAsWorkingDir ? Path.GetDirectoryName(filePath) : string.Empty,
- Verb = "runas",
- });
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message, "Could not start " + filePath);
- }
- });
+ Context.API.OpenDirectory(folderPath, fileNameOrFilePath);
}
private static void IncrementEverythingRunCounterIfNeeded(string fileOrFolder)
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
index 339eaaaaa..4077e2fcc 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
@@ -32,6 +32,7 @@ namespace Flow.Launcher.Plugin.Explorer
public bool ShowWindowsContextMenu { get; set; } = true;
+ public bool DefaultOpenFolderInFileManager { get; set; } = false;
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
index 153a8eb7e..9beb43a48 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
@@ -168,6 +168,11 @@
HorizontalAlignment="Left"
Content="{DynamicResource plugin_explorer_use_location_as_working_dir}"
IsChecked="{Binding Settings.UseLocationAsWorkingDir}" />
+
@@ -348,17 +353,11 @@
Header="{DynamicResource plugin_explorer_everything_setting_header}"
Style="{DynamicResource ExplorerTabItem}">
-
-
-
-
+