/**
 * This file is generated by dconfig2cpp.
 * Command line arguments: ./dconfig2cpp -p ./dde-control-center/toolGenerate/dconfig2cpp ./dde-control-center/misc/configs/org.deepin.dde.control-center.personalization.json
 * Generation time: 2025-01-14T10:54:58
 * JSON file version: 1.0
 * 
 * WARNING: DO NOT MODIFY THIS FILE MANUALLY.
 * If you need to change the content, please modify the dconfig2cpp tool.
 */

#ifndef ORG_DEEPIN_DDE_CONTROL-CENTER_PERSONALIZATION_H
#define ORG_DEEPIN_DDE_CONTROL-CENTER_PERSONALIZATION_H

#include <QThread>
#include <QVariant>
#include <QDebug>
#include <QAtomicPointer>
#include <QAtomicInteger>
#include <DConfig>

class org_deepin_dde_control-center_personalization : public QObject {
    Q_OBJECT

    Q_PROPERTY(QString compactDisplayStatus READ compactDisplayStatus WRITE setCompactDisplayStatus NOTIFY compactDisplayStatusChanged)
    Q_PROPERTY(QList<QVariant> hideIconThemes READ hideIconThemes WRITE setHideIconThemes NOTIFY hideIconThemesChanged)
    Q_PROPERTY(QString scrollbarPolicyStatus READ scrollbarPolicyStatus WRITE setScrollbarPolicyStatus NOTIFY scrollbarPolicyStatusChanged)
    Q_PROPERTY(QString titleBarHeightStatus READ titleBarHeightStatus WRITE setTitleBarHeightStatus NOTIFY titleBarHeightStatusChanged)
    Q_PROPERTY(bool titleBarHeightSupportCompactDisplay READ titleBarHeightSupportCompactDisplay WRITE setTitleBarHeightSupportCompactDisplay NOTIFY titleBarHeightSupportCompactDisplayChanged)
public:
    explicit org_deepin_dde_control-center_personalization(QThread *thread, const QString &appId, const QString &name, const QString &subpath, QObject *parent = nullptr)
        : QObject(parent) {

        if (!thread->isRunning()) {
            qWarning() << QStringLiteral("Warning: The provided thread is not running.");
        }
        Q_ASSERT(QThread::currentThread() != thread);
        auto worker = new QObject();
        worker->moveToThread(thread);
        QMetaObject::invokeMethod(worker, [=]() {
            auto config = DTK_CORE_NAMESPACE::DConfig::create(appId, name, subpath, nullptr);
            if (!config) {
                qWarning() << QStringLiteral("Failed to create DConfig instance.");
                worker->deleteLater();
                return;
            }
            config->moveToThread(QThread::currentThread());
            initialize(config);
            worker->deleteLater();
        });
    }
    explicit org_deepin_dde_control-center_personalization(QThread *thread, DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &appId, const QString &name, const QString &subpath, QObject *parent = nullptr)
        : QObject(parent) {

        if (!thread->isRunning()) {
            qWarning() << QStringLiteral("Warning: The provided thread is not running.");
        }
        Q_ASSERT(QThread::currentThread() != thread);
        auto worker = new QObject();
        worker->moveToThread(thread);
        QMetaObject::invokeMethod(worker, [=]() {
            auto config = DTK_CORE_NAMESPACE::DConfig::create(backend, appId, name, subpath, nullptr);
            if (!config) {
                qWarning() << QStringLiteral("Failed to create DConfig instance.");
                worker->deleteLater();
                return;
            }
            config->moveToThread(QThread::currentThread());
            initialize(config);
            worker->deleteLater();
        });
    }
    explicit org_deepin_dde_control-center_personalization(QThread *thread, const QString &name, const QString &subpath, QObject *parent = nullptr)
        : QObject(parent) {

        if (!thread->isRunning()) {
            qWarning() << QStringLiteral("Warning: The provided thread is not running.");
        }
        Q_ASSERT(QThread::currentThread() != thread);
        auto worker = new QObject();
        worker->moveToThread(thread);
        QMetaObject::invokeMethod(worker, [=]() {
            auto config = DTK_CORE_NAMESPACE::DConfig::create(name, subpath, nullptr);
            if (!config) {
                qWarning() << QStringLiteral("Failed to create DConfig instance.");
                worker->deleteLater();
                return;
            }
            config->moveToThread(QThread::currentThread());
            initialize(config);
            worker->deleteLater();
        });
    }
    explicit org_deepin_dde_control-center_personalization(QThread *thread, DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &name, const QString &subpath, QObject *parent = nullptr)
        : QObject(parent) {

        if (!thread->isRunning()) {
            qWarning() << QStringLiteral("Warning: The provided thread is not running.");
        }
        Q_ASSERT(QThread::currentThread() != thread);
        auto worker = new QObject();
        worker->moveToThread(thread);
        QMetaObject::invokeMethod(worker, [=]() {
            auto config = DTK_CORE_NAMESPACE::DConfig::create(backend, name, subpath, nullptr);
            if (!config) {
                qWarning() << QStringLiteral("Failed to create DConfig instance.");
                worker->deleteLater();
                return;
            }
            config->moveToThread(QThread::currentThread());
            initialize(config);
            worker->deleteLater();
        });
    }
    ~org_deepin_dde_control-center_personalization() {
        if (m_config.loadRelaxed()) {
            m_config.loadRelaxed()->deleteLater();
        }
    }

