Plugin page

This commit is contained in:
Niels Laute
2021-08-11 10:09:19 +02:00
parent d39f341f57
commit ba4aa3c33d
4 changed files with 167 additions and 214 deletions

View File

@@ -17,13 +17,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
{
public class PowerLauncherViewModel : Observable
{
private bool _isDarkThemeRadioButtonChecked;
private bool _isLightThemeRadioButtonChecked;
private bool _isSystemThemeRadioButtonChecked;
private bool _isCursorPositionRadioButtonChecked;
private bool _isPrimaryMonitorPositionRadioButtonChecked;
private bool _isFocusPositionRadioButtonChecked;
private int _themeIndex;
private int _monitorPositionIndex;
private GeneralSettings GeneralSettingsConfig { get; set; }
@@ -71,27 +66,27 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
switch (settings.Properties.Theme)
{
case Theme.Light:
_isLightThemeRadioButtonChecked = true;
break;
case Theme.Dark:
_isDarkThemeRadioButtonChecked = true;
_themeIndex = 0;
break;
case Theme.Light:
_themeIndex = 1;
break;
case Theme.System:
_isSystemThemeRadioButtonChecked = true;
_themeIndex = 2;
break;
}
switch (settings.Properties.Position)
{
case StartupPosition.Cursor:
_isCursorPositionRadioButtonChecked = true;
_monitorPositionIndex = 0;
break;
case StartupPosition.PrimaryMonitor:
_isPrimaryMonitorPositionRadioButtonChecked = true;
_monitorPositionIndex = 1;
break;
case StartupPosition.Focus:
_isFocusPositionRadioButtonChecked = true;
_monitorPositionIndex = 2;
break;
}
@@ -193,113 +188,72 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
}
}
public bool IsDarkThemeRadioButtonChecked
public int ThemeIndex
{
get
{
return _isDarkThemeRadioButtonChecked;
return _themeIndex;
}
set
{
if (value == true)
if (_themeIndex != value)
{
settings.Properties.Theme = Theme.Dark;
_isDarkThemeRadioButtonChecked = value;
if (value == 0)
{
// set theme to dark.
settings.Properties.Theme = Theme.Dark;
_themeIndex = value;
UpdateSettings();
}
UpdateSettings();
if (value == 1)
{
// set theme to light.
settings.Properties.Theme = Theme.Light;
_themeIndex = value;
UpdateSettings();
}
if (value == 2)
{
// set theme to system default.
settings.Properties.Theme = Theme.System;
_themeIndex = value;
UpdateSettings();
}
}
}
}
public bool IsLightThemeRadioButtonChecked
public int MonitorPositionIndex
{
get
{
return _isLightThemeRadioButtonChecked;
return _monitorPositionIndex;
}
set
{
if (value == true)
if (_monitorPositionIndex != value)
{
settings.Properties.Theme = Theme.Light;
_isDarkThemeRadioButtonChecked = value;
if (value == 0)
{
settings.Properties.Position = StartupPosition.Cursor;
UpdateSettings();
}
UpdateSettings();
}
}
}
if (value == 1)
{
settings.Properties.Position = StartupPosition.PrimaryMonitor;
UpdateSettings();
}
public bool IsSystemThemeRadioButtonChecked
{
get
{
return _isSystemThemeRadioButtonChecked;
}
set
{
if (value == true)
{
settings.Properties.Theme = Theme.System;
_isDarkThemeRadioButtonChecked = value;
UpdateSettings();
}
}
}
public bool IsCursorPositionRadioButtonChecked
{
get
{
return _isCursorPositionRadioButtonChecked;
}
set
{
if (value == true)
{
settings.Properties.Position = StartupPosition.Cursor;
_isCursorPositionRadioButtonChecked = value;
UpdateSettings();
}
}
}
public bool IsPrimaryMonitorPositionRadioButtonChecked
{
get
{
return _isPrimaryMonitorPositionRadioButtonChecked;
}
set
{
if (value == true)
{
settings.Properties.Position = StartupPosition.PrimaryMonitor;
_isPrimaryMonitorPositionRadioButtonChecked = value;
UpdateSettings();
}
}
}
public bool IsFocusPositionRadioButtonChecked
{
get
{
return _isFocusPositionRadioButtonChecked;
}
set
{
if (value == true)
{
settings.Properties.Position = StartupPosition.Focus;
_isFocusPositionRadioButtonChecked = value;
UpdateSettings();
if (value == 2)
{
settings.Properties.Position = StartupPosition.Focus;
UpdateSettings();
}
}
}
}

