/**
 * 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.power.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_POWER_H
#define ORG_DEEPIN_DDE_CONTROL-CENTER_POWER_H

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

class org_deepin_dde_control-center_power : public QObject {
    Q_OBJECT

    Q_PROPERTY(QList<QVariant> batteryLockDelay READ batteryLockDelay WRITE setBatteryLockDelay NOTIFY batteryLockDelayChanged)
    Q_PROPERTY(QList<QVariant> batteryScreenBlackDelay READ batteryScreenBlackDelay WRITE setBatteryScreenBlackDelay NOTIFY batteryScreenBlackDelayChanged)
    Q_PROPERTY(QList<QVariant> batterySleepDelay READ batterySleepDelay WRITE setBatterySleepDelay NOTIFY batterySleepDelayChanged)
    Q_PROPERTY(QString enableScheduledShutdown READ enableScheduledShutdown WRITE setEnableScheduledShutdown NOTIFY enableScheduledShutdownChanged)
    Q_PROPERTY(QList<QVariant> linePowerLockDelay READ linePowerLockDelay WRITE setLinePowerLockDelay NOTIFY linePowerLockDelayChanged)
    Q_PROPERTY(QList<QVariant> linePowerScreenBlackDelay READ linePowerScreenBlackDelay WRITE setLinePowerScreenBlackDelay NOTIFY linePowerScreenBlackDelayChanged)
    Q_PROPERTY(QList<QVariant> linePowerSleepDelay READ linePowerSleepDelay WRITE setLinePowerSleepDelay NOTIFY linePowerSleepDelayChanged)
    Q_PROPERTY(bool showHibernate READ showHibernate WRITE setShowHibernate NOTIFY showHibernateChanged)
    Q_PROPERTY(bool showShutdown READ showShutdown WRITE setShowShutdown NOTIFY showShutdownChanged)
    Q_PROPERTY(bool showSuspend READ showSuspend WRITE setShowSuspend NOTIFY showSuspendChanged)
public:
    explicit org_deepin_dde_control-center_power(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_power(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_power(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_power(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_power() {
        if (m_config.loadRelaxed()) {
            m_config.loadRelaxed()->deleteLater();
        }
    }

    QList<QVariant> batteryLockDelay() const {
        return p_batteryLockDelay;
    }
    void setBatteryLockDelay(const QList<QVariant> &value) {
        auto oldValue = p_batteryLockDelay;
        p_batteryLockDelay = value;
        markPropertySet(0);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("batteryLockDelay"), value);
            });
        }
        if (p_batteryLockDelay != oldValue) {
            Q_EMIT batteryLockDelayChanged();
        }
    }
    QList<QVariant> batteryScreenBlackDelay() const {
        return p_batteryScreenBlackDelay;
    }
    void setBatteryScreenBlackDelay(const QList<QVariant> &value) {
        auto oldValue = p_batteryScreenBlackDelay;
        p_batteryScreenBlackDelay = value;
        markPropertySet(1);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("batteryScreenBlackDelay"), value);
            });
        }
        if (p_batteryScreenBlackDelay != oldValue) {
            Q_EMIT batteryScreenBlackDelayChanged();
        }
    }
    QList<QVariant> batterySleepDelay() const {
        return p_batterySleepDelay;
    }
    void setBatterySleepDelay(const QList<QVariant> &value) {
        auto oldValue = p_batterySleepDelay;
        p_batterySleepDelay = value;
        markPropertySet(2);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("batterySleepDelay"), value);
            });
        }
        if (p_batterySleepDelay != oldValue) {
            Q_EMIT batterySleepDelayChanged();
        }
    }
    QString enableScheduledShutdown() const {
        return p_enableScheduledShutdown;
    }
    void setEnableScheduledShutdown(const QString &value) {
        auto oldValue = p_enableScheduledShutdown;
        p_enableScheduledShutdown = value;
        markPropertySet(3);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("enableScheduledShutdown"), value);
            });
        }
        if (p_enableScheduledShutdown != oldValue) {
            Q_EMIT enableScheduledShutdownChanged();
        }
    }
    QList<QVariant> linePowerLockDelay() const {
        return p_linePowerLockDelay;
    }
    void setLinePowerLockDelay(const QList<QVariant> &value) {
        auto oldValue = p_linePowerLockDelay;
        p_linePowerLockDelay = value;
        markPropertySet(4);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("linePowerLockDelay"), value);
            });
        }
        if (p_linePowerLockDelay != oldValue) {
            Q_EMIT linePowerLockDelayChanged();
        }
    }
    QList<QVariant> linePowerScreenBlackDelay() const {
        return p_linePowerScreenBlackDelay;
    }
    void setLinePowerScreenBlackDelay(const QList<QVariant> &value) {
        auto oldValue = p_linePowerScreenBlackDelay;
        p_linePowerScreenBlackDelay = value;
        markPropertySet(5);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("linePowerScreenBlackDelay"), value);
            });
        }
        if (p_linePowerScreenBlackDelay != oldValue) {
            Q_EMIT linePowerScreenBlackDelayChanged();
        }
    }
    QList<QVariant> linePowerSleepDelay() const {
        return p_linePowerSleepDelay;
    }
    void setLinePowerSleepDelay(const QList<QVariant> &value) {
        auto oldValue = p_linePowerSleepDelay;
        p_linePowerSleepDelay = value;
        markPropertySet(6);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("linePowerSleepDelay"), value);
            });
        }
        if (p_linePowerSleepDelay != oldValue) {
            Q_EMIT linePowerSleepDelayChanged();
        }
    }
    bool showHibernate() const {
        return p_showHibernate;
    }
    void setShowHibernate(const bool &value) {
        auto oldValue = p_showHibernate;
        p_showHibernate = value;
        markPropertySet(7);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("showHibernate"), value);
            });
        }
        if (p_showHibernate != oldValue) {
            Q_EMIT showHibernateChanged();
        }
    }
    bool showShutdown() const {
        return p_showShutdown;
    }
    void setShowShutdown(const bool &value) {
        auto oldValue = p_showShutdown;
        p_showShutdown = value;
        markPropertySet(8);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("showShutdown"), value);
            });
        }
        if (p_showShutdown != oldValue) {
            Q_EMIT showShutdownChanged();
        }
    }
    bool showSuspend() const {
        return p_showSuspend;
    }
    void setShowSuspend(const bool &value) {
        auto oldValue = p_showSuspend;
        p_showSuspend = value;
        markPropertySet(9);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("showSuspend"), value);
            });
        }
        if (p_showSuspend != oldValue) {
            Q_EMIT showSuspendChanged();
        }
    }
Q_SIGNALS:
    void batteryLockDelayChanged();
    void batteryScreenBlackDelayChanged();
    void batterySleepDelayChanged();
    void enableScheduledShutdownChanged();
    void linePowerLockDelayChanged();
    void linePowerScreenBlackDelayChanged();
    void linePowerSleepDelayChanged();
    void showHibernateChanged();
    void showShutdownChanged();
    void showSuspendChanged();
private:
    void initialize(DTK_CORE_NAMESPACE::DConfig *config) {
        Q_ASSERT(!m_config.loadRelaxed());
        m_config.storeRelaxed(config);
        if (testPropertySet(0)) {
            config->setValue(QStringLiteral("batteryLockDelay"), QVariant::fromValue(p_batteryLockDelay));
        } else {
            updateValue(QStringLiteral("batteryLockDelay"), QVariant::fromValue(p_batteryLockDelay));
        }
        if (testPropertySet(1)) {
            config->setValue(QStringLiteral("batteryScreenBlackDelay"), QVariant::fromValue(p_batteryScreenBlackDelay));
        } else {
            updateValue(QStringLiteral("batteryScreenBlackDelay"), QVariant::fromValue(p_batteryScreenBlackDelay));
        }
        if (testPropertySet(2)) {
            config->setValue(QStringLiteral("batterySleepDelay"), QVariant::fromValue(p_batterySleepDelay));
        } else {
            updateValue(QStringLiteral("batterySleepDelay"), QVariant::fromValue(p_batterySleepDelay));
        }
        if (testPropertySet(3)) {
            config->setValue(QStringLiteral("enableScheduledShutdown"), QVariant::fromValue(p_enableScheduledShutdown));
        } else {
            updateValue(QStringLiteral("enableScheduledShutdown"), QVariant::fromValue(p_enableScheduledShutdown));
        }
        if (testPropertySet(4)) {
            config->setValue(QStringLiteral("linePowerLockDelay"), QVariant::fromValue(p_linePowerLockDelay));
        } else {
            updateValue(QStringLiteral("linePowerLockDelay"), QVariant::fromValue(p_linePowerLockDelay));
        }
        if (testPropertySet(5)) {
            config->setValue(QStringLiteral("linePowerScreenBlackDelay"), QVariant::fromValue(p_linePowerScreenBlackDelay));
        } else {
            updateValue(QStringLiteral("linePowerScreenBlackDelay"), QVariant::fromValue(p_linePowerScreenBlackDelay));
        }
        if (testPropertySet(6)) {
            config->setValue(QStringLiteral("linePowerSleepDelay"), QVariant::fromValue(p_linePowerSleepDelay));
        } else {
            updateValue(QStringLiteral("linePowerSleepDelay"), QVariant::fromValue(p_linePowerSleepDelay));
        }
        if (testPropertySet(7)) {
            config->setValue(QStringLiteral("showHibernate"), QVariant::fromValue(p_showHibernate));
        } else {
            updateValue(QStringLiteral("showHibernate"), QVariant::fromValue(p_showHibernate));
        }
        if (testPropertySet(8)) {
            config->setValue(QStringLiteral("showShutdown"), QVariant::fromValue(p_showShutdown));
        } else {
            updateValue(QStringLiteral("showShutdown"), QVariant::fromValue(p_showShutdown));
        }
        if (testPropertySet(9)) {
            config->setValue(QStringLiteral("showSuspend"), QVariant::fromValue(p_showSuspend));
        } else {
            updateValue(QStringLiteral("showSuspend"), QVariant::fromValue(p_showSuspend));
        }

        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("batteryLockDelay")) {
            auto newValue = qvariant_cast<QList<QVariant>>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_batteryLockDelay != newValue) {
                    p_batteryLockDelay = newValue;
                    Q_EMIT batteryLockDelayChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("batteryScreenBlackDelay")) {
            auto newValue = qvariant_cast<QList<QVariant>>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_batteryScreenBlackDelay != newValue) {
                    p_batteryScreenBlackDelay = newValue;
                    Q_EMIT batteryScreenBlackDelayChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("batterySleepDelay")) {
            auto newValue = qvariant_cast<QList<QVariant>>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_batterySleepDelay != newValue) {
                    p_batterySleepDelay = newValue;
                    Q_EMIT batterySleepDelayChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("enableScheduledShutdown")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_enableScheduledShutdown != newValue) {
                    p_enableScheduledShutdown = newValue;
                    Q_EMIT enableScheduledShutdownChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("linePowerLockDelay")) {
            auto newValue = qvariant_cast<QList<QVariant>>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_linePowerLockDelay != newValue) {
                    p_linePowerLockDelay = newValue;
                    Q_EMIT linePowerLockDelayChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("linePowerScreenBlackDelay")) {
            auto newValue = qvariant_cast<QList<QVariant>>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_linePowerScreenBlackDelay != newValue) {
                    p_linePowerScreenBlackDelay = newValue;
                    Q_EMIT linePowerScreenBlackDelayChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("linePowerSleepDelay")) {
            auto newValue = qvariant_cast<QList<QVariant>>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_linePowerSleepDelay != newValue) {
                    p_linePowerSleepDelay = newValue;
                    Q_EMIT linePowerSleepDelayChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("showHibernate")) {
            auto newValue = qvariant_cast<bool>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_showHibernate != newValue) {
                    p_showHibernate = newValue;
                    Q_EMIT showHibernateChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("showShutdown")) {
            auto newValue = qvariant_cast<bool>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_showShutdown != newValue) {
                    p_showShutdown = newValue;
                    Q_EMIT showShutdownChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("showSuspend")) {
            auto newValue = qvariant_cast<bool>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_showSuspend != newValue) {
                    p_showSuspend = newValue;
                    Q_EMIT showSuspendChanged();
                }
            });
            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_batteryLockDelay { QList<QVariant>{QVariant(QStringLiteral("1m")), QVariant(QStringLiteral("5m")), QVariant(QStringLiteral("10m")), QVariant(QStringLiteral("15m")), QVariant(QStringLiteral("30m")), QVariant(QStringLiteral("1h"))} };
    QList<QVariant> p_batteryScreenBlackDelay { QList<QVariant>{QVariant(QStringLiteral("1m")), QVariant(QStringLiteral("5m")), QVariant(QStringLiteral("10m")), QVariant(QStringLiteral("15m")), QVariant(QStringLiteral("30m")), QVariant(QStringLiteral("1h"))} };
    QList<QVariant> p_batterySleepDelay { QList<QVariant>{QVariant(QStringLiteral("10m")), QVariant(QStringLiteral("15m")), QVariant(QStringLiteral("30m")), QVariant(QStringLiteral("1h")), QVariant(QStringLiteral("2h")), QVariant(QStringLiteral("3h"))} };
    QString p_enableScheduledShutdown { QStringLiteral("Enabled") };
    QList<QVariant> p_linePowerLockDelay { QList<QVariant>{QVariant(QStringLiteral("10m")), QVariant(QStringLiteral("15m")), QVariant(QStringLiteral("30m")), QVariant(QStringLiteral("1h")), QVariant(QStringLiteral("2h")), QVariant(QStringLiteral("3h"))} };
    QList<QVariant> p_linePowerScreenBlackDelay { QList<QVariant>{QVariant(QStringLiteral("1m")), QVariant(QStringLiteral("5m")), QVariant(QStringLiteral("10m")), QVariant(QStringLiteral("15m")), QVariant(QStringLiteral("30m")), QVariant(QStringLiteral("1h"))} };
    QList<QVariant> p_linePowerSleepDelay { QList<QVariant>{QVariant(QStringLiteral("10m")), QVariant(QStringLiteral("15m")), QVariant(QStringLiteral("30m")), QVariant(QStringLiteral("1h")), QVariant(QStringLiteral("2h")), QVariant(QStringLiteral("3h"))} };
    bool p_showHibernate { true };
    bool p_showShutdown { true };
    bool p_showSuspend { true };
    QAtomicInteger<quint32> m_propertySetStatus0 = 0;
};

#endif // ORG_DEEPIN_DDE_CONTROL-CENTER_POWER_H
