[PTRun]Add option to tab through results only (#22965)

* Added option to tab through results directly instead of context menu options

With reference to #22964

* Move setting to search results group
This commit is contained in:
Aditya Goturu 2023-01-10 19:34:50 +05:30 committed by GitHub
parent 9baaaefc5f
commit 25e9241d42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 76 additions and 8 deletions

View File

@ -150,6 +150,11 @@ namespace PowerLauncher
_settings.ClearInputOnLaunch = overloadSettings.Properties.ClearInputOnLaunch; _settings.ClearInputOnLaunch = overloadSettings.Properties.ClearInputOnLaunch;
} }
if (_settings.TabSelectsContextButtons != overloadSettings.Properties.TabSelectsContextButtons)
{
_settings.TabSelectsContextButtons = overloadSettings.Properties.TabSelectsContextButtons;
}
if (_settings.Theme != overloadSettings.Properties.Theme) if (_settings.Theme != overloadSettings.Properties.Theme)
{ {
_settings.Theme = overloadSettings.Properties.Theme; _settings.Theme = overloadSettings.Properties.Theme;

View File

@ -186,21 +186,45 @@ namespace PowerLauncher.ViewModel
public void SelectNextTabItem() public void SelectNextTabItem()
{ {
// Do nothing if there is no selected item or we've selected the next context button if (_settings.TabSelectsContextButtons)
if (!SelectedItem?.SelectNextContextButton() ?? true)
{ {
SelectNextResult(); // Do nothing if there is no selected item or we've selected the next context button
if (!SelectedItem?.SelectNextContextButton() ?? true)
{
SelectNextResult();
}
}
else
{
// Do nothing if there is no selected item
if (SelectedItem != null)
{
SelectNextResult();
}
} }
} }
public void SelectPrevTabItem() public void SelectPrevTabItem()
{ {
// Do nothing if there is no selected item or we've selected the previous context button if (_settings.TabSelectsContextButtons)
if (!SelectedItem?.SelectPrevContextButton() ?? true)
{ {
// Tabbing backwards should highlight the last item of the previous row // Do nothing if there is no selected item or we've selected the previous context button
SelectPrevResult(); if (!SelectedItem?.SelectPrevContextButton() ?? true)
SelectedItem?.SelectLastContextButton(); {
// Tabbing backwards should highlight the last item of the previous row
SelectPrevResult();
SelectedItem?.SelectLastContextButton();
}
}
else
{
// Do nothing if there is no selected item
if (SelectedItem != null)
{
// Tabbing backwards should highlight the last item of the previous row
SelectPrevResult();
SelectedItem?.SelectLastContextButton();
}
} }
} }

View File

@ -315,6 +315,8 @@ namespace Wox.Infrastructure.UserSettings
public bool ClearInputOnLaunch { get; set; } public bool ClearInputOnLaunch { get; set; }
public bool TabSelectsContextButtons { get; set; }
public bool RememberLastLaunchLocation { get; set; } public bool RememberLastLaunchLocation { get; set; }
public bool IgnoreHotkeysOnFullscreen { get; set; } public bool IgnoreHotkeysOnFullscreen { get; set; }

View File

@ -42,6 +42,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[JsonPropertyName("clear_input_on_launch")] [JsonPropertyName("clear_input_on_launch")]
public bool ClearInputOnLaunch { get; set; } public bool ClearInputOnLaunch { get; set; }
[JsonPropertyName("tab_selects_context_buttons")]
public bool TabSelectsContextButtons { get; set; }
[JsonPropertyName("theme")] [JsonPropertyName("theme")]
public Theme Theme { get; set; } public Theme Theme { get; set; }
@ -79,6 +82,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
SearchTypePreference = "application_name"; SearchTypePreference = "application_name";
IgnoreHotkeysInFullscreen = false; IgnoreHotkeysInFullscreen = false;
ClearInputOnLaunch = false; ClearInputOnLaunch = false;
TabSelectsContextButtons = true;
MaximumNumberOfResults = 4; MaximumNumberOfResults = 4;
Theme = Theme.System; Theme = Theme.System;
Position = StartupPosition.Cursor; Position = StartupPosition.Cursor;

View File

@ -71,6 +71,7 @@ namespace ViewModelTests
// Verify that the old settings persisted // Verify that the old settings persisted
Assert.AreEqual(originalGeneralSettings.Enabled.PowerLauncher, viewModel.EnablePowerLauncher); Assert.AreEqual(originalGeneralSettings.Enabled.PowerLauncher, viewModel.EnablePowerLauncher);
Assert.AreEqual(originalSettings.Properties.ClearInputOnLaunch, viewModel.ClearInputOnLaunch); Assert.AreEqual(originalSettings.Properties.ClearInputOnLaunch, viewModel.ClearInputOnLaunch);
Assert.AreEqual(originalSettings.Properties.TabSelectsContextButtons, viewModel.TabSelectsContextButtons);
Assert.AreEqual(originalSettings.Properties.CopyPathLocation.ToString(), viewModel.CopyPathLocation.ToString()); Assert.AreEqual(originalSettings.Properties.CopyPathLocation.ToString(), viewModel.CopyPathLocation.ToString());
Assert.AreEqual(originalSettings.Properties.IgnoreHotkeysInFullscreen, viewModel.IgnoreHotkeysInFullScreen); Assert.AreEqual(originalSettings.Properties.IgnoreHotkeysInFullscreen, viewModel.IgnoreHotkeysInFullScreen);
Assert.AreEqual(originalSettings.Properties.MaximumNumberOfResults, viewModel.MaximumNumberOfResults); Assert.AreEqual(originalSettings.Properties.MaximumNumberOfResults, viewModel.MaximumNumberOfResults);

View File

@ -493,6 +493,12 @@
<data name="PowerLauncher_ClearInputOnLaunch.Content" xml:space="preserve"> <data name="PowerLauncher_ClearInputOnLaunch.Content" xml:space="preserve">
<value>Clear the previous query on launch</value> <value>Clear the previous query on launch</value>
</data> </data>
<data name="PowerLauncher_TabSelectsContextButtons.Header" xml:space="preserve">
<value>Tab through context buttons</value>
</data>
<data name="PowerLauncher_TabSelectsContextButtons.Description" xml:space="preserve">
<value>Pressing tab will first select through the available context buttons of the current selection before moving onto the next result</value>
</data>
<data name="PowerLauncher_SearchQueryResultsWithDelay.Header" xml:space="preserve"> <data name="PowerLauncher_SearchQueryResultsWithDelay.Header" xml:space="preserve">
<value>Input Smoothing</value> <value>Input Smoothing</value>
<comment>This is about adding a delay to wait for more input before executing a search</comment> <comment>This is about adding a delay to wait for more input before executing a search</comment>

View File

@ -533,6 +533,23 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
} }
} }
public bool TabSelectsContextButtons
{
get
{
return settings.Properties.TabSelectsContextButtons;
}
set
{
if (settings.Properties.TabSelectsContextButtons != value)
{
settings.Properties.TabSelectsContextButtons = value;
UpdateSettings();
}
}
}
private ObservableCollection<PowerLauncherPluginViewModel> _plugins; private ObservableCollection<PowerLauncherPluginViewModel> _plugins;
public ObservableCollection<PowerLauncherPluginViewModel> Plugins public ObservableCollection<PowerLauncherPluginViewModel> Plugins

View File

@ -176,6 +176,15 @@
</labs:SettingsCard> </labs:SettingsCard>
</labs:SettingsExpander.Items> </labs:SettingsExpander.Items>
</labs:SettingsExpander> </labs:SettingsExpander>
<labs:SettingsCard
x:Uid="PowerLauncher_TabSelectsContextButtons"
HeaderIcon="{ui:FontIcon FontFamily={StaticResource SymbolThemeFontFamily}, Glyph=&#xE7FD;}">
<ToggleSwitch
x:Uid="ToggleSwitch"
IsOn="{x:Bind ViewModel.TabSelectsContextButtons, Mode=TwoWay}" />
</labs:SettingsCard>
</controls:SettingsGroup> </controls:SettingsGroup>
<!--<ComboBox x:Uid="PowerLauncher_SearchResultPreference" <!--<ComboBox x:Uid="PowerLauncher_SearchResultPreference"