/**
 * This file is generated by dconfig2cpp.
 * Command line arguments: /usr/lib/dtk6/DCore/bin/dconfig2cpp -o /build/treeland/src/treeland/build/src/appconfig.hpp -c AppConfig /build/treeland/src/treeland/misc/dconfig/org.deepin.dde.treeland.app.json
 * Generation time: 2026-08-18T12:51:56
 * JSON file version: 1.0
 * Tool version: 1.1
 *
 * WARNING: DO NOT MODIFY THIS FILE MANUALLY.
 * If you need to change the content, please modify the dconfig2cpp tool.
 */

#ifndef APPCONFIG_H
#define APPCONFIG_H

#define APPCONFIG_DCONFIG_FILE_VERSION_MAJOR 1
#define APPCONFIG_DCONFIG_FILE_VERSION_MINOR 1
#define APPCONFIG_DCONFIG_FILE_enablePrelaunchSplash
#define APPCONFIG_DCONFIG_FILE_lastWindowHeight
#define APPCONFIG_DCONFIG_FILE_lastWindowWidth
#define APPCONFIG_DCONFIG_FILE_splashDarkPalette
#define APPCONFIG_DCONFIG_FILE_splashLightPalette
#define APPCONFIG_DCONFIG_FILE_splashThemeType

#include <QThread>
#include <QVariant>
#include <QPointer>
#include <QDebug>
#include <QAtomicPointer>
#include <QAtomicInteger>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QProperty>
#endif
#include <QEvent>
#include <DSGApplication>
#include <DConfig>

class AppConfig : public QObject {
    Q_OBJECT