View File

@@ -284,6 +284,9 @@ Disabling this module or closing PowerToys will unmute the microphone and camera
<value>Shortcuts</value>
<comment>Keyboard Manager remap keyboard header</comment>
</data>
<data name="Shortcuts.Header" xml:space="preserve">
<value>Shortcuts</value>
</data>
<data name="RemapKeysList.AutomationProperties.Name" xml:space="preserve">
<value>Current Key Remappings</value>
</data>
@@ -328,7 +331,7 @@ Disabling this module or closing PowerToys will unmute the microphone and camera
<value>Enable PowerToys Run</value>
<comment>do not loc the Product name. Do you want this feature on / off</comment>
</data>
<data name="PowerLauncher_SearchResults.Text" xml:space="preserve">
<data name="PowerLauncher_SearchResults.Header" xml:space="preserve">
<value>Search &amp; results</value>
</data>
<data name="PowerLauncher_SearchResultPreference.Header" xml:space="preserve">
@@ -1048,7 +1051,7 @@ Made with 💗 by Microsoft and the PowerToys community.</value>
<data name="FancyZones_OverlappingZones.Header" xml:space="preserve">
<value>When multiple zones overlap</value>
</data>
<data name="PowerLauncher_Plugins.Text" xml:space="preserve">
<data name="PowerLauncher_Plugins.Header" xml:space="preserve">
<value>Plugins</value>
</data>
<data name="PowerLauncher_ActionKeyword.Text" xml:space="preserve">
@@ -1070,20 +1073,30 @@ Made with 💗 by Microsoft and the PowerToys community.</value>
<data name="Run_NotAccessibleWarning.Text" xml:space="preserve">
<value>* Please define an activation phrase or allow this plugin for the global results to use it.</value>
</data>
<data name="Run_AllPluginsDisabled.Text" xml:space="preserve">
<value>* PowerToys Run can't provide any results without plugins. Please enable at least one plugin.</value>
<data name="Run_AllPluginsDisabled.Title" xml:space="preserve">
<value>PowerToys Run can't provide any results without plugins</value>
</data>
<data name="Run_AllPluginsDisabled.Message" xml:space="preserve">
<value>Enable at least one plugin to get started</value>
</data>
<data name="Run_NotAllowedActionKeyword.Text" xml:space="preserve">
<value>* This activation phrase overrides the behavior of other plugins. Please change it to something else.</value>
</data>
<data name="Run_PluginUseDescription.Text" xml:space="preserve">
<data name="Run_PluginUseDescription.Header" xml:space="preserve">
<value>Plugins</value>
</data>
<data name="Run_PluginUseDescription.Description" xml:space="preserve">
<value>You can include or remove each plugin from the global results, change the direct activation phrase and configure additional options.</value>
</data>
<data name="Run_PositionAppearance_GroupSettings.Text" xml:space="preserve">
<data name="Run_PositionAppearance_GroupSettings.Header" xml:space="preserve">
<value>Position &amp; appearance</value>
</data>
<data name="Run_PositionHeader.Text" xml:space="preserve">
<value>Show PowerToys Run on</value>
<data name="Run_PositionHeader.Header" xml:space="preserve">
<value>Preferred monitor position</value>
<comment>as in Show PowerToys Run on primary monitor</comment>
</data>
<data name="Run_PositionHeader.Description" xml:space="preserve">
<value>If multiple monitors are in use, PowerToys Run can be launched on the desired monitor.</value>
<comment>as in Show PowerToys Run on primary monitor</comment>
</data>
<data name="Run_Radio_Position_Cursor.Content" xml:space="preserve">

View File

@@ -203,7 +203,7 @@
<Rectangle Style="{StaticResource ExpanderSeparatorStyle}" />
<CheckBox x:Uid="FancyZones_RestoreSize" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.RestoreSize}" Margin="{StaticResource ExpanderSettingMargin}"/>
<Rectangle Style="{StaticResource ExpanderSeparatorStyle}" />
<CheckBox x:Uid="FancyZones_MakeDraggedWindowTransparentCheckBoxControl" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.MakeDraggedWindowsTransparent}"/>
<CheckBox x:Uid="FancyZones_MakeDraggedWindowTransparentCheckBoxControl" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.MakeDraggedWindowsTransparent}" Margin="{StaticResource ExpanderSettingMargin}"/>
</StackPanel>
</muxc:Expander.Content>

