mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
added shortcut guide settings (#2247)
This commit is contained in:
@@ -142,7 +142,7 @@
|
||||
<comment>Navigation view item name for PowerRename</comment>
|
||||
</data>
|
||||
<data name="Shell_ShortcutGuide.Content" xml:space="preserve">
|
||||
<value>Shortcut Guide [Not Functional]</value>
|
||||
<value>Shortcut Guide</value>
|
||||
<comment>Navigation view item name for Shortcut Guide</comment>
|
||||
</data>
|
||||
<data name="Shell_PowerPreview.Content" xml:space="preserve">
|
||||
@@ -410,4 +410,19 @@
|
||||
<data name="FancyZones_SaveZoneInActiveColor.Content" xml:space="preserve">
|
||||
<value>Save Zone Inactive Color Choice</value>
|
||||
</data>
|
||||
<data name="ShortcutGuide_Description.Text" xml:space="preserve">
|
||||
<value>Shows a help overlay with Windows shortcuts when the Windows key is pressed.</value>
|
||||
</data>
|
||||
<data name="ShortcutGuide_PressTime.Header" xml:space="preserve">
|
||||
<value>How long to press the Windows key before showing the Shortcut Guide</value>
|
||||
</data>
|
||||
<data name="ShortcutGuide_Appearance_Behaiviour.Text" xml:space="preserve">
|
||||
<value>Appearance & behaviour</value>
|
||||
</data>
|
||||
<data name="ShortcutGuide_Enable.Header" xml:space="preserve">
|
||||
<value>Enable Shortcut Guide</value>
|
||||
</data>
|
||||
<data name="ShortcutGuide_OverlayOpacity.Header" xml:space="preserve">
|
||||
<value>Opacity of the Shortcut Guide's overlay background (%)</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -2,14 +2,172 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Lib;
|
||||
using Microsoft.PowerToys.Settings.UI.Views;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
public class ShortcutGuideViewModel : Observable
|
||||
{
|
||||
private ShortcutGuideSettings Settings { get; set; }
|
||||
|
||||
private const string ModuleName = "Shortcut Guide";
|
||||
|
||||
public ShortcutGuideViewModel()
|
||||
{
|
||||
try
|
||||
{
|
||||
Settings = SettingsUtils.GetSettings<ShortcutGuideSettings>(ModuleName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Settings = new ShortcutGuideSettings();
|
||||
SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
|
||||
}
|
||||
|
||||
GeneralSettings generalSettings;
|
||||
|
||||
try
|
||||
{
|
||||
generalSettings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
generalSettings = new GeneralSettings();
|
||||
SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty);
|
||||
}
|
||||
|
||||
this._isEnabled = generalSettings.Enabled.ShortcutGuide;
|
||||
this._pressTime = Settings.Properties.PressTime.Value;
|
||||
this._opacity = Settings.Properties.OverlayOpacity.Value;
|
||||
|
||||
string theme = Settings.Properties.Theme.Value;
|
||||
|
||||
if (theme == "dark")
|
||||
{
|
||||
_themeIndex = 0;
|
||||
}
|
||||
|
||||
if (theme == "light")
|
||||
{
|
||||
_themeIndex = 1;
|
||||
}
|
||||
|
||||
if (theme == "system")
|
||||
{
|
||||
_themeIndex = 2;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isEnabled = false;
|
||||
private int _themeIndex = 0;
|
||||
private int _pressTime = 0;
|
||||
private int _opacity = 0;
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isEnabled;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _isEnabled)
|
||||
{
|
||||
_isEnabled = value;
|
||||
GeneralSettings generalSettings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
|
||||
generalSettings.Enabled.ShortcutGuide = value;
|
||||
OutGoingGeneralSettings snd = new OutGoingGeneralSettings(generalSettings);
|
||||
|
||||
ShellPage.DefaultSndMSGCallback(snd.ToString());
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int ThemeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return _themeIndex;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_themeIndex != value)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
// set theme to dark.
|
||||
Settings.Properties.Theme.Value = "dark";
|
||||
_themeIndex = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
|
||||
if (value == 1)
|
||||
{
|
||||
// set theme to light.
|
||||
Settings.Properties.Theme.Value = "light";
|
||||
_themeIndex = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
|
||||
if (value == 2)
|
||||
{
|
||||
// set theme to system default.
|
||||
Settings.Properties.Theme.Value = "system";
|
||||
_themeIndex = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int PressTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return _pressTime;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_pressTime != value)
|
||||
{
|
||||
_pressTime = value;
|
||||
Settings.Properties.PressTime.Value = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int OverlayOpacity
|
||||
{
|
||||
get
|
||||
{
|
||||
return _opacity;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_opacity != value)
|
||||
{
|
||||
_opacity = value;
|
||||
Settings.Properties.OverlayOpacity.Value = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RaisePropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
OnPropertyChanged(propertyName);
|
||||
SndShortcutGuideSettings outsettings = new SndShortcutGuideSettings(Settings);
|
||||
SndModuleSettings<SndShortcutGuideSettings> ipcMessage = new SndModuleSettings<SndShortcutGuideSettings>(outsettings);
|
||||
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,35 +40,46 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="Shows a help overlay with Windows shortcuts when the Windows key is pressed."
|
||||
<StackPanel Orientation="Vertical" x:Name="ShortCutGuideView">
|
||||
<TextBlock x:Uid="ShortcutGuide_Description"
|
||||
TextWrapping="Wrap"/>
|
||||
|
||||
<ToggleSwitch Header="Enable Shortcut Guide"
|
||||
IsOn="True"
|
||||
Margin="{StaticResource SmallTopMargin}" />
|
||||
<ToggleSwitch x:Uid="ShortcutGuide_Enable"
|
||||
IsOn="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
Margin="{StaticResource SmallTopMargin}"/>
|
||||
|
||||
<TextBlock Text="Appearance & behaviour"
|
||||
<TextBlock x:Uid="ShortcutGuide_Appearance_Behaiviour"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||
|
||||
<muxc:NumberBox Header="How long to press the Windows key before showing the Shortcut Guide"
|
||||
<muxc:NumberBox x:Uid="ShortcutGuide_PressTime"
|
||||
Minimum="100"
|
||||
Value="900"
|
||||
SpinButtonPlacementMode="Inline"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="{StaticResource SmallTopMargin}" />
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Value="{ Binding Mode=TwoWay, Path=PressTime}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
||||
|
||||
<Slider Header="Opacity of the Shortcut Guide's overlay background (%)"
|
||||
<Slider x:Uid="ShortcutGuide_OverlayOpacity"
|
||||
Minimum="0"
|
||||
Maximum="100"
|
||||
Value="70"
|
||||
Value="{ Binding Mode=TwoWay, Path=OverlayOpacity}"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="{StaticResource MediumTopMargin}"/>
|
||||
Margin="{StaticResource MediumTopMargin}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
||||
|
||||
<muxc:RadioButtons Header="Theme" Margin="{StaticResource SmallTopMargin}">
|
||||
<RadioButton Content="Dark"/>
|
||||
<RadioButton Content="Light"/>
|
||||
<RadioButton Content="System default" IsChecked="True"/>
|
||||
|
||||
<muxc:RadioButtons x:Uid="RadioButtons_Name_Theme"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||
SelectedIndex="{ Binding Mode=TwoWay, Path=ThemeIndex}">
|
||||
<RadioButton x:Uid="GeneralPage_Radio_Theme_Dark"
|
||||
IsChecked="{ Binding Mode=TwoWay, Path=IsDarkThemeRadioButtonChecked}"/>
|
||||
|
||||
<RadioButton x:Uid="GeneralPage_Radio_Theme_Light"
|
||||
IsChecked="{ Binding Mode=TwoWay, Path=IsLightThemeRadioButtonChecked}"/>
|
||||
|
||||
<RadioButton x:Uid="GeneralPage_Radio_Theme_Default"
|
||||
IsChecked="{ Binding Mode=TwoWay, Path=IsSystemThemeRadioButtonChecked}"/>
|
||||
</muxc:RadioButtons>
|
||||
</StackPanel>
|
||||
|
||||
@@ -80,12 +91,14 @@
|
||||
Grid.Column="1">
|
||||
|
||||
<TextBlock
|
||||
Text="About this feature"
|
||||
x:Uid="About_This_Feature"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||
Margin="{StaticResource XSmallBottomMargin}"/>
|
||||
|
||||
<Image Source="https://raw.githubusercontent.com/microsoft/PowerToys/dev/build-features/doc/images/shortcut_guide/usage.png" />
|
||||
|
||||
<HyperlinkButton
|
||||
Content="Module overview"
|
||||
x:Uid="Module_overview"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/blob/master/src/modules/shortcut_guide/README.md"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
@@ -9,11 +9,13 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
{
|
||||
public sealed partial class ShortcutGuidePage : Page
|
||||
{
|
||||
public ShortcutGuideViewModel ViewModel { get; } = new ShortcutGuideViewModel();
|
||||
public ShortcutGuideViewModel ViewModel { get; set; }
|
||||
|
||||
public ShortcutGuidePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
ViewModel = new ShortcutGuideViewModel();
|
||||
this.ShortCutGuideView.DataContext = ViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user