Merge branch 'dev' into avalonia

This commit is contained in:
Kevin Zhang 2024-01-21 10:53:10 -06:00 committed by GitHub
commit ce6321cf8b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 60 additions and 8 deletions

View file

@ -54,6 +54,11 @@ namespace Flow.Launcher.Plugin.Explorer
contextMenus.Add(CreateOpenContainingFolderResult(record)); contextMenus.Add(CreateOpenContainingFolderResult(record));
if (record.Type == ResultType.File)
{
contextMenus.Add(CreateOpenWithMenu(record));
}
if (record.WindowsIndexed) if (record.WindowsIndexed)
{ {
contextMenus.Add(CreateOpenWindowsIndexingOptions()); contextMenus.Add(CreateOpenWindowsIndexingOptions());
@ -434,6 +439,22 @@ namespace Flow.Launcher.Plugin.Explorer
}; };
} }
private Result CreateOpenWithMenu(SearchResult record)
{
return new Result
{
Title = Context.API.GetTranslation("plugin_explorer_openwith"),
SubTitle = Context.API.GetTranslation("plugin_explorer_openwith_subtitle"),
Action = _ =>
{
Process.Start("rundll32.exe", $"{Path.Combine(Environment.SystemDirectory, "shell32.dll")},OpenAs_RunDLL {record.FullPath}");
return true;
},
IcoPath = Constants.ShowContextMenuImagePath,
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue7ac"),
};
}
private void LogException(string message, Exception e) private void LogException(string message, Exception e)
{ {
Log.Exception($"|Flow.Launcher.Plugin.Folder.ContextMenu|{message}", e); Log.Exception($"|Flow.Launcher.Plugin.Folder.ContextMenu|{message}", e);

View file

@ -102,7 +102,9 @@
<system:String x:Key="plugin_explorer_remove_from_quickaccess_title">Remove from Quick Access</system:String> <system:String x:Key="plugin_explorer_remove_from_quickaccess_title">Remove from Quick Access</system:String>
<system:String x:Key="plugin_explorer_remove_from_quickaccess_subtitle">Remove current item from Quick Access</system:String> <system:String x:Key="plugin_explorer_remove_from_quickaccess_subtitle">Remove current item from Quick Access</system:String>
<system:String x:Key="plugin_explorer_show_contextmenu_title">Show Windows Context Menu</system:String> <system:String x:Key="plugin_explorer_show_contextmenu_title">Show Windows Context Menu</system:String>
<system:String x:Key="plugin_explorer_openwith">Open With</system:String>
<system:String x:Key="plugin_explorer_openwith_subtitle">Select a program to open with</system:String>
<!-- Special Results--> <!-- Special Results-->
<system:String x:Key="plugin_explorer_diskfreespace">{0} free of {1}</system:String> <system:String x:Key="plugin_explorer_diskfreespace">{0} free of {1}</system:String>
<system:String x:Key="plugin_explorer_openresultfolder">Open in Default File Manager</system:String> <system:String x:Key="plugin_explorer_openresultfolder">Open in Default File Manager</system:String>

View file

@ -3,6 +3,8 @@
xmlns:system="clr-namespace:System;assembly=mscorlib"> xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="flowlauncher_plugin_cmd_relace_winr">Replace Win+R</system:String> <system:String x:Key="flowlauncher_plugin_cmd_relace_winr">Replace Win+R</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_close_cmd_after_press">Close Command Prompt after pressing any key</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_press_any_key_to_close">Press any key to close this window...</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_leave_cmd_open">Do not close Command Prompt after command execution</system:String> <system:String x:Key="flowlauncher_plugin_cmd_leave_cmd_open">Do not close Command Prompt after command execution</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_always_run_as_administrator">Always run as administrator</system:String> <system:String x:Key="flowlauncher_plugin_cmd_always_run_as_administrator">Always run as administrator</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_run_as_different_user">Run as different user</system:String> <system:String x:Key="flowlauncher_plugin_cmd_run_as_different_user">Run as different user</system:String>

View file

@ -203,7 +203,7 @@ namespace Flow.Launcher.Plugin.Shell
case Shell.Cmd: case Shell.Cmd:
{ {
info.FileName = "cmd.exe"; info.FileName = "cmd.exe";
info.Arguments = $"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command}"; info.Arguments = $"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command} {(_settings.CloseShellAfterPress ? $"&& echo {context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")} && pause > nul /c" : "")}";
//// Use info.Arguments instead of info.ArgumentList to enable users better control over the arguments they are writing. //// Use info.Arguments instead of info.ArgumentList to enable users better control over the arguments they are writing.
//// Previous code using ArgumentList, commands needed to be separated correctly: //// Previous code using ArgumentList, commands needed to be separated correctly:
@ -232,7 +232,7 @@ namespace Flow.Launcher.Plugin.Shell
else else
{ {
info.ArgumentList.Add("-Command"); info.ArgumentList.Add("-Command");
info.ArgumentList.Add(command); info.ArgumentList.Add($"{command}; {(_settings.CloseShellAfterPress ? $"Write-Host '{context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")}'; [System.Console]::ReadKey(); exit" : "")}");
} }
break; break;
} }
@ -245,7 +245,7 @@ namespace Flow.Launcher.Plugin.Shell
info.ArgumentList.Add("-NoExit"); info.ArgumentList.Add("-NoExit");
} }
info.ArgumentList.Add("-Command"); info.ArgumentList.Add("-Command");
info.ArgumentList.Add(command); info.ArgumentList.Add($"{command}; {(_settings.CloseShellAfterPress ? $"Write-Host '{context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")}'; [System.Console]::ReadKey(); exit" : "")}");
break; break;
} }