    Q_PROPERTY(bool enablePrelaunchSplash READ enablePrelaunchSplash WRITE setEnablePrelaunchSplash NOTIFY enablePrelaunchSplashChanged RESET resetEnablePrelaunchSplash)
    Q_PROPERTY(qlonglong lastWindowHeight READ lastWindowHeight WRITE setLastWindowHeight NOTIFY lastWindowHeightChanged RESET resetLastWindowHeight)
    Q_PROPERTY(qlonglong lastWindowWidth READ lastWindowWidth WRITE setLastWindowWidth NOTIFY lastWindowWidthChanged RESET resetLastWindowWidth)
    Q_PROPERTY(QString splashDarkPalette READ splashDarkPalette WRITE setSplashDarkPalette NOTIFY splashDarkPaletteChanged RESET resetSplashDarkPalette)
    Q_PROPERTY(QString splashLightPalette READ splashLightPalette WRITE setSplashLightPalette NOTIFY splashLightPaletteChanged RESET resetSplashLightPalette)
    Q_PROPERTY(qlonglong splashThemeType READ splashThemeType WRITE setSplashThemeType NOTIFY splashThemeTypeChanged RESET resetSplashThemeType)
    Q_CLASSINFO("DConfigKeyList", "enablePrelaunchSplash;lastWindowHeight;lastWindowWidth;splashDarkPalette;splashLightPalette;splashThemeType")
    Q_CLASSINFO("DConfigFileName", "org.deepin.dde.treeland.app")
    Q_CLASSINFO("DConfigFileVersion", "1.0")

public:
    explicit AppConfig(QThread *thread, DTK_CORE_NAMESPACE::DConfigBackend *backend,
                        const QString &name, const QString &appId, const QString &subpath,
                        bool isGeneric, QObject *parent)
                  : QObject(parent), m_data(new Data) {
        m_data->m_userConfig = this;
        m_data->moveToThread(this->thread());

        if (!thread->isRunning()) {
            qWarning() << QLatin1String("Warning: The provided thread is not running.");
        }
        Q_ASSERT(QThread::currentThread() != thread);
        auto worker = new QObject();
        worker->moveToThread(thread);

        QPointer<Data> safeData(m_data);

        QMetaObject::invokeMethod(worker, [safeData, backend, name, appId, subpath, isGeneric, worker]() mutable {
            delete worker;
            worker = nullptr;

            if (!safeData->m_status.testAndSetOrdered(static_cast<int>(Data::Status::Invalid),
                                                      static_cast<int>(Data::Status::Initializing))) {
                // CAS failed: status changed (e.g., set to Destroyed by destructor)
                // Schedule deletion of Data object via deleteLater to avoid direct delete in Config thread
                safeData->deleteLater();
                return;
            }

            DTK_CORE_NAMESPACE::DConfig *config = nullptr;
            if (isGeneric) {
                if (backend) {
                    config = DTK_CORE_NAMESPACE::DConfig::createGeneric(backend, name, subpath, nullptr);
                } else {
                    config = DTK_CORE_NAMESPACE::DConfig::createGeneric(name, subpath, nullptr);
                }
            } else {
                if (backend) {
                    if (appId.isNull()) {
                        config = DTK_CORE_NAMESPACE::DConfig::create(backend, DTK_CORE_NAMESPACE::DSGApplication::id(),
                                                                     name, subpath, nullptr);
                    } else {
                        config = DTK_CORE_NAMESPACE::DConfig::create(backend, appId, name, subpath, nullptr);
                    }
                } else {
                    if (appId.isNull()) {
                        config = DTK_CORE_NAMESPACE::DConfig::create(DTK_CORE_NAMESPACE::DSGApplication::id(),
                                                                     name, subpath, nullptr);
                    } else {
                        config = DTK_CORE_NAMESPACE::DConfig::create(appId, name, subpath, nullptr);
                    }
                }
            }

            if (!config || !config->isValid()) {
                qWarning() << QLatin1String("Failed to create DConfig instance.");

                QMetaObject::invokeMethod(safeData, [safeData]() {
                    if (safeData->m_status.testAndSetOrdered(static_cast<int>(Data::Status::Initializing),
                                                             static_cast<int>(Data::Status::Failed))) {
                        Q_EMIT safeData->m_userConfig->configInitializeFailed();
                    } else {
                        // CAS failed, destroy data object
                        delete safeData;
                    }
                }, Qt::QueuedConnection);

                if (config)
                    delete config;

                return;
            }
            config->moveToThread(QThread::currentThread());
            // Initialize through Data class
            safeData->initializeInConfigThread(config);

            // Queue state transition to main thread, to ensure config values are fully initialized.
            QMetaObject::invokeMethod(safeData, [safeData, config]() {
                // Try to transition from Initializing to Succeeded
                if (safeData->m_status.testAndSetOrdered(static_cast<int>(Data::Status::Initializing),
                                                         static_cast<int>(Data::Status::Succeeded))) {
                    // CAS succeeded: connect config destroyed signal to cleanup Data, then emit success signal to main thread
                    QObject::connect(config, &QObject::destroyed, safeData, &QObject::deleteLater);
                    if (safeData->m_userConfig) {
                        Q_EMIT safeData->m_userConfig->configInitializeSucceed(config);
                    }
                } else {
                    // CAS failed - state changed (e.g., set to Destroyed)
                    // We must clean up the config we just created
                    config->deleteLater();
                    safeData->deleteLater();
                }
            }, Qt::QueuedConnection);
        });
    }
    static AppConfig* create(const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new AppConfig(thread, nullptr, QStringLiteral(u"\u006f\u0072\u0067\u002e\u0064\u0065\u0065\u0070\u0069\u006e\u002e\u0064\u0064\u0065\u002e\u0074\u0072\u0065\u0065\u006c\u0061\u006e\u0064\u002e\u0061\u0070\u0070"), appId, subpath, false, parent); }
    static AppConfig* create(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new AppConfig(thread, backend, QStringLiteral(u"\u006f\u0072\u0067\u002e\u0064\u0065\u0065\u0070\u0069\u006e\u002e\u0064\u0064\u0065\u002e\u0074\u0072\u0065\u0065\u006c\u0061\u006e\u0064\u002e\u0061\u0070\u0070"), appId, subpath, false, parent); }
    static AppConfig* createByName(const QString &name, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new AppConfig(thread, nullptr, name, appId, subpath, false, parent); }
    static AppConfig* createByName(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &name, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new AppConfig(thread, backend, name, appId, subpath, false, parent); }
    static AppConfig* createGeneric(const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new AppConfig(thread, nullptr, QStringLiteral(u"\u006f\u0072\u0067\u002e\u0064\u0065\u0065\u0070\u0069\u006e\u002e\u0064\u0064\u0065\u002e\u0074\u0072\u0065\u0065\u006c\u0061\u006e\u0064\u002e\u0061\u0070\u0070"), {}, subpath, true, parent); }
    static AppConfig* create(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new AppConfig(thread, backend, QStringLiteral(u"\u006f\u0072\u0067\u002e\u0064\u0065\u0065\u0070\u0069\u006e\u002e\u0064\u0064\u0065\u002e\u0074\u0072\u0065\u0065\u006c\u0061\u006e\u0064\u002e\u0061\u0070\u0070"), {}, subpath, true, parent); }
    static AppConfig* createGenericByName(const QString &name, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new AppConfig(thread, nullptr, name, {}, subpath, true, parent); }
    static AppConfig* createGenericByName(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &name, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new AppConfig(thread, backend, name, {}, subpath, true, parent); }
    ~AppConfig() {
        m_data->m_userConfig = nullptr;
        int oldStatus = m_data->m_status.fetchAndStoreOrdered(static_cast<int>(Data::Status::Destroyed));
        if (oldStatus == static_cast<int>(Data::Status::Succeeded)) {
            // When Succeeded, release config object only
            auto config = m_data->m_config.loadRelaxed();
            Q_ASSERT(config);
            config->deleteLater();
            // m_data will be deleted by config's destroyed signal
        } else if (oldStatus == static_cast<int>(Data::Status::Failed)) {
            // When Failed state, schedule cleanup of Data object
            m_data->deleteLater();
        }
    }

