mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
* Add GPOWrapper headers and C++/WinRT library * Check GPO before starting utilities * Show message on GPO having disabled preview panes. * Don't generate thumbnails if GPO disabled * Fix FancyZonesEditor unable to recognize GPOWrapper * Move settings view models to the settings project * Use GPO to block enabling utilities in Settings * Hide context menu entries when gpo disables utilities * Apply gpo policies when enabling PowerToys on runner * Add version and metadata to dll * Add GPOWrapper to the installer * Fix MSBuild errors on WPF apps by using Projection * Signing * Add gpo files and publish them * Add GPO policies to the bug report tool * Add some documentation for using GPO * Mention support to actual lowest supported version of Windows * Move PowerToys to the root of administrative templates tree * Save policies on Software\Policies\PowerToys * Support both machine and user scopes * Fix documentation to reference computer and user scopes * Mention incompatibility with outlook in gpo * Set a better folder structure for gpo assets * Move PDF Handler warning to the description * Update doc/gpo/README.md Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com> * Add actual minimum version of PowerToys to gpo files * Fix identation * Remove GPOWrapper Readme * Add Active Directory instructions to doc Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
153 lines
3.3 KiB
C++
153 lines
3.3 KiB
C++
#pragma once
|
|
|
|
#include <common/utils/json.h>
|
|
#include <common/utils/gpo.h>
|
|
|
|
class CSettings
|
|
{
|
|
public:
|
|
CSettings();
|
|
|
|
inline bool GetEnabled()
|
|
{
|
|
auto gpoSetting = powertoys_gpo::getConfiguredPowerRenameEnabledValue();
|
|
if (gpoSetting == powertoys_gpo::gpo_rule_configured_enabled)
|
|
return true;
|
|
if (gpoSetting == powertoys_gpo::gpo_rule_configured_disabled)
|
|
return false;
|
|
Reload();
|
|
return settings.enabled;
|
|
}
|
|
|
|
inline void SetEnabled(bool enabled)
|
|
{
|
|
settings.enabled = enabled;
|
|
Save();
|
|
}
|
|
|
|
inline bool GetShowIconOnMenu() const
|
|
{
|
|
return settings.showIconOnMenu;
|
|
}
|
|
|
|
inline void SetShowIconOnMenu(bool show)
|
|
{
|
|
settings.showIconOnMenu = show;
|
|
}
|
|
|
|
inline bool GetExtendedContextMenuOnly() const
|
|
{
|
|
return settings.extendedContextMenuOnly;
|
|
}
|
|
|
|
inline void SetExtendedContextMenuOnly(bool extendedOnly)
|
|
{
|
|
settings.extendedContextMenuOnly = extendedOnly;
|
|
}
|
|
|
|
inline bool GetPersistState() const
|
|
{
|
|
return settings.persistState;
|
|
}
|
|
|
|
inline void SetPersistState(bool persistState)
|
|
{
|
|
settings.persistState = persistState;
|
|
}
|
|
|
|
inline bool GetUseBoostLib() const
|
|
{
|
|
return settings.useBoostLib;
|
|
}
|
|
|
|
inline void SetUseBoostLib(bool useBoostLib)
|
|
{
|
|
settings.useBoostLib = useBoostLib;
|
|
}
|
|
|
|
inline bool GetMRUEnabled() const
|
|
{
|
|
return settings.MRUEnabled;
|
|
}
|
|
|
|
inline void SetMRUEnabled(bool MRUEnabled)
|
|
{
|
|
settings.MRUEnabled = MRUEnabled;
|
|
}
|
|
|
|
inline unsigned int GetMaxMRUSize() const
|
|
{
|
|
return settings.maxMRUSize;
|
|
}
|
|
|
|
inline void SetMaxMRUSize(unsigned int maxMRUSize)
|
|
{
|
|
settings.maxMRUSize = maxMRUSize;
|
|
}
|
|
|
|
inline unsigned int GetFlags() const
|
|
{
|
|
return settings.flags;
|
|
}
|
|
|
|
inline void SetFlags(unsigned int flags)
|
|
{
|
|
settings.flags = flags;
|
|
WriteFlags();
|
|
}
|
|
|
|
inline const std::wstring& GetSearchText() const
|
|
{
|
|
return settings.searchText;
|
|
}
|
|
|
|
inline void SetSearchText(const std::wstring& text)
|
|
{
|
|
settings.searchText = text;
|
|
Save();
|
|
}
|
|
|
|
inline const std::wstring& GetReplaceText() const
|
|
{
|
|
return settings.replaceText;
|
|
}
|
|
|
|
inline void SetReplaceText(const std::wstring& text)
|
|
{
|
|
settings.replaceText = text;
|
|
Save();
|
|
}
|
|
|
|
void Save();
|
|
void Load();
|
|
|
|
private:
|
|
struct Settings
|
|
{
|
|
bool enabled{ true };
|
|
bool showIconOnMenu{ true };
|
|
bool extendedContextMenuOnly{ false }; // Disabled by default.
|
|
bool persistState{ true };
|
|
bool useBoostLib{ false }; // Disabled by default.
|
|
bool MRUEnabled{ true };
|
|
unsigned int maxMRUSize{ 10 };
|
|
unsigned int flags{ 0 };
|
|
std::wstring searchText{};
|
|
std::wstring replaceText{};
|
|
};
|
|
|
|
void Reload();
|
|
void MigrateFromRegistry();
|
|
void ParseJson();
|
|
|
|
void ReadFlags();
|
|
void WriteFlags();
|
|
|
|
Settings settings;
|
|
std::wstring jsonFilePath;
|
|
std::wstring UIFlagsFilePath;
|
|
FILETIME lastLoadedTime;
|
|
};
|
|
|
|
CSettings& CSettingsInstance();
|