mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add Open with Shell for folder result
This commit is contained in:
parent
6a5509bc80
commit
4b6b10af02
5 changed files with 88 additions and 4 deletions
|
|
@ -41,8 +41,10 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
contextMenus.Add(CreateOpenWithEditorResult(record));
|
||||
|
||||
if (record.Type == ResultType.Folder && record.WindowsIndexed)
|
||||
{
|
||||
contextMenus.Add(CreateAddToIndexSearchExclusionListResult(record));
|
||||
|
||||
contextMenus.Add(CreateOpenWithShellResult(record));
|
||||
}
|
||||
contextMenus.Add(CreateOpenContainingFolderResult(record));
|
||||
|
||||
contextMenus.Add(CreateOpenWindowsIndexingOptions());
|
||||
|
|
@ -246,12 +248,13 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Result CreateOpenWithEditorResult(SearchResult record)
|
||||
{
|
||||
string editorPath = Settings.EditorPath;
|
||||
|
||||
var name = Context.API.GetTranslation("plugin_explorer_openwitheditor")
|
||||
+ " " + Path.GetFileNameWithoutExtension(editorPath);
|
||||
var name = $"{Context.API.GetTranslation("plugin_explorer_openwitheditor")} {Path.GetFileNameWithoutExtension(editorPath)}";
|
||||
|
||||
return new Result
|
||||
{
|
||||
|
|
@ -274,6 +277,38 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
IcoPath = Constants.FileImagePath
|
||||
};
|
||||
}
|
||||
|
||||
private Result CreateOpenWithShellResult(SearchResult record)
|
||||
{
|
||||
string shellPath = Settings.ShellPath;
|
||||
|
||||
var name = $"{Context.API.GetTranslation("plugin_explorer_openwithshell")} {Path.GetFileNameWithoutExtension(shellPath)}";
|
||||
|
||||
return new Result
|
||||
{
|
||||
Title = name,
|
||||
Action = _ =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo()
|
||||
{
|
||||
FileName = shellPath,
|
||||
WorkingDirectory = record.FullPath
|
||||
});
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var message = $"Failed to open editor for file at {record.FullPath} with Shell {Path.GetFileNameWithoutExtension(shellPath)} at {shellPath}";
|
||||
LogException(message, e);
|
||||
Context.API.ShowMsgError(message);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
IcoPath = Constants.FileImagePath
|
||||
};
|
||||
}
|
||||
|
||||
private Result CreateAddToIndexSearchExclusionListResult(SearchResult record)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
<system:String x:Key="plugin_explorer_everything_sort_option">Sort Option:</system:String>
|
||||
<system:String x:Key="plugin_explorer_launch_hidden">Launch Hidden</system:String>
|
||||
<system:String x:Key="plugin_explorer_editor_path">Editor Path</system:String>
|
||||
<system:String x:Key="plugin_explorer_shell_path">Shell Path</system:String>
|
||||
<system:String x:Key="plugin_explorer_indexsearchexcludedpaths_header">Index Search Excluded Paths</system:String>
|
||||
<system:String x:Key="plugin_explorer_use_location_as_working_dir">Use search result's location as executable working directory</system:String>
|
||||
<system:String x:Key="plugin_explorer_usewindowsindexfordirectorysearch">Use Index Search For Path Search</system:String>
|
||||
|
|
@ -62,6 +63,7 @@
|
|||
<system:String x:Key="plugin_explorer_opencontainingfolder">Open containing folder</system:String>
|
||||
<system:String x:Key="plugin_explorer_opencontainingfolder_subtitle">Opens the location that contains the file or folder</system:String>
|
||||
<system:String x:Key="plugin_explorer_openwitheditor">Open With Editor:</system:String>
|
||||
<system:String x:Key="plugin_explorer_openwithshell">Open With Shell:</system:String>
|
||||
<system:String x:Key="plugin_explorer_excludefromindexsearch">Exclude current and sub-directories from Index Search</system:String>
|
||||
<system:String x:Key="plugin_explorer_excludedfromindexsearch_msg">Excluded from Index Search</system:String>
|
||||
<system:String x:Key="plugin_explorer_openindexingoptions">Open Windows Indexing Options</system:String>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
|
||||
public string EditorPath { get; set; } = "";
|
||||
|
||||
public string ShellPath { get; set; } = "cmd";
|
||||
|
||||
|
||||
public bool UseLocationAsWorkingDir { get; set; } = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -314,7 +314,10 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
|
|||
get => Settings.UseWindowsIndexForDirectorySearch;
|
||||
set => Settings.UseWindowsIndexForDirectorySearch = value;
|
||||
}
|
||||
public ICommand OpenEditorPath => new RelayCommand(_ =>
|
||||
|
||||
private ICommand _openEditorPathCommand;
|
||||
|
||||
public ICommand OpenEditorPath => _openEditorPathCommand ??= new RelayCommand(_ =>
|
||||
{
|
||||
var path = PromptUserSelectPath(ResultType.File, Settings.EditorPath != null ? Path.GetDirectoryName(Settings.EditorPath) : null);
|
||||
if (path is null)
|
||||
|
|
@ -323,6 +326,18 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
|
|||
EditorPath = path;
|
||||
});
|
||||
|
||||
private ICommand _openShellPathCommand;
|
||||
|
||||
public ICommand OpenShellPath => _openShellPathCommand ??= new RelayCommand(_ =>
|
||||
{
|
||||
var path = PromptUserSelectPath(ResultType.File, Settings.EditorPath != null ? Path.GetDirectoryName(Settings.EditorPath) : null);
|
||||
if (path is null)
|
||||
return;
|
||||
|
||||
ShellPath = path;
|
||||
});
|
||||
|
||||
|
||||
public string EditorPath
|
||||
{
|
||||
get => Settings.EditorPath;
|
||||
|
|
@ -333,6 +348,16 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public string ShellPath
|
||||
{
|
||||
get => Settings.ShellPath;
|
||||
set
|
||||
{
|
||||
Settings.ShellPath = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Everything FastSortWarning
|
||||
|
||||
|
|
|
|||
|
|
@ -109,6 +109,26 @@
|
|||
Command="{Binding OpenEditorPath}"
|
||||
Content="..." />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="10,6,6,6"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Text="{DynamicResource plugin_explorer_shell_path}" />
|
||||
<TextBox
|
||||
Margin="15"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
TextWrapping="NoWrap"
|
||||
MaxWidth="250"
|
||||
Text="{Binding ShellPath}" />
|
||||
<Button
|
||||
MinWidth="50"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="15"
|
||||
Command="{Binding OpenShellPath}"
|
||||
Content="..." />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Index Search Engine" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue