Files
PowerToys/src/modules/FileLocksmith/FileLocksmithExt/Settings.h
gokcekantarci 293b06d083 [File locksmith]Add setting to show only in extended context menu (#26711)
* [File Locksmith] Move File Locksmith "What's using this file?" into the extended context menu

* [File Locksmith] Add FileLocksmithExt to directory background context menu

* [File Locksmith]
* Directory background right click crash fixed.
*Settings added.

* [File Locksmith] Remove uncessary things.

* [File Locksmith] Spell check correction
2023-06-14 10:06:44 +01:00

57 lines
1.2 KiB
C++

#pragma once
#include "pch.h"
#include <common/utils/gpo.h>
class FileLocksmithSettings
{
public:
FileLocksmithSettings();
inline bool GetEnabled()
{
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;
Reload();
return settings.enabled;
}
inline void SetEnabled(bool enabled)
{
settings.enabled = enabled;
Save();
}
inline bool GetShowInExtendedContextMenu() const
{
return settings.showInExtendedContextMenu;
}
inline void SetExtendedContextMenuOnly(bool extendedOnly)
{
settings.showInExtendedContextMenu = extendedOnly;
}
void Save();
void Load();
private:
struct Settings
{
bool enabled{ true };
bool showInExtendedContextMenu{ false };
};
void Reload();
void ParseJson();
Settings settings;
std::wstring jsonFilePath;
FILETIME lastLoadedTime;
};
FileLocksmithSettings& FileLocksmithSettingsInstance();