348 lines
12 KiB
C++
348 lines
12 KiB
C++
#pragma once
|
|
|
|
#include <qfont.h>
|
|
#include <qstring.h>
|
|
#include <qvariantmap.h>
|
|
|
|
#include "settings/objectnode.hpp"
|
|
#include "common.hpp"
|
|
|
|
namespace ZShell::config {
|
|
|
|
using Qt::StringLiterals::operator""_s;
|
|
|
|
class RoundingTokens;
|
|
class SpacingTokens;
|
|
class PaddingTokens;
|
|
class AnimDurationTokens;
|
|
|
|
class AppearanceRounding : public settings::ObjectNode {
|
|
CONFIG_NODE(AppearanceRounding, settings::ObjectNode)
|
|
|
|
CONFIG_PROPERTY(qreal, scale, 1)
|
|
|
|
Q_PROPERTY(int extraSmall READ extraSmall NOTIFY valuesChanged)
|
|
Q_PROPERTY(int small READ small NOTIFY valuesChanged)
|
|
Q_PROPERTY(int medium READ medium NOTIFY valuesChanged)
|
|
Q_PROPERTY(int large READ large NOTIFY valuesChanged)
|
|
Q_PROPERTY(int largeIncreased READ largeIncreased NOTIFY valuesChanged)
|
|
Q_PROPERTY(int extraLarge READ extraLarge NOTIFY valuesChanged)
|
|
Q_PROPERTY(
|
|
int extraLargeIncreased READ extraLargeIncreased NOTIFY valuesChanged)
|
|
Q_PROPERTY(int extraExtraLarge READ extraExtraLarge NOTIFY valuesChanged)
|
|
Q_PROPERTY(int full READ full NOTIFY valuesChanged)
|
|
|
|
public:
|
|
void bindTokens(RoundingTokens* tokens);
|
|
|
|
[[nodiscard]] int extraSmall() const;
|
|
[[nodiscard]] int small() const;
|
|
[[nodiscard]] int medium() const;
|
|
[[nodiscard]] int large() const;
|
|
[[nodiscard]] int largeIncreased() const;
|
|
[[nodiscard]] int extraLarge() const;
|
|
[[nodiscard]] int extraLargeIncreased() const;
|
|
[[nodiscard]] int extraExtraLarge() const;
|
|
[[nodiscard]] int full() const;
|
|
|
|
signals:
|
|
void valuesChanged();
|
|
|
|
private:
|
|
RoundingTokens* m_tokens = nullptr;
|
|
};
|
|
|
|
class AppearanceSpacing : public settings::ObjectNode {
|
|
CONFIG_NODE(AppearanceSpacing, settings::ObjectNode)
|
|
|
|
CONFIG_PROPERTY(qreal, scale, 1)
|
|
|
|
Q_PROPERTY(int extraSmall READ extraSmall NOTIFY valuesChanged)
|
|
Q_PROPERTY(int small READ small NOTIFY valuesChanged)
|
|
Q_PROPERTY(int medium READ medium NOTIFY valuesChanged)
|
|
Q_PROPERTY(int large READ large NOTIFY valuesChanged)
|
|
Q_PROPERTY(int largeIncreased READ largeIncreased NOTIFY valuesChanged)
|
|
Q_PROPERTY(int extraLarge READ extraLarge NOTIFY valuesChanged)
|
|
Q_PROPERTY(
|
|
int extraLargeIncreased READ extraLargeIncreased NOTIFY valuesChanged)
|
|
Q_PROPERTY(int extraExtraLarge READ extraExtraLarge NOTIFY valuesChanged)
|
|
|
|
public:
|
|
void bindTokens(SpacingTokens* tokens);
|
|
|
|
[[nodiscard]] int extraSmall() const;
|
|
[[nodiscard]] int small() const;
|
|
[[nodiscard]] int medium() const;
|
|
[[nodiscard]] int large() const;
|
|
[[nodiscard]] int largeIncreased() const;
|
|
[[nodiscard]] int extraLarge() const;
|
|
[[nodiscard]] int extraLargeIncreased() const;
|
|
[[nodiscard]] int extraExtraLarge() const;
|
|
|
|
signals:
|
|
void valuesChanged();
|
|
|
|
private:
|
|
SpacingTokens* m_tokens = nullptr;
|
|
};
|
|
|
|
class AppearancePadding : public settings::ObjectNode {
|
|
CONFIG_NODE(AppearancePadding, settings::ObjectNode)
|
|
|
|
CONFIG_PROPERTY(qreal, scale, 1)
|
|
|
|
Q_PROPERTY(int extraSmall READ extraSmall NOTIFY valuesChanged)
|
|
Q_PROPERTY(int smaller READ smaller NOTIFY valuesChanged)
|
|
Q_PROPERTY(int small READ small NOTIFY valuesChanged)
|
|
Q_PROPERTY(int medium READ medium NOTIFY valuesChanged)
|
|
Q_PROPERTY(int large READ large NOTIFY valuesChanged)
|
|
Q_PROPERTY(int largeIncreased READ largeIncreased NOTIFY valuesChanged)
|
|
Q_PROPERTY(int extraLarge READ extraLarge NOTIFY valuesChanged)
|
|
Q_PROPERTY(
|
|
int extraLargeIncreased READ extraLargeIncreased NOTIFY valuesChanged)
|
|
Q_PROPERTY(int extraExtraLarge READ extraExtraLarge NOTIFY valuesChanged)
|
|
|
|
public:
|
|
void bindTokens(PaddingTokens* tokens);
|
|
|
|
[[nodiscard]] int extraSmall() const;
|
|
[[nodiscard]] int smaller() const;
|
|
[[nodiscard]] int small() const;
|
|
[[nodiscard]] int medium() const;
|
|
[[nodiscard]] int large() const;
|
|
[[nodiscard]] int largeIncreased() const;
|
|
[[nodiscard]] int extraLarge() const;
|
|
[[nodiscard]] int extraLargeIncreased() const;
|
|
[[nodiscard]] int extraExtraLarge() const;
|
|
|
|
signals:
|
|
void valuesChanged();
|
|
|
|
private:
|
|
PaddingTokens* m_tokens = nullptr;
|
|
};
|
|
|
|
namespace detail {
|
|
|
|
struct FontConfig {
|
|
QString family = {};
|
|
int size;
|
|
int weight = QFont::Normal;
|
|
bool italic = false;
|
|
QVariantMap vaxes = {{u"ROND"_s, 25}};
|
|
};
|
|
|
|
} // namespace detail
|
|
|
|
class FontSizeNode : public settings::ObjectNode {
|
|
CONFIG_NODE(FontSizeNode, settings::ObjectNode)
|
|
};
|
|
|
|
class FontStyleNode : public settings::ObjectNode {
|
|
CONFIG_NODE(FontStyleNode, settings::ObjectNode)
|
|
|
|
public:
|
|
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 { \
|
|
CONFIG_NODE(FontConfig##Style##Size, FontSizeNode) \
|
|
\
|
|
CONFIG_PROPERTY( \
|
|
QString, \
|
|
family, \
|
|
ARG(props).family) /* Empty inherits the style family */ \
|
|
CONFIG_PROPERTY(int, size, ARG(props).size) \
|
|
CONFIG_PROPERTY(int, weight, ARG(props).weight) \
|
|
CONFIG_PROPERTY(bool, italic, ARG(props).italic) \
|
|
CONFIG_PROPERTY(QVariantMap, vaxes, ARG(props).vaxes) \
|
|
};
|
|
#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 { \
|
|
CONFIG_NODE(FontStyle##Style, FontStyleNode) \
|
|
\
|
|
CONFIG_PROPERTY(QString, family, family_) \
|
|
CONFIG_SUBOBJECT(FontConfig##Style##Large, large) \
|
|
CONFIG_SUBOBJECT(FontConfig##Style##Medium, medium) \
|
|
CONFIG_SUBOBJECT(FontConfig##Style##Small, small) \
|
|
\
|
|
public: \
|
|
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, u"GoogleSansFlex"_s,
|
|
FONT({ .size = 32, .weight = QFont::Medium }),
|
|
FONT({ .size = 28, .weight = QFont::Medium }),
|
|
FONT({ .size = 24, .weight = QFont::Medium })
|
|
)
|
|
FONT_STYLE(Title, u"GoogleSansFlex"_s,
|
|
FONT({ .size = 22, .weight = QFont::Medium }),
|
|
FONT({ .size = 16, .weight = QFont::Medium }),
|
|
FONT({ .size = 14, .weight = QFont::Medium })
|
|
)
|
|
FONT_STYLE(Body, u"GoogleSansFlex"_s,
|
|
FONT({ .size = 16 }),
|
|
FONT({ .size = 14 }),
|
|
FONT({ .size = 12 })
|
|
)
|
|
FONT_STYLE(Label, u"GoogleSansFlex"_s,
|
|
FONT({ .size = 14, .weight = QFont::Medium }),
|
|
FONT({ .size = 12, .weight = QFont::Medium }),
|
|
FONT({ .size = 11 })
|
|
)
|
|
FONT_STYLE(Mono, u"CaskaydiaCove NF"_s,
|
|
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 {
|
|
CONFIG_NODE(FontStyleIcon, FontStyleNode)
|
|
|
|
CONFIG_PROPERTY(QString, family, u"Material Symbols Rounded"_s)
|
|
CONFIG_SUBOBJECT(FontConfigIconExtraLarge, extraLarge)
|
|
CONFIG_SUBOBJECT(FontConfigIconLarge, large)
|
|
CONFIG_SUBOBJECT(FontConfigIconMedium, medium)
|
|
CONFIG_SUBOBJECT(FontConfigIconSmall, small)
|
|
|
|
public:
|
|
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 FontFamily : public settings::ObjectNode {
|
|
CONFIG_NODE(FontFamily, settings::ObjectNode)
|
|
|
|
CONFIG_PROPERTY(QString, clock, QStringLiteral("Rubik"))
|
|
CONFIG_PROPERTY(
|
|
QString, material, QStringLiteral("Material Symbols Rounded"))
|
|
CONFIG_PROPERTY(QString, mono, QStringLiteral("CaskaydiaCove NF"))
|
|
CONFIG_PROPERTY(QString, sans, QStringLiteral("Segoe UI Variable Text"))
|
|
};
|
|
|
|
class AppearanceFont : public settings::ObjectNode {
|
|
CONFIG_NODE(AppearanceFont, settings::ObjectNode)
|
|
|
|
CONFIG_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)
|
|
CONFIG_PROPERTY(QString, clock, QStringLiteral("Rubik"))
|
|
CONFIG_PROPERTY(QString, workspaces, QStringLiteral("Rubik"))
|
|
};
|
|
|
|
class AnimDurations : public settings::ObjectNode {
|
|
CONFIG_NODE(AnimDurations, settings::ObjectNode)
|
|
|
|
CONFIG_GLOBAL_PROPERTY(qreal, scale, 1)
|
|
|
|
Q_PROPERTY(int small READ small NOTIFY valuesChanged)
|
|
Q_PROPERTY(int normal READ normal NOTIFY valuesChanged)
|
|
Q_PROPERTY(int large READ large NOTIFY valuesChanged)
|
|
Q_PROPERTY(int extraLarge READ extraLarge NOTIFY valuesChanged)
|
|
Q_PROPERTY(
|
|
int expressiveFastSpatial READ expressiveFastSpatial NOTIFY
|
|
valuesChanged)
|
|
Q_PROPERTY(
|
|
int expressiveDefaultSpatial READ expressiveDefaultSpatial NOTIFY
|
|
valuesChanged)
|
|
Q_PROPERTY(
|
|
int expressiveSlowSpatial READ expressiveSlowSpatial NOTIFY
|
|
valuesChanged)
|
|
Q_PROPERTY(
|
|
int expressiveFastEffects READ expressiveFastEffects NOTIFY
|
|
valuesChanged)
|
|
Q_PROPERTY(
|
|
int expressiveDefaultEffects READ expressiveDefaultEffects NOTIFY
|
|
valuesChanged)
|
|
Q_PROPERTY(
|
|
int expressiveSlowEffects READ expressiveSlowEffects NOTIFY
|
|
valuesChanged)
|
|
|
|
public:
|
|
void bindTokens(AnimDurationTokens* tokens);
|
|
|
|
[[nodiscard]] int small() const;
|
|
[[nodiscard]] int normal() const;
|
|
[[nodiscard]] int large() const;
|
|
[[nodiscard]] int extraLarge() const;
|
|
[[nodiscard]] int expressiveFastSpatial() const;
|
|
[[nodiscard]] int expressiveDefaultSpatial() const;
|
|
[[nodiscard]] int expressiveSlowSpatial() const;
|
|
[[nodiscard]] int expressiveFastEffects() const;
|
|
[[nodiscard]] int expressiveDefaultEffects() const;
|
|
[[nodiscard]] int expressiveSlowEffects() const;
|
|
|
|
signals:
|
|
void valuesChanged();
|
|
|
|
private:
|
|
AnimDurationTokens* m_tokens = nullptr;
|
|
};
|
|
|
|
class Anim : public settings::ObjectNode {
|
|
CONFIG_NODE(Anim, settings::ObjectNode)
|
|
|
|
CONFIG_PROPERTY(int, mediaGifSpeedAdjustment, 300)
|
|
CONFIG_PROPERTY(qreal, sessionGifSpeed, 0.7)
|
|
CONFIG_SUBOBJECT(AnimDurations, durations)
|
|
};
|
|
|
|
class Deform : public settings::ObjectNode {
|
|
CONFIG_NODE(Deform, settings::ObjectNode)
|
|
|
|
CONFIG_PROPERTY(qreal, scale, 1)
|
|
};
|
|
|
|
class AppearanceTransparency : public settings::ObjectNode {
|
|
CONFIG_NODE(AppearanceTransparency, settings::ObjectNode)
|
|
|
|
CONFIG_GLOBAL_PROPERTY(bool, enabled, false)
|
|
CONFIG_GLOBAL_PROPERTY(qreal, base, 0.85)
|
|
CONFIG_GLOBAL_PROPERTY(qreal, layers, 0.4)
|
|
};
|
|
|
|
class Appearance : public settings::ObjectNode {
|
|
CONFIG_NODE(Appearance, settings::ObjectNode)
|
|
|
|
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(AppearanceTransparency, transparency)
|
|
};
|
|
|
|
} // namespace ZShell::config
|