View file

@ -7,6 +7,8 @@ namespace Flow.Launcher.Plugin.Shell
public Shell Shell { get; set; } = Shell.Cmd; public Shell Shell { get; set; } = Shell.Cmd;
public bool ReplaceWinR { get; set; } = false; public bool ReplaceWinR { get; set; } = false;
public bool CloseShellAfterPress { get; set; } = false;
public bool LeaveShellOpen { get; set; } public bool LeaveShellOpen { get; set; }

View file

@ -15,6 +15,7 @@
<RowDefinition /> <RowDefinition />
<RowDefinition /> <RowDefinition />
<RowDefinition /> <RowDefinition />
<RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<CheckBox <CheckBox
x:Name="ReplaceWinR" x:Name="ReplaceWinR"
@ -23,20 +24,26 @@
HorizontalAlignment="Left" HorizontalAlignment="Left"
Content="{DynamicResource flowlauncher_plugin_cmd_relace_winr}" /> Content="{DynamicResource flowlauncher_plugin_cmd_relace_winr}" />
<CheckBox <CheckBox
x:Name="LeaveShellOpen" x:Name="CloseShellAfterPress"
Grid.Row="1" Grid.Row="1"
Margin="10,5,5,5" Margin="10,5,5,5"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Content="{DynamicResource flowlauncher_plugin_cmd_close_cmd_after_press}" />
<CheckBox
x:Name="LeaveShellOpen"
Grid.Row="2"
Margin="10,5,5,5"
HorizontalAlignment="Left"
Content="{DynamicResource flowlauncher_plugin_cmd_leave_cmd_open}" /> Content="{DynamicResource flowlauncher_plugin_cmd_leave_cmd_open}" />
<CheckBox <CheckBox
x:Name="AlwaysRunAsAdministrator" x:Name="AlwaysRunAsAdministrator"
Grid.Row="2" Grid.Row="3"
Margin="10,5,5,5" Margin="10,5,5,5"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Content="{DynamicResource flowlauncher_plugin_cmd_always_run_as_administrator}" /> Content="{DynamicResource flowlauncher_plugin_cmd_always_run_as_administrator}" />
<ComboBox <ComboBox
x:Name="ShellComboBox" x:Name="ShellComboBox"
Grid.Row="3" Grid.Row="4"
Margin="10,5,5,5" Margin="10,5,5,5"
HorizontalAlignment="Left"> HorizontalAlignment="Left">
<ComboBoxItem>CMD</ComboBoxItem> <ComboBoxItem>CMD</ComboBoxItem>
@ -44,7 +51,7 @@
<ComboBoxItem>Pwsh</ComboBoxItem> <ComboBoxItem>Pwsh</ComboBoxItem>
<ComboBoxItem>RunCommand</ComboBoxItem> <ComboBoxItem>RunCommand</ComboBoxItem>
</ComboBox> </ComboBox>
<StackPanel Grid.Row="4" Orientation="Horizontal"> <StackPanel Grid.Row="5" Orientation="Horizontal">
<CheckBox <CheckBox
x:Name="ShowOnlyMostUsedCMDs" x:Name="ShowOnlyMostUsedCMDs"
Margin="10,5,5,5" Margin="10,5,5,5"

View file

@ -17,6 +17,8 @@ namespace Flow.Launcher.Plugin.Shell
private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re) private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re)
{ {
ReplaceWinR.IsChecked = _settings.ReplaceWinR; ReplaceWinR.IsChecked = _settings.ReplaceWinR;
CloseShellAfterPress.IsChecked = _settings.CloseShellAfterPress;
LeaveShellOpen.IsChecked = _settings.LeaveShellOpen; LeaveShellOpen.IsChecked = _settings.LeaveShellOpen;
@ -38,14 +40,30 @@ namespace Flow.Launcher.Plugin.Shell
_settings.ShowOnlyMostUsedCMDsNumber = (int)ShowOnlyMostUsedCMDsNumber.SelectedItem; _settings.ShowOnlyMostUsedCMDsNumber = (int)ShowOnlyMostUsedCMDsNumber.SelectedItem;
} }
CloseShellAfterPress.Checked += (o, e) =>
{
_settings.CloseShellAfterPress = true;
LeaveShellOpen.IsChecked = false;
LeaveShellOpen.IsEnabled = false;
};
CloseShellAfterPress.Unchecked += (o, e) =>
{
_settings.CloseShellAfterPress = false;
LeaveShellOpen.IsEnabled = true;
};
LeaveShellOpen.Checked += (o, e) => LeaveShellOpen.Checked += (o, e) =>
{ {
_settings.LeaveShellOpen = true; _settings.LeaveShellOpen = true;
CloseShellAfterPress.IsChecked = false;
CloseShellAfterPress.IsEnabled = false;
}; };
LeaveShellOpen.Unchecked += (o, e) => LeaveShellOpen.Unchecked += (o, e) =>
{ {
_settings.LeaveShellOpen = false; _settings.LeaveShellOpen = false;
CloseShellAfterPress.IsEnabled = true;
}; };
AlwaysRunAsAdministrator.Checked += (o, e) => AlwaysRunAsAdministrator.Checked += (o, e) =>