fix: define declared method + insert new bar entries to config file list + rename Hyprsunset -> Nightlight

This commit is contained in:
2026-09-30 14:26:56 +02:00
parent 133d453f6f
commit 10d763cfe5
23 changed files with 1445 additions and 1184 deletions
+48 -40
View File
@@ -13,69 +13,77 @@ namespace ZShell::settings {
class ValueCodec;
struct Annotation {
QVariant defaultValue;
bool globalOnly = false;
// NOLINTNEXTLINE(readability-redundant-member-init) callers will get missing field init warnings without
QList<QMetaType> allowedTypes = {}; // For QVariant properties
QVariant defaultValue;
bool globalOnly = false;
// NOLINTNEXTLINE(readability-redundant-member-init) callers will get missing field init warnings without
QList<QMetaType> allowedTypes = {}; // For QVariant properties
// NOLINTNEXTLINE(readability-redundant-member-init)
QString identityKey = {};
};
namespace detail {
// Return trivially copyable types (e.g. bool) by value and others (e.g. QVariant) by const ref
template <typename T>
using AnnotationReturn = std::conditional_t<std::is_trivially_copyable_v<T> && sizeof(T) <= sizeof(void*), T, const T&>;
using AnnotationReturn = std::conditional_t<
std::is_trivially_copyable_v<T> && sizeof(T) <= sizeof(void*),
T,
const T&>;
} // namespace detail
#define ANNOTATION(Type, name) \
Q_PROPERTY(Type name READ name) \
\
public: \
[[nodiscard]] detail::AnnotationReturn<Type> name() const { \
return annotation.name; \
} \
\
private:
#define ANNOTATION(Type, name) \
Q_PROPERTY(Type name READ name) \
\
public: \
[[nodiscard]] detail::AnnotationReturn<Type> name() const { \
return annotation.name; \
} \
\
private:
struct Descriptor {
Q_GADGET
QML_VALUE_TYPE(descriptor)
Q_GADGET
QML_VALUE_TYPE(descriptor)
Q_PROPERTY(QString key MEMBER key)
Q_PROPERTY(QString type READ typeString)
Q_PROPERTY(int metaIndex MEMBER metaIndex)
Q_PROPERTY(bool isNode MEMBER isNode)
Q_PROPERTY(QString key MEMBER key)
Q_PROPERTY(QString type READ typeString)
Q_PROPERTY(int metaIndex MEMBER metaIndex)
Q_PROPERTY(bool isNode MEMBER isNode)
ANNOTATION(QVariant, defaultValue)
ANNOTATION(bool, globalOnly)
ANNOTATION(QVariant, defaultValue)
ANNOTATION(bool, globalOnly)
ANNOTATION(QString, identityKey)
public:
QString key;
QMetaType type;
int metaIndex;
bool isNode;
Annotation annotation;
const ValueCodec* codec = nullptr; // Null for nodes and unsupported types
public:
QString key;
QMetaType type;
int metaIndex;
bool isNode;
Annotation annotation;
const ValueCodec* codec = nullptr; // Null for nodes and unsupported types
[[nodiscard]] QString typeString() const;
[[nodiscard]] bool accepts(const QMetaType& valueType) const;
[[nodiscard]] QString typeString() const;
[[nodiscard]] bool accepts(const QMetaType& valueType) const;
};
#undef ANNOTATION
class Schema {
public:
static Schema build(const QMetaObject* meta, int baseOffset, bool includeReadOnly = false);
static void annotate(const QMetaObject* meta, const QString& key, Annotation annotation);
public:
static Schema build(
const QMetaObject* meta, int baseOffset, bool includeReadOnly = false);
static void annotate(
const QMetaObject* meta, const QString& key, Annotation annotation);
[[nodiscard]] const QList<Descriptor>& descriptors() const;
[[nodiscard]] const Descriptor* get(const QString& key) const;
[[nodiscard]] const QList<Descriptor>& descriptors() const;
[[nodiscard]] const Descriptor* get(const QString& key) const;
private:
explicit Schema() = default;
private:
explicit Schema() = default;
QList<Descriptor> m_descriptors;
QHash<QString, qsizetype> m_keyToIndex;
QList<Descriptor> m_descriptors;
QHash<QString, qsizetype> m_keyToIndex;
};
} // namespace ZShell::settings