mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 22:40:05 +00:00
Refactor settings to be managed by singletons
This commit is contained in:
parent
acc782b2bc
commit
b66ca2cb09
21 changed files with 138 additions and 133 deletions
|
|
@ -16,10 +16,10 @@ namespace settings
|
|||
|
||||
static const std::string logPrefix_ = "scwx::qt::settings::general_settings";
|
||||
|
||||
class GeneralSettingsImpl
|
||||
class GeneralSettings::Impl
|
||||
{
|
||||
public:
|
||||
explicit GeneralSettingsImpl()
|
||||
explicit Impl()
|
||||
{
|
||||
std::string defaultDefaultAlertActionValue =
|
||||
types::GetAlertActionName(types::AlertAction::Go);
|
||||
|
|
@ -102,7 +102,7 @@ public:
|
|||
{ return !value.empty(); });
|
||||
}
|
||||
|
||||
~GeneralSettingsImpl() {}
|
||||
~Impl() {}
|
||||
|
||||
SettingsVariable<bool> debugEnabled_ {"debug_enabled"};
|
||||
SettingsVariable<std::string> defaultAlertAction_ {"default_alert_action"};
|
||||
|
|
@ -120,7 +120,7 @@ public:
|
|||
};
|
||||
|
||||
GeneralSettings::GeneralSettings() :
|
||||
SettingsCategory("general"), p(std::make_unique<GeneralSettingsImpl>())
|
||||
SettingsCategory("general"), p(std::make_unique<Impl>())
|
||||
{
|
||||
RegisterVariables({&p->debugEnabled_,
|
||||
&p->defaultAlertAction_,
|
||||
|
|
@ -221,6 +221,12 @@ bool GeneralSettings::Shutdown()
|
|||
return dataChanged;
|
||||
}
|
||||
|
||||
GeneralSettings& GeneralSettings::Instance()
|
||||
{
|
||||
static GeneralSettings generalSettings_;
|
||||
return generalSettings_;
|
||||
}
|
||||
|
||||
bool operator==(const GeneralSettings& lhs, const GeneralSettings& rhs)
|
||||
{
|
||||
return (lhs.p->debugEnabled_ == rhs.p->debugEnabled_ &&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue