[Settings] Create a global static instance of SettingsUtils (#44064)

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

SettingsUtils is initialized multiple times over the whole solution.
This creates one singeltone instance (with the default settings), so it
only has to be initialized once (and improve performance a bit with
that)

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
This commit is contained in:
Noraa Junker
2025-12-08 04:55:51 +01:00
committed by GitHub
parent a37add8f08
commit 9439b6df41
84 changed files with 158 additions and 149 deletions

View File

@@ -133,7 +133,7 @@ namespace Microsoft.PowerToys.Settings.UI
var settingValue = cmdArgs[3];
try
{
SetSettingCommandLineCommand.Execute(settingName, settingValue, new SettingsUtils());
SetSettingCommandLineCommand.Execute(settingName, settingValue, SettingsUtils.Default);
}
catch (Exception ex)
{
@@ -151,7 +151,7 @@ namespace Microsoft.PowerToys.Settings.UI
{
using (var settings = JsonDocument.Parse(File.ReadAllText(ipcFileName)))
{
SetAdditionalSettingsCommandLineCommand.Execute(moduleName, settings, new SettingsUtils());
SetAdditionalSettingsCommandLineCommand.Execute(moduleName, settings, SettingsUtils.Default);
}
}
catch (Exception ex)
@@ -357,7 +357,7 @@ namespace Microsoft.PowerToys.Settings.UI
return 0;
}
private static ISettingsUtils settingsUtils = new SettingsUtils();
private static ISettingsUtils settingsUtils = SettingsUtils.Default;
private static ThemeService themeService = new ThemeService(SettingsRepository<GeneralSettings>.GetInstance(settingsUtils));
public static ThemeService ThemeService => themeService;

View File

@@ -26,7 +26,7 @@ namespace Microsoft.PowerToys.Settings.UI.SettingsXAML.Controls.Dashboard
public ShortcutConflictWindow()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new ShortcutConflictViewModel(
settingsUtils,
SettingsRepository<GeneralSettings>.GetInstance(settingsUtils),

View File

@@ -24,7 +24,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
{
this.InitializeComponent();
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new AllAppsViewModel(SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), Views.ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;
}

View File

@@ -27,7 +27,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
public LaunchPage()
{
this.InitializeComponent();
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new LauncherViewModel(SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), Views.ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;
}
@@ -51,7 +51,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
break;
case ModuleType.EnvironmentVariables: // Launch Environment Variables
{
bool launchAdmin = SettingsRepository<EnvironmentVariablesSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.LaunchAdministrator;
bool launchAdmin = SettingsRepository<EnvironmentVariablesSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.LaunchAdministrator;
string eventName = !App.IsElevated && launchAdmin
? Constants.ShowEnvironmentVariablesAdminSharedEvent()
: Constants.ShowEnvironmentVariablesSharedEvent();
@@ -74,7 +74,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
case ModuleType.Hosts: // Launch Hosts
{
bool launchAdmin = SettingsRepository<HostsSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.LaunchAdministrator;
bool launchAdmin = SettingsRepository<HostsSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.LaunchAdministrator;
string eventName = !App.IsElevated && launchAdmin
? Constants.ShowHostsAdminSharedEvent()
: Constants.ShowHostsSharedEvent();

View File

@@ -81,7 +81,7 @@ namespace Microsoft.PowerToys.Settings.UI
// open main window
ShellPage.SetUpdatingGeneralSettingsCallback((ModuleType moduleType, bool isEnabled) =>
{
SettingsRepository<GeneralSettings> repository = SettingsRepository<GeneralSettings>.GetInstance(new SettingsUtils());
SettingsRepository<GeneralSettings> repository = SettingsRepository<GeneralSettings>.GetInstance(SettingsUtils.Default);
GeneralSettings generalSettingsConfig = repository.SettingsConfig;
bool needToUpdate = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, moduleType) != isEnabled;

View File

@@ -35,9 +35,9 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.LogOpeningModuleEvent();
AdvancedPasteUIHotkeyControl.Keys = SettingsRepository<AdvancedPasteSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.AdvancedPasteUIShortcut.GetKeysList();
PasteAsPlainTextHotkeyControl.Keys = SettingsRepository<AdvancedPasteSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.PasteAsPlainTextShortcut.GetKeysList();
PasteAsMarkdownHotkeyControl.Keys = SettingsRepository<AdvancedPasteSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.PasteAsMarkdownShortcut.GetKeysList();
AdvancedPasteUIHotkeyControl.Keys = SettingsRepository<AdvancedPasteSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.AdvancedPasteUIShortcut.GetKeysList();
PasteAsPlainTextHotkeyControl.Keys = SettingsRepository<AdvancedPasteSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.PasteAsPlainTextShortcut.GetKeysList();
PasteAsMarkdownHotkeyControl.Keys = SettingsRepository<AdvancedPasteSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.PasteAsMarkdownShortcut.GetKeysList();
// TODO(stefan): Check how to remove additional space if item is set to Collapsed.
if (PasteAsMarkdownHotkeyControl.Keys.Count > 0)
@@ -45,7 +45,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
PasteAsMarkdownHotkeyControl.Visibility = Microsoft.UI.Xaml.Visibility.Visible;
}
PasteAsJsonHotkeyControl.Keys = SettingsRepository<AdvancedPasteSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.PasteAsJsonShortcut.GetKeysList();
PasteAsJsonHotkeyControl.Keys = SettingsRepository<AdvancedPasteSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.PasteAsJsonShortcut.GetKeysList();
if (PasteAsJsonHotkeyControl.Keys.Count > 0)
{
PasteAsJsonHotkeyControl.Visibility = Microsoft.UI.Xaml.Visibility.Visible;

View File

@@ -35,7 +35,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.LogOpeningModuleEvent();
HotkeyControl.Keys = SettingsRepository<AlwaysOnTopSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.Hotkey.Value.GetKeysList();
HotkeyControl.Keys = SettingsRepository<AlwaysOnTopSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.Hotkey.Value.GetKeysList();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)

View File

@@ -50,7 +50,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.LogOpeningModuleEvent();
ColorPickerSettings settings = new SettingsUtils().GetSettingsOrDefault<ColorPickerSettings, ColorPickerSettingsVersion1>(ColorPickerSettings.ModuleName, settingsUpgrader: ColorPickerSettings.UpgradeSettings);
ColorPickerSettings settings = SettingsUtils.Default.GetSettingsOrDefault<ColorPickerSettings, ColorPickerSettingsVersion1>(ColorPickerSettings.ModuleName, settingsUpgrader: ColorPickerSettings.UpgradeSettings);
HotkeyControl.Keys = settings.Properties.ActivationShortcut.GetKeysList();
}

View File

@@ -35,8 +35,8 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.LogOpeningModuleEvent();
ReparentHotkeyControl.Keys = SettingsRepository<CropAndLockSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ReparentHotkey.Value.GetKeysList();
ThumbnailHotkeyControl.Keys = SettingsRepository<CropAndLockSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ThumbnailHotkey.Value.GetKeysList();
ReparentHotkeyControl.Keys = SettingsRepository<CropAndLockSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.ReparentHotkey.Value.GetKeysList();
ThumbnailHotkeyControl.Keys = SettingsRepository<CropAndLockSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.ThumbnailHotkey.Value.GetKeysList();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)

View File

@@ -37,7 +37,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private void Launch_EnvironmentVariables_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
bool launchAdmin = SettingsRepository<EnvironmentVariablesSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.LaunchAdministrator;
bool launchAdmin = SettingsRepository<EnvironmentVariablesSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.LaunchAdministrator;
string eventName = !App.IsElevated && launchAdmin
? Constants.ShowEnvironmentVariablesAdminSharedEvent()
: Constants.ShowEnvironmentVariablesSharedEvent();

View File

@@ -35,7 +35,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.LogOpeningModuleEvent();
HotkeyControl.Keys = SettingsRepository<FancyZonesSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.FancyzonesEditorHotkey.Value.GetKeysList();
HotkeyControl.Keys = SettingsRepository<FancyZonesSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.FancyzonesEditorHotkey.Value.GetKeysList();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)

View File

@@ -37,7 +37,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private void Launch_Hosts_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
bool launchAdmin = SettingsRepository<HostsSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.LaunchAdministrator;
bool launchAdmin = SettingsRepository<HostsSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.LaunchAdministrator;
string eventName = !App.IsElevated && launchAdmin
? Constants.ShowHostsAdminSharedEvent()
: Constants.ShowHostsSharedEvent();

View File

@@ -38,7 +38,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.LogOpeningModuleEvent();
HotkeyActivation.Keys = SettingsRepository<MeasureToolSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.GetKeysList();
HotkeyActivation.Keys = SettingsRepository<MeasureToolSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.ActivationShortcut.GetKeysList();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)

