[Shortcut Guide] Activate with Windows key press (#13342)

* [Shortcut Guide] Activate with Windows key press

* fix spellchecker

* pr comments: fix search and add lock

* Add activation method combo box

* fix spellchecker issue for customized

* Standardize centralized hotkeys file names

* Add warning when using the long win key method

* Address PR feedback on text

* More PR feedback
This commit is contained in:
Jaime Bernardo
2021-09-23 14:23:22 +01:00
committed by GitHub
parent a0ebe5ed54
commit f647223e94
15 changed files with 308 additions and 20 deletions

View File

@@ -11,6 +11,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
public ShortcutGuideProperties()
{
OverlayOpacity = new IntProperty(90);
UseLegacyPressWinKeyBehavior = new BoolProperty(false);
PressTime = new IntProperty(900);
Theme = new StringProperty("system");
DisabledApps = new StringProperty();
@@ -23,6 +24,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[JsonPropertyName("overlay_opacity")]
public IntProperty OverlayOpacity { get; set; }
[JsonPropertyName("use_legacy_press_win_key_behavior")]
public BoolProperty UseLegacyPressWinKeyBehavior { get; set; }
[JsonPropertyName("press_time")]
public IntProperty PressTime { get; set; }

View File

@@ -52,6 +52,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
SendConfigMSG = ipcMSGCallBackFunc;
_isEnabled = GeneralSettingsConfig.Enabled.ShortcutGuide;
_useLegacyPressWinKeyBehavior = Settings.Properties.UseLegacyPressWinKeyBehavior.Value;
_pressTime = Settings.Properties.PressTime.Value;
_opacity = Settings.Properties.OverlayOpacity.Value;
_disabledApps = Settings.Properties.DisabledApps.Value;
@@ -66,6 +67,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private bool _isEnabled;
private int _themeIndex;
private bool _useLegacyPressWinKeyBehavior;
private int _pressTime;
private int _opacity;
@@ -151,6 +153,42 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
}
}
public bool UseLegacyPressWinKeyBehavior
{
get
{
return _useLegacyPressWinKeyBehavior;
}
set
{
if (_useLegacyPressWinKeyBehavior != value)
{
_useLegacyPressWinKeyBehavior = value;
Settings.Properties.UseLegacyPressWinKeyBehavior.Value = value;
NotifyPropertyChanged();
}
}
}
public int PressTime
{
get
{
return _pressTime;
}
set
{
if (_pressTime != value)
{
_pressTime = value;
Settings.Properties.PressTime.Value = value;
NotifyPropertyChanged();
}
}
}
public string DisabledApps
{
get

View File

@@ -615,6 +615,24 @@
<value>Press duration before showing (ms)</value>
<comment>pressing a key in milliseconds</comment>
</data>
<data name="ShortcutGuide_PressTime.Description" xml:space="preserve">
<value>How long to press the Windows key to activate the module</value>
</data>
<data name="ShortcutGuide_ActivationMethod.Header" xml:space="preserve">
<value>Activation method</value>
</data>
<data name="ShortcutGuide_ActivationMethod.Description" xml:space="preserve">
<value>Use a shortcut or press the Windows key for some time to activate</value>
</data>
<data name="Radio_ShortcutGuide_ActivationMethod_CustomizedShortcut.Content" xml:space="preserve">
<value>Customized shortcut</value>
</data>
<data name="Radio_ShortcutGuide_ActivationMethod_LongPressWindowsKey.Content" xml:space="preserve">
<value>Hold down Windows key</value>
</data>
<data name="ShortcutGuide_PressWinKeyWarning.Title" xml:space="preserve">
<value>In some edge cases Shortcut Guide might not function correctly when using this activation method</value>
</data>
<data name="ShortcutGuide_Appearance_Behavior.Header" xml:space="preserve">
<value>Appearance &amp; behavior</value>
</data>

View File

@@ -12,6 +12,9 @@
<Page.Resources>
<converters:StringFormatConverter x:Key="StringFormatConverter"/>
<converters:BoolToObjectConverter x:Key="BoolToComboBoxIndexConverter" TrueValue="1" FalseValue="0"/>
<converters:BoolToVisibilityConverter x:Key="TrueToVisibleConverter" TrueValue="Visible" FalseValue="Collapsed"/>
<converters:BoolToVisibilityConverter x:Key="FalseToVisibleConverter" TrueValue="Collapsed" FalseValue="Visible"/>
</Page.Resources>
<controls:SettingsPageControl x:Uid="ShortcutGuide"
@@ -29,12 +32,43 @@
<controls:SettingsGroup x:Uid="Shortcut" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}">
<controls:Setting x:Uid="Activation_Shortcut" Icon="&#xEDA7;" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}">
<controls:Setting x:Uid="ShortcutGuide_ActivationMethod">
<controls:Setting.ActionContent>
<ComboBox SelectedIndex="{x:Bind Mode=TwoWay, Path=ViewModel.UseLegacyPressWinKeyBehavior, Converter={StaticResource BoolToComboBoxIndexConverter}}" MinWidth="{StaticResource SettingActionControlMinWidth}">
<ComboBoxItem x:Uid="Radio_ShortcutGuide_ActivationMethod_CustomizedShortcut"/>
<ComboBoxItem x:Uid="Radio_ShortcutGuide_ActivationMethod_LongPressWindowsKey"/>
</ComboBox>
</controls:Setting.ActionContent>
</controls:Setting>
<controls:Setting x:Uid="Activation_Shortcut" Icon="&#xEDA7;" Visibility="{x:Bind Mode=OneWay, Path=ViewModel.UseLegacyPressWinKeyBehavior, Converter={StaticResource FalseToVisibleConverter}}">
<controls:Setting.ActionContent>
<controls:ShortcutControl HotkeySettings="{x:Bind Path=ViewModel.OpenShortcutGuide, Mode=TwoWay}"
MinWidth="{StaticResource SettingActionControlMinWidth}"/>
</controls:Setting.ActionContent>
</controls:Setting>
<controls:Setting x:Uid="ShortcutGuide_PressTime" Icon="&#xE916;" Visibility="{x:Bind Mode=OneWay, Path=ViewModel.UseLegacyPressWinKeyBehavior, Converter={StaticResource TrueToVisibleConverter}}">
<controls:Setting.ActionContent>
<muxc:NumberBox
Minimum="100"
Value="{x:Bind Mode=TwoWay, Path=ViewModel.PressTime}"
MinWidth="{StaticResource SettingActionControlMinWidth}"
SpinButtonPlacementMode="Compact"
HorizontalAlignment="Left"
SmallChange="50"
LargeChange="100"
/>
</controls:Setting.ActionContent>
</controls:Setting>
<muxc:InfoBar
x:Uid="ShortcutGuide_PressWinKeyWarning"
Severity="Warning"
IsOpen="{x:Bind Mode=OneWay, Path=ViewModel.UseLegacyPressWinKeyBehavior}"
IsClosable="False"
/>
</controls:SettingsGroup>
<controls:SettingsGroup x:Uid="ShortcutGuide_Appearance_Behavior" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}">