    QString compactDisplayStatus() const {
        return p_compactDisplayStatus;
    }
    void setCompactDisplayStatus(const QString &value) {
        auto oldValue = p_compactDisplayStatus;
        p_compactDisplayStatus = value;
        markPropertySet(0);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("compactDisplayStatus"), value);
            });
        }
        if (p_compactDisplayStatus != oldValue) {
            Q_EMIT compactDisplayStatusChanged();
        }
    }
    QList<QVariant> hideIconThemes() const {
        return p_hideIconThemes;
    }
    void setHideIconThemes(const QList<QVariant> &value) {
        auto oldValue = p_hideIconThemes;
        p_hideIconThemes = value;
        markPropertySet(1);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("hideIconThemes"), value);
            });
        }
        if (p_hideIconThemes != oldValue) {
            Q_EMIT hideIconThemesChanged();
        }
    }
    QString scrollbarPolicyStatus() const {
        return p_scrollbarPolicyStatus;
    }
    void setScrollbarPolicyStatus(const QString &value) {
        auto oldValue = p_scrollbarPolicyStatus;
        p_scrollbarPolicyStatus = value;
        markPropertySet(2);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("scrollbarPolicyStatus"), value);
            });
        }
        if (p_scrollbarPolicyStatus != oldValue) {
            Q_EMIT scrollbarPolicyStatusChanged();
        }
    }
    QString titleBarHeightStatus() const {
        return p_titleBarHeightStatus;
    }
    void setTitleBarHeightStatus(const QString &value) {
        auto oldValue = p_titleBarHeightStatus;
        p_titleBarHeightStatus = value;
        markPropertySet(3);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("titleBarHeightStatus"), value);
            });
        }
        if (p_titleBarHeightStatus != oldValue) {
            Q_EMIT titleBarHeightStatusChanged();
        }
    }
    bool titleBarHeightSupportCompactDisplay() const {
        return p_titleBarHeightSupportCompactDisplay;
    }
    void setTitleBarHeightSupportCompactDisplay(const bool &value) {
        auto oldValue = p_titleBarHeightSupportCompactDisplay;
        p_titleBarHeightSupportCompactDisplay = value;
        markPropertySet(4);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("titleBarHeightSupportCompactDisplay"), value);
            });
        }
        if (p_titleBarHeightSupportCompactDisplay != oldValue) {
            Q_EMIT titleBarHeightSupportCompactDisplayChanged();
        }
    }
Q_SIGNALS:
    void compactDisplayStatusChanged();
    void hideIconThemesChanged();
    void scrollbarPolicyStatusChanged();
    void titleBarHeightStatusChanged();
    void titleBarHeightSupportCompactDisplayChanged();
