[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;
}
if (_settings.TabSelectsContextButtons != overloadSettings.Properties.TabSelectsContextButtons)
{
_settings.TabSelectsContextButtons = overloadSettings.Properties.TabSelectsContextButtons;
}
if (_settings.Theme != overloadSettings.Properties.Theme)
{
_settings.Theme = overloadSettings.Properties.Theme;

View File

@ -185,6 +185,8 @@ namespace PowerLauncher.ViewModel
}
public void SelectNextTabItem()
{
if (_settings.TabSelectsContextButtons)
{
// Do nothing if there is no selected item or we've selected the next context button
if (!SelectedItem?.SelectNextContextButton() ?? true)
@ -192,8 +194,19 @@ namespace PowerLauncher.ViewModel
SelectNextResult();
}
}
else
{
// Do nothing if there is no selected item
if (SelectedItem != null)
{
SelectNextResult();
}
}
}
public void SelectPrevTabItem()
{
if (_settings.TabSelectsContextButtons)
{
// Do nothing if there is no selected item or we've selected the previous context button
if (!SelectedItem?.SelectPrevContextButton() ?? true)
@ -203,6 +216,17 @@ namespace PowerLauncher.ViewModel
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();
}
}
}
public void SelectNextContextMenuItem()
{

View File

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

View File

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

View File

@ -71,6 +71,7 @@ namespace ViewModelTests
// Verify that the old settings persisted
Assert.AreEqual(originalGeneralSettings.Enabled.PowerLauncher, viewModel.EnablePowerLauncher);
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.IgnoreHotkeysInFullscreen, viewModel.IgnoreHotkeysInFullScreen);
Assert.AreEqual(originalSettings.Properties.MaximumNumberOfResults, viewModel.MaximumNumberOfResults);

View File

@ -493,6 +493,12 @@
<data name="PowerLauncher_ClearInputOnLaunch.Content" xml:space="preserve">
<value>Clear the previous query on launch</value>
</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">
<value>Input Smoothing</value>
<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;
public ObservableCollection<PowerLauncherPluginViewModel> Plugins

View File

@ -176,6 +176,15 @@
</labs:SettingsCard>
</labs:SettingsExpander.Items>
</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>
<!--<ComboBox x:Uid="PowerLauncher_SearchResultPreference"