diff --git a/toolGenerate/dconfig2cpp/dconf-example_meta.hpp b/toolGenerate/dconfig2cpp/dconf-example_meta.hpp new file mode 100644 index 0000000..f98d93e --- /dev/null +++ b/toolGenerate/dconfig2cpp/dconf-example_meta.hpp @@ -0,0 +1,554 @@ +/** + * This file is generated by dconfig2cpp. + * Command line arguments: ./dconfig2cpp -p ./dtkcore/toolGenerate/dconfig2cpp ./dtkcore/tests/data/dconf-example.meta.json + * Generation time: 2025-01-13T16:35:06 + * 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 DCONF-EXAMPLE_META_H +#define DCONF-EXAMPLE_META_H + +#include +#include +#include +#include +#include +#include + +class dconf-example_meta : public QObject { + Q_OBJECT + + Q_PROPERTY(QList array READ array WRITE setArray NOTIFY arrayChanged) + Q_PROPERTY(QList array_map READ array_map WRITE setArray_map NOTIFY array_mapChanged) + Q_PROPERTY(QList array_map_struct READ array_map_struct WRITE setArray_map_struct NOTIFY array_map_structChanged) + Q_PROPERTY(bool canExit READ canExit WRITE setCanExit NOTIFY canExitChanged) + Q_PROPERTY(QString key2 READ key2 WRITE setKey2 NOTIFY key2Changed) + Q_PROPERTY(QString key3 READ key3 WRITE setKey3 NOTIFY key3Changed) + Q_PROPERTY(QVariantMap map READ map WRITE setMap NOTIFY mapChanged) + Q_PROPERTY(QVariantMap map_array READ map_array WRITE setMap_array NOTIFY map_arrayChanged) + Q_PROPERTY(double number READ number WRITE setNumber NOTIFY numberChanged) + Q_PROPERTY(double numberDouble READ numberDouble WRITE setNumberDouble NOTIFY numberDoubleChanged) + Q_PROPERTY(bool publicConfig READ publicConfig WRITE setPublicConfig NOTIFY publicConfigChanged) + Q_PROPERTY(QVariantMap struct READ struct WRITE setStruct NOTIFY structChanged) +public: + explicit dconf-example_meta(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 dconf-example_meta(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 dconf-example_meta(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 dconf-example_meta(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(); + }); + } + ~dconf-example_meta() { + if (m_config.loadRelaxed()) { + m_config.loadRelaxed()->deleteLater(); + } + } + + QList array() const { + return p_array; + } + void setArray(const QList &value) { + auto oldValue = p_array; + p_array = value; + markPropertySet(0); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("array"), value); + }); + } + if (p_array != oldValue) { + Q_EMIT arrayChanged(); + } + } + QList array_map() const { + return p_array_map; + } + void setArray_map(const QList &value) { + auto oldValue = p_array_map; + p_array_map = value; + markPropertySet(1); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("array_map"), value); + }); + } + if (p_array_map != oldValue) { + Q_EMIT array_mapChanged(); + } + } + QList array_map_struct() const { + return p_array_map_struct; + } + void setArray_map_struct(const QList &value) { + auto oldValue = p_array_map_struct; + p_array_map_struct = value; + markPropertySet(2); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("array_map_struct"), value); + }); + } + if (p_array_map_struct != oldValue) { + Q_EMIT array_map_structChanged(); + } + } + bool canExit() const { + return p_canExit; + } + void setCanExit(const bool &value) { + auto oldValue = p_canExit; + p_canExit = value; + markPropertySet(3); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("canExit"), value); + }); + } + if (p_canExit != oldValue) { + Q_EMIT canExitChanged(); + } + } + QString key2() const { + return p_key2; + } + void setKey2(const QString &value) { + auto oldValue = p_key2; + p_key2 = value; + markPropertySet(4); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("key2"), value); + }); + } + if (p_key2 != oldValue) { + Q_EMIT key2Changed(); + } + } + QString key3() const { + return p_key3; + } + void setKey3(const QString &value) { + auto oldValue = p_key3; + p_key3 = value; + markPropertySet(5); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("key3"), value); + }); + } + if (p_key3 != oldValue) { + Q_EMIT key3Changed(); + } + } + QVariantMap map() const { + return p_map; + } + void setMap(const QVariantMap &value) { + auto oldValue = p_map; + p_map = value; + markPropertySet(6); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("map"), value); + }); + } + if (p_map != oldValue) { + Q_EMIT mapChanged(); + } + } + QVariantMap map_array() const { + return p_map_array; + } + void setMap_array(const QVariantMap &value) { + auto oldValue = p_map_array; + p_map_array = value; + markPropertySet(7); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("map_array"), value); + }); + } + if (p_map_array != oldValue) { + Q_EMIT map_arrayChanged(); + } + } + double number() const { + return p_number; + } + void setNumber(const double &value) { + auto oldValue = p_number; + p_number = value; + markPropertySet(8); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("number"), value); + }); + } + if (p_number != oldValue) { + Q_EMIT numberChanged(); + } + } + double numberDouble() const { + return p_numberDouble; + } + void setNumberDouble(const double &value) { + auto oldValue = p_numberDouble; + p_numberDouble = value; + markPropertySet(9); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("numberDouble"), value); + }); + } + if (p_numberDouble != oldValue) { + Q_EMIT numberDoubleChanged(); + } + } + bool publicConfig() const { + return p_publicConfig; + } + void setPublicConfig(const bool &value) { + auto oldValue = p_publicConfig; + p_publicConfig = value; + markPropertySet(10); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("publicConfig"), value); + }); + } + if (p_publicConfig != oldValue) { + Q_EMIT publicConfigChanged(); + } + } + QVariantMap struct() const { + return p_struct; + } + void setStruct(const QVariantMap &value) { + auto oldValue = p_struct; + p_struct = value; + markPropertySet(11); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("struct"), value); + }); + } + if (p_struct != oldValue) { + Q_EMIT structChanged(); + } + } +Q_SIGNALS: + void arrayChanged(); + void array_mapChanged(); + void array_map_structChanged(); + void canExitChanged(); + void key2Changed(); + void key3Changed(); + void mapChanged(); + void map_arrayChanged(); + void numberChanged(); + void numberDoubleChanged(); + void publicConfigChanged(); + void structChanged(); +private: + void initialize(DTK_CORE_NAMESPACE::DConfig *config) { + Q_ASSERT(!m_config.loadRelaxed()); + m_config.storeRelaxed(config); + if (testPropertySet(0)) { + config->setValue(QStringLiteral("array"), QVariant::fromValue(p_array)); + } else { + updateValue(QStringLiteral("array"), QVariant::fromValue(p_array)); + } + if (testPropertySet(1)) { + config->setValue(QStringLiteral("array_map"), QVariant::fromValue(p_array_map)); + } else { + updateValue(QStringLiteral("array_map"), QVariant::fromValue(p_array_map)); + } + if (testPropertySet(2)) { + config->setValue(QStringLiteral("array_map_struct"), QVariant::fromValue(p_array_map_struct)); + } else { + updateValue(QStringLiteral("array_map_struct"), QVariant::fromValue(p_array_map_struct)); + } + if (testPropertySet(3)) { + config->setValue(QStringLiteral("canExit"), QVariant::fromValue(p_canExit)); + } else { + updateValue(QStringLiteral("canExit"), QVariant::fromValue(p_canExit)); + } + if (testPropertySet(4)) { + config->setValue(QStringLiteral("key2"), QVariant::fromValue(p_key2)); + } else { + updateValue(QStringLiteral("key2"), QVariant::fromValue(p_key2)); + } + if (testPropertySet(5)) { + config->setValue(QStringLiteral("key3"), QVariant::fromValue(p_key3)); + } else { + updateValue(QStringLiteral("key3"), QVariant::fromValue(p_key3)); + } + if (testPropertySet(6)) { + config->setValue(QStringLiteral("map"), QVariant::fromValue(p_map)); + } else { + updateValue(QStringLiteral("map"), QVariant::fromValue(p_map)); + } + if (testPropertySet(7)) { + config->setValue(QStringLiteral("map_array"), QVariant::fromValue(p_map_array)); + } else { + updateValue(QStringLiteral("map_array"), QVariant::fromValue(p_map_array)); + } + if (testPropertySet(8)) { + config->setValue(QStringLiteral("number"), QVariant::fromValue(p_number)); + } else { + updateValue(QStringLiteral("number"), QVariant::fromValue(p_number)); + } + if (testPropertySet(9)) { + config->setValue(QStringLiteral("numberDouble"), QVariant::fromValue(p_numberDouble)); + } else { + updateValue(QStringLiteral("numberDouble"), QVariant::fromValue(p_numberDouble)); + } + if (testPropertySet(10)) { + config->setValue(QStringLiteral("publicConfig"), QVariant::fromValue(p_publicConfig)); + } else { + updateValue(QStringLiteral("publicConfig"), QVariant::fromValue(p_publicConfig)); + } + if (testPropertySet(11)) { + config->setValue(QStringLiteral("struct"), QVariant::fromValue(p_struct)); + } else { + updateValue(QStringLiteral("struct"), QVariant::fromValue(p_struct)); + } + + 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("array")) { + auto newValue = qvariant_cast>(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_array != newValue) { + p_array = newValue; + Q_EMIT arrayChanged(); + } + }); + return; + } + if (key == QStringLiteral("array_map")) { + auto newValue = qvariant_cast>(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_array_map != newValue) { + p_array_map = newValue; + Q_EMIT array_mapChanged(); + } + }); + return; + } + if (key == QStringLiteral("array_map_struct")) { + auto newValue = qvariant_cast>(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_array_map_struct != newValue) { + p_array_map_struct = newValue; + Q_EMIT array_map_structChanged(); + } + }); + return; + } + if (key == QStringLiteral("canExit")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_canExit != newValue) { + p_canExit = newValue; + Q_EMIT canExitChanged(); + } + }); + return; + } + if (key == QStringLiteral("key2")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_key2 != newValue) { + p_key2 = newValue; + Q_EMIT key2Changed(); + } + }); + return; + } + if (key == QStringLiteral("key3")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_key3 != newValue) { + p_key3 = newValue; + Q_EMIT key3Changed(); + } + }); + return; + } + if (key == QStringLiteral("map")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_map != newValue) { + p_map = newValue; + Q_EMIT mapChanged(); + } + }); + return; + } + if (key == QStringLiteral("map_array")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_map_array != newValue) { + p_map_array = newValue; + Q_EMIT map_arrayChanged(); + } + }); + return; + } + if (key == QStringLiteral("number")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_number != newValue) { + p_number = newValue; + Q_EMIT numberChanged(); + } + }); + return; + } + if (key == QStringLiteral("numberDouble")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_numberDouble != newValue) { + p_numberDouble = newValue; + Q_EMIT numberDoubleChanged(); + } + }); + return; + } + if (key == QStringLiteral("publicConfig")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_publicConfig != newValue) { + p_publicConfig = newValue; + Q_EMIT publicConfigChanged(); + } + }); + return; + } + if (key == QStringLiteral("struct")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_struct != newValue) { + p_struct = newValue; + Q_EMIT structChanged(); + } + }); + 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; + QList p_array { QList{QVariant(QStringLiteral("value1")), QVariant(QStringLiteral("value2"))} }; + QList p_array_map { QList{QVariant(QVariantMap{{QStringLiteral("key1"), QVariant(QStringLiteral("value1"))}, {QStringLiteral("key2"), QVariant(QStringLiteral("value2"))}})} }; + QList p_array_map_struct { QList{QVariant(QVariantMap{{QStringLiteral("key1"), QVariant(QVariantMap{{QStringLiteral("field1"), QVariant(QStringLiteral("value1"))}})}, {QStringLiteral("key2"), QVariant(QStringLiteral("value2"))}})} }; + bool p_canExit { true }; + QString p_key2 { QStringLiteral("125") }; + QString p_key3 { QStringLiteral("application") }; + QVariantMap p_map { QVariantMap{{QStringLiteral("key1"), QVariant(QStringLiteral("value1"))}, {QStringLiteral("key2"), QVariant(QStringLiteral("value2"))}} }; + QVariantMap p_map_array { QVariantMap{{QStringLiteral("key1"), QVariant(QList{QVariant(QStringLiteral("value1"))})}, {QStringLiteral("key2"), QVariant(QList{QVariant(QStringLiteral("value2"))})}} }; + double p_number { 1 }; + double p_numberDouble { 1 }; + bool p_publicConfig { true }; + QVariantMap p_struct { QVariantMap{{QStringLiteral("key1"), QVariant(QStringLiteral("value1"))}, {QStringLiteral("key2"), QVariant(QStringLiteral("value2"))}} }; + QAtomicInteger m_propertySetStatus0 = 0; +}; + +#endif // DCONF-EXAMPLE_META_H diff --git a/toolGenerate/dconfig2cpp/dconf-example_other_app_configure_meta.hpp b/toolGenerate/dconfig2cpp/dconf-example_other_app_configure_meta.hpp new file mode 100644 index 0000000..64b3a09 --- /dev/null +++ b/toolGenerate/dconfig2cpp/dconf-example_other_app_configure_meta.hpp @@ -0,0 +1,214 @@ +/** + * This file is generated by dconfig2cpp. + * Command line arguments: ./dconfig2cpp -p ./dtkcore/toolGenerate/dconfig2cpp ./dtkcore/tests/data/dconf-example_other_app_configure.meta.json + * Generation time: 2025-01-13T16:35:06 + * 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 DCONF-EXAMPLE_OTHER_APP_CONFIGURE_META_H +#define DCONF-EXAMPLE_OTHER_APP_CONFIGURE_META_H + +#include +#include +#include +#include +#include +#include + +class dconf-example_other_app_configure_meta : public QObject { + Q_OBJECT + + Q_PROPERTY(QString appPrivate READ appPrivate WRITE setAppPrivate NOTIFY appPrivateChanged) + Q_PROPERTY(QString appPublic READ appPublic WRITE setAppPublic NOTIFY appPublicChanged) +public: + explicit dconf-example_other_app_configure_meta(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 dconf-example_other_app_configure_meta(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 dconf-example_other_app_configure_meta(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 dconf-example_other_app_configure_meta(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(); + }); + } + ~dconf-example_other_app_configure_meta() { + if (m_config.loadRelaxed()) { + m_config.loadRelaxed()->deleteLater(); + } + } + + QString appPrivate() const { + return p_appPrivate; + } + void setAppPrivate(const QString &value) { + auto oldValue = p_appPrivate; + p_appPrivate = value; + markPropertySet(0); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("appPrivate"), value); + }); + } + if (p_appPrivate != oldValue) { + Q_EMIT appPrivateChanged(); + } + } + QString appPublic() const { + return p_appPublic; + } + void setAppPublic(const QString &value) { + auto oldValue = p_appPublic; + p_appPublic = value; + markPropertySet(1); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("appPublic"), value); + }); + } + if (p_appPublic != oldValue) { + Q_EMIT appPublicChanged(); + } + } +Q_SIGNALS: + void appPrivateChanged(); + void appPublicChanged(); +private: + void initialize(DTK_CORE_NAMESPACE::DConfig *config) { + Q_ASSERT(!m_config.loadRelaxed()); + m_config.storeRelaxed(config); + if (testPropertySet(0)) { + config->setValue(QStringLiteral("appPrivate"), QVariant::fromValue(p_appPrivate)); + } else { + updateValue(QStringLiteral("appPrivate"), QVariant::fromValue(p_appPrivate)); + } + if (testPropertySet(1)) { + config->setValue(QStringLiteral("appPublic"), QVariant::fromValue(p_appPublic)); + } else { + updateValue(QStringLiteral("appPublic"), QVariant::fromValue(p_appPublic)); + } + + 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("appPrivate")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_appPrivate != newValue) { + p_appPrivate = newValue; + Q_EMIT appPrivateChanged(); + } + }); + return; + } + if (key == QStringLiteral("appPublic")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_appPublic != newValue) { + p_appPublic = newValue; + Q_EMIT appPublicChanged(); + } + }); + 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; + QString p_appPrivate { QStringLiteral("appPrivate") }; + QString p_appPublic { QStringLiteral("publicValue") }; + QAtomicInteger m_propertySetStatus0 = 0; +}; + +#endif // DCONF-EXAMPLE_OTHER_APP_CONFIGURE_META_H diff --git a/toolGenerate/dconfig2cpp/dconf-global_meta.hpp b/toolGenerate/dconfig2cpp/dconf-global_meta.hpp new file mode 100644 index 0000000..bd4fc61 --- /dev/null +++ b/toolGenerate/dconfig2cpp/dconf-global_meta.hpp @@ -0,0 +1,180 @@ +/** + * This file is generated by dconfig2cpp. + * Command line arguments: ./dconfig2cpp -p ./dtkcore/toolGenerate/dconfig2cpp ./dtkcore/tests/data/dconf-global.meta.json + * Generation time: 2025-01-13T16:35:06 + * 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 DCONF-GLOBAL_META_H +#define DCONF-GLOBAL_META_H + +#include +#include +#include +#include +#include +#include + +class dconf-global_meta : public QObject { + Q_OBJECT + + Q_PROPERTY(QString key3 READ key3 WRITE setKey3 NOTIFY key3Changed) +public: + explicit dconf-global_meta(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 dconf-global_meta(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 dconf-global_meta(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 dconf-global_meta(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(); + }); + } + ~dconf-global_meta() { + if (m_config.loadRelaxed()) { + m_config.loadRelaxed()->deleteLater(); + } + } + + QString key3() const { + return p_key3; + } + void setKey3(const QString &value) { + auto oldValue = p_key3; + p_key3 = value; + markPropertySet(0); + if (auto config = m_config.loadRelaxed()) { + QMetaObject::invokeMethod(config, [this, value]() { + m_config.loadRelaxed()->setValue(QStringLiteral("key3"), value); + }); + } + if (p_key3 != oldValue) { + Q_EMIT key3Changed(); + } + } +Q_SIGNALS: + void key3Changed(); +private: + void initialize(DTK_CORE_NAMESPACE::DConfig *config) { + Q_ASSERT(!m_config.loadRelaxed()); + m_config.storeRelaxed(config); + if (testPropertySet(0)) { + config->setValue(QStringLiteral("key3"), QVariant::fromValue(p_key3)); + } else { + updateValue(QStringLiteral("key3"), QVariant::fromValue(p_key3)); + } + + 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("key3")) { + auto newValue = qvariant_cast(value); + QMetaObject::invokeMethod(this, [this, newValue]() { + if (p_key3 != newValue) { + p_key3 = newValue; + Q_EMIT key3Changed(); + } + }); + 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; + QString p_key3 { QStringLiteral("global") }; + QAtomicInteger m_propertySetStatus0 = 0; +}; + +#endif // DCONF-GLOBAL_META_H diff --git a/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.ManagerAdaptor.cpp b/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.ManagerAdaptor.cpp new file mode 100644 index 0000000..920f32c --- /dev/null +++ b/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.ManagerAdaptor.cpp @@ -0,0 +1,113 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp ./dtkcore/src/dbus/org.desktopspec.ConfigManager.Manager.xml -a ./dtkcore/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.ManagerAdaptor -i ./dtkcore/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.Manager.h + * + * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#include "./dtkcore/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.ManagerAdaptor.h" +#include +#include +#include +#include +#include +#include +#include + +/* + * Implementation of adaptor class ManagerAdaptor + */ + +ManagerAdaptor::ManagerAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +ManagerAdaptor::~ManagerAdaptor() +{ + // destructor +} + +QStringList ManagerAdaptor::keyList() const +{ + // get the value of property keyList + return qvariant_cast< QStringList >(parent()->property("keyList")); +} + +QString ManagerAdaptor::version() const +{ + // get the value of property version + return qvariant_cast< QString >(parent()->property("version")); +} + +QString ManagerAdaptor::description(const QString &key, const QString &language) +{ + // handle method call org.desktopspec.ConfigManager.Manager.description + QString description; + QMetaObject::invokeMethod(parent(), "description", Q_RETURN_ARG(QString, description), Q_ARG(QString, key), Q_ARG(QString, language)); + return description; +} + +bool ManagerAdaptor::isDefaultValue(const QString &key) +{ + // handle method call org.desktopspec.ConfigManager.Manager.isDefaultValue + bool isDefaultValue; + QMetaObject::invokeMethod(parent(), "isDefaultValue", Q_RETURN_ARG(bool, isDefaultValue), Q_ARG(QString, key)); + return isDefaultValue; +} + +QString ManagerAdaptor::name(const QString &key, const QString &language) +{ + // handle method call org.desktopspec.ConfigManager.Manager.name + QString name; + QMetaObject::invokeMethod(parent(), "name", Q_RETURN_ARG(QString, name), Q_ARG(QString, key), Q_ARG(QString, language)); + return name; +} + +QString ManagerAdaptor::permissions(const QString &key) +{ + // handle method call org.desktopspec.ConfigManager.Manager.permissions + QString permissions; + QMetaObject::invokeMethod(parent(), "permissions", Q_RETURN_ARG(QString, permissions), Q_ARG(QString, key)); + return permissions; +} + +void ManagerAdaptor::release() +{ + // handle method call org.desktopspec.ConfigManager.Manager.release + QMetaObject::invokeMethod(parent(), "release"); +} + +void ManagerAdaptor::reset(const QString &key) +{ + // handle method call org.desktopspec.ConfigManager.Manager.reset + QMetaObject::invokeMethod(parent(), "reset", Q_ARG(QString, key)); +} + +void ManagerAdaptor::setValue(const QString &key, const QDBusVariant &value) +{ + // handle method call org.desktopspec.ConfigManager.Manager.setValue + QMetaObject::invokeMethod(parent(), "setValue", Q_ARG(QString, key), Q_ARG(QDBusVariant, value)); +} + +QDBusVariant ManagerAdaptor::value(const QString &key) +{ + // handle method call org.desktopspec.ConfigManager.Manager.value + QDBusVariant value; + QMetaObject::invokeMethod(parent(), "value", Q_RETURN_ARG(QDBusVariant, value), Q_ARG(QString, key)); + return value; +} + +QString ManagerAdaptor::visibility(const QString &key) +{ + // handle method call org.desktopspec.ConfigManager.Manager.visibility + QString visibility; + QMetaObject::invokeMethod(parent(), "visibility", Q_RETURN_ARG(QString, visibility), Q_ARG(QString, key)); + return visibility; +} + diff --git a/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.ManagerAdaptor.h b/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.ManagerAdaptor.h new file mode 100644 index 0000000..4aa5e5c --- /dev/null +++ b/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.ManagerAdaptor.h @@ -0,0 +1,102 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp ./dtkcore/src/dbus/org.desktopspec.ConfigManager.Manager.xml -a ./dtkcore/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.ManagerAdaptor -i ./dtkcore/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.Manager.h + * + * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#ifndef ORG_DESKTOPSPEC_CONFIGMANAGER_MANAGERADAPTOR_H +#define ORG_DESKTOPSPEC_CONFIGMANAGER_MANAGERADAPTOR_H + +#include +#include +#include "./dtkcore/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.Manager.h" +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +/* + * Adaptor class for interface org.desktopspec.ConfigManager.Manager + */ +class ManagerAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.desktopspec.ConfigManager.Manager") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + ManagerAdaptor(QObject *parent); + virtual ~ManagerAdaptor(); + +public: // PROPERTIES + Q_PROPERTY(QStringList keyList READ keyList) + QStringList keyList() const; + + Q_PROPERTY(QString version READ version) + QString version() const; + +public Q_SLOTS: // METHODS + QString description(const QString &key, const QString &language); + bool isDefaultValue(const QString &key); + QString name(const QString &key, const QString &language); + QString permissions(const QString &key); + void release(); + void reset(const QString &key); + void setValue(const QString &key, const QDBusVariant &value); + QDBusVariant value(const QString &key); + QString visibility(const QString &key); +Q_SIGNALS: // SIGNALS + void valueChanged(const QString &key); +}; + +#endif diff --git a/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManagerAdaptor.cpp b/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManagerAdaptor.cpp new file mode 100644 index 0000000..120fc9c --- /dev/null +++ b/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManagerAdaptor.cpp @@ -0,0 +1,55 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp ./dtkcore/src/dbus/org.desktopspec.ConfigManager.xml -a ./dtkcore/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManagerAdaptor -i ./dtkcore/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.h + * + * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#include "./dtkcore/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManagerAdaptor.h" +#include +#include +#include +#include +#include +#include +#include + +/* + * Implementation of adaptor class ConfigManagerAdaptor + */ + +ConfigManagerAdaptor::ConfigManagerAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +ConfigManagerAdaptor::~ConfigManagerAdaptor() +{ + // destructor +} + +QDBusObjectPath ConfigManagerAdaptor::acquireManager(const QString &appid, const QString &name, const QString &subpath) +{ + // handle method call org.desktopspec.ConfigManager.acquireManager + QDBusObjectPath path; + QMetaObject::invokeMethod(parent(), "acquireManager", Q_RETURN_ARG(QDBusObjectPath, path), Q_ARG(QString, appid), Q_ARG(QString, name), Q_ARG(QString, subpath)); + return path; +} + +void ConfigManagerAdaptor::sync(const QString &path) +{ + // handle method call org.desktopspec.ConfigManager.sync + QMetaObject::invokeMethod(parent(), "sync", Q_ARG(QString, path)); +} + +void ConfigManagerAdaptor::update(const QString &path) +{ + // handle method call org.desktopspec.ConfigManager.update + QMetaObject::invokeMethod(parent(), "update", Q_ARG(QString, path)); +} + diff --git a/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManagerAdaptor.h b/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManagerAdaptor.h new file mode 100644 index 0000000..abb79a7 --- /dev/null +++ b/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManagerAdaptor.h @@ -0,0 +1,62 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp ./dtkcore/src/dbus/org.desktopspec.ConfigManager.xml -a ./dtkcore/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManagerAdaptor -i ./dtkcore/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.h + * + * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#ifndef ORG_DESKTOPSPEC_CONFIGMANAGERADAPTOR_H +#define ORG_DESKTOPSPEC_CONFIGMANAGERADAPTOR_H + +#include +#include +#include "./dtkcore/toolGenerate/qdbusxml2cpp/org.desktopspec.ConfigManager.h" +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +/* + * Adaptor class for interface org.desktopspec.ConfigManager + */ +class ConfigManagerAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.desktopspec.ConfigManager") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + ConfigManagerAdaptor(QObject *parent); + virtual ~ConfigManagerAdaptor(); + +public: // PROPERTIES +public Q_SLOTS: // METHODS + QDBusObjectPath acquireManager(const QString &appid, const QString &name, const QString &subpath); + void sync(const QString &path); + void update(const QString &path); +Q_SIGNALS: // SIGNALS +}; + +#endif