private:
    void initialize(DTK_CORE_NAMESPACE::DConfig *config) {
        Q_ASSERT(!m_config.loadRelaxed());
        m_config.storeRelaxed(config);
        if (testPropertySet(0)) {
            config->setValue(QStringLiteral("compactDisplayStatus"), QVariant::fromValue(p_compactDisplayStatus));
        } else {
            updateValue(QStringLiteral("compactDisplayStatus"), QVariant::fromValue(p_compactDisplayStatus));
        }
        if (testPropertySet(1)) {
            config->setValue(QStringLiteral("hideIconThemes"), QVariant::fromValue(p_hideIconThemes));
        } else {
            updateValue(QStringLiteral("hideIconThemes"), QVariant::fromValue(p_hideIconThemes));
        }
        if (testPropertySet(2)) {
            config->setValue(QStringLiteral("scrollbarPolicyStatus"), QVariant::fromValue(p_scrollbarPolicyStatus));
        } else {
            updateValue(QStringLiteral("scrollbarPolicyStatus"), QVariant::fromValue(p_scrollbarPolicyStatus));
        }
        if (testPropertySet(3)) {
            config->setValue(QStringLiteral("titleBarHeightStatus"), QVariant::fromValue(p_titleBarHeightStatus));
        } else {
            updateValue(QStringLiteral("titleBarHeightStatus"), QVariant::fromValue(p_titleBarHeightStatus));
        }
        if (testPropertySet(4)) {
            config->setValue(QStringLiteral("titleBarHeightSupportCompactDisplay"), QVariant::fromValue(p_titleBarHeightSupportCompactDisplay));
        } else {
            updateValue(QStringLiteral("titleBarHeightSupportCompactDisplay"), QVariant::fromValue(p_titleBarHeightSupportCompactDisplay));
        }

        connect(config, &DTK_CORE_NAMESPACE::DConfig::valueChanged, this, [this](const QString &key) {
            updateValue(key);
        }, Qt::DirectConnection);
    }
    void updateValue(const QString &key, const QVariant &fallback = QVariant()) {
        Q_ASSERT(QThread::currentThread() == m_config.loadRelaxed()->thread());
        const QVariant &value = m_config.loadRelaxed()->value(key, fallback);
        if (key == QStringLiteral("compactDisplayStatus")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_compactDisplayStatus != newValue) {
                    p_compactDisplayStatus = newValue;
                    Q_EMIT compactDisplayStatusChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("hideIconThemes")) {
            auto newValue = qvariant_cast<QList<QVariant>>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_hideIconThemes != newValue) {
                    p_hideIconThemes = newValue;
                    Q_EMIT hideIconThemesChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("scrollbarPolicyStatus")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_scrollbarPolicyStatus != newValue) {
                    p_scrollbarPolicyStatus = newValue;
                    Q_EMIT scrollbarPolicyStatusChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("titleBarHeightStatus")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_titleBarHeightStatus != newValue) {
                    p_titleBarHeightStatus = newValue;
                    Q_EMIT titleBarHeightStatusChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("titleBarHeightSupportCompactDisplay")) {
            auto newValue = qvariant_cast<bool>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_titleBarHeightSupportCompactDisplay != newValue) {
                    p_titleBarHeightSupportCompactDisplay = newValue;
                    Q_EMIT titleBarHeightSupportCompactDisplayChanged();
                }
            });
            return;
        }
    }
    inline void markPropertySet(const int index) {
        if (index < 32) {
            m_propertySetStatus0.fetchAndOrOrdered(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();
    }
    QAtomicPointer<DTK_CORE_NAMESPACE::DConfig> m_config = nullptr;
    QString p_compactDisplayStatus { QStringLiteral("Enabled") };
    QList<QVariant> p_hideIconThemes { QList<QVariant>{QVariant(QStringLiteral("Papirus")), QVariant(QStringLiteral("Papirus-Dark")), QVariant(QStringLiteral("Papirus-Light")), QVariant(QStringLiteral("ePapirus")), QVariant(QStringLiteral("ePapirus-Dark"))} };
    QString p_scrollbarPolicyStatus { QStringLiteral("Enabled") };
    QString p_titleBarHeightStatus { QStringLiteral("Enabled") };
    bool p_titleBarHeightSupportCompactDisplay { true };
    QAtomicInteger<quint32> m_propertySetStatus0 = 0;
};

#endif // ORG_DEEPIN_DDE_CONTROL-CENTER_PERSONALIZATION_H
