mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[settings] Show uneditable shortcut in CmdPal page (#38060)
* [settings] Show CmdPal shortcut * show in dashboard as well   As noted in #37908
This commit is contained in:
@@ -4,15 +4,19 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using global::PowerToys.GPOWrapper;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
||||
using Microsoft.PowerToys.Settings.UI.ViewModels.Commands;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Windows.Management.Deployment;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
@@ -21,12 +25,16 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
private GpoRuleConfigured _enabledGpoRuleConfiguration;
|
||||
private bool _isEnabled;
|
||||
private HotkeySettings _hotkey;
|
||||
private IFileSystemWatcher _watcher;
|
||||
private DispatcherQueue _uiDispatcherQueue;
|
||||
private CmdPalProperties _cmdPalProperties;
|
||||
|
||||
private GeneralSettings GeneralSettingsConfig { get; set; }
|
||||
|
||||
private Func<string, int> SendConfigMSG { get; }
|
||||
|
||||
public CmdPalViewModel(ISettingsUtils settingsUtils, ISettingsRepository<GeneralSettings> settingsRepository, Func<string, int> ipcMSGCallBackFunc)
|
||||
public CmdPalViewModel(ISettingsUtils settingsUtils, ISettingsRepository<GeneralSettings> settingsRepository, Func<string, int> ipcMSGCallBackFunc, DispatcherQueue uiDispatcherQueue)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(settingsUtils);
|
||||
|
||||
@@ -35,8 +43,32 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
GeneralSettingsConfig = settingsRepository.SettingsConfig;
|
||||
|
||||
_uiDispatcherQueue = uiDispatcherQueue;
|
||||
_cmdPalProperties = new CmdPalProperties();
|
||||
|
||||
InitializeEnabledValue();
|
||||
|
||||
var localAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
|
||||
#if DEBUG
|
||||
var settingsPath = Path.Combine(localAppDataDir, "Packages", "Microsoft.CommandPalette.Dev_8wekyb3d8bbwe", "LocalState", "settings.json");
|
||||
#else
|
||||
var settingsPath = Path.Combine(localAppDataDir, "Packages", "Microsoft.CommandPalette_8wekyb3d8bbwe", "LocalState", "settings.json");
|
||||
#endif
|
||||
|
||||
_hotkey = _cmdPalProperties.Hotkey;
|
||||
|
||||
_watcher = Helper.GetFileWatcher(settingsPath, () =>
|
||||
{
|
||||
_cmdPalProperties.InitializeHotkey();
|
||||
_hotkey = _cmdPalProperties.Hotkey;
|
||||
|
||||
_uiDispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
OnPropertyChanged(nameof(Hotkey));
|
||||
});
|
||||
});
|
||||
|
||||
// set the callback functions value to handle outgoing IPC message.
|
||||
SendConfigMSG = ipcMSGCallBackFunc;
|
||||
}
|
||||
@@ -82,6 +114,15 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public HotkeySettings Hotkey
|
||||
{
|
||||
get => _hotkey;
|
||||
|
||||
private set
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEnabledGpoConfigured { get; private set; }
|
||||
|
||||
public void RefreshEnabledState()
|
||||
|
||||
Reference in New Issue
Block a user