mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 19:10:06 +00:00
Add UI settings for collapsible groups
This commit is contained in:
parent
af650c6687
commit
1e4e2ba1b4
5 changed files with 162 additions and 3 deletions
|
|
@ -121,7 +121,8 @@ set(HDR_SETTINGS source/scwx/qt/settings/general_settings.hpp
|
||||||
source/scwx/qt/settings/settings_interface.hpp
|
source/scwx/qt/settings/settings_interface.hpp
|
||||||
source/scwx/qt/settings/settings_interface_base.hpp
|
source/scwx/qt/settings/settings_interface_base.hpp
|
||||||
source/scwx/qt/settings/settings_variable.hpp
|
source/scwx/qt/settings/settings_variable.hpp
|
||||||
source/scwx/qt/settings/settings_variable_base.hpp)
|
source/scwx/qt/settings/settings_variable_base.hpp
|
||||||
|
source/scwx/qt/settings/ui_settings.hpp)
|
||||||
set(SRC_SETTINGS source/scwx/qt/settings/general_settings.cpp
|
set(SRC_SETTINGS source/scwx/qt/settings/general_settings.cpp
|
||||||
source/scwx/qt/settings/map_settings.cpp
|
source/scwx/qt/settings/map_settings.cpp
|
||||||
source/scwx/qt/settings/palette_settings.cpp
|
source/scwx/qt/settings/palette_settings.cpp
|
||||||
|
|
@ -130,7 +131,8 @@ set(SRC_SETTINGS source/scwx/qt/settings/general_settings.cpp
|
||||||
source/scwx/qt/settings/settings_interface.cpp
|
source/scwx/qt/settings/settings_interface.cpp
|
||||||
source/scwx/qt/settings/settings_interface_base.cpp
|
source/scwx/qt/settings/settings_interface_base.cpp
|
||||||
source/scwx/qt/settings/settings_variable.cpp
|
source/scwx/qt/settings/settings_variable.cpp
|
||||||
source/scwx/qt/settings/settings_variable_base.cpp)
|
source/scwx/qt/settings/settings_variable_base.cpp
|
||||||
|
source/scwx/qt/settings/ui_settings.cpp)
|
||||||
set(HDR_TYPES source/scwx/qt/types/alert_types.hpp
|
set(HDR_TYPES source/scwx/qt/types/alert_types.hpp
|
||||||
source/scwx/qt/types/font_types.hpp
|
source/scwx/qt/types/font_types.hpp
|
||||||
source/scwx/qt/types/github_types.hpp
|
source/scwx/qt/types/github_types.hpp
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <scwx/qt/manager/settings_manager.hpp>
|
#include <scwx/qt/manager/settings_manager.hpp>
|
||||||
#include <scwx/qt/map/map_provider.hpp>
|
#include <scwx/qt/map/map_provider.hpp>
|
||||||
|
#include <scwx/qt/settings/ui_settings.hpp>
|
||||||
#include <scwx/qt/util/json.hpp>
|
#include <scwx/qt/util/json.hpp>
|
||||||
#include <scwx/util/logger.hpp>
|
#include <scwx/util/logger.hpp>
|
||||||
|
|
||||||
|
|
@ -96,6 +97,7 @@ void Shutdown()
|
||||||
|
|
||||||
dataChanged |= general_settings().Shutdown();
|
dataChanged |= general_settings().Shutdown();
|
||||||
dataChanged |= map_settings().Shutdown();
|
dataChanged |= map_settings().Shutdown();
|
||||||
|
dataChanged |= settings::UiSettings::Instance().Shutdown();
|
||||||
|
|
||||||
if (dataChanged)
|
if (dataChanged)
|
||||||
{
|
{
|
||||||
|
|
@ -128,6 +130,7 @@ static boost::json::value ConvertSettingsToJson()
|
||||||
general_settings().WriteJson(settingsJson);
|
general_settings().WriteJson(settingsJson);
|
||||||
map_settings().WriteJson(settingsJson);
|
map_settings().WriteJson(settingsJson);
|
||||||
palette_settings().WriteJson(settingsJson);
|
palette_settings().WriteJson(settingsJson);
|
||||||
|
settings::UiSettings::Instance().WriteJson(settingsJson);
|
||||||
|
|
||||||
return settingsJson;
|
return settingsJson;
|
||||||
}
|
}
|
||||||
|
|
@ -139,6 +142,7 @@ static void GenerateDefaultSettings()
|
||||||
general_settings().SetDefaults();
|
general_settings().SetDefaults();
|
||||||
map_settings().SetDefaults();
|
map_settings().SetDefaults();
|
||||||
palette_settings().SetDefaults();
|
palette_settings().SetDefaults();
|
||||||
|
settings::UiSettings::Instance().SetDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool LoadSettings(const boost::json::object& settingsJson)
|
static bool LoadSettings(const boost::json::object& settingsJson)
|
||||||
|
|
@ -150,6 +154,7 @@ static bool LoadSettings(const boost::json::object& settingsJson)
|
||||||
jsonDirty |= !general_settings().ReadJson(settingsJson);
|
jsonDirty |= !general_settings().ReadJson(settingsJson);
|
||||||
jsonDirty |= !map_settings().ReadJson(settingsJson);
|
jsonDirty |= !map_settings().ReadJson(settingsJson);
|
||||||
jsonDirty |= !palette_settings().ReadJson(settingsJson);
|
jsonDirty |= !palette_settings().ReadJson(settingsJson);
|
||||||
|
jsonDirty |= !settings::UiSettings::Instance().ReadJson(settingsJson);
|
||||||
|
|
||||||
return jsonDirty;
|
return jsonDirty;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
104
scwx-qt/source/scwx/qt/settings/ui_settings.cpp
Normal file
104
scwx-qt/source/scwx/qt/settings/ui_settings.cpp
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
#include <scwx/qt/settings/ui_settings.hpp>
|
||||||
|
|
||||||
|
namespace scwx
|
||||||
|
{
|
||||||
|
namespace qt
|
||||||
|
{
|
||||||
|
namespace settings
|
||||||
|
{
|
||||||
|
|
||||||
|
static const std::string logPrefix_ = "scwx::qt::settings::ui_settings";
|
||||||
|
|
||||||
|
class UiSettingsImpl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit UiSettingsImpl()
|
||||||
|
{
|
||||||
|
level2ProductsExpanded_.SetDefault(false);
|
||||||
|
level2SettingsExpanded_.SetDefault(true);
|
||||||
|
level3ProductsExpanded_.SetDefault(true);
|
||||||
|
mapSettingsExpanded_.SetDefault(true);
|
||||||
|
timelineExpanded_.SetDefault(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
~UiSettingsImpl() {}
|
||||||
|
|
||||||
|
SettingsVariable<bool> level2ProductsExpanded_ {"level2_products_expanded"};
|
||||||
|
SettingsVariable<bool> level2SettingsExpanded_ {"level2_settings_expanded"};
|
||||||
|
SettingsVariable<bool> level3ProductsExpanded_ {"level3_products_expanded"};
|
||||||
|
SettingsVariable<bool> mapSettingsExpanded_ {"map_settings_expanded"};
|
||||||
|
SettingsVariable<bool> timelineExpanded_ {"timeline_expanded"};
|
||||||
|
};
|
||||||
|
|
||||||
|
UiSettings::UiSettings() :
|
||||||
|
SettingsCategory("ui"), p(std::make_unique<UiSettingsImpl>())
|
||||||
|
{
|
||||||
|
RegisterVariables({&p->level2ProductsExpanded_,
|
||||||
|
&p->level2SettingsExpanded_,
|
||||||
|
&p->level3ProductsExpanded_,
|
||||||
|
&p->mapSettingsExpanded_,
|
||||||
|
&p->timelineExpanded_});
|
||||||
|
SetDefaults();
|
||||||
|
}
|
||||||
|
UiSettings::~UiSettings() = default;
|
||||||
|
|
||||||
|
UiSettings::UiSettings(UiSettings&&) noexcept = default;
|
||||||
|
UiSettings& UiSettings::operator=(UiSettings&&) noexcept = default;
|
||||||
|
|
||||||
|
SettingsVariable<bool>& UiSettings::level2_products_expanded() const
|
||||||
|
{
|
||||||
|
return p->level2ProductsExpanded_;
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsVariable<bool>& UiSettings::level2_settings_expanded() const
|
||||||
|
{
|
||||||
|
return p->level2SettingsExpanded_;
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsVariable<bool>& UiSettings::level3_products_expanded() const
|
||||||
|
{
|
||||||
|
return p->level3ProductsExpanded_;
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsVariable<bool>& UiSettings::map_settings_expanded() const
|
||||||
|
{
|
||||||
|
return p->mapSettingsExpanded_;
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsVariable<bool>& UiSettings::timeline_expanded() const
|
||||||
|
{
|
||||||
|
return p->timelineExpanded_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UiSettings::Shutdown()
|
||||||
|
{
|
||||||
|
bool dataChanged = false;
|
||||||
|
|
||||||
|
// Commit settings that are managed separate from the settings dialog
|
||||||
|
dataChanged |= p->level2ProductsExpanded_.Commit();
|
||||||
|
dataChanged |= p->level2SettingsExpanded_.Commit();
|
||||||
|
dataChanged |= p->level3ProductsExpanded_.Commit();
|
||||||
|
dataChanged |= p->mapSettingsExpanded_.Commit();
|
||||||
|
dataChanged |= p->timelineExpanded_.Commit();
|
||||||
|
|
||||||
|
return dataChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
UiSettings& UiSettings::Instance()
|
||||||
|
{
|
||||||
|
static UiSettings uiSettings_;
|
||||||
|
return uiSettings_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const UiSettings& lhs, const UiSettings& rhs)
|
||||||
|
{
|
||||||
|
return (lhs.p->level2ProductsExpanded_ == rhs.p->level2ProductsExpanded_ &&
|
||||||
|
lhs.p->level2SettingsExpanded_ == rhs.p->level2SettingsExpanded_ &&
|
||||||
|
lhs.p->level3ProductsExpanded_ == rhs.p->level3ProductsExpanded_ &&
|
||||||
|
lhs.p->mapSettingsExpanded_ == rhs.p->mapSettingsExpanded_ &&
|
||||||
|
lhs.p->timelineExpanded_ == rhs.p->timelineExpanded_);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace settings
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace scwx
|
||||||
48
scwx-qt/source/scwx/qt/settings/ui_settings.hpp
Normal file
48
scwx-qt/source/scwx/qt/settings/ui_settings.hpp
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <scwx/qt/settings/settings_category.hpp>
|
||||||
|
#include <scwx/qt/settings/settings_variable.hpp>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace scwx
|
||||||
|
{
|
||||||
|
namespace qt
|
||||||
|
{
|
||||||
|
namespace settings
|
||||||
|
{
|
||||||
|
|
||||||
|
class UiSettingsImpl;
|
||||||
|
|
||||||
|
class UiSettings : public SettingsCategory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit UiSettings();
|
||||||
|
~UiSettings();
|
||||||
|
|
||||||
|
UiSettings(const UiSettings&) = delete;
|
||||||
|
UiSettings& operator=(const UiSettings&) = delete;
|
||||||
|
|
||||||
|
UiSettings(UiSettings&&) noexcept;
|
||||||
|
UiSettings& operator=(UiSettings&&) noexcept;
|
||||||
|
|
||||||
|
SettingsVariable<bool>& level2_products_expanded() const;
|
||||||
|
SettingsVariable<bool>& level2_settings_expanded() const;
|
||||||
|
SettingsVariable<bool>& level3_products_expanded() const;
|
||||||
|
SettingsVariable<bool>& map_settings_expanded() const;
|
||||||
|
SettingsVariable<bool>& timeline_expanded() const;
|
||||||
|
|
||||||
|
bool Shutdown();
|
||||||
|
|
||||||
|
static UiSettings& Instance();
|
||||||
|
|
||||||
|
friend bool operator==(const UiSettings& lhs, const UiSettings& rhs);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<UiSettingsImpl> p;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace settings
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace scwx
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 875afa5ead329536f802096ca1d2ef1010a7cc6b
|
Subproject commit b2fa7d866800902f4c092c567017c832bcdbe702
|
||||||
Loading…
Add table
Add a link
Reference in a new issue