/**
 * This file is generated by dconfig2cpp.
 * Command line arguments: ./build/tools/dconfig2cpp/dconfig2cpp /usr/share/dsg/configs/org.deepin.dtk.preference.json
 * Generation time: 2025-08-20T15:40:55
 * 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 DCONFIG_ORG_DEEPIN_DTK_PREFERENCE_H
#define DCONFIG_ORG_DEEPIN_DTK_PREFERENCE_H

#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 <DSGApplication>
#include <DConfig>

class dconfig_org_deepin_dtk_preference : public QObject {
    Q_OBJECT

    Q_PROPERTY(bool autoDisplayFeature READ autoDisplayFeature WRITE setAutoDisplayFeature NOTIFY autoDisplayFeatureChanged RESET resetAutoDisplayFeature)
    Q_PROPERTY(bool enableDtkAnimations READ enableDtkAnimations WRITE setEnableDtkAnimations NOTIFY enableDtkAnimationsChanged RESET resetEnableDtkAnimations)
    Q_PROPERTY(bool featureUpdated READ featureUpdated WRITE setFeatureUpdated NOTIFY featureUpdatedChanged RESET resetFeatureUpdated)
    Q_PROPERTY(bool keyboardsearchDisabled READ keyboardsearchDisabled WRITE setKeyboardsearchDisabled NOTIFY keyboardsearchDisabledChanged RESET resetKeyboardsearchDisabled)
    Q_PROPERTY(QString rules READ rules WRITE setRules NOTIFY rulesChanged RESET resetRules)
    Q_PROPERTY(qlonglong scrollBarPolicy READ scrollBarPolicy WRITE setScrollBarPolicy NOTIFY scrollBarPolicyChanged RESET resetScrollBarPolicy)
    Q_PROPERTY(qlonglong sizeMode READ sizeMode WRITE setSizeMode NOTIFY sizeModeChanged RESET resetSizeMode)
    Q_PROPERTY(qlonglong themeType READ themeType WRITE setThemeType NOTIFY themeTypeChanged RESET resetThemeType)
    Q_PROPERTY(qlonglong titlebarHeight READ titlebarHeight WRITE setTitlebarHeight NOTIFY titlebarHeightChanged RESET resetTitlebarHeight)
    Q_PROPERTY(bool underlineShortcut READ underlineShortcut WRITE setUnderlineShortcut NOTIFY underlineShortcutChanged RESET resetUnderlineShortcut)
    Q_CLASSINFO("DConfigKeyList", "autoDisplayFeature;enableDtkAnimations;featureUpdated;keyboardsearchDisabled;rules;scrollBarPolicy;sizeMode;themeType;titlebarHeight;underlineShortcut")
    Q_CLASSINFO("DConfigFileName", "org.deepin.dtk.preference")
    Q_CLASSINFO("DConfigFileVersion", "1.0")

public:
    explicit dconfig_org_deepin_dtk_preference(QThread *thread, DTK_CORE_NAMESPACE::DConfigBackend *backend,
                        const QString &name, const QString &appId, const QString &subpath,
                        bool isGeneric, QObject *parent)
                : QObject(nullptr) {
        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<QObject> watcher(parent);
        QMetaObject::invokeMethod(worker, [=, this]() {
            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) {
                qWarning() << QLatin1String("Failed to create DConfig instance.");
                worker->deleteLater();
                return;
            }
            config->moveToThread(QThread::currentThread());
            initializeInConfigThread(config);
            if (watcher != parent) {
                // delete this if watcher is changed to nullptr.
                deleteLater();
            } else if (!this->parent() && parent) {
                // !parent() means that parent is not changed.
                this->setParent(watcher);
            }
            worker->deleteLater();
        });
    }
    static dconfig_org_deepin_dtk_preference* create(const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_org_deepin_dtk_preference(thread, nullptr, QStringLiteral(u"\u006f\u0072\u0067\u002e\u0064\u0065\u0065\u0070\u0069\u006e\u002e\u0064\u0074\u006b\u002e\u0070\u0072\u0065\u0066\u0065\u0072\u0065\u006e\u0063\u0065"), appId, subpath, false, parent); }
    static dconfig_org_deepin_dtk_preference* create(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_org_deepin_dtk_preference(thread, backend, QStringLiteral(u"\u006f\u0072\u0067\u002e\u0064\u0065\u0065\u0070\u0069\u006e\u002e\u0064\u0074\u006b\u002e\u0070\u0072\u0065\u0066\u0065\u0072\u0065\u006e\u0063\u0065"), appId, subpath, false, parent); }
    static dconfig_org_deepin_dtk_preference* createByName(const QString &name, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_org_deepin_dtk_preference(thread, nullptr, name, appId, subpath, false, parent); }
    static dconfig_org_deepin_dtk_preference* 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 dconfig_org_deepin_dtk_preference(thread, backend, name, appId, subpath, false, parent); }
    static dconfig_org_deepin_dtk_preference* createGeneric(const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_org_deepin_dtk_preference(thread, nullptr, QStringLiteral(u"\u006f\u0072\u0067\u002e\u0064\u0065\u0065\u0070\u0069\u006e\u002e\u0064\u0074\u006b\u002e\u0070\u0072\u0065\u0066\u0065\u0072\u0065\u006e\u0063\u0065"), {}, subpath, true, parent); }
    static dconfig_org_deepin_dtk_preference* create(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_org_deepin_dtk_preference(thread, backend, QStringLiteral(u"\u006f\u0072\u0067\u002e\u0064\u0065\u0065\u0070\u0069\u006e\u002e\u0064\u0074\u006b\u002e\u0070\u0072\u0065\u0066\u0065\u0072\u0065\u006e\u0063\u0065"), {}, subpath, true, parent); }
    static dconfig_org_deepin_dtk_preference* createGenericByName(const QString &name, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_org_deepin_dtk_preference(thread, nullptr, name, {}, subpath, true, parent); }
    static dconfig_org_deepin_dtk_preference* createGenericByName(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &name, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_org_deepin_dtk_preference(thread, backend, name, {}, subpath, true, parent); }
    ~dconfig_org_deepin_dtk_preference() {
        if (m_config.loadRelaxed()) {
            m_config.loadRelaxed()->deleteLater();
            m_config.storeRelaxed(nullptr);
        }
    }

    Q_INVOKABLE DTK_CORE_NAMESPACE::DConfig *config() const {
        return m_config.loadRelaxed();
    }

    Q_INVOKABLE bool isInitializeSucceed() const {
        return m_status.loadRelaxed() == static_cast<int>(Status::Succeed);
    }

    Q_INVOKABLE bool isInitializeFailed() const {
        return m_status.loadRelaxed() == static_cast<int>(Status::Failed);
    }

    Q_INVOKABLE bool isInitializing() const {
        return m_status.loadRelaxed() == static_cast<int>(Status::Invalid);
    }

    Q_INVOKABLE QStringList keyList() const {
        return { QStringLiteral("autoDisplayFeature"),
                 QStringLiteral("enableDtkAnimations"),
                 QStringLiteral("featureUpdated"),
                 QStringLiteral("keyboardsearchDisabled"),
                 QStringLiteral("rules"),
                 QStringLiteral("scrollBarPolicy"),
                 QStringLiteral("sizeMode"),
                 QStringLiteral("themeType"),
                 QStringLiteral("titlebarHeight"),
                 QStringLiteral("underlineShortcut")};
    }

    Q_INVOKABLE bool isDefaultValue(const QString &key) const {
        if (key == QStringLiteral("autoDisplayFeature"))
            return autoDisplayFeatureIsDefaultValue();
        if (key == QStringLiteral("enableDtkAnimations"))
            return enableDtkAnimationsIsDefaultValue();
        if (key == QStringLiteral("featureUpdated"))
            return featureUpdatedIsDefaultValue();
        if (key == QStringLiteral("keyboardsearchDisabled"))
            return keyboardsearchDisabledIsDefaultValue();
        if (key == QStringLiteral("rules"))
            return rulesIsDefaultValue();
        if (key == QStringLiteral("scrollBarPolicy"))
            return scrollBarPolicyIsDefaultValue();
        if (key == QStringLiteral("sizeMode"))
            return sizeModeIsDefaultValue();
        if (key == QStringLiteral("themeType"))
            return themeTypeIsDefaultValue();
        if (key == QStringLiteral("titlebarHeight"))
            return titlebarHeightIsDefaultValue();
        if (key == QStringLiteral("underlineShortcut"))
            return underlineShortcutIsDefaultValue();
        return false;
    }

    bool autoDisplayFeature() const {
        return p_autoDisplayFeature;
    }
    void setAutoDisplayFeature(const bool &value) {
        auto oldValue = p_autoDisplayFeature;
        p_autoDisplayFeature = value;
        markPropertySet(0);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("autoDisplayFeature"), value);
            });
        }
        if (p_autoDisplayFeature != oldValue) {
            Q_EMIT autoDisplayFeatureChanged();
            Q_EMIT valueChanged(QStringLiteral("autoDisplayFeature"), value);
        }
    }
    void resetAutoDisplayFeature() {
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this]() {
                m_config.loadRelaxed()->reset(QStringLiteral("autoDisplayFeature"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<bool> bindableAutoDisplayFeature() {
        return QBindable<bool>(this, "autoDisplayFeature");
    }
#endif
    Q_INVOKABLE bool autoDisplayFeatureIsDefaultValue() const {
        return !testPropertySet(0);
    }
    bool enableDtkAnimations() const {
        return p_enableDtkAnimations;
    }
    void setEnableDtkAnimations(const bool &value) {
        auto oldValue = p_enableDtkAnimations;
        p_enableDtkAnimations = value;
        markPropertySet(1);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("enableDtkAnimations"), value);
            });
        }
        if (p_enableDtkAnimations != oldValue) {
            Q_EMIT enableDtkAnimationsChanged();
            Q_EMIT valueChanged(QStringLiteral("enableDtkAnimations"), value);
        }
    }
    void resetEnableDtkAnimations() {
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this]() {
                m_config.loadRelaxed()->reset(QStringLiteral("enableDtkAnimations"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<bool> bindableEnableDtkAnimations() {
        return QBindable<bool>(this, "enableDtkAnimations");
    }
#endif
    Q_INVOKABLE bool enableDtkAnimationsIsDefaultValue() const {
        return !testPropertySet(1);
    }
    bool featureUpdated() const {
        return p_featureUpdated;
    }
    void setFeatureUpdated(const bool &value) {
        auto oldValue = p_featureUpdated;
        p_featureUpdated = value;
        markPropertySet(2);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("featureUpdated"), value);
            });
        }
        if (p_featureUpdated != oldValue) {
            Q_EMIT featureUpdatedChanged();
            Q_EMIT valueChanged(QStringLiteral("featureUpdated"), value);
        }
    }
    void resetFeatureUpdated() {
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this]() {
                m_config.loadRelaxed()->reset(QStringLiteral("featureUpdated"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<bool> bindableFeatureUpdated() {
        return QBindable<bool>(this, "featureUpdated");
    }
#endif
    Q_INVOKABLE bool featureUpdatedIsDefaultValue() const {
        return !testPropertySet(2);
    }
    bool keyboardsearchDisabled() const {
        return p_keyboardsearchDisabled;
    }
    void setKeyboardsearchDisabled(const bool &value) {
        auto oldValue = p_keyboardsearchDisabled;
        p_keyboardsearchDisabled = value;
        markPropertySet(3);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("keyboardsearchDisabled"), value);
            });
        }
        if (p_keyboardsearchDisabled != oldValue) {
            Q_EMIT keyboardsearchDisabledChanged();
            Q_EMIT valueChanged(QStringLiteral("keyboardsearchDisabled"), value);
        }
    }
    void resetKeyboardsearchDisabled() {
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this]() {
                m_config.loadRelaxed()->reset(QStringLiteral("keyboardsearchDisabled"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<bool> bindableKeyboardsearchDisabled() {
        return QBindable<bool>(this, "keyboardsearchDisabled");
    }
#endif
    Q_INVOKABLE bool keyboardsearchDisabledIsDefaultValue() const {
        return !testPropertySet(3);
    }
    QString rules() const {
        return p_rules;
    }
    void setRules(const QString &value) {
        auto oldValue = p_rules;
        p_rules = value;
        markPropertySet(4);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("rules"), value);
            });
        }
        if (p_rules != oldValue) {
            Q_EMIT rulesChanged();
            Q_EMIT valueChanged(QStringLiteral("rules"), value);
        }
    }
    void resetRules() {
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this]() {
                m_config.loadRelaxed()->reset(QStringLiteral("rules"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<QString> bindableRules() {
        return QBindable<QString>(this, "rules");
    }
#endif
    Q_INVOKABLE bool rulesIsDefaultValue() const {
        return !testPropertySet(4);
    }
    qlonglong scrollBarPolicy() const {
        return p_scrollBarPolicy;
    }
    void setScrollBarPolicy(const qlonglong &value) {
        auto oldValue = p_scrollBarPolicy;
        p_scrollBarPolicy = value;
        markPropertySet(5);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("scrollBarPolicy"), value);
            });
        }
        if (p_scrollBarPolicy != oldValue) {
            Q_EMIT scrollBarPolicyChanged();
            Q_EMIT valueChanged(QStringLiteral("scrollBarPolicy"), value);
        }
    }
    void resetScrollBarPolicy() {
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this]() {
                m_config.loadRelaxed()->reset(QStringLiteral("scrollBarPolicy"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<qlonglong> bindableScrollBarPolicy() {
        return QBindable<qlonglong>(this, "scrollBarPolicy");
    }
#endif
    Q_INVOKABLE bool scrollBarPolicyIsDefaultValue() const {
        return !testPropertySet(5);
    }
    qlonglong sizeMode() const {
        return p_sizeMode;
    }
    void setSizeMode(const qlonglong &value) {
        auto oldValue = p_sizeMode;
        p_sizeMode = value;
        markPropertySet(6);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("sizeMode"), value);
            });
        }
        if (p_sizeMode != oldValue) {
            Q_EMIT sizeModeChanged();
            Q_EMIT valueChanged(QStringLiteral("sizeMode"), value);
        }
    }
    void resetSizeMode() {
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this]() {
                m_config.loadRelaxed()->reset(QStringLiteral("sizeMode"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<qlonglong> bindableSizeMode() {
        return QBindable<qlonglong>(this, "sizeMode");
    }
#endif
    Q_INVOKABLE bool sizeModeIsDefaultValue() const {
        return !testPropertySet(6);
    }
    qlonglong themeType() const {
        return p_themeType;
    }
    void setThemeType(const qlonglong &value) {
        auto oldValue = p_themeType;
        p_themeType = value;
        markPropertySet(7);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("themeType"), value);
            });
        }
        if (p_themeType != oldValue) {
            Q_EMIT themeTypeChanged();
            Q_EMIT valueChanged(QStringLiteral("themeType"), value);
        }
    }
    void resetThemeType() {
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this]() {
                m_config.loadRelaxed()->reset(QStringLiteral("themeType"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<qlonglong> bindableThemeType() {
        return QBindable<qlonglong>(this, "themeType");
    }
#endif
    Q_INVOKABLE bool themeTypeIsDefaultValue() const {
        return !testPropertySet(7);
    }
    qlonglong titlebarHeight() const {
        return p_titlebarHeight;
    }
    void setTitlebarHeight(const qlonglong &value) {
        auto oldValue = p_titlebarHeight;
        p_titlebarHeight = value;
        markPropertySet(8);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("titlebarHeight"), value);
            });
        }
        if (p_titlebarHeight != oldValue) {
            Q_EMIT titlebarHeightChanged();
            Q_EMIT valueChanged(QStringLiteral("titlebarHeight"), value);
        }
    }
    void resetTitlebarHeight() {
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this]() {
                m_config.loadRelaxed()->reset(QStringLiteral("titlebarHeight"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<qlonglong> bindableTitlebarHeight() {
        return QBindable<qlonglong>(this, "titlebarHeight");
    }
#endif
    Q_INVOKABLE bool titlebarHeightIsDefaultValue() const {
        return !testPropertySet(8);
    }
    bool underlineShortcut() const {
        return p_underlineShortcut;
    }
    void setUnderlineShortcut(const bool &value) {
        auto oldValue = p_underlineShortcut;
        p_underlineShortcut = value;
        markPropertySet(9);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("underlineShortcut"), value);
            });
        }
        if (p_underlineShortcut != oldValue) {
            Q_EMIT underlineShortcutChanged();
            Q_EMIT valueChanged(QStringLiteral("underlineShortcut"), value);
        }
    }
    void resetUnderlineShortcut() {
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this]() {
                m_config.loadRelaxed()->reset(QStringLiteral("underlineShortcut"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<bool> bindableUnderlineShortcut() {
        return QBindable<bool>(this, "underlineShortcut");
    }
#endif
    Q_INVOKABLE bool underlineShortcutIsDefaultValue() const {
        return !testPropertySet(9);
    }
Q_SIGNALS:
    void configInitializeFailed(DTK_CORE_NAMESPACE::DConfig *config);
    void configInitializeSucceed(DTK_CORE_NAMESPACE::DConfig *config);
    void valueChanged(const QString &key, const QVariant &value);

    void autoDisplayFeatureChanged();
    void enableDtkAnimationsChanged();
    void featureUpdatedChanged();
    void keyboardsearchDisabledChanged();
    void rulesChanged();
    void scrollBarPolicyChanged();
    void sizeModeChanged();
    void themeTypeChanged();
    void titlebarHeightChanged();
    void underlineShortcutChanged();
private:
    void initializeInConfigThread(DTK_CORE_NAMESPACE::DConfig *config) {
        Q_ASSERT(!m_config.loadRelaxed());
        m_config.storeRelaxed(config);
        if (!config->isValid()) {
           m_status.storeRelaxed(static_cast<int>(Status::Failed));
           Q_EMIT configInitializeFailed(config);
           return;
        }

        if (testPropertySet(0)) {
            config->setValue(QStringLiteral("autoDisplayFeature"), QVariant::fromValue(p_autoDisplayFeature));
        } else {
            updateValue(QStringLiteral("autoDisplayFeature"), QVariant::fromValue(p_autoDisplayFeature));
        }
        if (testPropertySet(1)) {
            config->setValue(QStringLiteral("enableDtkAnimations"), QVariant::fromValue(p_enableDtkAnimations));
        } else {
            updateValue(QStringLiteral("enableDtkAnimations"), QVariant::fromValue(p_enableDtkAnimations));
        }
        if (testPropertySet(2)) {
            config->setValue(QStringLiteral("featureUpdated"), QVariant::fromValue(p_featureUpdated));
        } else {
            updateValue(QStringLiteral("featureUpdated"), QVariant::fromValue(p_featureUpdated));
        }
        if (testPropertySet(3)) {
            config->setValue(QStringLiteral("keyboardsearchDisabled"), QVariant::fromValue(p_keyboardsearchDisabled));
        } else {
            updateValue(QStringLiteral("keyboardsearchDisabled"), QVariant::fromValue(p_keyboardsearchDisabled));
        }
        if (testPropertySet(4)) {
            config->setValue(QStringLiteral("rules"), QVariant::fromValue(p_rules));
        } else {
            updateValue(QStringLiteral("rules"), QVariant::fromValue(p_rules));
        }
        if (testPropertySet(5)) {
            config->setValue(QStringLiteral("scrollBarPolicy"), QVariant::fromValue(p_scrollBarPolicy));
        } else {
            updateValue(QStringLiteral("scrollBarPolicy"), QVariant::fromValue(p_scrollBarPolicy));
        }
        if (testPropertySet(6)) {
            config->setValue(QStringLiteral("sizeMode"), QVariant::fromValue(p_sizeMode));
        } else {
            updateValue(QStringLiteral("sizeMode"), QVariant::fromValue(p_sizeMode));
        }
        if (testPropertySet(7)) {
            config->setValue(QStringLiteral("themeType"), QVariant::fromValue(p_themeType));
        } else {
            updateValue(QStringLiteral("themeType"), QVariant::fromValue(p_themeType));
        }
        if (testPropertySet(8)) {
            config->setValue(QStringLiteral("titlebarHeight"), QVariant::fromValue(p_titlebarHeight));
        } else {
            updateValue(QStringLiteral("titlebarHeight"), QVariant::fromValue(p_titlebarHeight));
        }
        if (testPropertySet(9)) {
            config->setValue(QStringLiteral("underlineShortcut"), QVariant::fromValue(p_underlineShortcut));
        } else {
            updateValue(QStringLiteral("underlineShortcut"), QVariant::fromValue(p_underlineShortcut));
        }

        if (!m_config.loadRelaxed())
            return;
        connect(config, &DTK_CORE_NAMESPACE::DConfig::valueChanged, this, [this](const QString &key) {
            updateValue(key);
        }, Qt::DirectConnection);

        m_status.storeRelaxed(static_cast<int>(Status::Succeed));
        Q_EMIT configInitializeSucceed(config);
    }
    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("autoDisplayFeature")) {
            markPropertySet(0, !m_config.loadRelaxed()->isDefaultValue(key));
            auto newValue = qvariant_cast<bool>(value);
            QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                Q_ASSERT(QThread::currentThread() == this->thread());
                if (p_autoDisplayFeature != newValue) {
                    p_autoDisplayFeature = newValue;
                    Q_EMIT autoDisplayFeatureChanged();
                    Q_EMIT valueChanged(key, value);
                }
            });
            return;
        }
        if (key == QStringLiteral("enableDtkAnimations")) {
            markPropertySet(1, !m_config.loadRelaxed()->isDefaultValue(key));
            auto newValue = qvariant_cast<bool>(value);
            QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                Q_ASSERT(QThread::currentThread() == this->thread());
                if (p_enableDtkAnimations != newValue) {
                    p_enableDtkAnimations = newValue;
                    Q_EMIT enableDtkAnimationsChanged();
                    Q_EMIT valueChanged(key, value);
                }
            });
            return;
        }
        if (key == QStringLiteral("featureUpdated")) {
            markPropertySet(2, !m_config.loadRelaxed()->isDefaultValue(key));
            auto newValue = qvariant_cast<bool>(value);
            QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                Q_ASSERT(QThread::currentThread() == this->thread());
                if (p_featureUpdated != newValue) {
                    p_featureUpdated = newValue;
                    Q_EMIT featureUpdatedChanged();
                    Q_EMIT valueChanged(key, value);
                }
            });
            return;
        }
        if (key == QStringLiteral("keyboardsearchDisabled")) {
            markPropertySet(3, !m_config.loadRelaxed()->isDefaultValue(key));
            auto newValue = qvariant_cast<bool>(value);
            QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                Q_ASSERT(QThread::currentThread() == this->thread());
                if (p_keyboardsearchDisabled != newValue) {
                    p_keyboardsearchDisabled = newValue;
                    Q_EMIT keyboardsearchDisabledChanged();
                    Q_EMIT valueChanged(key, value);
                }
            });
            return;
        }
        if (key == QStringLiteral("rules")) {
            markPropertySet(4, !m_config.loadRelaxed()->isDefaultValue(key));
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                Q_ASSERT(QThread::currentThread() == this->thread());
                if (p_rules != newValue) {
                    p_rules = newValue;
                    Q_EMIT rulesChanged();
                    Q_EMIT valueChanged(key, value);
                }
            });
            return;
        }
        if (key == QStringLiteral("scrollBarPolicy")) {
            markPropertySet(5, !m_config.loadRelaxed()->isDefaultValue(key));
            auto newValue = qvariant_cast<qlonglong>(value);
            QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                Q_ASSERT(QThread::currentThread() == this->thread());
                if (p_scrollBarPolicy != newValue) {
                    p_scrollBarPolicy = newValue;
                    Q_EMIT scrollBarPolicyChanged();
                    Q_EMIT valueChanged(key, value);
                }
            });
            return;
        }
        if (key == QStringLiteral("sizeMode")) {
            markPropertySet(6, !m_config.loadRelaxed()->isDefaultValue(key));
            auto newValue = qvariant_cast<qlonglong>(value);
            QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                Q_ASSERT(QThread::currentThread() == this->thread());
                if (p_sizeMode != newValue) {
                    p_sizeMode = newValue;
                    Q_EMIT sizeModeChanged();
                    Q_EMIT valueChanged(key, value);
                }
            });
            return;
        }
        if (key == QStringLiteral("themeType")) {
            markPropertySet(7, !m_config.loadRelaxed()->isDefaultValue(key));
            auto newValue = qvariant_cast<qlonglong>(value);
            QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                Q_ASSERT(QThread::currentThread() == this->thread());
                if (p_themeType != newValue) {
                    p_themeType = newValue;
                    Q_EMIT themeTypeChanged();
                    Q_EMIT valueChanged(key, value);
                }
            });
            return;
        }
        if (key == QStringLiteral("titlebarHeight")) {
            markPropertySet(8, !m_config.loadRelaxed()->isDefaultValue(key));
            auto newValue = qvariant_cast<qlonglong>(value);
            QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                Q_ASSERT(QThread::currentThread() == this->thread());
                if (p_titlebarHeight != newValue) {
                    p_titlebarHeight = newValue;
                    Q_EMIT titlebarHeightChanged();
                    Q_EMIT valueChanged(key, value);
                }
            });
            return;
        }
        if (key == QStringLiteral("underlineShortcut")) {
            markPropertySet(9, !m_config.loadRelaxed()->isDefaultValue(key));
            auto newValue = qvariant_cast<bool>(value);
            QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                Q_ASSERT(QThread::currentThread() == this->thread());
                if (p_underlineShortcut != newValue) {
                    p_underlineShortcut = newValue;
                    Q_EMIT underlineShortcutChanged();
                    Q_EMIT 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();
    }

    QAtomicPointer<DTK_CORE_NAMESPACE::DConfig> m_config = nullptr;

public:
    enum class Status {
        Invalid = 0,
        Succeed = 1,
        Failed = 2
    };
private:
    QAtomicInteger<int> m_status = static_cast<int>(Status::Invalid);

    bool p_autoDisplayFeature { false };
    bool p_enableDtkAnimations { false };
    bool p_featureUpdated { false };
    bool p_keyboardsearchDisabled { false };
    // Default value: "*.debug=false"
    QString p_rules { QStringLiteral(u"\u002a\u002e\u0064\u0065\u0062\u0075\u0067\u003d\u0066\u0061\u006c\u0073\u0065") };
    qlonglong p_scrollBarPolicy { 0 };
    qlonglong p_sizeMode { 0 };
    qlonglong p_themeType { 0 };
    qlonglong p_titlebarHeight { -1 };
    bool p_underlineShortcut { false };
    QAtomicInteger<quint32> m_propertySetStatus0 = 0;
};

#endif // DCONFIG_ORG_DEEPIN_DTK_PREFERENCE_H
