/**
 * 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.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_H
#define ORG_DEEPIN_DDE_CONTROL-CENTER_H

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

class org_deepin_dde_control-center : public QObject {
    Q_OBJECT

    Q_PROPERTY(QList<QVariant> disableModule READ disableModule WRITE setDisableModule NOTIFY disableModuleChanged)
    Q_PROPERTY(double height READ height WRITE setHeight NOTIFY heightChanged)
    Q_PROPERTY(QList<QVariant> hideModule READ hideModule WRITE setHideModule NOTIFY hideModuleChanged)
    Q_PROPERTY(double width READ width WRITE setWidth NOTIFY widthChanged)
public:
    explicit org_deepin_dde_control-center(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(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(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(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() {
        if (m_config.loadRelaxed()) {
            m_config.loadRelaxed()->deleteLater();
        }
    }

    QList<QVariant> disableModule() const {
        return p_disableModule;
    }
    void setDisableModule(const QList<QVariant> &value) {
        auto oldValue = p_disableModule;
        p_disableModule = value;
        markPropertySet(0);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("disableModule"), value);
            });
        }
        if (p_disableModule != oldValue) {
            Q_EMIT disableModuleChanged();
        }
    }
    double height() const {
        return p_height;
    }
    void setHeight(const double &value) {
        auto oldValue = p_height;
        p_height = value;
        markPropertySet(1);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("height"), value);
            });
        }
        if (p_height != oldValue) {
            Q_EMIT heightChanged();
        }
    }
    QList<QVariant> hideModule() const {
        return p_hideModule;
    }
    void setHideModule(const QList<QVariant> &value) {
        auto oldValue = p_hideModule;
        p_hideModule = value;
        markPropertySet(2);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("hideModule"), value);
            });
        }
        if (p_hideModule != oldValue) {
            Q_EMIT hideModuleChanged();
        }
    }
    double width() const {
        return p_width;
    }
    void setWidth(const double &value) {
        auto oldValue = p_width;
        p_width = value;
        markPropertySet(3);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("width"), value);
            });
        }
        if (p_width != oldValue) {
            Q_EMIT widthChanged();
        }
    }
Q_SIGNALS:
    void disableModuleChanged();
    void heightChanged();
    void hideModuleChanged();
    void widthChanged();
private:
    void initialize(DTK_CORE_NAMESPACE::DConfig *config) {
        Q_ASSERT(!m_config.loadRelaxed());
        m_config.storeRelaxed(config);
        if (testPropertySet(0)) {
            config->setValue(QStringLiteral("disableModule"), QVariant::fromValue(p_disableModule));
        } else {
            updateValue(QStringLiteral("disableModule"), QVariant::fromValue(p_disableModule));
        }
        if (testPropertySet(1)) {
            config->setValue(QStringLiteral("height"), QVariant::fromValue(p_height));
        } else {
            updateValue(QStringLiteral("height"), QVariant::fromValue(p_height));
        }
        if (testPropertySet(2)) {
            config->setValue(QStringLiteral("hideModule"), QVariant::fromValue(p_hideModule));
        } else {
            updateValue(QStringLiteral("hideModule"), QVariant::fromValue(p_hideModule));
        }
        if (testPropertySet(3)) {
            config->setValue(QStringLiteral("width"), QVariant::fromValue(p_width));
        } else {
            updateValue(QStringLiteral("width"), QVariant::fromValue(p_width));
        }

        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("disableModule")) {
            auto newValue = qvariant_cast<QList<QVariant>>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_disableModule != newValue) {
                    p_disableModule = newValue;
                    Q_EMIT disableModuleChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("height")) {
            auto newValue = qvariant_cast<double>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_height != newValue) {
                    p_height = newValue;
                    Q_EMIT heightChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("hideModule")) {
            auto newValue = qvariant_cast<QList<QVariant>>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_hideModule != newValue) {
                    p_hideModule = newValue;
                    Q_EMIT hideModuleChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("width")) {
            auto newValue = qvariant_cast<double>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_width != newValue) {
                    p_width = newValue;
                    Q_EMIT widthChanged();
                }
            });
            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;
    QList<QVariant> p_disableModule { QList<QVariant>{} };
    double p_height { 600 };
    QList<QVariant> p_hideModule { QList<QVariant>{} };
    double p_width { 800 };
    QAtomicInteger<quint32> m_propertySetStatus0 = 0;
};

#endif // ORG_DEEPIN_DDE_CONTROL-CENTER_H
