419 lines
14 KiB
C++
419 lines
14 KiB
C++
#pragma once
|
|
|
|
#include "configobject.hpp"
|
|
#include <QFont>
|
|
#include <QVariantMap>
|
|
#include <limits>
|
|
#include <qqmlregistration.h>
|
|
|
|
namespace ZShell::config {
|
|
|
|
class AnimDurations : public ConfigObject {
|
|
Q_OBJECT
|
|
QML_ANONYMOUS
|
|
|
|
CFG_PROPERTY(qreal, scale, 1)
|
|
|
|
Q_PROPERTY(int extraLarge READ extraLarge NOTIFY scaleChanged)
|
|
Q_PROPERTY(
|
|
int expressiveDefaultEffects READ expressiveDefaultEffects NOTIFY
|
|
scaleChanged)
|
|
Q_PROPERTY(
|
|
int expressiveDefaultSpatial READ expressiveDefaultSpatial NOTIFY
|
|
scaleChanged)
|
|
Q_PROPERTY(
|
|
int expressiveFastEffects READ expressiveFastEffects NOTIFY scaleChanged)
|
|
Q_PROPERTY(
|
|
int expressiveFastSpatial READ expressiveFastSpatial NOTIFY scaleChanged)
|
|
Q_PROPERTY(
|
|
int expressiveSlowEffects READ expressiveSlowEffects NOTIFY scaleChanged)
|
|
Q_PROPERTY(
|
|
int expressiveSlowSpatial READ expressiveSlowSpatial NOTIFY scaleChanged)
|
|
Q_PROPERTY(int large READ large NOTIFY scaleChanged)
|
|
Q_PROPERTY(int normal READ normal NOTIFY scaleChanged)
|
|
Q_PROPERTY(int small READ small NOTIFY scaleChanged)
|
|
|
|
public:
|
|
explicit AnimDurations(QObject* parent = nullptr) : ConfigObject(parent) {}
|
|
|
|
[[nodiscard]] int small() const { return static_cast<int>(200 * scale()); }
|
|
[[nodiscard]] int normal() const { return static_cast<int>(400 * scale()); }
|
|
[[nodiscard]] int large() const { return static_cast<int>(600 * scale()); }
|
|
[[nodiscard]] int extraLarge() const {
|
|
return static_cast<int>(1000 * scale());
|
|
}
|
|
[[nodiscard]] int expressiveFastSpatial() const {
|
|
return static_cast<int>(350 * scale());
|
|
}
|
|
[[nodiscard]] int expressiveDefaultSpatial() const {
|
|
return static_cast<int>(500 * scale());
|
|
}
|
|
[[nodiscard]] int expressiveSlowSpatial() const {
|
|
return static_cast<int>(650 * scale());
|
|
}
|
|
[[nodiscard]] int expressiveFastEffects() const {
|
|
return static_cast<int>(150 * scale());
|
|
}
|
|
[[nodiscard]] int expressiveDefaultEffects() const {
|
|
return static_cast<int>(200 * scale());
|
|
}
|
|
[[nodiscard]] int expressiveSlowEffects() const {
|
|
return static_cast<int>(300 * scale());
|
|
}
|
|
};
|
|
|
|
class Anim : public ConfigObject {
|
|
Q_OBJECT
|
|
QML_ANONYMOUS
|
|
|
|
CFG_PROPERTY(int, mediaGifSpeedAdjustment, 300)
|
|
CFG_PROPERTY(qreal, sessionGifSpeed, 0.7)
|
|
CONFIG_SUBOBJECT(AnimDurations, durations)
|
|
|
|
public:
|
|
explicit Anim(QObject* parent = nullptr)
|
|
: ConfigObject(parent), m_durations(new AnimDurations(this)) {}
|
|
};
|
|
|
|
class Deform : public ConfigObject {
|
|
Q_OBJECT
|
|
QML_ANONYMOUS
|
|
|
|
CFG_PROPERTY(qreal, scale, 1)
|
|
|
|
public:
|
|
explicit Deform(QObject* parent = nullptr) : ConfigObject(parent) {}
|
|
};
|
|
|
|
class FontFamily : public ConfigObject {
|
|
Q_OBJECT
|
|
QML_ANONYMOUS
|
|
|
|
CFG_PROPERTY(QString, clock, QStringLiteral("Rubik"))
|
|
CFG_PROPERTY(QString, material, QStringLiteral("Material Symbols Rounded"))
|
|
CFG_PROPERTY(QString, mono, QStringLiteral("CaskaydiaCove NF"))
|
|
CFG_PROPERTY(QString, sans, QStringLiteral("Segoe UI Variable Text"))
|
|
|
|
public:
|
|
explicit FontFamily(QObject* parent = nullptr) : ConfigObject(parent) {}
|
|
};
|
|
|
|
namespace detail {
|
|
|
|
struct FontConfig {
|
|
QString family = {};
|
|
int size;
|
|
int weight = QFont::Normal;
|
|
bool italic = false;
|
|
QVariantMap vaxes = {{QStringLiteral("ROND"), 25}};
|
|
};
|
|
|
|
} // namespace detail
|
|
|
|
class FontSizeNode : public ConfigObject {
|
|
public:
|
|
explicit FontSizeNode(QObject* parent = nullptr) : ConfigObject(parent) {}
|
|
};
|
|
|
|
class FontStyleNode : public ConfigObject {
|
|
public:
|
|
explicit FontStyleNode(QObject* parent = nullptr) : ConfigObject(parent) {}
|
|
|
|
virtual FontSizeNode* largeNode() const = 0;
|
|
virtual FontSizeNode* mediumNode() const = 0;
|
|
virtual FontSizeNode* smallNode() const = 0;
|
|
virtual FontSizeNode* extraLargeNode() const { return nullptr; }
|
|
};
|
|
|
|
#define ARG(...) __VA_ARGS__
|
|
#define FONT(...) ZShell::config::detail::FontConfig __VA_ARGS__
|
|
#define FONT_CONFIG(Style, Size, props) \
|
|
class FontConfig##Style##Size : public FontSizeNode { \
|
|
Q_OBJECT QML_ANONYMOUS \
|
|
\
|
|
CFG_PROPERTY(QString, family, ARG(props).family) \
|
|
CFG_PROPERTY(int, size, ARG(props).size) \
|
|
CFG_PROPERTY(int, weight, ARG(props).weight) \
|
|
CFG_PROPERTY(bool, italic, ARG(props).italic) \
|
|
CFG_PROPERTY(QVariantMap, vaxes, ARG(props).vaxes) \
|
|
\
|
|
public \
|
|
: explicit FontConfig##Style##Size(QObject* parent = nullptr) \
|
|
: FontSizeNode(parent) {} \
|
|
};
|
|
#define FONT_STYLE(Style, family_, large_, medium_, small_) \
|
|
FONT_CONFIG(Style, Large, ARG(large_)) \
|
|
FONT_CONFIG(Style, Medium, ARG(medium_)) \
|
|
FONT_CONFIG(Style, Small, ARG(small_)) \
|
|
\
|
|
class FontStyle##Style : public FontStyleNode { \
|
|
Q_OBJECT QML_ANONYMOUS \
|
|
\
|
|
CFG_PROPERTY(QString, family, family_) \
|
|
CONFIG_SUBOBJECT(FontConfig##Style##Large, large) \
|
|
CONFIG_SUBOBJECT(FontConfig##Style##Medium, medium) \
|
|
CONFIG_SUBOBJECT(FontConfig##Style##Small, small) \
|
|
\
|
|
public \
|
|
: explicit FontStyle##Style(QObject* parent = nullptr) \
|
|
: FontStyleNode(parent) \
|
|
, m_large(new FontConfig##Style##Large(this)) \
|
|
, m_medium(new FontConfig##Style##Medium(this)) \
|
|
, m_small(new FontConfig##Style##Small(this)) {} \
|
|
\
|
|
FontSizeNode* largeNode() const override { return m_large; } \
|
|
FontSizeNode* mediumNode() const override { return m_medium; } \
|
|
FontSizeNode* smallNode() const override { return m_small; } \
|
|
};
|
|
|
|
// clang-format off
|
|
FONT_STYLE(Headline, QStringLiteral("GoogleSansFlex"),
|
|
FONT({ .size = 32, .weight = QFont::Medium }),
|
|
FONT({ .size = 28, .weight = QFont::Medium }),
|
|
FONT({ .size = 24, .weight = QFont::Medium })
|
|
)
|
|
FONT_STYLE(Title, QStringLiteral("GoogleSansFlex"),
|
|
FONT({ .size = 22, .weight = QFont::Medium }),
|
|
FONT({ .size = 16, .weight = QFont::Medium }),
|
|
FONT({ .size = 14, .weight = QFont::Medium })
|
|
)
|
|
FONT_STYLE(Body, QStringLiteral("GoogleSansFlex"),
|
|
FONT({ .size = 16 }),
|
|
FONT({ .size = 14 }),
|
|
FONT({ .size = 12 })
|
|
)
|
|
FONT_STYLE(Label, QStringLiteral("GoogleSansFlex"),
|
|
FONT({ .size = 14, .weight = QFont::Medium }),
|
|
FONT({ .size = 12, .weight = QFont::Medium }),
|
|
FONT({ .size = 11 })
|
|
)
|
|
FONT_STYLE(Mono, QStringLiteral("CaskaydiaCove NF"),
|
|
FONT({ .size = 16, .vaxes = {} }),
|
|
FONT({ .size = 14, .vaxes = {} }),
|
|
FONT({ .size = 12, .vaxes = {} })
|
|
)
|
|
// clang-format on
|
|
|
|
FONT_CONFIG(Icon, ExtraLarge, FONT({.size = static_cast<int>(48 / 1.33)}))
|
|
FONT_CONFIG(Icon, Large, FONT({.size = static_cast<int>(32 / 1.33)}))
|
|
FONT_CONFIG(Icon, Medium, FONT({.size = static_cast<int>(24 / 1.33)}))
|
|
FONT_CONFIG(Icon, Small, FONT({.size = static_cast<int>(20 / 1.33)}))
|
|
|
|
class FontStyleIcon : public FontStyleNode {
|
|
Q_OBJECT
|
|
QML_ANONYMOUS
|
|
|
|
CFG_PROPERTY(QString, family, QStringLiteral("Material Symbols Rounded"))
|
|
CONFIG_SUBOBJECT(FontConfigIconExtraLarge, extraLarge)
|
|
CONFIG_SUBOBJECT(FontConfigIconLarge, large)
|
|
CONFIG_SUBOBJECT(FontConfigIconMedium, medium)
|
|
CONFIG_SUBOBJECT(FontConfigIconSmall, small)
|
|
|
|
public:
|
|
explicit FontStyleIcon(QObject* parent = nullptr)
|
|
: FontStyleNode(parent)
|
|
, m_extraLarge(new FontConfigIconExtraLarge(this))
|
|
, m_large(new FontConfigIconLarge(this))
|
|
, m_medium(new FontConfigIconMedium(this))
|
|
, m_small(new FontConfigIconSmall(this)) {}
|
|
|
|
FontSizeNode* extraLargeNode() const override { return m_extraLarge; }
|
|
FontSizeNode* largeNode() const override { return m_large; }
|
|
FontSizeNode* mediumNode() const override { return m_medium; }
|
|
FontSizeNode* smallNode() const override { return m_small; }
|
|
};
|
|
|
|
#undef ARG
|
|
#undef FONT
|
|
#undef FONT_CONFIG
|
|
#undef FONT_STYLE
|
|
|
|
class AppearanceFont : public ConfigObject {
|
|
Q_OBJECT
|
|
QML_ANONYMOUS
|
|
|
|
CFG_PROPERTY(qreal, scale, 1)
|
|
CONFIG_SUBOBJECT(FontFamily, family)
|
|
CONFIG_SUBOBJECT(FontStyleHeadline, headline)
|
|
CONFIG_SUBOBJECT(FontStyleTitle, title)
|
|
CONFIG_SUBOBJECT(FontStyleBody, body)
|
|
CONFIG_SUBOBJECT(FontStyleLabel, label)
|
|
CONFIG_SUBOBJECT(FontStyleMono, mono)
|
|
CONFIG_SUBOBJECT(FontStyleIcon, icon)
|
|
CFG_PROPERTY(QString, clock, QStringLiteral("Rubik"))
|
|
CFG_PROPERTY(QString, workspaces, QStringLiteral("Rubik"))
|
|
|
|
public:
|
|
explicit AppearanceFont(QObject* parent = nullptr)
|
|
: ConfigObject(parent)
|
|
, m_family(new FontFamily(this))
|
|
, m_headline(new FontStyleHeadline(this))
|
|
, m_title(new FontStyleTitle(this))
|
|
, m_body(new FontStyleBody(this))
|
|
, m_label(new FontStyleLabel(this))
|
|
, m_mono(new FontStyleMono(this))
|
|
, m_icon(new FontStyleIcon(this)) {}
|
|
};
|
|
|
|
class Transparency : public ConfigObject {
|
|
Q_OBJECT
|
|
QML_ANONYMOUS
|
|
|
|
CFG_PROPERTY(qreal, base, 0.85)
|
|
CFG_PROPERTY(bool, enabled, false)
|
|
CFG_PROPERTY(qreal, layers, 0.4)
|
|
|
|
public:
|
|
explicit Transparency(QObject* parent = nullptr) : ConfigObject(parent) {}
|
|
};
|
|
|
|
class AppearanceRounding : public ConfigObject {
|
|
Q_OBJECT
|
|
QML_ANONYMOUS
|
|
|
|
CFG_PROPERTY(qreal, scale, 1)
|
|
|
|
Q_PROPERTY(int extraSmall READ extraSmall NOTIFY scaleChanged)
|
|
Q_PROPERTY(int small READ small NOTIFY scaleChanged)
|
|
Q_PROPERTY(int medium READ medium NOTIFY scaleChanged)
|
|
Q_PROPERTY(int large READ large NOTIFY scaleChanged)
|
|
Q_PROPERTY(int largeIncreased READ largeIncreased NOTIFY scaleChanged)
|
|
Q_PROPERTY(int extraLarge READ extraLarge NOTIFY scaleChanged)
|
|
Q_PROPERTY(
|
|
int extraLargeIncreased READ extraLargeIncreased NOTIFY scaleChanged)
|
|
Q_PROPERTY(int extraExtraLarge READ extraExtraLarge NOTIFY scaleChanged)
|
|
Q_PROPERTY(int full READ full CONSTANT)
|
|
|
|
public:
|
|
explicit AppearanceRounding(QObject* parent = nullptr)
|
|
: ConfigObject(parent) {}
|
|
|
|
[[nodiscard]] int extraSmall() const {
|
|
return static_cast<int>(4 * scale());
|
|
}
|
|
[[nodiscard]] int small() const { return static_cast<int>(8 * scale()); }
|
|
[[nodiscard]] int medium() const { return static_cast<int>(12 * scale()); }
|
|
[[nodiscard]] int large() const { return static_cast<int>(16 * scale()); }
|
|
[[nodiscard]] int largeIncreased() const {
|
|
return static_cast<int>(20 * scale());
|
|
}
|
|
[[nodiscard]] int extraLarge() const {
|
|
return static_cast<int>(28 * scale());
|
|
}
|
|
[[nodiscard]] int extraLargeIncreased() const {
|
|
return static_cast<int>(32 * scale());
|
|
}
|
|
[[nodiscard]] int extraExtraLarge() const {
|
|
return static_cast<int>(48 * scale());
|
|
}
|
|
[[nodiscard]] int full() const { return std::numeric_limits<int>::max(); }
|
|
};
|
|
|
|
class AppearanceSpacing : public ConfigObject {
|
|
Q_OBJECT
|
|
QML_ANONYMOUS
|
|
|
|
CFG_PROPERTY(qreal, scale, 1)
|
|
|
|
Q_PROPERTY(int extraSmall READ extraSmall NOTIFY scaleChanged)
|
|
Q_PROPERTY(int small READ small NOTIFY scaleChanged)
|
|
Q_PROPERTY(int medium READ medium NOTIFY scaleChanged)
|
|
Q_PROPERTY(int large READ large NOTIFY scaleChanged)
|
|
Q_PROPERTY(int largeIncreased READ largeIncreased NOTIFY scaleChanged)
|
|
Q_PROPERTY(int extraLarge READ extraLarge NOTIFY scaleChanged)
|
|
Q_PROPERTY(
|
|
int extraLargeIncreased READ extraLargeIncreased NOTIFY scaleChanged)
|
|
Q_PROPERTY(int extraExtraLarge READ extraExtraLarge NOTIFY scaleChanged)
|
|
|
|
public:
|
|
explicit AppearanceSpacing(QObject* parent = nullptr)
|
|
: ConfigObject(parent) {}
|
|
|
|
[[nodiscard]] int extraSmall() const {
|
|
return static_cast<int>(4 * scale());
|
|
}
|
|
[[nodiscard]] int small() const { return static_cast<int>(8 * scale()); }
|
|
[[nodiscard]] int medium() const { return static_cast<int>(12 * scale()); }
|
|
[[nodiscard]] int large() const { return static_cast<int>(16 * scale()); }
|
|
[[nodiscard]] int largeIncreased() const {
|
|
return static_cast<int>(20 * scale());
|
|
}
|
|
[[nodiscard]] int extraLarge() const {
|
|
return static_cast<int>(28 * scale());
|
|
}
|
|
[[nodiscard]] int extraLargeIncreased() const {
|
|
return static_cast<int>(32 * scale());
|
|
}
|
|
[[nodiscard]] int extraExtraLarge() const {
|
|
return static_cast<int>(48 * scale());
|
|
}
|
|
};
|
|
|
|
class AppearancePadding : public ConfigObject {
|
|
Q_OBJECT
|
|
QML_ANONYMOUS
|
|
|
|
CFG_PROPERTY(qreal, scale, 1)
|
|
|
|
Q_PROPERTY(int extraSmall READ extraSmall NOTIFY scaleChanged)
|
|
Q_PROPERTY(int smaller READ smaller NOTIFY scaleChanged)
|
|
Q_PROPERTY(int small READ small NOTIFY scaleChanged)
|
|
Q_PROPERTY(int medium READ medium NOTIFY scaleChanged)
|
|
Q_PROPERTY(int large READ large NOTIFY scaleChanged)
|
|
Q_PROPERTY(int largeIncreased READ largeIncreased NOTIFY scaleChanged)
|
|
Q_PROPERTY(int extraLarge READ extraLarge NOTIFY scaleChanged)
|
|
Q_PROPERTY(
|
|
int extraLargeIncreased READ extraLargeIncreased NOTIFY scaleChanged)
|
|
Q_PROPERTY(int extraExtraLarge READ extraExtraLarge NOTIFY scaleChanged)
|
|
|
|
public:
|
|
explicit AppearancePadding(QObject* parent = nullptr)
|
|
: ConfigObject(parent) {}
|
|
|
|
[[nodiscard]] int extraSmall() const {
|
|
return static_cast<int>(4 * scale());
|
|
}
|
|
[[nodiscard]] int smaller() const { return static_cast<int>(5 * scale()); }
|
|
[[nodiscard]] int small() const { return static_cast<int>(8 * scale()); }
|
|
[[nodiscard]] int medium() const { return static_cast<int>(12 * scale()); }
|
|
[[nodiscard]] int large() const { return static_cast<int>(16 * scale()); }
|
|
[[nodiscard]] int largeIncreased() const {
|
|
return static_cast<int>(20 * scale());
|
|
}
|
|
[[nodiscard]] int extraLarge() const {
|
|
return static_cast<int>(28 * scale());
|
|
}
|
|
[[nodiscard]] int extraLargeIncreased() const {
|
|
return static_cast<int>(32 * scale());
|
|
}
|
|
[[nodiscard]] int extraExtraLarge() const {
|
|
return static_cast<int>(48 * scale());
|
|
}
|
|
};
|
|
|
|
class Appearance : public ConfigObject {
|
|
Q_OBJECT
|
|
QML_ANONYMOUS
|
|
|
|
CONFIG_SUBOBJECT(Anim, anim)
|
|
CONFIG_SUBOBJECT(Deform, deform)
|
|
CONFIG_SUBOBJECT(AppearanceFont, font)
|
|
CONFIG_SUBOBJECT(AppearanceRounding, rounding)
|
|
CONFIG_SUBOBJECT(AppearanceSpacing, spacing)
|
|
CONFIG_SUBOBJECT(AppearancePadding, padding)
|
|
CONFIG_SUBOBJECT(Transparency, transparency)
|
|
|
|
public:
|
|
explicit Appearance(QObject* parent = nullptr)
|
|
: ConfigObject(parent)
|
|
, m_anim(new Anim(this))
|
|
, m_deform(new Deform(this))
|
|
, m_font(new AppearanceFont(this))
|
|
, m_rounding(new AppearanceRounding(this))
|
|
, m_spacing(new AppearanceSpacing(this))
|
|
, m_padding(new AppearancePadding(this))
|
|
, m_transparency(new Transparency(this)) {};
|
|
};
|
|
|
|
} // namespace ZShell::config
|