Settings.h
 1  #pragma once
 2  
 3  #include "pch.h"
 4  #include <common/utils/gpo.h>
 5  
 6  class CSettings
 7  {
 8  public:
 9      CSettings();
10  
11      inline bool GetEnabled()
12      {
13          auto gpoSetting = powertoys_gpo::getConfiguredImageResizerEnabledValue();
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          RefreshEnabledState();
19          return settings.enabled;
20      }
21  
22      void Save();
23      void Load();
24  
25  private:
26      struct Settings
27      {
28          bool enabled{ true };
29      };
30  
31      void RefreshEnabledState();
32      void Reload();
33      void MigrateFromRegistry();
34      void ParseJson();
35  
36      Settings settings;
37      std::wstring jsonFilePath;
38      std::wstring generalJsonFilePath;
39      FILETIME lastLoadedTime;
40      FILETIME lastLoadedGeneralSettingsTime{};
41  };
42  
43  CSettings& CSettingsInstance();