[Settings]Theme override fix and cleanup (#32362)

* theme override fix and cleanup

* test fix
This commit is contained in:
Davide Giacometti
2024-04-17 16:39:19 +02:00
committed by GitHub
parent fba5f6f002
commit b14aa8276d
9 changed files with 89 additions and 129 deletions

View File

@@ -64,8 +64,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
UpdatingSettings updatingSettingsConfig = UpdatingSettings.LoadSettings();
UpdateAvailable = updatingSettingsConfig != null && (updatingSettingsConfig.State == UpdatingSettings.UpdatingState.ReadyToInstall || updatingSettingsConfig.State == UpdatingSettings.UpdatingState.ReadyToDownload);
App.UpdateUIThemeMethod(generalSettingsConfig.Theme);
}
private void AddDashboardListItem(ModuleType moduleType)

View File

@@ -7,7 +7,6 @@ using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Abstractions;
using System.Net.NetworkInformation;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.Json;
@@ -48,8 +47,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public ButtonClickCommand UpdateNowButtonEventHandler { get; set; }
public Func<string, int> UpdateUIThemeCallBack { get; }
public Func<string, int> SendConfigMSG { get; }
public Func<string, int> SendRestartAsAdminConfigMSG { get; }
@@ -68,7 +65,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private SettingsBackupAndRestoreUtils settingsBackupAndRestoreUtils = SettingsBackupAndRestoreUtils.Instance;
public GeneralViewModel(ISettingsRepository<GeneralSettings> settingsRepository, string runAsAdminText, string runAsUserText, bool isElevated, bool isAdmin, Func<string, int> updateTheme, Func<string, int> ipcMSGCallBackFunc, Func<string, int> ipcMSGRestartAsAdminMSGCallBackFunc, Func<string, int> ipcMSGCheckForUpdatesCallBackFunc, string configFileSubfolder = "", Action dispatcherAction = null, Action hideBackupAndRestoreMessageAreaAction = null, Action<int> doBackupAndRestoreDryRun = null, Func<Task<string>> pickSingleFolderDialog = null, object resourceLoader = null)
public GeneralViewModel(ISettingsRepository<GeneralSettings> settingsRepository, string runAsAdminText, string runAsUserText, bool isElevated, bool isAdmin, Func<string, int> ipcMSGCallBackFunc, Func<string, int> ipcMSGRestartAsAdminMSGCallBackFunc, Func<string, int> ipcMSGCheckForUpdatesCallBackFunc, string configFileSubfolder = "", Action dispatcherAction = null, Action hideBackupAndRestoreMessageAreaAction = null, Action<int> doBackupAndRestoreDryRun = null, Func<Task<string>> pickSingleFolderDialog = null, object resourceLoader = null)
{
CheckForUpdatesEventHandler = new ButtonClickCommand(CheckForUpdatesClick);
RestartElevatedButtonEventHandler = new ButtonClickCommand(RestartElevated);
@@ -97,9 +94,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
SendCheckForUpdatesConfigMSG = ipcMSGCheckForUpdatesCallBackFunc;
SendRestartAsAdminConfigMSG = ipcMSGRestartAsAdminMSGCallBackFunc;
// set the callback function value to update the UI theme.
UpdateUIThemeCallBack = updateTheme;
// Update Settings file folder:
_settingsConfigFileFolder = configFileSubfolder;
@@ -440,14 +434,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_themeIndex = value;
try
{
UpdateUIThemeCallBack(GeneralSettingsConfig.Theme);
}
catch (Exception e)
{
Logger.LogError("Exception encountered when changing Settings theme", e);
}
App.ThemeService.ApplyTheme();
NotifyPropertyChanged();
}