feat: move size tokens to subobject
This commit is contained in:
parent
3a37d77d1f
commit
2b2d5a4873
2 changed files with 37 additions and 26 deletions
|
|
@ -20,17 +20,7 @@ QString configDir() {
|
|||
TokenConfig::TokenConfig(QObject* parent)
|
||||
: RootConfig(parent)
|
||||
, m_appearance(new AppearanceTokens(this))
|
||||
, m_bar(new BarTokens(this))
|
||||
, m_dashboard(new DashboardTokens(this))
|
||||
, m_launcher(new LauncherTokens(this))
|
||||
, m_notifs(new NotifsTokens(this))
|
||||
, m_osd(new OsdTokens(this))
|
||||
, m_session(new SessionTokens(this))
|
||||
, m_sidebar(new SidebarTokens(this))
|
||||
, m_utilities(new UtilitiesTokens(this))
|
||||
, m_lock(new LockTokens(this))
|
||||
, m_winfo(new WInfoTokens(this))
|
||||
, m_controlCenter(new ControlCenterTokens(this)) {
|
||||
, m_sizes(new SizeTokens(this)) {
|
||||
s_instance = this;
|
||||
|
||||
setupFileBackend(configDir() + QStringLiteral("shell-tokens.json"));
|
||||
|
|
@ -43,17 +33,7 @@ TokenConfig::TokenConfig(QObject* parent)
|
|||
TokenConfig::TokenConfig(TokenConfig* fallback, const QString& filePath, QObject* parent)
|
||||
: RootConfig(parent)
|
||||
, m_appearance(new AppearanceTokens(this))
|
||||
, m_bar(new BarTokens(this))
|
||||
, m_dashboard(new DashboardTokens(this))
|
||||
, m_launcher(new LauncherTokens(this))
|
||||
, m_notifs(new NotifsTokens(this))
|
||||
, m_osd(new OsdTokens(this))
|
||||
, m_session(new SessionTokens(this))
|
||||
, m_sidebar(new SidebarTokens(this))
|
||||
, m_utilities(new UtilitiesTokens(this))
|
||||
, m_lock(new LockTokens(this))
|
||||
, m_winfo(new WInfoTokens(this))
|
||||
, m_controlCenter(new ControlCenterTokens(this)) {
|
||||
, m_sizes(new SizeTokens(this)) {
|
||||
setSparse(true);
|
||||
if (!filePath.isEmpty())
|
||||
setupFileBackend(filePath);
|
||||
|
|
@ -132,6 +112,13 @@ const AppearanceTransparency* Tokens::transparency() const {
|
|||
return a ? a->transparency() : nullptr;
|
||||
}
|
||||
|
||||
const SizeTokens* Tokens::sizes() const {
|
||||
if (m_scope && m_scope->tokens())
|
||||
return m_scope->tokens()->sizes();
|
||||
auto* global = TokenConfig::instance();
|
||||
return global ? global->sizes() : nullptr;
|
||||
}
|
||||
|
||||
Tokens* Tokens::qmlAttachedProperties(QObject* object) {
|
||||
// Ensure GlobalConfig singleton is created before any attached property access
|
||||
if (!GlobalConfig::instance()) {
|
||||
|
|
|
|||
|
|
@ -290,12 +290,10 @@ public:
|
|||
: ConfigObject(parent) {}
|
||||
};
|
||||
|
||||
class TokenConfig : public RootConfig {
|
||||
class SizeTokens : public ConfigObject {
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
QML_SINGLETON
|
||||
QML_ANONYMOUS
|
||||
|
||||
CONFIG_SUBOBJECT(AppearanceTokens, appearance)
|
||||
CONFIG_SUBOBJECT(BarTokens, bar)
|
||||
CONFIG_SUBOBJECT(DashboardTokens, dashboard)
|
||||
CONFIG_SUBOBJECT(LauncherTokens, launcher)
|
||||
|
|
@ -308,6 +306,30 @@ class TokenConfig : public RootConfig {
|
|||
CONFIG_SUBOBJECT(WInfoTokens, winfo)
|
||||
CONFIG_SUBOBJECT(ControlCenterTokens, controlCenter)
|
||||
|
||||
public:
|
||||
explicit SizeTokens(QObject* parent = nullptr)
|
||||
: ConfigObject(parent)
|
||||
, m_bar(new BarTokens(this))
|
||||
, m_dashboard(new DashboardTokens(this))
|
||||
, m_launcher(new LauncherTokens(this))
|
||||
, m_notifs(new NotifsTokens(this))
|
||||
, m_osd(new OsdTokens(this))
|
||||
, m_session(new SessionTokens(this))
|
||||
, m_sidebar(new SidebarTokens(this))
|
||||
, m_utilities(new UtilitiesTokens(this))
|
||||
, m_lock(new LockTokens(this))
|
||||
, m_winfo(new WInfoTokens(this))
|
||||
, m_controlCenter(new ControlCenterTokens(this)) {}
|
||||
};
|
||||
|
||||
class TokenConfig : public RootConfig {
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
QML_SINGLETON
|
||||
|
||||
CONFIG_SUBOBJECT(AppearanceTokens, appearance)
|
||||
CONFIG_SUBOBJECT(SizeTokens, sizes)
|
||||
|
||||
public:
|
||||
static TokenConfig* instance();
|
||||
[[nodiscard]] Q_INVOKABLE TokenConfig* defaults();
|
||||
|
|
@ -336,6 +358,7 @@ class Tokens : public QObject {
|
|||
Q_PROPERTY(const caelestia::config::AppearanceFont* font READ font NOTIFY sourceChanged)
|
||||
Q_PROPERTY(const caelestia::config::AppearanceAnim* anim READ anim NOTIFY sourceChanged)
|
||||
Q_PROPERTY(const caelestia::config::AppearanceTransparency* transparency READ transparency NOTIFY sourceChanged)
|
||||
Q_PROPERTY(const caelestia::config::SizeTokens* sizes READ sizes NOTIFY sourceChanged)
|
||||
|
||||
public:
|
||||
explicit Tokens(ConfigScope* scope, QObject* parent = nullptr);
|
||||
|
|
@ -346,6 +369,7 @@ public:
|
|||
[[nodiscard]] const AppearanceFont* font() const;
|
||||
[[nodiscard]] const AppearanceAnim* anim() const;
|
||||
[[nodiscard]] const AppearanceTransparency* transparency() const;
|
||||
[[nodiscard]] const SizeTokens* sizes() const;
|
||||
|
||||
static Tokens* qmlAttachedProperties(QObject* object);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue