Settings Flyout improvement (#43840)

<!-- 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
This pull request introduces the new Quick Access feature to PowerToys
by integrating its host process management into the runner and system
tray. The changes add the Quick Access host implementation, update
project and build files to include it, and modify the runner and tray
icon logic to launch and interact with the Quick Access UI.

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

- [x] Closes: #43694
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [x] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **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
<img width="290" height="420" alt="image"
src="https://github.com/user-attachments/assets/7390a706-171c-479f-a4a2-999b18cfc65f"
/>

<img width="290" height="420" alt="image"
src="https://github.com/user-attachments/assets/99e99bc9-b1a3-46c6-b648-81e3048dec1b"
/>

<img width="490" height="350" alt="image"
src="https://github.com/user-attachments/assets/2cce4ad6-a54e-4587-87b7-fdc7fba1f54f"
/>

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

---------

Signed-off-by: Shawn Yuan (from Dev Box) <shuaiyuan@microsoft.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
This commit is contained in:
Shawn Yuan
2026-01-07 16:38:09 +08:00
committed by GitHub
parent 19c9b4e1fd
commit 9086995eeb
89 changed files with 3916 additions and 1388 deletions

View File

@@ -31,7 +31,7 @@ using Windows.System.Profile;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public partial class GeneralViewModel : Observable
public partial class GeneralViewModel : PageViewModelBase
{
public enum InstallScope
{
@@ -39,6 +39,16 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
PerUser,
}
protected override string ModuleName => "GeneralSettings";
public override Dictionary<string, HotkeySettings[]> GetAllHotkeySettings()
{
return new Dictionary<string, HotkeySettings[]>
{
{ ModuleName, new HotkeySettings[] { QuickAccessShortcut } },
};
}
private GeneralSettings GeneralSettingsConfig { get; set; }
private UpdatingSettings UpdatingSettingsConfig { get; set; }
@@ -75,6 +85,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private string _settingsConfigFileFolder = string.Empty;
private ISettingsRepository<GeneralSettings> _settingsRepository;
private Microsoft.UI.Dispatching.DispatcherQueue _dispatcherQueue;
private IFileSystemWatcher _fileWatcher;
private Func<Task<string>> PickSingleFolderDialog { get; }
@@ -100,6 +113,10 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
// To obtain the general settings configuration of PowerToys if it exists, else to create a new file and return the default configurations.
ArgumentNullException.ThrowIfNull(settingsRepository);
_settingsRepository = settingsRepository;
_settingsRepository.SettingsChanged += OnSettingsChanged;
_dispatcherQueue = GetDispatcherQueue();
GeneralSettingsConfig = settingsRepository.SettingsConfig;
UpdatingSettingsConfig = UpdatingSettings.LoadSettings();
if (UpdatingSettingsConfig == null)
@@ -155,6 +172,12 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_isElevated = isElevated;
_runElevated = GeneralSettingsConfig.RunElevated;
_enableWarningsElevatedApps = GeneralSettingsConfig.EnableWarningsElevatedApps;
_enableQuickAccess = GeneralSettingsConfig.EnableQuickAccess;
_quickAccessShortcut = GeneralSettingsConfig.QuickAccessShortcut;
if (_quickAccessShortcut != null)
{
_quickAccessShortcut.PropertyChanged += QuickAccessShortcut_PropertyChanged;
}
RunningAsUserDefaultText = runAsUserText;
RunningAsAdminDefaultText = runAsAdminText;
@@ -236,6 +259,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private bool _runElevated;
private bool _isAdmin;
private bool _enableWarningsElevatedApps;
private bool _enableQuickAccess;
private HotkeySettings _quickAccessShortcut;
private int _themeIndex;
private bool _showNewUpdatesToastNotification;
@@ -480,6 +505,57 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
public bool EnableQuickAccess
{
get
{
return _enableQuickAccess;
}
set
{
if (_enableQuickAccess != value)
{
_enableQuickAccess = value;
GeneralSettingsConfig.EnableQuickAccess = value;
NotifyPropertyChanged();
}
}
}
public HotkeySettings QuickAccessShortcut
{
get
{
return _quickAccessShortcut;
}
set
{
if (_quickAccessShortcut != value)
{
if (_quickAccessShortcut != null)
{
_quickAccessShortcut.PropertyChanged -= QuickAccessShortcut_PropertyChanged;
}
_quickAccessShortcut = value;
if (_quickAccessShortcut != null)
{
_quickAccessShortcut.PropertyChanged += QuickAccessShortcut_PropertyChanged;
}
GeneralSettingsConfig.QuickAccessShortcut = value;
NotifyPropertyChanged();
}
}
}
private void QuickAccessShortcut_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
NotifyPropertyChanged(nameof(QuickAccessShortcut));
}
public bool SomeUpdateSettingsAreGpoManaged
{
get
@@ -1434,5 +1510,35 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
Process.Start("explorer.exe", etwDirPath);
}
}
private void OnSettingsChanged(GeneralSettings newSettings)
{
_dispatcherQueue?.TryEnqueue(() =>
{
GeneralSettingsConfig = newSettings;
if (_enableQuickAccess != newSettings.EnableQuickAccess)
{
_enableQuickAccess = newSettings.EnableQuickAccess;
OnPropertyChanged(nameof(EnableQuickAccess));
}
});
}
public override void Dispose()
{
base.Dispose();
if (_settingsRepository != null)
{
_settingsRepository.SettingsChanged -= OnSettingsChanged;
}
GC.SuppressFinalize(this);
}
protected virtual Microsoft.UI.Dispatching.DispatcherQueue GetDispatcherQueue()
{
return Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();
}
}
}