[Settings] Reset Activation Key to Default Value (#26449)

* Add Default Value field to all controls

* Add reset button to Control field

* Improve button
Improve appearance
Add ToolTipService
Add AutomationProperties

* Move Reset button to Shortcut Dialog

* Fix Video Conferencing crash

* Change `Use Default` to `Reset`
This commit is contained in:
Sven
2023-06-20 15:42:04 +02:00
committed by GitHub
parent a883dcc283
commit 46ed52eab6
23 changed files with 127 additions and 78 deletions

View File

@@ -148,7 +148,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (_colorPickerSettings.Properties.ActivationShortcut != value)
{
_colorPickerSettings.Properties.ActivationShortcut = value;
_colorPickerSettings.Properties.ActivationShortcut = value ?? _colorPickerSettings.Properties.DefaultActivationShortcut;
OnPropertyChanged(nameof(ActivationShortcut));
NotifySettingsChanged();
}

View File

@@ -209,7 +209,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (Settings.Properties.ActivationShortcut != value)
{
Settings.Properties.ActivationShortcut = value;
Settings.Properties.ActivationShortcut = value ?? Settings.Properties.DefaultActivationShortcut;
NotifyPropertyChanged();

View File

@@ -427,7 +427,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (MouseHighlighterSettingsConfig.Properties.ActivationShortcut != value)
{
MouseHighlighterSettingsConfig.Properties.ActivationShortcut = value;
MouseHighlighterSettingsConfig.Properties.ActivationShortcut = value ?? MouseHighlighterSettingsConfig.Properties.DefaultActivationShortcut;
NotifyMouseHighlighterPropertyChanged();
}
}
@@ -595,7 +595,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (MouseJumpSettingsConfig.Properties.ActivationShortcut != value)
{
MouseJumpSettingsConfig.Properties.ActivationShortcut = value;
MouseJumpSettingsConfig.Properties.ActivationShortcut = value ?? MouseJumpSettingsConfig.Properties.DefaultActivationShortcut;
NotifyMouseJumpPropertyChanged();
}
}
@@ -676,7 +676,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (MousePointerCrosshairsSettingsConfig.Properties.ActivationShortcut != value)
{
MousePointerCrosshairsSettingsConfig.Properties.ActivationShortcut = value;
MousePointerCrosshairsSettingsConfig.Properties.ActivationShortcut = value ?? MousePointerCrosshairsSettingsConfig.Properties.DefaultActivationShortcut;
NotifyMousePointerCrosshairsPropertyChanged();
}
}

View File

@@ -126,7 +126,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (_pastePlainSettings.Properties.ActivationShortcut != value)
{
_pastePlainSettings.Properties.ActivationShortcut = value;
_pastePlainSettings.Properties.ActivationShortcut = value ?? _pastePlainSettings.Properties.DefaultActivationShortcut;
OnPropertyChanged(nameof(ActivationShortcut));
OnPropertyChanged(nameof(IsConflictingCopyShortcut));

View File

@@ -102,7 +102,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (_peekSettings.Properties.ActivationShortcut != value)
{
_peekSettings.Properties.ActivationShortcut = value;
_peekSettings.Properties.ActivationShortcut = value ?? _peekSettings.Properties.DefaultActivationShortcut;
OnPropertyChanged(nameof(ActivationShortcut));
NotifySettingsChanged();
}

View File

@@ -319,7 +319,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (settings.Properties.OpenPowerLauncher != value)
{
settings.Properties.OpenPowerLauncher = value;
settings.Properties.OpenPowerLauncher = value ?? settings.Properties.DefaultOpenPowerLauncher;
UpdateSettings();
}
}
@@ -455,7 +455,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (settings.Properties.OpenFileLocation != value)
{
settings.Properties.OpenFileLocation = value;
settings.Properties.OpenFileLocation = value ?? settings.Properties.DefaultOpenFileLocation;
UpdateSettings();
}
}
@@ -472,7 +472,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (settings.Properties.CopyPathLocation != value)
{
settings.Properties.CopyPathLocation = value;
settings.Properties.CopyPathLocation = value ?? settings.Properties.DefaultCopyPathLocation;
UpdateSettings();
}
}

View File

@@ -158,7 +158,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (_powerOcrSettings.Properties.ActivationShortcut != value)
{
_powerOcrSettings.Properties.ActivationShortcut = value;
_powerOcrSettings.Properties.ActivationShortcut = value ?? _powerOcrSettings.Properties.DefaultActivationShortcut;
OnPropertyChanged(nameof(ActivationShortcut));
_settingsUtils.SaveSettings(_powerOcrSettings.ToJsonString(), PowerOcrSettings.ModuleName);

View File

@@ -138,7 +138,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (Settings.Properties.OpenShortcutGuide != value)
{
Settings.Properties.OpenShortcutGuide = value;
Settings.Properties.OpenShortcutGuide = value ?? Settings.Properties.DefaultOpenShortcutGuide;
NotifyPropertyChanged();
}
}

View File

@@ -319,8 +319,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (value != _cameraAndMicrophoneMuteHotkey)
{
_cameraAndMicrophoneMuteHotkey = value;
Settings.Properties.MuteCameraAndMicrophoneHotkey.Value = value;
var hotkey = value ?? Settings.Properties.DefaultMuteCameraAndMicrophoneHotkey;
_cameraAndMicrophoneMuteHotkey = hotkey;
Settings.Properties.MuteCameraAndMicrophoneHotkey.Value = hotkey;
RaisePropertyChanged(nameof(CameraAndMicrophoneMuteHotkey));
}
}
@@ -337,8 +338,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (value != _microphoneMuteHotkey)
{
_microphoneMuteHotkey = value;
Settings.Properties.MuteMicrophoneHotkey.Value = value;
var hotkey = value ?? Settings.Properties.DefaultMuteMicrophoneHotkey;
_microphoneMuteHotkey = hotkey;
Settings.Properties.MuteMicrophoneHotkey.Value = hotkey;
RaisePropertyChanged(nameof(MicrophoneMuteHotkey));
}
}
@@ -355,8 +357,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (value != _microphonePushToTalkHotkey)
{
_microphonePushToTalkHotkey = value;
Settings.Properties.PushToTalkMicrophoneHotkey.Value = value;
var hotkey = value ?? Settings.Properties.DefaultMuteMicrophoneHotkey;
_microphonePushToTalkHotkey = hotkey;
Settings.Properties.PushToTalkMicrophoneHotkey.Value = hotkey;
RaisePropertyChanged(nameof(MicrophonePushToTalkHotkey));
}
}
@@ -391,8 +394,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (value != _cameraMuteHotkey)
{
_cameraMuteHotkey = value;
Settings.Properties.MuteCameraHotkey.Value = value;
var hotkey = value ?? Settings.Properties.DefaultMuteCameraHotkey;
_cameraMuteHotkey = hotkey;
Settings.Properties.MuteCameraHotkey.Value = hotkey;
RaisePropertyChanged(nameof(CameraMuteHotkey));
}
}