    Q_INVOKABLE DTK_CORE_NAMESPACE::DConfig *config() const {
        return m_data->m_config.loadRelaxed();
    }
    // Deprecated: Use isInitializeSucceeded() instead
    Q_INVOKABLE Q_DECL_DEPRECATED_X("Use isInitializeSucceeded() instead")
    bool isInitializeSucceed() const {
        return isInitializeSucceeded();
    }
    Q_INVOKABLE bool isInitializeSucceeded() const {
        return m_data->m_status.loadRelaxed() == static_cast<int>(Data::Status::Succeeded);
    }
    Q_INVOKABLE bool isInitializeFailed() const {
        return m_data->m_status.loadRelaxed() == static_cast<int>(Data::Status::Failed);
    }
    Q_INVOKABLE bool isInitializing() const {
        return m_data->m_status.loadRelaxed() == static_cast<int>(Data::Status::Initializing);
    }

    Q_INVOKABLE QStringList keyList() const {
        return { QStringLiteral("enablePrelaunchSplash"),
                 QStringLiteral("lastWindowHeight"),
                 QStringLiteral("lastWindowWidth"),
                 QStringLiteral("splashDarkPalette"),
                 QStringLiteral("splashLightPalette"),
                 QStringLiteral("splashThemeType")};
    }

    Q_INVOKABLE bool isDefaultValue(const QString &key) const {
        if (key == QStringLiteral("enablePrelaunchSplash"))
            return enablePrelaunchSplashIsDefaultValue();
        if (key == QStringLiteral("lastWindowHeight"))
            return lastWindowHeightIsDefaultValue();
        if (key == QStringLiteral("lastWindowWidth"))
            return lastWindowWidthIsDefaultValue();
        if (key == QStringLiteral("splashDarkPalette"))
            return splashDarkPaletteIsDefaultValue();
        if (key == QStringLiteral("splashLightPalette"))
            return splashLightPaletteIsDefaultValue();
        if (key == QStringLiteral("splashThemeType"))
            return splashThemeTypeIsDefaultValue();
        return false;
    }