View File

@@ -21,10 +21,10 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.Overview]);
DataContext = ViewModel;
FancyZonesHotkeyControl.Keys = SettingsRepository<FancyZonesSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.FancyzonesEditorHotkey.Value.GetKeysList();
RunHotkeyControl.Keys = SettingsRepository<PowerLauncherSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.OpenPowerLauncher.GetKeysList();
ColorPickerHotkeyControl.Keys = SettingsRepository<ColorPickerSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.GetKeysList();
AlwaysOnTopHotkeyControl.Keys = SettingsRepository<AlwaysOnTopSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.Hotkey.Value.GetKeysList();
FancyZonesHotkeyControl.Keys = SettingsRepository<FancyZonesSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.FancyzonesEditorHotkey.Value.GetKeysList();
RunHotkeyControl.Keys = SettingsRepository<PowerLauncherSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.OpenPowerLauncher.GetKeysList();
ColorPickerHotkeyControl.Keys = SettingsRepository<ColorPickerSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.ActivationShortcut.GetKeysList();
AlwaysOnTopHotkeyControl.Keys = SettingsRepository<AlwaysOnTopSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.Hotkey.Value.GetKeysList();
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)

View File

@@ -38,7 +38,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.LogOpeningModuleEvent();
HotkeyControl.Keys = SettingsRepository<PeekSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.GetKeysList();
HotkeyControl.Keys = SettingsRepository<PeekSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.ActivationShortcut.GetKeysList();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)

