-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Synchronize source files from linuxdeepin/dtkwidget. Source-pull-request: linuxdeepin/dtkwidget#631
- Loading branch information
1 parent
274973a
commit aa8f2ae
Showing
3 changed files
with
259 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
214 changes: 214 additions & 0 deletions
214
toolGenerate/dconfig2cpp/org_deepin_dtkwidget_feature-display.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,214 @@ | ||
/** | ||
* This file is generated by dconfig2cpp. | ||
* Command line arguments: ./dconfig2cpp -p ./dtkwidget/toolGenerate/dconfig2cpp ./dtkwidget/src/org.deepin.dtkwidget.feature-display.json | ||
* Generation time: 2025-01-13T16:35:04 | ||
* 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 <QThread> | ||
#include <QVariant> | ||
#include <QDebug> | ||
#include <QAtomicPointer> | ||
#include <QAtomicInteger> | ||
#include <DConfig> | ||
|
||
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<bool>(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<bool>(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<DTK_CORE_NAMESPACE::DConfig> m_config = nullptr; | ||
bool p_autoDisplayFeature { false }; | ||
bool p_featureUpdated { false }; | ||
QAtomicInteger<quint32> m_propertySetStatus0 = 0; | ||
}; | ||
|
||
#endif // ORG_DEEPIN_DTKWIDGET_FEATURE-DISPLAY_H |