diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/GeneralViewModel.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/GeneralViewModel.cs index 8c9befc026..f9f98a4c0b 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/GeneralViewModel.cs +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/GeneralViewModel.cs @@ -265,65 +265,27 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels { if (_themeIndex != value) { - if (value == 0) + switch (value) { - // set theme to dark. - GeneralSettingsConfig.Theme = "dark"; - _themeIndex = value; - - try - { - UpdateUIThemeCallBack(GeneralSettingsConfig.Theme); - } -#pragma warning disable CA1031 // Do not catch general exception types - catch (Exception e) -#pragma warning restore CA1031 // Do not catch general exception types - { - Logger.LogError("Exception encountered when changing Settings theme", e); - } - - NotifyPropertyChanged(); + case 0: GeneralSettingsConfig.Theme = "dark"; break; + case 1: GeneralSettingsConfig.Theme = "light"; break; + case 2: GeneralSettingsConfig.Theme = "system"; break; } - if (value == 1) + _themeIndex = value; + + try { - // set theme to light. - GeneralSettingsConfig.Theme = "light"; - _themeIndex = value; - - try - { - UpdateUIThemeCallBack(GeneralSettingsConfig.Theme); - } + UpdateUIThemeCallBack(GeneralSettingsConfig.Theme); + } #pragma warning disable CA1031 // Do not catch general exception types - catch (Exception e) + catch (Exception e) #pragma warning restore CA1031 // Do not catch general exception types - { - Logger.LogError("Exception encountered when changing Settings theme", e); - } - - NotifyPropertyChanged(); + { + Logger.LogError("Exception encountered when changing Settings theme", e); } - if (value == 2) - { - // set theme to system default. - GeneralSettingsConfig.Theme = "system"; - _themeIndex = value; - - try - { - UpdateUIThemeCallBack(GeneralSettingsConfig.Theme); - } -#pragma warning disable CA1031 // Do not catch general exception types - catch (Exception e) -#pragma warning restore CA1031 // Do not catch general exception types - { - Logger.LogError("Exception encountered when changing Settings theme", e); - } - - NotifyPropertyChanged(); - } + NotifyPropertyChanged(); } } } diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/PowerLauncherViewModel.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/PowerLauncherViewModel.cs index f1cc292784..bedf317679 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/PowerLauncherViewModel.cs +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/PowerLauncherViewModel.cs @@ -197,32 +197,15 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels set { - if (_themeIndex != value) + switch (value) { - if (value == 0) - { - // set theme to dark. - settings.Properties.Theme = Theme.Dark; - _themeIndex = value; - 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(); - } + case 0: settings.Properties.Theme = Theme.Dark; break; + case 1: settings.Properties.Theme = Theme.Light; break; + case 2: settings.Properties.Theme = Theme.System; break; } + + _themeIndex = value; + UpdateSettings(); } } @@ -237,23 +220,15 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels { if (_monitorPositionIndex != value) { - if (value == 0) + switch (value) { - settings.Properties.Position = StartupPosition.Cursor; - UpdateSettings(); + case 0: settings.Properties.Position = StartupPosition.Cursor; break; + case 1: settings.Properties.Position = StartupPosition.PrimaryMonitor; break; + case 2: settings.Properties.Position = StartupPosition.Focus; break; } - if (value == 1) - { - settings.Properties.Position = StartupPosition.PrimaryMonitor; - UpdateSettings(); - } - - if (value == 2) - { - settings.Properties.Position = StartupPosition.Focus; - UpdateSettings(); - } + _monitorPositionIndex = value; + UpdateSettings(); } } } diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/ShortcutGuideViewModel.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/ShortcutGuideViewModel.cs index be2faed406..50720a3e33 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/ShortcutGuideViewModel.cs +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/ShortcutGuideViewModel.cs @@ -56,21 +56,11 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels _opacity = Settings.Properties.OverlayOpacity.Value; _disabledApps = Settings.Properties.DisabledApps.Value; - string theme = Settings.Properties.Theme.Value; - - if (theme == "dark") + switch (Settings.Properties.Theme.Value) { - _themeIndex = 0; - } - - if (theme == "light") - { - _themeIndex = 1; - } - - if (theme == "system") - { - _themeIndex = 2; + case "dark": _themeIndex = 0; break; + case "light": _themeIndex = 1; break; + case "system": _themeIndex = 2; break; } } @@ -130,29 +120,15 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels { if (_themeIndex != value) { - if (value == 0) + switch (value) { - // set theme to dark. - Settings.Properties.Theme.Value = "dark"; - _themeIndex = value; - NotifyPropertyChanged(); + case 0: Settings.Properties.Theme.Value = "dark"; break; + case 1: Settings.Properties.Theme.Value = "light"; break; + case 2: Settings.Properties.Theme.Value = "system"; break; } - if (value == 1) - { - // set theme to light. - Settings.Properties.Theme.Value = "light"; - _themeIndex = value; - NotifyPropertyChanged(); - } - - if (value == 2) - { - // set theme to system default. - Settings.Properties.Theme.Value = "system"; - _themeIndex = value; - NotifyPropertyChanged(); - } + _themeIndex = value; + NotifyPropertyChanged(); } } } diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw index cde78cc859..fe14c58585 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw @@ -272,7 +272,7 @@ Disabling this module or closing PowerToys will unmute the microphone and camera Remap a key Keyboard Manager remap keyboard button content - + Keys Keyboard Manager remap keyboard header @@ -280,7 +280,7 @@ Disabling this module or closing PowerToys will unmute the microphone and camera Remap a shortcut Keyboard Manager remap shortcuts button - + Shortcuts Keyboard Manager remap keyboard header @@ -413,7 +413,7 @@ Disabling this module or closing PowerToys will unmute the microphone and camera Excluded apps - Excludes an application from snappting to zones and will only react to Windows Snap. Add one application name per line. + Excludes an application from snapping to zones and will only react to Windows Snap. Add one application name per line. Zone opacity @@ -950,7 +950,7 @@ Made with 💗 by Microsoft and the PowerToys community. Picker behavior - + This format will be copied to your clipboard @@ -969,9 +969,8 @@ Made with 💗 by Microsoft and the PowerToys community. Windows - refers to a set of windows, not the product name + refers to a set of windows, not the product name - Behavior @@ -999,16 +998,16 @@ Made with 💗 by Microsoft and the PowerToys community. Color formats - + Select which color formats (and in what order) should show up in the editor - + Move up - + Move down - + Show color name when color picking @@ -1129,7 +1128,6 @@ Made with 💗 by Microsoft and the PowerToys community. You can configure layout-specific shortcuts in the editor - Quick layout switch