View File

@@ -22,21 +22,42 @@
<controls:SettingsPageControl.ModuleContent>
<StackPanel Orientation="Vertical">
<ToggleSwitch x:Uid="PowerLauncher_EnablePowerLauncher"
IsOn="{x:Bind Mode=TwoWay, Path=ViewModel.EnablePowerLauncher}"/>
<TextBlock x:Uid="Shortcuts"
Style="{StaticResource SettingsGroupTitleStyle}"
Opacity="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher, Converter={StaticResource ModuleEnabledToOpacityConverter}}"/>
<controls:Setting x:Uid="PowerLauncher_EnablePowerLauncher">
<controls:Setting.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerToysRun.png" ShowAsMonochrome="False" />
</controls:Setting.Icon>
<controls:Setting.ActionContent>
<ToggleSwitch IsOn="{x:Bind ViewModel.EnablePowerLauncher, Mode=TwoWay}" FlowDirection="RightToLeft" />
</controls:Setting.ActionContent>
</controls:Setting>
<controls:HotkeySettingsControl x:Uid="PowerLauncher_OpenPowerLauncher"
HorizontalAlignment="Left"
MinWidth="240"
Margin="{StaticResource SmallTopMargin}"
HotkeySettings="{x:Bind Path=ViewModel.OpenPowerLauncher, Mode=TwoWay}"
Keys="Win, Ctrl, Alt, Shift"
Enabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"/>
<!--<Custom:HotkeySettingsControl x:Uid="PowerLauncher_OpenFileLocation"
<controls:SettingsGroup x:Uid="Shortcuts" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}">
<muxc:Expander IsExpanded="True">
<muxc:Expander.Header>
<controls:Setting x:Uid="Activation_Shortcut" Icon="&#xEDA7;" Style="{StaticResource ExpanderHeaderSettingStyle}">
<controls:Setting.Description>
<TextBlock>
<Run x:Uid="ShortcutWarningLabel"/>
<Run Text="Win, Ctrl, Alt, Shift"/>
</TextBlock>
</controls:Setting.Description>
<controls:Setting.ActionContent>
<controls:HotkeySettingsControl Width="240" HotkeySettings="{x:Bind Path=ViewModel.OpenPowerLauncher, Mode=TwoWay}" Keys="Win, Ctrl, Alt, Shift"/>
</controls:Setting.ActionContent>
</controls:Setting>
</muxc:Expander.Header>
<muxc:Expander.Content>
<StackPanel>
<CheckBox x:Uid="PowerLauncher_IgnoreHotkeysInFullScreen" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.IgnoreHotkeysInFullScreen}" Margin="{StaticResource ExpanderSettingMargin}" />
</StackPanel>
</muxc:Expander.Content>
</muxc:Expander>
</controls:SettingsGroup>
<!--<Custom:HotkeySettingsControl x:Uid="PowerLauncher_OpenFileLocation"
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}"
HotkeySettings="{Binding Path=ViewModel.OpenFileLocation, Mode=TwoWay}"
@@ -57,29 +78,41 @@
IsEnabled="False"
/>-->
<!--<CheckBox x:Uid="PowerLauncher_OverrideWinRKey"
<!--<CheckBox x:Uid="PowerLauncher_OverrideWinRKey"
Margin="{StaticResource SmallTopMargin}"
IsChecked="False"
IsEnabled="False"
/>-->
<!--<CheckBox x:Uid="PowerLauncher_OverrideWinSKey"
<!--<CheckBox x:Uid="PowerLauncher_OverrideWinSKey"
Margin="{StaticResource SmallTopMargin}"
IsChecked="{Binding Mode=TwoWay, Path=ViewModel.OverrideWinSKey}"
IsEnabled="False"
/>-->
<CheckBox x:Uid="PowerLauncher_IgnoreHotkeysInFullScreen"
Margin="{StaticResource SmallTopMargin}"
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.IgnoreHotkeysInFullScreen}"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"
/>
<TextBlock x:Uid="PowerLauncher_SearchResults"
Style="{StaticResource SettingsGroupTitleStyle}"
Opacity="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher, Converter={StaticResource ModuleEnabledToOpacityConverter}}"/>
<!--<ComboBox x:Uid="PowerLauncher_SearchResultPreference"
<controls:SettingsGroup x:Uid="PowerLauncher_SearchResults" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}">
<muxc:Expander IsExpanded="True">
<muxc:Expander.Header>
<controls:Setting x:Uid="PowerLauncher_MaximumNumberOfResults" Icon="&#xE721;" Style="{StaticResource ExpanderHeaderSettingStyle}">
<controls:Setting.ActionContent>
<muxc:NumberBox Value="{Binding Mode=TwoWay, Path=MaximumNumberOfResults}"
Width="240"
SpinButtonPlacementMode="Compact"
Minimum="1"/>
</controls:Setting.ActionContent>
</controls:Setting>
</muxc:Expander.Header>
<muxc:Expander.Content>
<CheckBox x:Uid="PowerLauncher_ClearInputOnLaunch" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.ClearInputOnLaunch}" Margin="{StaticResource ExpanderSettingMargin}" />
</muxc:Expander.Content>
</muxc:Expander>
</controls:SettingsGroup>
<!--<ComboBox x:Uid="PowerLauncher_SearchResultPreference"
MinWidth="320"
Margin="{StaticResource SmallTopMargin}"
ItemsSource="{Binding searchResultPreferencesOptions}"
@@ -99,95 +132,47 @@
IsEnabled="False"
/>-->
<muxc:NumberBox x:Uid="PowerLauncher_MaximumNumberOfResults"
Value="{Binding Mode=TwoWay, Path=MaximumNumberOfResults}"
MinWidth="240"
SpinButtonPlacementMode="Compact"
HorizontalAlignment="Left"
Minimum="1"
Margin="{StaticResource SmallTopMargin}"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"/>
<controls:SettingsGroup x:Uid="Run_PositionAppearance_GroupSettings" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}">
<controls:Setting x:Uid="Run_PositionHeader" Icon="&#xE18C;">
<controls:Setting.ActionContent>
<ComboBox SelectedIndex="{x:Bind Mode=TwoWay, Path=ViewModel.MonitorPositionIndex}">
<ComboBoxItem x:Uid="Run_Radio_Position_Cursor"/>
<ComboBoxItem x:Uid="Run_Radio_Position_Primary_Monitor"/>
<ComboBoxItem x:Uid="Run_Radio_Position_Focus"/>
</ComboBox>
</controls:Setting.ActionContent>
</controls:Setting>
<CheckBox x:Uid="PowerLauncher_ClearInputOnLaunch"
Margin="{StaticResource SmallTopMargin}"
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.ClearInputOnLaunch}"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"
/>
<controls:Setting x:Uid="ColorModeHeader" Icon="&#xE771;">
<controls:Setting.Description>
<HyperlinkButton Click="OpenColorsSettings_Click"
x:Uid="Windows_Color_Settings"/>
</controls:Setting.Description>
<controls:Setting.ActionContent>
<ComboBox SelectedIndex="{x:Bind Mode=TwoWay, Path=ViewModel.ThemeIndex}">
<ComboBoxItem x:Uid="Radio_Theme_Dark"/>
<ComboBoxItem x:Uid="Radio_Theme_Light"/>
<ComboBoxItem x:Uid="Radio_Theme_Default"/>
</ComboBox>
</controls:Setting.ActionContent>
</controls:Setting>
<TextBlock x:Uid="Run_PositionAppearance_GroupSettings"
Style="{StaticResource SettingsGroupTitleStyle}"
Opacity="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher, Converter={StaticResource ModuleEnabledToOpacityConverter}}" />
</controls:SettingsGroup>
<TextBlock x:Uid="Run_PositionHeader"
x:Name="RadioButtons_Name_Position"
Margin="{StaticResource SmallTopMargin}"
Opacity="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher, Converter={StaticResource ModuleEnabledToOpacityConverter}}" />
<StackPanel AutomationProperties.LabeledBy="{Binding ElementName=RadioButtons_Name_Position}">
<RadioButton x:Uid="Run_Radio_Position_Primary_Monitor"
GroupName="Run_Position"
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.IsPrimaryMonitorPositionRadioButtonChecked}"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"/>
<controls:SettingsGroup x:Uid="PowerLauncher_Plugins" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}">
<controls:Setting x:Uid="Run_PluginUseDescription" Icon="&#xEA86;"/>
<muxc:InfoBar x:Uid="Run_AllPluginsDisabled" Severity="Error" IsOpen="{x:Bind ViewModel.ShowAllPluginsDisabledWarning, Mode=OneWay}" IsClosable="False" />
<RadioButton x:Uid="Run_Radio_Position_Cursor"
GroupName="Run_Position"
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.IsCursorPositionRadioButtonChecked}"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"/>
<RadioButton x:Uid="Run_Radio_Position_Focus"
GroupName="Run_Position"
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.IsFocusPositionRadioButtonChecked}"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"/>
</StackPanel>
<!-- We cannot navigate to all the radio buttons using the arrow keys because of an XYNavigation issue in the RadioButtons control.
The screen reader does not read the heading when we tab into a radio button, even though the LabeledBy automation property is set.
Link to the issue in the winui repository - https://github.com/microsoft/microsoft-ui-xaml/issues/3156 -->
<TextBlock x:Uid="ColorModeHeader"
x:Name="RadioButtons_Name_Theme"
Margin="{StaticResource SmallTopMargin}"
Opacity="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher, Converter={StaticResource ModuleEnabledToOpacityConverter}}" />
<StackPanel AutomationProperties.LabeledBy="{Binding ElementName=RadioButtons_Name_Theme}">
<RadioButton x:Uid="Radio_Theme_Dark"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"
IsChecked="{Binding Mode=TwoWay, Path=IsDarkThemeRadioButtonChecked}" />
<RadioButton x:Uid="Radio_Theme_Light"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"
IsChecked="{Binding Mode=TwoWay, Path=IsLightThemeRadioButtonChecked}" />
<RadioButton x:Uid="Radio_Theme_Default"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"
IsChecked="{Binding Mode=TwoWay, Path=IsSystemThemeRadioButtonChecked}" />
<HyperlinkButton Click="OpenColorsSettings_Click" Margin="-12,0,0,0"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}">
<TextBlock x:Uid="Windows_Color_Settings" />
</HyperlinkButton>
</StackPanel>
<TextBlock x:Uid="PowerLauncher_Plugins"
Style="{StaticResource SettingsGroupTitleStyle}"
Opacity="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher, Converter={StaticResource ModuleEnabledToOpacityConverter}}"/>
<TextBlock x:Uid="Run_PluginUseDescription"
Margin="{StaticResource SmallTopMargin}"
Opacity="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher, Converter={StaticResource ModuleEnabledToOpacityConverter}}"
TextWrapping="Wrap"/>
<StackPanel Orientation="Horizontal" Visibility="{x:Bind ViewModel.ShowPluginsLoadingMessage, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
<muxc:ProgressRing IsActive="True" Width="20" Height="20" Margin="18,18" />
<TextBlock x:Uid="Run_PluginsLoading" Style="{ThemeResource SecondaryTextStyle}" VerticalAlignment="Center" />
</StackPanel>
<TextBlock x:Uid="Run_AllPluginsDisabled"
Foreground="{ThemeResource SystemControlErrorTextForegroundBrush}"
Visibility="{x:Bind ViewModel.ShowAllPluginsDisabledWarning, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
TextWrapping="Wrap"
Margin="{StaticResource SmallTopMargin}"/>
<TextBlock x:Uid="Run_PluginsLoading"
Visibility="{x:Bind ViewModel.ShowPluginsLoadingMessage, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
TextWrapping="Wrap"
Margin="{StaticResource SmallTopMargin}"/>
<ListView ItemsSource="{x:Bind Path=ViewModel.Plugins, Mode=OneWay}"
<ListView ItemsSource="{x:Bind Path=ViewModel.Plugins, Mode=OneWay}"
IsItemClickEnabled="True"
SelectionChanged="PluginsListView_SelectionChanged"
x:Name="PluginsListView"
@@ -324,7 +309,8 @@
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</controls:SettingsGroup>
</StackPanel>
</controls:SettingsPageControl.ModuleContent>
<controls:SettingsPageControl.ModuleLinks>