From ba050942ea8a81c440096788de298725c776c872 Mon Sep 17 00:00:00 2001 From: jingshenghao Date: Mon, 13 Jan 2025 17:02:41 +0800 Subject: [PATCH] feat: Add files generated by qdbusXML2cpp and DCONG2cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add files generated by qdbusXML2cpp and DCONG2cpp Log: Add files generated by qdbusXML2cpp and DCONG2cpp --- .reuse/dep5 | 4 + .../org_deepin_dtkwidget_feature-display.hpp | 214 ++++++++++++++++++ 2 files changed, 218 insertions(+) create mode 100644 toolGenerate/dconfig2cpp/org_deepin_dtkwidget_feature-display.hpp diff --git a/.reuse/dep5 b/.reuse/dep5 index 3941adf59..07052b2e3 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -97,3 +97,7 @@ License: LGPL-3.0-or-later Files: tests/data/* Copyright: None License: CC0-1.0 + +Files: toolGenerate/**/* +Copyright: None +License: CC0-1.0 diff --git a/toolGenerate/dconfig2cpp/org_deepin_dtkwidget_feature-display.hpp b/toolGenerate/dconfig2cpp/org_deepin_dtkwidget_feature-display.hpp new file mode 100644 index 000000000..d3566514b --- /dev/null +++ b/toolGenerate/dconfig2cpp/org_deepin_dtkwidget_feature-display.hpp @@ -0,0 +1,214 @@ +/** + * This file is generated by dconfig2cpp. + * Command line arguments: ./dconfig2cpp -p ./dtk6widget/toolGenerate/dconfig2cpp ./dtk6widget/src/org.deepin.dtkwidget.feature-display.json + * Generation time: 2025-01-14T10:54:59 + * 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_DTKWIDGET_FEATURE-DISPLAY_H +#define ORG_DEEPIN_DTKWIDGET_FEATURE-DISPLAY_H + +#include +#include +#include +#include +#include +#include + +class org_deepin_dtkwidget_feature-display : public QObject { + Q_OBJECT + + Q_PROPERTY(bool autoDisplayFeature READ autoDisplayFeature WRITE setAutoDisplayFeature NOTIFY autoDisplayFeatureChanged) + Q_PROPERTY(bool featureUpdated READ featureUpdated WRITE setFeatureUpdated NOTIFY featureUpdatedChanged) +public: + explicit org_deepin_dtkwidget_feature-display(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_dtkwidget_feature-display(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_dtkwidget_feature-display(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_dtkwidget_feature-display(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_dtkwidget_feature-display() { + if (m_config.loadRelaxed()) { + m_config.loadRelaxed()->deleteLater(); + } + } + + 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(); + } + } + bool featureUpdated() const { + return p_featureUpdated; + } + void setFeatureUpdated(const bool &value) { + auto oldValue = p_featureUpdated; + p_featureUpdated = value; + markPropertySet(1); + 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_SIGNALS: + void autoDisplayFeatureChanged(); + void featureUpdatedChanged(); +private: + void initialize(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("featureUpdated"), QVariant::fromValue(p_featureUpdated)); + } else { + updateValue(QStringLiteral("featureUpdated"), QVariant::fromValue(p_featureUpdated)); + } + + 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("autoDisplayFeature")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_autoDisplayFeature != newValue) { + p_autoDisplayFeature = newValue; + Q_EMIT autoDisplayFeatureChanged(); + } + }); + return; + } + if (key == QStringLiteral("featureUpdated")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_featureUpdated != newValue) { + p_featureUpdated = newValue; + Q_EMIT featureUpdatedChanged(); + } + }); + 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 m_config = nullptr; + bool p_autoDisplayFeature { false }; + bool p_featureUpdated { false }; + QAtomicInteger m_propertySetStatus0 = 0; +}; + +#endif // ORG_DEEPIN_DTKWIDGET_FEATURE-DISPLAY_H