    bool enablePrelaunchSplash() const {
        return m_data->p_enablePrelaunchSplash;
    }
    void setEnablePrelaunchSplash(const bool &value) {
        auto oldValue = m_data->p_enablePrelaunchSplash;
        m_data->p_enablePrelaunchSplash = value;
        m_data->markPropertySet(0);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("enablePrelaunchSplash"), value);
            });
        }
        if (m_data->p_enablePrelaunchSplash != oldValue) {
            Q_EMIT enablePrelaunchSplashChanged();
            Q_EMIT valueChanged(QStringLiteral("enablePrelaunchSplash"), value);
        }
    }
    void resetEnablePrelaunchSplash() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("enablePrelaunchSplash"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<bool> bindableEnablePrelaunchSplash() {
        return QBindable<bool>(this, "enablePrelaunchSplash");
    }
#endif
    Q_INVOKABLE bool enablePrelaunchSplashIsDefaultValue() const {
        return !m_data->testPropertySet(0);
    }
    qlonglong lastWindowHeight() const {
        return m_data->p_lastWindowHeight;
    }
    void setLastWindowHeight(const qlonglong &value) {
        auto oldValue = m_data->p_lastWindowHeight;
        m_data->p_lastWindowHeight = value;
        m_data->markPropertySet(1);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("lastWindowHeight"), value);
            });
        }
        if (m_data->p_lastWindowHeight != oldValue) {
            Q_EMIT lastWindowHeightChanged();
            Q_EMIT valueChanged(QStringLiteral("lastWindowHeight"), value);
        }
    }
    void resetLastWindowHeight() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("lastWindowHeight"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<qlonglong> bindableLastWindowHeight() {
        return QBindable<qlonglong>(this, "lastWindowHeight");
    }
#endif
    Q_INVOKABLE bool lastWindowHeightIsDefaultValue() const {
        return !m_data->testPropertySet(1);
    }
    qlonglong lastWindowWidth() const {
        return m_data->p_lastWindowWidth;
    }
    void setLastWindowWidth(const qlonglong &value) {
        auto oldValue = m_data->p_lastWindowWidth;
        m_data->p_lastWindowWidth = value;
        m_data->markPropertySet(2);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("lastWindowWidth"), value);
            });
        }
        if (m_data->p_lastWindowWidth != oldValue) {
            Q_EMIT lastWindowWidthChanged();
            Q_EMIT valueChanged(QStringLiteral("lastWindowWidth"), value);
        }
    }
    void resetLastWindowWidth() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("lastWindowWidth"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<qlonglong> bindableLastWindowWidth() {
        return QBindable<qlonglong>(this, "lastWindowWidth");
    }
#endif
    Q_INVOKABLE bool lastWindowWidthIsDefaultValue() const {
        return !m_data->testPropertySet(2);
    }
    QString splashDarkPalette() const {
        return m_data->p_splashDarkPalette;
    }
    void setSplashDarkPalette(const QString &value) {
        auto oldValue = m_data->p_splashDarkPalette;
        m_data->p_splashDarkPalette = value;
        m_data->markPropertySet(3);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("splashDarkPalette"), value);
            });
        }
        if (m_data->p_splashDarkPalette != oldValue) {
            Q_EMIT splashDarkPaletteChanged();
            Q_EMIT valueChanged(QStringLiteral("splashDarkPalette"), value);
        }
    }
    void resetSplashDarkPalette() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("splashDarkPalette"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<QString> bindableSplashDarkPalette() {
        return QBindable<QString>(this, "splashDarkPalette");
    }
#endif
    Q_INVOKABLE bool splashDarkPaletteIsDefaultValue() const {
        return !m_data->testPropertySet(3);
    }
    QString splashLightPalette() const {
        return m_data->p_splashLightPalette;
    }
    void setSplashLightPalette(const QString &value) {
        auto oldValue = m_data->p_splashLightPalette;
        m_data->p_splashLightPalette = value;
        m_data->markPropertySet(4);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("splashLightPalette"), value);
            });
        }
        if (m_data->p_splashLightPalette != oldValue) {
            Q_EMIT splashLightPaletteChanged();
            Q_EMIT valueChanged(QStringLiteral("splashLightPalette"), value);
        }
    }
    void resetSplashLightPalette() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("splashLightPalette"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<QString> bindableSplashLightPalette() {
        return QBindable<QString>(this, "splashLightPalette");
    }
#endif
    Q_INVOKABLE bool splashLightPaletteIsDefaultValue() const {
        return !m_data->testPropertySet(4);
    }
    qlonglong splashThemeType() const {
        return m_data->p_splashThemeType;
    }
    void setSplashThemeType(const qlonglong &value) {
        auto oldValue = m_data->p_splashThemeType;
        m_data->p_splashThemeType = value;
        m_data->markPropertySet(5);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("splashThemeType"), value);
            });
        }
        if (m_data->p_splashThemeType != oldValue) {
            Q_EMIT splashThemeTypeChanged();
            Q_EMIT valueChanged(QStringLiteral("splashThemeType"), value);
        }
    }
    void resetSplashThemeType() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("splashThemeType"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<qlonglong> bindableSplashThemeType() {
        return QBindable<qlonglong>(this, "splashThemeType");
    }
#endif
    Q_INVOKABLE bool splashThemeTypeIsDefaultValue() const {
        return !m_data->testPropertySet(5);
    }
protected:
    bool event(QEvent *e) override {
        if (e->type() == QEvent::ThreadChange) {
            Q_ASSERT(this->thread() == m_data->thread());
        }
        return QObject::event(e);
    }
Q_SIGNALS:
    void configInitializeFailed();
    void configInitializeSucceed(DTK_CORE_NAMESPACE::DConfig *config);
    void valueChanged(const QString &key, const QVariant &value);
    void enablePrelaunchSplashChanged();
    void lastWindowHeightChanged();
    void lastWindowWidthChanged();
    void splashDarkPaletteChanged();
    void splashLightPaletteChanged();
    void splashThemeTypeChanged();

private:
    // Prevent external moveToThread calls
    using QObject::moveToThread;
    class Data : public QObject {
    public:
        enum class Status {
            Invalid = 0,
            Initializing = 1,
            Succeeded = 2,
            Failed = 3,
            Destroyed = 4
        };

        explicit Data()
            : QObject(nullptr) {}

        inline void initializeInConfigThread(DTK_CORE_NAMESPACE::DConfig *config) {
            Q_ASSERT(!m_config.loadRelaxed());
            m_config.storeRelaxed(config);
            if (testPropertySet(0)) {
                config->setValue(QStringLiteral("enablePrelaunchSplash"), QVariant::fromValue(p_enablePrelaunchSplash));
            } else {
                updateValue(QStringLiteral("enablePrelaunchSplash"), QVariant::fromValue(p_enablePrelaunchSplash));
            }
            if (testPropertySet(1)) {
                config->setValue(QStringLiteral("lastWindowHeight"), QVariant::fromValue(p_lastWindowHeight));
            } else {
                updateValue(QStringLiteral("lastWindowHeight"), QVariant::fromValue(p_lastWindowHeight));
            }
            if (testPropertySet(2)) {
                config->setValue(QStringLiteral("lastWindowWidth"), QVariant::fromValue(p_lastWindowWidth));
            } else {
                updateValue(QStringLiteral("lastWindowWidth"), QVariant::fromValue(p_lastWindowWidth));
            }
            if (testPropertySet(3)) {
                config->setValue(QStringLiteral("splashDarkPalette"), QVariant::fromValue(p_splashDarkPalette));
            } else {
                updateValue(QStringLiteral("splashDarkPalette"), QVariant::fromValue(p_splashDarkPalette));
            }
            if (testPropertySet(4)) {
                config->setValue(QStringLiteral("splashLightPalette"), QVariant::fromValue(p_splashLightPalette));
            } else {
                updateValue(QStringLiteral("splashLightPalette"), QVariant::fromValue(p_splashLightPalette));
            }
            if (testPropertySet(5)) {
                config->setValue(QStringLiteral("splashThemeType"), QVariant::fromValue(p_splashThemeType));
            } else {
                updateValue(QStringLiteral("splashThemeType"), QVariant::fromValue(p_splashThemeType));
            }
            connect(config, &DTK_CORE_NAMESPACE::DConfig::valueChanged, this, [this](const QString &key) {
                updateValue(key);
            }, Qt::DirectConnection);
        }

        inline void updateValue(const QString &key, const QVariant &fallback = QVariant()) {
            if (!m_config.loadRelaxed())
                return;
            Q_ASSERT(QThread::currentThread() == m_config.loadRelaxed()->thread());
            const QVariant &value = m_config.loadRelaxed()->value(key, fallback);
            if (key == QStringLiteral("enablePrelaunchSplash")) {
                markPropertySet(0, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<bool>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_enablePrelaunchSplash != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_enablePrelaunchSplash = newValue;
                        Q_EMIT m_userConfig->enablePrelaunchSplashChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("lastWindowHeight")) {
                markPropertySet(1, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<qlonglong>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_lastWindowHeight != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_lastWindowHeight = newValue;
                        Q_EMIT m_userConfig->lastWindowHeightChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("lastWindowWidth")) {
                markPropertySet(2, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<qlonglong>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_lastWindowWidth != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_lastWindowWidth = newValue;
                        Q_EMIT m_userConfig->lastWindowWidthChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("splashDarkPalette")) {
                markPropertySet(3, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<QString>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_splashDarkPalette != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_splashDarkPalette = newValue;
                        Q_EMIT m_userConfig->splashDarkPaletteChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("splashLightPalette")) {
                markPropertySet(4, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<QString>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_splashLightPalette != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_splashLightPalette = newValue;
                        Q_EMIT m_userConfig->splashLightPaletteChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("splashThemeType")) {
                markPropertySet(5, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<qlonglong>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_splashThemeType != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_splashThemeType = newValue;
                        Q_EMIT m_userConfig->splashThemeTypeChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
        }
        inline void markPropertySet(const int index, bool on = true) {
            if (index < 32) {
                if (on)
                    m_propertySetStatus0.fetchAndOrOrdered(1 << (index - 0));
                else
                    m_propertySetStatus0.fetchAndAndOrdered(~(1 << (index - 0)));
                return;
            }
            Q_UNREACHABLE();
        }
        inline bool testPropertySet(const int index) const {
            if (index < 32) {
                return (m_propertySetStatus0.loadRelaxed() & (1 << (index - 0)));
            }
            Q_UNREACHABLE();
        }
        // Member variables
        QAtomicPointer<DTK_CORE_NAMESPACE::DConfig> m_config = nullptr;
        QAtomicInteger<int> m_status = static_cast<int>(Status::Invalid);
        QPointer<AppConfig> m_userConfig = nullptr;
        QAtomicInteger<quint32> m_propertySetStatus0 = 0;

        // Property storage
        bool p_enablePrelaunchSplash { true };
        qlonglong p_lastWindowHeight { 600 };
        qlonglong p_lastWindowWidth { 800 };
        // Default value: "#181818"
        QString p_splashDarkPalette { QStringLiteral(u"\u0023\u0031\u0038\u0031\u0038\u0031\u0038") };
        // Default value: "#FFFFFF"
        QString p_splashLightPalette { QStringLiteral(u"\u0023\u0046\u0046\u0046\u0046\u0046\u0046") };
        qlonglong p_splashThemeType { 0 };
    };

    QPointer<Data> m_data;
};

#endif // APPCONFIG_H
