| 1 |
/** |
| 2 |
* This file is generated by dconfig2cpp. |
| 3 |
* Command line arguments: /home/zccrs/projects/dtkcore/build/unknown-Debug/tools/dconfig2cpp/dconfig2cpp /home/zccrs/projects/dtkcommon/configs/org.deepin.dtk.preference.json |
| 4 |
* Generation time: 2025-03-06T10:40:41 |
| 5 |
* JSON file version: 1.0 |
| 6 |
* |
| 7 |
* WARNING: DO NOT MODIFY THIS FILE MANUALLY. |
| 8 |
* If you need to change the content, please modify the dconfig2cpp tool. |
| 9 |
*/ |
| 10 |
|
| 11 |
#ifndef DCONFIG_ORG_DEEPIN_DTK_PREFERENCE_H |
| 12 |
#define DCONFIG_ORG_DEEPIN_DTK_PREFERENCE_H |
| 13 |
|
| 14 |
#include <QThread> |
| 15 |
#include <QVariant> |
| 16 |
#include <QDebug> |
| 17 |
#include <QAtomicPointer> |
| 18 |
#include <QAtomicInteger> |
| 19 |
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 20 |
#include <QProperty> |
| 21 |
#endif |
| 22 |
#include <DConfig> |
| 23 |
|
| 24 |
class dconfig_org_deepin_dtk_preference : public QObject { |
| 25 |
Q_OBJECT |
| 26 |
|
| 27 |
Q_PROPERTY(bool autoDisplayFeature READ autoDisplayFeature WRITE setAutoDisplayFeature NOTIFY autoDisplayFeatureChanged RESET resetAutoDisplayFeature) |
| 28 |
Q_PROPERTY(bool featureUpdated READ featureUpdated WRITE setFeatureUpdated NOTIFY featureUpdatedChanged RESET resetFeatureUpdated) |
| 29 |
Q_PROPERTY(bool keyboardsearchDisabled READ keyboardsearchDisabled WRITE setKeyboardsearchDisabled NOTIFY keyboardsearchDisabledChanged RESET resetKeyboardsearchDisabled) |
| 30 |
Q_PROPERTY(QString rules READ rules WRITE setRules NOTIFY rulesChanged RESET resetRules) |
| 31 |
Q_PROPERTY(qlonglong themeType READ themeType WRITE setThemeType NOTIFY themeTypeChanged RESET resetThemeType) |
| 32 |
Q_PROPERTY(qlonglong titlebarHeight READ titlebarHeight WRITE setTitlebarHeight NOTIFY titlebarHeightChanged RESET resetTitlebarHeight) |
| 33 |
Q_PROPERTY(bool underlineShortcut READ underlineShortcut WRITE setUnderlineShortcut NOTIFY underlineShortcutChanged RESET resetUnderlineShortcut) |
| 34 |
Q_CLASSINFO("DConfigKeyList", "autoDisplayFeature;featureUpdated;keyboardsearchDisabled;rules;themeType;titlebarHeight;underlineShortcut") |
| 35 |
Q_CLASSINFO("DConfigFileName", "org.deepin.dtk.preference") |
| 36 |
Q_CLASSINFO("DConfigFileVersion", "1.0") |
| 37 |
|
| 38 |
public: |
| 39 |
explicit dconfig_org_deepin_dtk_preference(QThread *thread, DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &name, const QString &appId, const QString &subpath, QObject *parent) |
| 40 |
: QObject(parent) { |
| 41 |
if (!thread->isRunning()) { |
| 42 |
qWarning() << QLatin1String("Warning: The provided thread is not running."); |
| 43 |
} |
| 44 |
Q_ASSERT(QThread::currentThread() != thread); |
| 45 |
auto worker = new QObject(); |
| 46 |
worker->moveToThread(thread); |
| 47 |
QMetaObject::invokeMethod(worker, [=, this]() { |
| 48 |
DTK_CORE_NAMESPACE::DConfig *config = nullptr; |
| 49 |
if (backend) { |
| 50 |
if (appId.isNull()) { |
| 51 |
config = DTK_CORE_NAMESPACE::DConfig::create(backend, name, subpath, nullptr); |
| 52 |
} else { |
| 53 |
config = DTK_CORE_NAMESPACE::DConfig::create(backend, appId, name, subpath, nullptr); |
| 54 |
} |
| 55 |
} else { |
| 56 |
if (appId.isNull()) { |
| 57 |
config = DTK_CORE_NAMESPACE::DConfig::create(name, subpath, nullptr); |
| 58 |
} else { |
| 59 |
config = DTK_CORE_NAMESPACE::DConfig::create(appId, name, subpath, nullptr); |
| 60 |
} |
| 61 |
} |
| 62 |
if (!config) { |
| 63 |
qWarning() << QLatin1String("Failed to create DConfig instance."); |
| 64 |
worker->deleteLater(); |
| 65 |
return; |
| 66 |
} |
| 67 |
config->moveToThread(QThread::currentThread()); |
| 68 |
initializeInConfigThread(config); |
| 69 |
worker->deleteLater(); |
| 70 |
}); |
| 71 |
} |
| 72 |
static dconfig_org_deepin_dtk_preference* create(const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread()) |
| 73 |
{ return new dconfig_org_deepin_dtk_preference(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, parent); } |
| 74 |
static dconfig_org_deepin_dtk_preference* create(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread()) |
| 75 |
{ return new dconfig_org_deepin_dtk_preference(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, parent); } |
| 76 |
static dconfig_org_deepin_dtk_preference* createByName(const QString &name, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread()) |
| 77 |
{ return new dconfig_org_deepin_dtk_preference(thread, nullptr, name, appId, subpath, parent); } |
| 78 |
static dconfig_org_deepin_dtk_preference* 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()) |
| 79 |
{ return new dconfig_org_deepin_dtk_preference(thread, backend, name, appId, subpath, parent); } |
| 80 |
~dconfig_org_deepin_dtk_preference() { |
| 81 |
if (m_config.loadRelaxed()) { |
| 82 |
m_config.loadRelaxed()->deleteLater(); |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
Q_INVOKABLE DTK_CORE_NAMESPACE::DConfig *config() const { |
| 87 |
return m_config.loadRelaxed(); |
| 88 |
} |
| 89 |
|
| 90 |
Q_INVOKABLE bool isInitializeSucceed() const { |
| 91 |
return m_status.loadRelaxed() == static_cast<int>(Status::Succeed); |
| 92 |
} |
| 93 |
|
| 94 |
Q_INVOKABLE bool isInitializeFailed() const { |
| 95 |
return m_status.loadRelaxed() == static_cast<int>(Status::Failed); |
| 96 |
} |
| 97 |
|
| 98 |
Q_INVOKABLE bool isInitializing() const { |
| 99 |
return m_status.loadRelaxed() == static_cast<int>(Status::Invalid); |
| 100 |
} |
| 101 |
|
| 102 |
Q_INVOKABLE QStringList keyList() const { |
| 103 |
return { QStringLiteral("autoDisplayFeature"), |
| 104 |
QStringLiteral("featureUpdated"), |
| 105 |
QStringLiteral("keyboardsearchDisabled"), |
| 106 |
QStringLiteral("rules"), |
| 107 |
QStringLiteral("themeType"), |
| 108 |
QStringLiteral("titlebarHeight"), |
| 109 |
QStringLiteral("underlineShortcut")}; |
| 110 |
} |
| 111 |
|
| 112 |
Q_INVOKABLE bool isDefaultValue(const QString &key) const { |
| 113 |
if (key == QStringLiteral("autoDisplayFeature")) |
| 114 |
return autoDisplayFeatureIsDefaultValue(); |
| 115 |
if (key == QStringLiteral("featureUpdated")) |
| 116 |
return featureUpdatedIsDefaultValue(); |
| 117 |
if (key == QStringLiteral("keyboardsearchDisabled")) |
| 118 |
return keyboardsearchDisabledIsDefaultValue(); |
| 119 |
if (key == QStringLiteral("rules")) |
| 120 |
return rulesIsDefaultValue(); |
| 121 |
if (key == QStringLiteral("themeType")) |
| 122 |
return themeTypeIsDefaultValue(); |
| 123 |
if (key == QStringLiteral("titlebarHeight")) |
| 124 |
return titlebarHeightIsDefaultValue(); |
| 125 |
if (key == QStringLiteral("underlineShortcut")) |
| 126 |
return underlineShortcutIsDefaultValue(); |
| 127 |
return false; |
| 128 |
} |
| 129 |
|
| 130 |
bool autoDisplayFeature() const { |
| 131 |
return p_autoDisplayFeature; |
| 132 |
} |
| 133 |
void setAutoDisplayFeature(const bool &value) { |
| 134 |
auto oldValue = p_autoDisplayFeature; |
| 135 |
p_autoDisplayFeature = value; |
| 136 |
markPropertySet(0); |
| 137 |
if (auto config = m_config.loadRelaxed()) { |
| 138 |
QMetaObject::invokeMethod(config, [this, value]() { |
| 139 |
m_config.loadRelaxed()->setValue(QStringLiteral("autoDisplayFeature"), value); |
| 140 |
}); |
| 141 |
} |
| 142 |
if (p_autoDisplayFeature != oldValue) { |
| 143 |
Q_EMIT autoDisplayFeatureChanged(); |
| 144 |
Q_EMIT valueChanged(QStringLiteral("autoDisplayFeature"), value); |
| 145 |
} |
| 146 |
} |
| 147 |
void resetAutoDisplayFeature() { |
| 148 |
if (auto config = m_config.loadRelaxed()) { |
| 149 |
QMetaObject::invokeMethod(config, [this]() { |
| 150 |
m_config.loadRelaxed()->reset(QStringLiteral("autoDisplayFeature")); |
| 151 |
}); |
| 152 |
} |
| 153 |
} |
| 154 |
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 155 |
QBindable<bool> bindableAutoDisplayFeature() { |
| 156 |
return QBindable<bool>(this, QStringLiteral("autoDisplayFeature")); |
| 157 |
} |
| 158 |
#endif |
| 159 |
Q_INVOKABLE bool autoDisplayFeatureIsDefaultValue() const { |
| 160 |
return !testPropertySet(0); |
| 161 |
} |
| 162 |
bool featureUpdated() const { |
| 163 |
return p_featureUpdated; |
| 164 |
} |
| 165 |
void setFeatureUpdated(const bool &value) { |
| 166 |
auto oldValue = p_featureUpdated; |
| 167 |
p_featureUpdated = value; |
| 168 |
markPropertySet(1); |
| 169 |
if (auto config = m_config.loadRelaxed()) { |
| 170 |
QMetaObject::invokeMethod(config, [this, value]() { |
| 171 |
m_config.loadRelaxed()->setValue(QStringLiteral("featureUpdated"), value); |
| 172 |
}); |
| 173 |
} |
| 174 |
if (p_featureUpdated != oldValue) { |
| 175 |
Q_EMIT featureUpdatedChanged(); |
| 176 |
Q_EMIT valueChanged(QStringLiteral("featureUpdated"), value); |
| 177 |
} |
| 178 |
} |
| 179 |
void resetFeatureUpdated() { |
| 180 |
if (auto config = m_config.loadRelaxed()) { |
| 181 |
QMetaObject::invokeMethod(config, [this]() { |
| 182 |
m_config.loadRelaxed()->reset(QStringLiteral("featureUpdated")); |
| 183 |
}); |
| 184 |
} |
| 185 |
} |
| 186 |
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 187 |
QBindable<bool> bindableFeatureUpdated() { |
| 188 |
return QBindable<bool>(this, QStringLiteral("featureUpdated")); |
| 189 |
} |
| 190 |
#endif |
| 191 |
Q_INVOKABLE bool featureUpdatedIsDefaultValue() const { |
| 192 |
return !testPropertySet(1); |
| 193 |
} |
| 194 |
bool keyboardsearchDisabled() const { |
| 195 |
return p_keyboardsearchDisabled; |
| 196 |
} |
| 197 |
void setKeyboardsearchDisabled(const bool &value) { |
| 198 |
auto oldValue = p_keyboardsearchDisabled; |
| 199 |
p_keyboardsearchDisabled = value; |
| 200 |
markPropertySet(2); |
| 201 |
if (auto config = m_config.loadRelaxed()) { |
| 202 |
QMetaObject::invokeMethod(config, [this, value]() { |
| 203 |
m_config.loadRelaxed()->setValue(QStringLiteral("keyboardsearchDisabled"), value); |
| 204 |
}); |
| 205 |
} |
| 206 |
if (p_keyboardsearchDisabled != oldValue) { |
| 207 |
Q_EMIT keyboardsearchDisabledChanged(); |
| 208 |
Q_EMIT valueChanged(QStringLiteral("keyboardsearchDisabled"), value); |
| 209 |
} |
| 210 |
} |
| 211 |
void resetKeyboardsearchDisabled() { |
| 212 |
if (auto config = m_config.loadRelaxed()) { |
| 213 |
QMetaObject::invokeMethod(config, [this]() { |
| 214 |
m_config.loadRelaxed()->reset(QStringLiteral("keyboardsearchDisabled")); |
| 215 |
}); |
| 216 |
} |
| 217 |
} |
| 218 |
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 219 |
QBindable<bool> bindableKeyboardsearchDisabled() { |
| 220 |
return QBindable<bool>(this, QStringLiteral("keyboardsearchDisabled")); |
| 221 |
} |
| 222 |
#endif |
| 223 |
Q_INVOKABLE bool keyboardsearchDisabledIsDefaultValue() const { |
| 224 |
return !testPropertySet(2); |
| 225 |
} |
| 226 |
QString rules() const { |
| 227 |
return p_rules; |
| 228 |
} |
| 229 |
void setRules(const QString &value) { |
| 230 |
auto oldValue = p_rules; |
| 231 |
p_rules = value; |
| 232 |
markPropertySet(3); |
| 233 |
if (auto config = m_config.loadRelaxed()) { |
| 234 |
QMetaObject::invokeMethod(config, [this, value]() { |
| 235 |
m_config.loadRelaxed()->setValue(QStringLiteral("rules"), value); |
| 236 |
}); |
| 237 |
} |
| 238 |
if (p_rules != oldValue) { |
| 239 |
Q_EMIT rulesChanged(); |
| 240 |
Q_EMIT valueChanged(QStringLiteral("rules"), value); |
| 241 |
} |
| 242 |
} |
| 243 |
void resetRules() { |
| 244 |
if (auto config = m_config.loadRelaxed()) { |
| 245 |
QMetaObject::invokeMethod(config, [this]() { |
| 246 |
m_config.loadRelaxed()->reset(QStringLiteral("rules")); |
| 247 |
}); |
| 248 |
} |
| 249 |
} |
| 250 |
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 251 |
QBindable<QString> bindableRules() { |
| 252 |
return QBindable<QString>(this, QStringLiteral("rules")); |
| 253 |
} |
| 254 |
#endif |
| 255 |
Q_INVOKABLE bool rulesIsDefaultValue() const { |
| 256 |
return !testPropertySet(3); |
| 257 |
} |
| 258 |
qlonglong themeType() const { |
| 259 |
return p_themeType; |
| 260 |
} |
| 261 |
void setThemeType(const qlonglong &value) { |
| 262 |
auto oldValue = p_themeType; |
| 263 |
p_themeType = value; |
| 264 |
markPropertySet(4); |
| 265 |
if (auto config = m_config.loadRelaxed()) { |
| 266 |
QMetaObject::invokeMethod(config, [this, value]() { |
| 267 |
m_config.loadRelaxed()->setValue(QStringLiteral("themeType"), value); |
| 268 |
}); |
| 269 |
} |
| 270 |
if (p_themeType != oldValue) { |
| 271 |
Q_EMIT themeTypeChanged(); |
| 272 |
Q_EMIT valueChanged(QStringLiteral("themeType"), value); |
| 273 |
} |
| 274 |
} |
| 275 |
void resetThemeType() { |
| 276 |
if (auto config = m_config.loadRelaxed()) { |
| 277 |
QMetaObject::invokeMethod(config, [this]() { |
| 278 |
m_config.loadRelaxed()->reset(QStringLiteral("themeType")); |
| 279 |
}); |
| 280 |
} |
| 281 |
} |
| 282 |
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 283 |
QBindable<qlonglong> bindableThemeType() { |
| 284 |
return QBindable<qlonglong>(this, QStringLiteral("themeType")); |
| 285 |
} |
| 286 |
#endif |
| 287 |
Q_INVOKABLE bool themeTypeIsDefaultValue() const { |
| 288 |
return !testPropertySet(4); |
| 289 |
} |
| 290 |
qlonglong titlebarHeight() const { |
| 291 |
return p_titlebarHeight; |
| 292 |
} |
| 293 |
void setTitlebarHeight(const qlonglong &value) { |
| 294 |
auto oldValue = p_titlebarHeight; |
| 295 |
p_titlebarHeight = value; |
| 296 |
markPropertySet(5); |
| 297 |
if (auto config = m_config.loadRelaxed()) { |
| 298 |
QMetaObject::invokeMethod(config, [this, value]() { |
| 299 |
m_config.loadRelaxed()->setValue(QStringLiteral("titlebarHeight"), value); |
| 300 |
}); |
| 301 |
} |
| 302 |
if (p_titlebarHeight != oldValue) { |
| 303 |
Q_EMIT titlebarHeightChanged(); |
| 304 |
Q_EMIT valueChanged(QStringLiteral("titlebarHeight"), value); |
| 305 |
} |
| 306 |
} |
| 307 |
void resetTitlebarHeight() { |
| 308 |
if (auto config = m_config.loadRelaxed()) { |
| 309 |
QMetaObject::invokeMethod(config, [this]() { |
| 310 |
m_config.loadRelaxed()->reset(QStringLiteral("titlebarHeight")); |
| 311 |
}); |
| 312 |
} |
| 313 |
} |
| 314 |
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 315 |
QBindable<qlonglong> bindableTitlebarHeight() { |
| 316 |
return QBindable<qlonglong>(this, QStringLiteral("titlebarHeight")); |
| 317 |
} |
| 318 |
#endif |
| 319 |
Q_INVOKABLE bool titlebarHeightIsDefaultValue() const { |
| 320 |
return !testPropertySet(5); |
| 321 |
} |
| 322 |
bool underlineShortcut() const { |
| 323 |
return p_underlineShortcut; |
| 324 |
} |
| 325 |
void setUnderlineShortcut(const bool &value) { |
| 326 |
auto oldValue = p_underlineShortcut; |
| 327 |
p_underlineShortcut = value; |
| 328 |
markPropertySet(6); |
| 329 |
if (auto config = m_config.loadRelaxed()) { |
| 330 |
QMetaObject::invokeMethod(config, [this, value]() { |
| 331 |
m_config.loadRelaxed()->setValue(QStringLiteral("underlineShortcut"), value); |
| 332 |
}); |
| 333 |
} |
| 334 |
if (p_underlineShortcut != oldValue) { |
| 335 |
Q_EMIT underlineShortcutChanged(); |
| 336 |
Q_EMIT valueChanged(QStringLiteral("underlineShortcut"), value); |
| 337 |
} |
| 338 |
} |
| 339 |
void resetUnderlineShortcut() { |
| 340 |
if (auto config = m_config.loadRelaxed()) { |
| 341 |
QMetaObject::invokeMethod(config, [this]() { |
| 342 |
m_config.loadRelaxed()->reset(QStringLiteral("underlineShortcut")); |
| 343 |
}); |
| 344 |
} |
| 345 |
} |
| 346 |
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 347 |
QBindable<bool> bindableUnderlineShortcut() { |
| 348 |
return QBindable<bool>(this, QStringLiteral("underlineShortcut")); |
| 349 |
} |
| 350 |
#endif |
| 351 |
Q_INVOKABLE bool underlineShortcutIsDefaultValue() const { |
| 352 |
return !testPropertySet(6); |
| 353 |
} |
| 354 |
Q_SIGNALS: |
| 355 |
void configInitializeFailed(DTK_CORE_NAMESPACE::DConfig *config); |
| 356 |
void configInitializeSucceed(DTK_CORE_NAMESPACE::DConfig *config); |
| 357 |
void valueChanged(const QString &key, const QVariant &value); |
| 358 |
|
| 359 |
void autoDisplayFeatureChanged(); |
| 360 |
void featureUpdatedChanged(); |
| 361 |
void keyboardsearchDisabledChanged(); |
| 362 |
void rulesChanged(); |
| 363 |
void themeTypeChanged(); |
| 364 |
void titlebarHeightChanged(); |
| 365 |
void underlineShortcutChanged(); |
| 366 |
private: |
| 367 |
void initializeInConfigThread(DTK_CORE_NAMESPACE::DConfig *config) { |
| 368 |
Q_ASSERT(!m_config.loadRelaxed()); |
| 369 |
m_config.storeRelaxed(config); |
| 370 |
if (!config->isValid()) { |
| 371 |
m_status.storeRelaxed(static_cast<int>(Status::Failed)); |
| 372 |
Q_EMIT configInitializeFailed(config); |
| 373 |
return; |
| 374 |
} |
| 375 |
|
| 376 |
if (testPropertySet(0)) { |
| 377 |
config->setValue(QStringLiteral("autoDisplayFeature"), QVariant::fromValue(p_autoDisplayFeature)); |
| 378 |
} else { |
| 379 |
updateValue(QStringLiteral("autoDisplayFeature"), QVariant::fromValue(p_autoDisplayFeature)); |
| 380 |
} |
| 381 |
if (testPropertySet(1)) { |
| 382 |
config->setValue(QStringLiteral("featureUpdated"), QVariant::fromValue(p_featureUpdated)); |
| 383 |
} else { |
| 384 |
updateValue(QStringLiteral("featureUpdated"), QVariant::fromValue(p_featureUpdated)); |
| 385 |
} |
| 386 |
if (testPropertySet(2)) { |
| 387 |
config->setValue(QStringLiteral("keyboardsearchDisabled"), QVariant::fromValue(p_keyboardsearchDisabled)); |
| 388 |
} else { |
| 389 |
updateValue(QStringLiteral("keyboardsearchDisabled"), QVariant::fromValue(p_keyboardsearchDisabled)); |
| 390 |
} |
| 391 |
if (testPropertySet(3)) { |
| 392 |
config->setValue(QStringLiteral("rules"), QVariant::fromValue(p_rules)); |
| 393 |
} else { |
| 394 |
updateValue(QStringLiteral("rules"), QVariant::fromValue(p_rules)); |
| 395 |
} |
| 396 |
if (testPropertySet(4)) { |
| 397 |
config->setValue(QStringLiteral("themeType"), QVariant::fromValue(p_themeType)); |
| 398 |
} else { |
| 399 |
updateValue(QStringLiteral("themeType"), QVariant::fromValue(p_themeType)); |
| 400 |
} |
| 401 |
if (testPropertySet(5)) { |
| 402 |
config->setValue(QStringLiteral("titlebarHeight"), QVariant::fromValue(p_titlebarHeight)); |
| 403 |
} else { |
| 404 |
updateValue(QStringLiteral("titlebarHeight"), QVariant::fromValue(p_titlebarHeight)); |
| 405 |
} |
| 406 |
if (testPropertySet(6)) { |
| 407 |
config->setValue(QStringLiteral("underlineShortcut"), QVariant::fromValue(p_underlineShortcut)); |
| 408 |
} else { |
| 409 |
updateValue(QStringLiteral("underlineShortcut"), QVariant::fromValue(p_underlineShortcut)); |
| 410 |
} |
| 411 |
|
| 412 |
connect(config, &DTK_CORE_NAMESPACE::DConfig::valueChanged, this, [this](const QString &key) { |
| 413 |
updateValue(key); |
| 414 |
}, Qt::DirectConnection); |
| 415 |
|
| 416 |
m_status.storeRelaxed(static_cast<int>(Status::Succeed)); |
| 417 |
Q_EMIT configInitializeSucceed(config); |
| 418 |
} |
| 419 |
void updateValue(const QString &key, const QVariant &fallback = QVariant()) { |
| 420 |
Q_ASSERT(QThread::currentThread() == m_config.loadRelaxed()->thread()); |
| 421 |
const QVariant &value = m_config.loadRelaxed()->value(key, fallback); |
| 422 |
if (key == QStringLiteral("autoDisplayFeature")) { |
| 423 |
markPropertySet(0, !m_config.loadRelaxed()->isDefaultValue(key)); |
| 424 |
auto newValue = qvariant_cast<bool>(value); |
| 425 |
QMetaObject::invokeMethod(this, [this, newValue, key, value]() { |
| 426 |
Q_ASSERT(QThread::currentThread() == this->thread()); |
| 427 |
if (p_autoDisplayFeature != newValue) { |
| 428 |
p_autoDisplayFeature = newValue; |
| 429 |
Q_EMIT autoDisplayFeatureChanged(); |
| 430 |
Q_EMIT valueChanged(key, value); |
| 431 |
} |
| 432 |
}); |
| 433 |
return; |
| 434 |
} |
| 435 |
if (key == QStringLiteral("featureUpdated")) { |
| 436 |
markPropertySet(1, !m_config.loadRelaxed()->isDefaultValue(key)); |
| 437 |
auto newValue = qvariant_cast<bool>(value); |
| 438 |
QMetaObject::invokeMethod(this, [this, newValue, key, value]() { |
| 439 |
Q_ASSERT(QThread::currentThread() == this->thread()); |
| 440 |
if (p_featureUpdated != newValue) { |
| 441 |
p_featureUpdated = newValue; |
| 442 |
Q_EMIT featureUpdatedChanged(); |
| 443 |
Q_EMIT valueChanged(key, value); |
| 444 |
} |
| 445 |
}); |
| 446 |
return; |
| 447 |
} |
| 448 |
if (key == QStringLiteral("keyboardsearchDisabled")) { |
| 449 |
markPropertySet(2, !m_config.loadRelaxed()->isDefaultValue(key)); |
| 450 |
auto newValue = qvariant_cast<bool>(value); |
| 451 |
QMetaObject::invokeMethod(this, [this, newValue, key, value]() { |
| 452 |
Q_ASSERT(QThread::currentThread() == this->thread()); |
| 453 |
if (p_keyboardsearchDisabled != newValue) { |
| 454 |
p_keyboardsearchDisabled = newValue; |
| 455 |
Q_EMIT keyboardsearchDisabledChanged(); |
| 456 |
Q_EMIT valueChanged(key, value); |
| 457 |
} |
| 458 |
}); |
| 459 |
return; |
| 460 |
} |
| 461 |
if (key == QStringLiteral("rules")) { |
| 462 |
markPropertySet(3, !m_config.loadRelaxed()->isDefaultValue(key)); |
| 463 |
auto newValue = qvariant_cast<QString>(value); |
| 464 |
QMetaObject::invokeMethod(this, [this, newValue, key, value]() { |
| 465 |
Q_ASSERT(QThread::currentThread() == this->thread()); |
| 466 |
if (p_rules != newValue) { |
| 467 |
p_rules = newValue; |
| 468 |
Q_EMIT rulesChanged(); |
| 469 |
Q_EMIT valueChanged(key, value); |
| 470 |
} |
| 471 |
}); |
| 472 |
return; |
| 473 |
} |
| 474 |
if (key == QStringLiteral("themeType")) { |
| 475 |
markPropertySet(4, !m_config.loadRelaxed()->isDefaultValue(key)); |
| 476 |
auto newValue = qvariant_cast<qlonglong>(value); |
| 477 |
QMetaObject::invokeMethod(this, [this, newValue, key, value]() { |
| 478 |
Q_ASSERT(QThread::currentThread() == this->thread()); |
| 479 |
if (p_themeType != newValue) { |
| 480 |
p_themeType = newValue; |
| 481 |
Q_EMIT themeTypeChanged(); |
| 482 |
Q_EMIT valueChanged(key, value); |
| 483 |
} |
| 484 |
}); |
| 485 |
return; |
| 486 |
} |
| 487 |
if (key == QStringLiteral("titlebarHeight")) { |
| 488 |
markPropertySet(5, !m_config.loadRelaxed()->isDefaultValue(key)); |
| 489 |
auto newValue = qvariant_cast<qlonglong>(value); |
| 490 |
QMetaObject::invokeMethod(this, [this, newValue, key, value]() { |
| 491 |
Q_ASSERT(QThread::currentThread() == this->thread()); |
| 492 |
if (p_titlebarHeight != newValue) { |
| 493 |
p_titlebarHeight = newValue; |
| 494 |
Q_EMIT titlebarHeightChanged(); |
| 495 |
Q_EMIT valueChanged(key, value); |
| 496 |
} |
| 497 |
}); |
| 498 |
return; |
| 499 |
} |
| 500 |
if (key == QStringLiteral("underlineShortcut")) { |
| 501 |
markPropertySet(6, !m_config.loadRelaxed()->isDefaultValue(key)); |
| 502 |
auto newValue = qvariant_cast<bool>(value); |
| 503 |
QMetaObject::invokeMethod(this, [this, newValue, key, value]() { |
| 504 |
Q_ASSERT(QThread::currentThread() == this->thread()); |
| 505 |
if (p_underlineShortcut != newValue) { |
| 506 |
p_underlineShortcut = newValue; |
| 507 |
Q_EMIT underlineShortcutChanged(); |
| 508 |
Q_EMIT valueChanged(key, value); |
| 509 |
} |
| 510 |
}); |
| 511 |
return; |
| 512 |
} |
| 513 |
} |
| 514 |
inline void markPropertySet(const int index, bool on = true) { |
| 515 |
if (index < 32) { |
| 516 |
if (on) |
| 517 |
m_propertySetStatus0.fetchAndOrOrdered(1 << (index - 0)); |
| 518 |
else |
| 519 |
m_propertySetStatus0.fetchAndAndOrdered(1 << (index - 0)); |
| 520 |
return; |
| 521 |
} |
| 522 |
Q_UNREACHABLE(); |
| 523 |
} |
| 524 |
inline bool testPropertySet(const int index) const { |
| 525 |
if (index < 32) { |
| 526 |
return (m_propertySetStatus0.loadRelaxed() & (1 << (index - 0))); |
| 527 |
} |
| 528 |
Q_UNREACHABLE(); |
| 529 |
} |
| 530 |
|
| 531 |
QAtomicPointer<DTK_CORE_NAMESPACE::DConfig> m_config = nullptr; |
| 532 |
|
| 533 |
public: |
| 534 |
enum class Status { |
| 535 |
Invalid = 0, |
| 536 |
Succeed = 1, |
| 537 |
Failed = 2 |
| 538 |
}; |
| 539 |
private: |
| 540 |
QAtomicInteger<int> m_status = static_cast<int>(Status::Invalid); |
| 541 |
|
| 542 |
bool p_autoDisplayFeature { false }; |
| 543 |
bool p_featureUpdated { false }; |
| 544 |
bool p_keyboardsearchDisabled { false }; |
| 545 |
// Default value: "" |
| 546 |
QString p_rules { QLatin1String("") }; |
| 547 |
qlonglong p_themeType { 0 }; |
| 548 |
qlonglong p_titlebarHeight { -1 }; |
| 549 |
bool p_underlineShortcut { false }; |
| 550 |
QAtomicInteger<quint32> m_propertySetStatus0 = 0; |
| 551 |
}; |
| 552 |
|
| 553 |
#endif // DCONFIG_ORG_DEEPIN_DTK_PREFERENCE_H |