View File

@@ -35,7 +35,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.LogOpeningModuleEvent();
HotkeyControl.Keys = SettingsRepository<PowerOcrSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.GetKeysList();
HotkeyControl.Keys = SettingsRepository<PowerOcrSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.ActivationShortcut.GetKeysList();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)

View File

@@ -54,7 +54,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
ViewModel.LogOpeningModuleEvent();
HotkeyControl.Keys = SettingsRepository<PowerLauncherSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.OpenPowerLauncher.GetKeysList();
HotkeyControl.Keys = SettingsRepository<PowerLauncherSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.OpenPowerLauncher.GetKeysList();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)

View File

@@ -51,7 +51,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public ObservableCollection<OobePowerToysModule> Modules { get; }
private static ISettingsUtils settingsUtils = new SettingsUtils();
private static ISettingsUtils settingsUtils = SettingsUtils.Default;
/* NOTE: Experimentation for OOBE is currently turned off on server side. Keeping this code in a comment to allow future experiments.
private bool ExperimentationToggleSwitchEnabled { get; set; } = true;

View File

@@ -56,7 +56,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.LogOpeningModuleEvent();
var settingsProperties = SettingsRepository<ShortcutGuideSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties;
var settingsProperties = SettingsRepository<ShortcutGuideSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties;
if ((bool)settingsProperties.UseLegacyPressWinKeyBehavior.Value)
{

View File

@@ -38,7 +38,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.LogOpeningModuleEvent();
HotkeyControl.Keys = SettingsRepository<WorkspacesSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.Hotkey.Value.GetKeysList();
HotkeyControl.Keys = SettingsRepository<WorkspacesSettings>.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.Hotkey.Value.GetKeysList();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)

View File

@@ -44,7 +44,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public AdvancedPastePage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new AdvancedPasteViewModel(
settingsUtils,
SettingsRepository<GeneralSettings>.GetInstance(settingsUtils),

View File

@@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public AlwaysOnTopPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new AlwaysOnTopViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), SettingsRepository<AlwaysOnTopSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;
InitializeComponent();

View File

@@ -36,7 +36,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
_dispatcherQueue = DispatcherQueue.GetForCurrentThread();
_fileSystem = new FileSystem();
_settingsUtils = new SettingsUtils();
_settingsUtils = SettingsUtils.Default;
_sendConfigMsg = ShellPage.SendDefaultIPCMessage;
ViewModel = new AwakeViewModel();

View File

@@ -19,7 +19,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public CmdPalPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new CmdPalViewModel(
settingsUtils,
SettingsRepository<GeneralSettings>.GetInstance(settingsUtils),

View File

@@ -27,7 +27,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public ColorPickerPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new ColorPickerViewModel(
settingsUtils,
SettingsRepository<GeneralSettings>.GetInstance(settingsUtils),

View File

@@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public CropAndLockPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new CropAndLockViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), SettingsRepository<CropAndLockSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;
InitializeComponent();

View File

@@ -34,7 +34,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public DashboardPage()
{
InitializeComponent();
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new DashboardViewModel(
SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage);

View File

@@ -16,7 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public EnvironmentVariablesPage()
{
InitializeComponent();
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new EnvironmentVariablesViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), SettingsRepository<EnvironmentVariablesSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, App.IsElevated);
}

View File

@@ -16,7 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public FancyZonesPage()
{
InitializeComponent();
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new FancyZonesViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), SettingsRepository<FancyZonesSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;
Loaded += (s, e) => ViewModel.OnPageLoaded();

View File

@@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public FileLocksmithPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new FileLocksmithViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;
InitializeComponent();

View File

@@ -38,7 +38,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
// Load string resources
var loader = Helpers.ResourceLoaderInstance.ResourceLoader;
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
Action stateUpdatingAction = () =>
{

View File

@@ -16,7 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public HostsPage()
{
InitializeComponent();
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new HostsViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), SettingsRepository<HostsSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, App.IsElevated);
BackupsCountInputSettingsCard.Header = ResourceLoaderInstance.ResourceLoader.GetString("Hosts_Backup_CountInput_Header");
BackupsCountInputSettingsCard.Description = ResourceLoaderInstance.ResourceLoader.GetString("Hosts_Backup_CountInput_Description");

View File

@@ -21,7 +21,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public ImageResizerPage()
{
InitializeComponent();
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
var resourceLoader = ResourceLoaderInstance.ResourceLoader;
Func<string, string> loader = resourceLoader.GetString;

View File

@@ -28,7 +28,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public KeyboardManagerPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new KeyboardManagerViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, FilterRemapKeysList);
watcher = Helper.GetFileWatcher(

View File

@@ -40,7 +40,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public LightSwitchPage()
{
this.settingsUtils = new SettingsUtils();
this.settingsUtils = SettingsUtils.Default;
this.sendConfigMsg = ShellPage.SendDefaultIPCMessage;
this.generalSettingsRepository = SettingsRepository<GeneralSettings>.GetInstance(this.settingsUtils);

View File

@@ -17,7 +17,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public MeasureToolPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new MeasureToolViewModel(
settingsUtils,
SettingsRepository<GeneralSettings>.GetInstance(settingsUtils),

View File

@@ -22,7 +22,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
// By mistake, the first release of Find My Mouse was saving settings in two places at the same time.
// Delete the wrong path for Find My Mouse settings.
var tempSettingsUtils = new SettingsUtils();
var tempSettingsUtils = SettingsUtils.Default;
if (tempSettingsUtils.SettingsExists("Find My Mouse"))
{
var settingsFilePath = tempSettingsUtils.GetSettingsFilePath("Find My Mouse");
@@ -34,7 +34,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
}
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new MouseUtilsViewModel(
settingsUtils,
SettingsRepository<GeneralSettings>.GetInstance(settingsUtils),

View File

@@ -33,7 +33,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public MouseWithoutBordersPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new MouseWithoutBordersViewModel(
settingsUtils,
SettingsRepository<GeneralSettings>.GetInstance(settingsUtils),

View File

@@ -16,7 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public NewPlusPage()
{
InitializeComponent();
var settings_utils = new SettingsUtils();
var settings_utils = SettingsUtils.Default;
ViewModel = new NewPlusViewModel(settings_utils, SettingsRepository<GeneralSettings>.GetInstance(settings_utils), ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;
}

View File

@@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public PeekPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new PeekViewModel(
settingsUtils,
SettingsRepository<GeneralSettings>.GetInstance(settingsUtils),

View File

@@ -17,7 +17,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public PowerAccentPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new PowerAccentViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;
this.InitializeComponent();

View File

@@ -34,7 +34,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public PowerLauncherPage()
{
InitializeComponent();
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
_lastIPCMessageSentTick = Environment.TickCount;
PowerLauncherSettings settings = SettingsRepository<PowerLauncherSettings>.GetInstance(settingsUtils)?.SettingsConfig;

View File

@@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public PowerOcrPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new PowerOcrViewModel(
settingsUtils,
SettingsRepository<GeneralSettings>.GetInstance(settingsUtils),

View File

@@ -19,7 +19,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public PowerPreviewPage()
{
InitializeComponent();
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new PowerPreviewViewModel(SettingsRepository<PowerPreviewSettings>.GetInstance(settingsUtils), SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;
}

View File

@@ -16,7 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public PowerRenamePage()
{
InitializeComponent();
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new PowerRenameViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;

View File

@@ -14,7 +14,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public RegistryPreviewPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new RegistryPreviewViewModel(
SettingsRepository<GeneralSettings>.GetInstance(settingsUtils),
SettingsRepository<RegistryPreviewSettings>.GetInstance(settingsUtils),

View File

@@ -151,7 +151,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
InitializeComponent();
SetWindowTitle();
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new ShellViewModel(SettingsRepository<GeneralSettings>.GetInstance(settingsUtils));
DataContext = ViewModel;
ShellHandler = this;

View File

@@ -17,7 +17,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
InitializeComponent();
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new ShortcutGuideViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), SettingsRepository<ShortcutGuideSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;

View File

@@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public WorkspacesPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new WorkspacesViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), SettingsRepository<WorkspacesSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;
InitializeComponent();

View File

@@ -104,7 +104,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public ZoomItPage()
{
var settingsUtils = new SettingsUtils();
var settingsUtils = SettingsUtils.Default;
ViewModel = new ZoomItViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, PickFileDialog, PickFontDialog);
DataContext = ViewModel;
InitializeComponent();