Settings.h
 1  #pragma once
 2  
 3  #include "pch.h"
 4  #include <common/utils/gpo.h>
 5  
 6  class FileLocksmithSettings
 7  {
 8  public:
 9      FileLocksmithSettings();
10  
11      inline bool GetEnabled()
12      {
13          auto gpoSetting = powertoys_gpo::getConfiguredFileLocksmithEnabledValue();
14          if (gpoSetting == powertoys_gpo::gpo_rule_configured_enabled)
15              return true;
16          if (gpoSetting == powertoys_gpo::gpo_rule_configured_disabled)
17              return false;
18          Reload();
19          RefreshEnabledState();
20          return settings.enabled;
21      }
22  
23      inline bool GetShowInExtendedContextMenu() const
24      {
25          return settings.showInExtendedContextMenu;
26      }
27  
28      inline void SetExtendedContextMenuOnly(bool extendedOnly)
29      {
30          settings.showInExtendedContextMenu = extendedOnly;
31      }
32  
33      void Save();
34      void Load();
35  
36  private:
37      struct Settings
38      {
39          bool enabled{ true };
40          bool showInExtendedContextMenu{ false };
41      };
42  
43      void RefreshEnabledState();
44      void Reload();
45      void ParseJson();
46  
47      Settings settings;
48      std::wstring generalJsonFilePath;
49      std::wstring jsonFilePath;
50      FILETIME lastLoadedTime{};
51      FILETIME lastLoadedGeneralSettingsTime{};
52  };
53  
54  FileLocksmithSettings& FileLocksmithSettingsInstance();