/**
 * This file is generated by dconfig2cpp.
 * Command line arguments: /usr/lib/dtk6/DCore/bin/dconfig2cpp -o /build/dtkgui/src/build-qt6/dtkgui/build/src/orgdeepindtkpreference.hpp -c OrgDeepinDTKPreference /usr/share/dsg/configs/org.deepin.dtk.preference.json
 * Generation time: 2026-06-04T13:22:24
 * 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 ORGDEEPINDTKPREFERENCE_H
#define ORGDEEPINDTKPREFERENCE_H

#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_VERSION_MAJOR 1
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_VERSION_MINOR 1
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_autoDisplayFeature
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_colorMode
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_defaultColorMode
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_disableInWindowBlur
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_enableDtkAnimations
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_featureUpdated
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_keyboardsearchDisabled
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_rules
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_scrollBarPolicy
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_sizeMode
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_themeType
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_titlebarHeight
#define ORGDEEPINDTKPREFERENCE_DCONFIG_FILE_underlineShortcut

#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 OrgDeepinDTKPreference : public QObject {
    Q_OBJECT

    Q_PROPERTY(bool autoDisplayFeature READ autoDisplayFeature WRITE setAutoDisplayFeature NOTIFY autoDisplayFeatureChanged RESET resetAutoDisplayFeature)
    Q_PROPERTY(QString colorMode READ colorMode WRITE setColorMode NOTIFY colorModeChanged RESET resetColorMode)
    Q_PROPERTY(QString defaultColorMode READ defaultColorMode WRITE setDefaultColorMode NOTIFY defaultColorModeChanged RESET resetDefaultColorMode)
    Q_PROPERTY(bool disableInWindowBlur READ disableInWindowBlur WRITE setDisableInWindowBlur NOTIFY disableInWindowBlurChanged RESET resetDisableInWindowBlur)
    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;colorMode;defaultColorMode;disableInWindowBlur;enableDtkAnimations;featureUpdated;keyboardsearchDisabled;rules;scrollBarPolicy;sizeMode;themeType;titlebarHeight;underlineShortcut")
    Q_CLASSINFO("DConfigFileName", "org.deepin.dtk.preference")
    Q_CLASSINFO("DConfigFileVersion", "1.0")

public:
    explicit OrgDeepinDTKPreference(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 OrgDeepinDTKPreference* create(const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new OrgDeepinDTKPreference(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 OrgDeepinDTKPreference* create(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new OrgDeepinDTKPreference(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 OrgDeepinDTKPreference* createByName(const QString &name, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new OrgDeepinDTKPreference(thread, nullptr, name, appId, subpath, false, parent); }
    static OrgDeepinDTKPreference* 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 OrgDeepinDTKPreference(thread, backend, name, appId, subpath, false, parent); }
    static OrgDeepinDTKPreference* createGeneric(const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new OrgDeepinDTKPreference(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 OrgDeepinDTKPreference* create(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new OrgDeepinDTKPreference(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 OrgDeepinDTKPreference* createGenericByName(const QString &name, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new OrgDeepinDTKPreference(thread, nullptr, name, {}, subpath, true, parent); }
    static OrgDeepinDTKPreference* createGenericByName(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &name, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new OrgDeepinDTKPreference(thread, backend, name, {}, subpath, true, parent); }
    ~OrgDeepinDTKPreference() {
        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("autoDisplayFeature"),
                 QStringLiteral("colorMode"),
                 QStringLiteral("defaultColorMode"),
                 QStringLiteral("disableInWindowBlur"),
                 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("colorMode"))
            return colorModeIsDefaultValue();
        if (key == QStringLiteral("defaultColorMode"))
            return defaultColorModeIsDefaultValue();
        if (key == QStringLiteral("disableInWindowBlur"))
            return disableInWindowBlurIsDefaultValue();
        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 m_data->p_autoDisplayFeature;
    }
    void setAutoDisplayFeature(const bool &value) {
        auto oldValue = m_data->p_autoDisplayFeature;
        m_data->p_autoDisplayFeature = value;
        m_data->markPropertySet(0);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("autoDisplayFeature"), value);
            });
        }
        if (m_data->p_autoDisplayFeature != oldValue) {
            Q_EMIT autoDisplayFeatureChanged();
            Q_EMIT valueChanged(QStringLiteral("autoDisplayFeature"), value);
        }
    }
    void resetAutoDisplayFeature() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->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 !m_data->testPropertySet(0);
    }
    QString colorMode() const {
        return m_data->p_colorMode;
    }
    void setColorMode(const QString &value) {
        auto oldValue = m_data->p_colorMode;
        m_data->p_colorMode = value;
        m_data->markPropertySet(1);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("colorMode"), value);
            });
        }
        if (m_data->p_colorMode != oldValue) {
            Q_EMIT colorModeChanged();
            Q_EMIT valueChanged(QStringLiteral("colorMode"), value);
        }
    }
    void resetColorMode() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("colorMode"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<QString> bindableColorMode() {
        return QBindable<QString>(this, "colorMode");
    }
#endif
    Q_INVOKABLE bool colorModeIsDefaultValue() const {
        return !m_data->testPropertySet(1);
    }
    QString defaultColorMode() const {
        return m_data->p_defaultColorMode;
    }
    void setDefaultColorMode(const QString &value) {
        auto oldValue = m_data->p_defaultColorMode;
        m_data->p_defaultColorMode = value;
        m_data->markPropertySet(2);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("defaultColorMode"), value);
            });
        }
        if (m_data->p_defaultColorMode != oldValue) {
            Q_EMIT defaultColorModeChanged();
            Q_EMIT valueChanged(QStringLiteral("defaultColorMode"), value);
        }
    }
    void resetDefaultColorMode() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("defaultColorMode"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<QString> bindableDefaultColorMode() {
        return QBindable<QString>(this, "defaultColorMode");
    }
#endif
    Q_INVOKABLE bool defaultColorModeIsDefaultValue() const {
        return !m_data->testPropertySet(2);
    }
    bool disableInWindowBlur() const {
        return m_data->p_disableInWindowBlur;
    }
    void setDisableInWindowBlur(const bool &value) {
        auto oldValue = m_data->p_disableInWindowBlur;
        m_data->p_disableInWindowBlur = value;
        m_data->markPropertySet(3);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("disableInWindowBlur"), value);
            });
        }
        if (m_data->p_disableInWindowBlur != oldValue) {
            Q_EMIT disableInWindowBlurChanged();
            Q_EMIT valueChanged(QStringLiteral("disableInWindowBlur"), value);
        }
    }
    void resetDisableInWindowBlur() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("disableInWindowBlur"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<bool> bindableDisableInWindowBlur() {
        return QBindable<bool>(this, "disableInWindowBlur");
    }
#endif
    Q_INVOKABLE bool disableInWindowBlurIsDefaultValue() const {
        return !m_data->testPropertySet(3);
    }
    bool enableDtkAnimations() const {
        return m_data->p_enableDtkAnimations;
    }
    void setEnableDtkAnimations(const bool &value) {
        auto oldValue = m_data->p_enableDtkAnimations;
        m_data->p_enableDtkAnimations = value;
        m_data->markPropertySet(4);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("enableDtkAnimations"), value);
            });
        }
        if (m_data->p_enableDtkAnimations != oldValue) {
            Q_EMIT enableDtkAnimationsChanged();
            Q_EMIT valueChanged(QStringLiteral("enableDtkAnimations"), value);
        }
    }
    void resetEnableDtkAnimations() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->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 !m_data->testPropertySet(4);
    }
    bool featureUpdated() const {
        return m_data->p_featureUpdated;
    }
    void setFeatureUpdated(const bool &value) {
        auto oldValue = m_data->p_featureUpdated;
        m_data->p_featureUpdated = value;
        m_data->markPropertySet(5);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("featureUpdated"), value);
            });
        }
        if (m_data->p_featureUpdated != oldValue) {
            Q_EMIT featureUpdatedChanged();
            Q_EMIT valueChanged(QStringLiteral("featureUpdated"), value);
        }
    }
    void resetFeatureUpdated() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->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 !m_data->testPropertySet(5);
    }
    bool keyboardsearchDisabled() const {
        return m_data->p_keyboardsearchDisabled;
    }
    void setKeyboardsearchDisabled(const bool &value) {
        auto oldValue = m_data->p_keyboardsearchDisabled;
        m_data->p_keyboardsearchDisabled = value;
        m_data->markPropertySet(6);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("keyboardsearchDisabled"), value);
            });
        }
        if (m_data->p_keyboardsearchDisabled != oldValue) {
            Q_EMIT keyboardsearchDisabledChanged();
            Q_EMIT valueChanged(QStringLiteral("keyboardsearchDisabled"), value);
        }
    }
    void resetKeyboardsearchDisabled() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->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 !m_data->testPropertySet(6);
    }
    QString rules() const {
        return m_data->p_rules;
    }
    void setRules(const QString &value) {
        auto oldValue = m_data->p_rules;
        m_data->p_rules = value;
        m_data->markPropertySet(7);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("rules"), value);
            });
        }
        if (m_data->p_rules != oldValue) {
            Q_EMIT rulesChanged();
            Q_EMIT valueChanged(QStringLiteral("rules"), value);
        }
    }
    void resetRules() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->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 !m_data->testPropertySet(7);
    }
    qlonglong scrollBarPolicy() const {
        return m_data->p_scrollBarPolicy;
    }
    void setScrollBarPolicy(const qlonglong &value) {
        auto oldValue = m_data->p_scrollBarPolicy;
        m_data->p_scrollBarPolicy = value;
        m_data->markPropertySet(8);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("scrollBarPolicy"), value);
            });
        }
        if (m_data->p_scrollBarPolicy != oldValue) {
            Q_EMIT scrollBarPolicyChanged();
            Q_EMIT valueChanged(QStringLiteral("scrollBarPolicy"), value);
        }
    }
    void resetScrollBarPolicy() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->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 !m_data->testPropertySet(8);
    }
    qlonglong sizeMode() const {
        return m_data->p_sizeMode;
    }
    void setSizeMode(const qlonglong &value) {
        auto oldValue = m_data->p_sizeMode;
        m_data->p_sizeMode = value;
        m_data->markPropertySet(9);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("sizeMode"), value);
            });
        }
        if (m_data->p_sizeMode != oldValue) {
            Q_EMIT sizeModeChanged();
            Q_EMIT valueChanged(QStringLiteral("sizeMode"), value);
        }
    }
    void resetSizeMode() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->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 !m_data->testPropertySet(9);
    }
    qlonglong themeType() const {
        return m_data->p_themeType;
    }
    void setThemeType(const qlonglong &value) {
        auto oldValue = m_data->p_themeType;
        m_data->p_themeType = value;
        m_data->markPropertySet(10);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("themeType"), value);
            });
        }
        if (m_data->p_themeType != oldValue) {
            Q_EMIT themeTypeChanged();
            Q_EMIT valueChanged(QStringLiteral("themeType"), value);
        }
    }
    void resetThemeType() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->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 !m_data->testPropertySet(10);
    }
    qlonglong titlebarHeight() const {
        return m_data->p_titlebarHeight;
    }
    void setTitlebarHeight(const qlonglong &value) {
        auto oldValue = m_data->p_titlebarHeight;
        m_data->p_titlebarHeight = value;
        m_data->markPropertySet(11);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("titlebarHeight"), value);
            });
        }
        if (m_data->p_titlebarHeight != oldValue) {
            Q_EMIT titlebarHeightChanged();
            Q_EMIT valueChanged(QStringLiteral("titlebarHeight"), value);
        }
    }
    void resetTitlebarHeight() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->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 !m_data->testPropertySet(11);
    }
    bool underlineShortcut() const {
        return m_data->p_underlineShortcut;
    }
    void setUnderlineShortcut(const bool &value) {
        auto oldValue = m_data->p_underlineShortcut;
        m_data->p_underlineShortcut = value;
        m_data->markPropertySet(12);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("underlineShortcut"), value);
            });
        }
        if (m_data->p_underlineShortcut != oldValue) {
            Q_EMIT underlineShortcutChanged();
            Q_EMIT valueChanged(QStringLiteral("underlineShortcut"), value);
        }
    }
    void resetUnderlineShortcut() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->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 !m_data->testPropertySet(12);
    }
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 autoDisplayFeatureChanged();
    void colorModeChanged();
    void defaultColorModeChanged();
    void disableInWindowBlurChanged();
    void enableDtkAnimationsChanged();
    void featureUpdatedChanged();
    void keyboardsearchDisabledChanged();
    void rulesChanged();
    void scrollBarPolicyChanged();
    void sizeModeChanged();
    void themeTypeChanged();
    void titlebarHeightChanged();
    void underlineShortcutChanged();

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("autoDisplayFeature"), QVariant::fromValue(p_autoDisplayFeature));
            } else {
                updateValue(QStringLiteral("autoDisplayFeature"), QVariant::fromValue(p_autoDisplayFeature));
            }
            if (testPropertySet(1)) {
                config->setValue(QStringLiteral("colorMode"), QVariant::fromValue(p_colorMode));
            } else {
                updateValue(QStringLiteral("colorMode"), QVariant::fromValue(p_colorMode));
            }
            if (testPropertySet(2)) {
                config->setValue(QStringLiteral("defaultColorMode"), QVariant::fromValue(p_defaultColorMode));
            } else {
                updateValue(QStringLiteral("defaultColorMode"), QVariant::fromValue(p_defaultColorMode));
            }
            if (testPropertySet(3)) {
                config->setValue(QStringLiteral("disableInWindowBlur"), QVariant::fromValue(p_disableInWindowBlur));
            } else {
                updateValue(QStringLiteral("disableInWindowBlur"), QVariant::fromValue(p_disableInWindowBlur));
            }
            if (testPropertySet(4)) {
                config->setValue(QStringLiteral("enableDtkAnimations"), QVariant::fromValue(p_enableDtkAnimations));
            } else {
                updateValue(QStringLiteral("enableDtkAnimations"), QVariant::fromValue(p_enableDtkAnimations));
            }
            if (testPropertySet(5)) {
                config->setValue(QStringLiteral("featureUpdated"), QVariant::fromValue(p_featureUpdated));
            } else {
                updateValue(QStringLiteral("featureUpdated"), QVariant::fromValue(p_featureUpdated));
            }
            if (testPropertySet(6)) {
                config->setValue(QStringLiteral("keyboardsearchDisabled"), QVariant::fromValue(p_keyboardsearchDisabled));
            } else {
                updateValue(QStringLiteral("keyboardsearchDisabled"), QVariant::fromValue(p_keyboardsearchDisabled));
            }
            if (testPropertySet(7)) {
                config->setValue(QStringLiteral("rules"), QVariant::fromValue(p_rules));
            } else {
                updateValue(QStringLiteral("rules"), QVariant::fromValue(p_rules));
            }
            if (testPropertySet(8)) {
                config->setValue(QStringLiteral("scrollBarPolicy"), QVariant::fromValue(p_scrollBarPolicy));
            } else {
                updateValue(QStringLiteral("scrollBarPolicy"), QVariant::fromValue(p_scrollBarPolicy));
            }
            if (testPropertySet(9)) {
                config->setValue(QStringLiteral("sizeMode"), QVariant::fromValue(p_sizeMode));
            } else {
                updateValue(QStringLiteral("sizeMode"), QVariant::fromValue(p_sizeMode));
            }
            if (testPropertySet(10)) {
                config->setValue(QStringLiteral("themeType"), QVariant::fromValue(p_themeType));
            } else {
                updateValue(QStringLiteral("themeType"), QVariant::fromValue(p_themeType));
            }
            if (testPropertySet(11)) {
                config->setValue(QStringLiteral("titlebarHeight"), QVariant::fromValue(p_titlebarHeight));
            } else {
                updateValue(QStringLiteral("titlebarHeight"), QVariant::fromValue(p_titlebarHeight));
            }
            if (testPropertySet(12)) {
                config->setValue(QStringLiteral("underlineShortcut"), QVariant::fromValue(p_underlineShortcut));
            } else {
                updateValue(QStringLiteral("underlineShortcut"), QVariant::fromValue(p_underlineShortcut));
            }
            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("autoDisplayFeature")) {
                markPropertySet(0, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<bool>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_autoDisplayFeature != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_autoDisplayFeature = newValue;
                        Q_EMIT m_userConfig->autoDisplayFeatureChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("colorMode")) {
                markPropertySet(1, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<QString>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_colorMode != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_colorMode = newValue;
                        Q_EMIT m_userConfig->colorModeChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("defaultColorMode")) {
                markPropertySet(2, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<QString>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_defaultColorMode != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_defaultColorMode = newValue;
                        Q_EMIT m_userConfig->defaultColorModeChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("disableInWindowBlur")) {
                markPropertySet(3, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<bool>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_disableInWindowBlur != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_disableInWindowBlur = newValue;
                        Q_EMIT m_userConfig->disableInWindowBlurChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("enableDtkAnimations")) {
                markPropertySet(4, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<bool>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_enableDtkAnimations != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_enableDtkAnimations = newValue;
                        Q_EMIT m_userConfig->enableDtkAnimationsChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("featureUpdated")) {
                markPropertySet(5, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<bool>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_featureUpdated != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_featureUpdated = newValue;
                        Q_EMIT m_userConfig->featureUpdatedChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("keyboardsearchDisabled")) {
                markPropertySet(6, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<bool>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_keyboardsearchDisabled != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_keyboardsearchDisabled = newValue;
                        Q_EMIT m_userConfig->keyboardsearchDisabledChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("rules")) {
                markPropertySet(7, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<QString>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_rules != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_rules = newValue;
                        Q_EMIT m_userConfig->rulesChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("scrollBarPolicy")) {
                markPropertySet(8, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<qlonglong>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_scrollBarPolicy != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_scrollBarPolicy = newValue;
                        Q_EMIT m_userConfig->scrollBarPolicyChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("sizeMode")) {
                markPropertySet(9, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<qlonglong>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_sizeMode != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_sizeMode = newValue;
                        Q_EMIT m_userConfig->sizeModeChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("themeType")) {
                markPropertySet(10, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<qlonglong>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_themeType != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_themeType = newValue;
                        Q_EMIT m_userConfig->themeTypeChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("titlebarHeight")) {
                markPropertySet(11, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<qlonglong>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_titlebarHeight != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_titlebarHeight = newValue;
                        Q_EMIT m_userConfig->titlebarHeightChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("underlineShortcut")) {
                markPropertySet(12, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<bool>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_underlineShortcut != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_underlineShortcut = newValue;
                        Q_EMIT m_userConfig->underlineShortcutChanged();
                        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<OrgDeepinDTKPreference> m_userConfig = nullptr;
        QAtomicInteger<quint32> m_propertySetStatus0 = 0;

        // Property storage
        bool p_autoDisplayFeature { false };
        // Default value: ""
        QString p_colorMode { QLatin1String("") };
        // Default value: "color"
        QString p_defaultColorMode { QStringLiteral(u"\u0063\u006f\u006c\u006f\u0072") };
        bool p_disableInWindowBlur { 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 };
    };

    QPointer<Data> m_data;
};

#endif // ORGDEEPINDTKPREFERENCE_H
