Files
PowerToys/src/modules/FileLocksmith/FileLocksmithExt/Settings.h

46 lines
897 B
C
Raw Normal View History

2022-09-20 12:20:49 +02:00
#pragma once
#include "pch.h"
2022-10-26 16:19:56 +01:00
#include <common/utils/gpo.h>
2022-09-20 12:20:49 +02:00
class FileLocksmithSettings
{
public:
FileLocksmithSettings();
inline bool GetEnabled()
{
2022-10-26 16:19:56 +01:00
auto gpoSetting = powertoys_gpo::getConfiguredFileLocksmithEnabledValue();
if (gpoSetting == powertoys_gpo::gpo_rule_configured_enabled)
return true;
if (gpoSetting == powertoys_gpo::gpo_rule_configured_disabled)
return false;
2022-09-20 12:20:49 +02:00
Reload();
return settings.enabled;
}
inline void SetEnabled(bool enabled)
{
settings.enabled = enabled;
Save();
}
void Save();
void Load();
private:
struct Settings
{
bool enabled{ true };
};
void Reload();
void ParseJson();
Settings settings;
std::wstring jsonFilePath;
FILETIME lastLoadedTime;
};
FileLocksmithSettings& FileLocksmithSettingsInstance();