mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
[PTRun]Allow interaction with plugin hints (#30531)
This commit is contained in:
committed by
GitHub
parent
0e01314bbd
commit
e73e73fa6c
@@ -74,8 +74,10 @@
|
|||||||
Margin="16,0,0,0"
|
Margin="16,0,0,0"
|
||||||
ItemContainerStyle="{StaticResource PluginsListViewItemStyle}"
|
ItemContainerStyle="{StaticResource PluginsListViewItemStyle}"
|
||||||
ItemsSource="{Binding Plugins}"
|
ItemsSource="{Binding Plugins}"
|
||||||
|
PreviewMouseLeftButtonUp="PluginsHintsList_PreviewMouseLeftButtonUp"
|
||||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||||
|
SelectedItem="{Binding SelectedPlugin, Mode=TwoWay}"
|
||||||
SelectionMode="Single">
|
SelectionMode="Single">
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
|||||||
@@ -364,6 +364,11 @@ namespace PowerLauncher
|
|||||||
BringProcessToForeground();
|
BringProcessToForeground();
|
||||||
|
|
||||||
_viewModel.SetPluginsOverviewVisibility();
|
_viewModel.SetPluginsOverviewVisibility();
|
||||||
|
if (_viewModel.Plugins.Count > 0)
|
||||||
|
{
|
||||||
|
_viewModel.SelectedPlugin = null;
|
||||||
|
pluginsHintsList.ScrollIntoView(pluginsHintsList.Items[0]);
|
||||||
|
}
|
||||||
|
|
||||||
// HACK: Setting focus here again fixes some focus issues, like on first run or after showing a message box.
|
// HACK: Setting focus here again fixes some focus issues, like on first run or after showing a message box.
|
||||||
SearchBox.QueryTextBox.Focus();
|
SearchBox.QueryTextBox.Focus();
|
||||||
@@ -484,66 +489,101 @@ namespace PowerLauncher
|
|||||||
|
|
||||||
private void Launcher_KeyDown(object sender, KeyEventArgs e)
|
private void Launcher_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Tab && (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)))
|
if (_viewModel.PluginsOverviewVisibility == Visibility.Visible)
|
||||||
{
|
{
|
||||||
_viewModel.SelectPrevTabItemCommand.Execute(null);
|
if (e.Key == Key.Up)
|
||||||
UpdateTextBoxToSelectedItem();
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
else if (e.Key == Key.Tab)
|
|
||||||
{
|
|
||||||
_viewModel.SelectNextTabItemCommand.Execute(null);
|
|
||||||
UpdateTextBoxToSelectedItem();
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
else if (e.Key == Key.Down)
|
|
||||||
{
|
|
||||||
_viewModel.SelectNextItemCommand.Execute(null);
|
|
||||||
UpdateTextBoxToSelectedItem();
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
else if (e.Key == Key.Up)
|
|
||||||
{
|
|
||||||
_viewModel.SelectPrevItemCommand.Execute(null);
|
|
||||||
UpdateTextBoxToSelectedItem();
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
else if (e.Key == Key.Right)
|
|
||||||
{
|
|
||||||
if (SearchBox.QueryTextBox.CaretIndex == SearchBox.QueryTextBox.Text.Length)
|
|
||||||
{
|
{
|
||||||
_viewModel.SelectNextContextMenuItemCommand.Execute(null);
|
_viewModel.SelectPrevOverviewPluginCommand.Execute(null);
|
||||||
|
pluginsHintsList.ScrollIntoView(_viewModel.SelectedPlugin);
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
else if (e.Key == Key.Down)
|
||||||
|
{
|
||||||
|
_viewModel.SelectNextOverviewPluginCommand.Execute(null);
|
||||||
|
pluginsHintsList.ScrollIntoView(_viewModel.SelectedPlugin);
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
else if (e.Key == Key.Tab && (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)))
|
||||||
|
{
|
||||||
|
_viewModel.SelectPrevOverviewPluginCommand.Execute(null);
|
||||||
|
pluginsHintsList.ScrollIntoView(_viewModel.SelectedPlugin);
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
else if (e.Key == Key.Tab)
|
||||||
|
{
|
||||||
|
_viewModel.SelectNextOverviewPluginCommand.Execute(null);
|
||||||
|
pluginsHintsList.ScrollIntoView(_viewModel.SelectedPlugin);
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
else if (e.Key == Key.Enter)
|
||||||
|
{
|
||||||
|
QueryForSelectedPlugin();
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.Key == Key.Left)
|
else
|
||||||
{
|
{
|
||||||
if (SearchBox.QueryTextBox.CaretIndex == SearchBox.QueryTextBox.Text.Length)
|
if (e.Key == Key.Tab && (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)))
|
||||||
{
|
{
|
||||||
if (_viewModel.Results != null && _viewModel.Results.IsContextMenuItemSelected())
|
_viewModel.SelectPrevTabItemCommand.Execute(null);
|
||||||
|
UpdateTextBoxToSelectedItem();
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
else if (e.Key == Key.Tab)
|
||||||
|
{
|
||||||
|
_viewModel.SelectNextTabItemCommand.Execute(null);
|
||||||
|
UpdateTextBoxToSelectedItem();
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
else if (e.Key == Key.Down)
|
||||||
|
{
|
||||||
|
_viewModel.SelectNextItemCommand.Execute(null);
|
||||||
|
UpdateTextBoxToSelectedItem();
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
else if (e.Key == Key.Up)
|
||||||
|
{
|
||||||
|
_viewModel.SelectPrevItemCommand.Execute(null);
|
||||||
|
UpdateTextBoxToSelectedItem();
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
else if (e.Key == Key.Right)
|
||||||
|
{
|
||||||
|
if (SearchBox.QueryTextBox.CaretIndex == SearchBox.QueryTextBox.Text.Length)
|
||||||
{
|
{
|
||||||
_viewModel.SelectPreviousContextMenuItemCommand.Execute(null);
|
_viewModel.SelectNextContextMenuItemCommand.Execute(null);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (e.Key == Key.Left)
|
||||||
else if (e.Key == Key.PageDown)
|
{
|
||||||
{
|
if (SearchBox.QueryTextBox.CaretIndex == SearchBox.QueryTextBox.Text.Length)
|
||||||
_viewModel.SelectNextPageCommand.Execute(null);
|
{
|
||||||
e.Handled = true;
|
if (_viewModel.Results != null && _viewModel.Results.IsContextMenuItemSelected())
|
||||||
}
|
{
|
||||||
else if (e.Key == Key.PageUp)
|
_viewModel.SelectPreviousContextMenuItemCommand.Execute(null);
|
||||||
{
|
e.Handled = true;
|
||||||
_viewModel.SelectPrevPageCommand.Execute(null);
|
}
|
||||||
e.Handled = true;
|
}
|
||||||
}
|
}
|
||||||
else if (e.Key == Key.Back)
|
else if (e.Key == Key.PageDown)
|
||||||
{
|
{
|
||||||
_deletePressed = true;
|
_viewModel.SelectNextPageCommand.Execute(null);
|
||||||
}
|
e.Handled = true;
|
||||||
else
|
}
|
||||||
{
|
else if (e.Key == Key.PageUp)
|
||||||
_viewModel.HandleContextMenu(e.Key, Keyboard.Modifiers);
|
{
|
||||||
|
_viewModel.SelectPrevPageCommand.Execute(null);
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
else if (e.Key == Key.Back)
|
||||||
|
{
|
||||||
|
_deletePressed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_viewModel.HandleContextMenu(e.Key, Keyboard.Modifiers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -796,5 +836,25 @@ namespace PowerLauncher
|
|||||||
|
|
||||||
_hwndSource = null;
|
_hwndSource = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void PluginsHintsList_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
QueryForSelectedPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QueryForSelectedPlugin()
|
||||||
|
{
|
||||||
|
if (_viewModel.Plugins.Count > 0 && _viewModel.SelectedPlugin != null)
|
||||||
|
{
|
||||||
|
// Needed to update UI in case the user choose the same plugin multiple times
|
||||||
|
_viewModel.ChangeQueryText(string.Empty);
|
||||||
|
|
||||||
|
_viewModel.ChangeQueryText(_viewModel.SelectedPlugin.Metadata.ActionKeyword, true);
|
||||||
|
SearchBox.QueryTextBox.Focus();
|
||||||
|
|
||||||
|
_viewModel.SelectedPlugin = null;
|
||||||
|
pluginsHintsList.ScrollIntoView(pluginsHintsList.Items[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,24 +41,20 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
<ControlTemplate.Triggers>
|
<ControlTemplate.Triggers>
|
||||||
<MultiTrigger>
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
<MultiTrigger.Conditions>
|
<Setter TargetName="Border" Property="Background">
|
||||||
<Condition Property="IsEnabled" Value="True" />
|
|
||||||
<Condition Property="IsMouseOver" Value="True" />
|
|
||||||
</MultiTrigger.Conditions>
|
|
||||||
<!--<Setter TargetName="Border" Property="Background">
|
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<SolidColorBrush Color="{DynamicResource SubtleFillColorSecondary}" />
|
<SolidColorBrush Color="{DynamicResource SubtleFillColorSecondary}" />
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>-->
|
</Setter>
|
||||||
</MultiTrigger>
|
</Trigger>
|
||||||
<Trigger Property="IsSelected" Value="True">
|
<Trigger Property="IsSelected" Value="True">
|
||||||
<!--<Setter TargetName="ActiveRectangle" Property="Visibility" Value="Visible" />
|
<Setter TargetName="ActiveRectangle" Property="Visibility" Value="Visible" />
|
||||||
<Setter TargetName="Border" Property="Background">
|
<Setter TargetName="Border" Property="Background">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<SolidColorBrush Color="{DynamicResource SubtleFillColorSecondary}" />
|
<SolidColorBrush Color="{DynamicResource SubtleFillColorSecondary}" />
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>-->
|
</Setter>
|
||||||
</Trigger>
|
</Trigger>
|
||||||
</ControlTemplate.Triggers>
|
</ControlTemplate.Triggers>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) Microsoft Corporation
|
// Copyright (c) Microsoft Corporation
|
||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
@@ -132,6 +132,10 @@ namespace PowerLauncher.ViewModel
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else if (e.PropertyName == nameof(PowerToysRunSettings.ShowPluginsOverview))
|
||||||
|
{
|
||||||
|
RefreshPluginsOverview();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SetHotkey(hwnd, _settings.Hotkey, OnHotkey);
|
SetHotkey(hwnd, _settings.Hotkey, OnHotkey);
|
||||||
@@ -299,6 +303,16 @@ namespace PowerLauncher.ViewModel
|
|||||||
OnPropertyChanged(nameof(SystemQueryText));
|
OnPropertyChanged(nameof(SystemQueryText));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
SelectNextOverviewPluginCommand = new RelayCommand(_ =>
|
||||||
|
{
|
||||||
|
SelectNextOverviewPlugin();
|
||||||
|
});
|
||||||
|
|
||||||
|
SelectPrevOverviewPluginCommand = new RelayCommand(_ =>
|
||||||
|
{
|
||||||
|
SelectPrevOverviewPlugin();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResultsViewModel _results;
|
private ResultsViewModel _results;
|
||||||
@@ -473,6 +487,10 @@ namespace PowerLauncher.ViewModel
|
|||||||
|
|
||||||
public ICommand ClearQueryCommand { get; private set; }
|
public ICommand ClearQueryCommand { get; private set; }
|
||||||
|
|
||||||
|
public ICommand SelectNextOverviewPluginCommand { get; private set; }
|
||||||
|
|
||||||
|
public ICommand SelectPrevOverviewPluginCommand { get; private set; }
|
||||||
|
|
||||||
public class QueryTuningOptions
|
public class QueryTuningOptions
|
||||||
{
|
{
|
||||||
public int SearchClickedItemWeight { get; set; }
|
public int SearchClickedItemWeight { get; set; }
|
||||||
@@ -1212,6 +1230,22 @@ namespace PowerLauncher.ViewModel
|
|||||||
|
|
||||||
public ObservableCollection<PluginPair> Plugins { get; } = new();
|
public ObservableCollection<PluginPair> Plugins { get; } = new();
|
||||||
|
|
||||||
|
private PluginPair _selectedPlugin;
|
||||||
|
|
||||||
|
public PluginPair SelectedPlugin
|
||||||
|
{
|
||||||
|
get => _selectedPlugin;
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_selectedPlugin != value)
|
||||||
|
{
|
||||||
|
_selectedPlugin = value;
|
||||||
|
OnPropertyChanged(nameof(SelectedPlugin));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Visibility _pluginsOverviewVisibility = Visibility.Visible;
|
private Visibility _pluginsOverviewVisibility = Visibility.Visible;
|
||||||
|
|
||||||
public Visibility PluginsOverviewVisibility
|
public Visibility PluginsOverviewVisibility
|
||||||
@@ -1245,5 +1279,51 @@ namespace PowerLauncher.ViewModel
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SelectNextOverviewPlugin()
|
||||||
|
{
|
||||||
|
if (Plugins.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var selectedIndex = Plugins.IndexOf(SelectedPlugin);
|
||||||
|
if (selectedIndex == -1)
|
||||||
|
{
|
||||||
|
selectedIndex = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (++selectedIndex > Plugins.Count - 1)
|
||||||
|
{
|
||||||
|
selectedIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedPlugin = Plugins[selectedIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SelectPrevOverviewPlugin()
|
||||||
|
{
|
||||||
|
if (Plugins.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var selectedIndex = Plugins.IndexOf(SelectedPlugin);
|
||||||
|
if (selectedIndex == -1)
|
||||||
|
{
|
||||||
|
selectedIndex = Plugins.Count - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (--selectedIndex < 0)
|
||||||
|
{
|
||||||
|
selectedIndex = Plugins.Count - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedPlugin = Plugins[selectedIndex];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -326,7 +326,20 @@ namespace Wox.Infrastructure.UserSettings
|
|||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShowPluginsOverviewMode ShowPluginsOverview { get; set; } = ShowPluginsOverviewMode.All;
|
private ShowPluginsOverviewMode _showPluginsOverview = ShowPluginsOverviewMode.All;
|
||||||
|
|
||||||
|
public ShowPluginsOverviewMode ShowPluginsOverview
|
||||||
|
{
|
||||||
|
get => _showPluginsOverview;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_showPluginsOverview != value)
|
||||||
|
{
|
||||||
|
_showPluginsOverview = value;
|
||||||
|
OnPropertyChanged(nameof(ShowPluginsOverview));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool IgnoreHotkeysOnFullscreen { get; set; }
|
public bool IgnoreHotkeysOnFullscreen { get; set; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user