Changeset View
Changeset View
Standalone View
Standalone View
kcms/colors/colors.cpp
Show All 29 Lines | |||||
30 | #include <QProcess> | 30 | #include <QProcess> | ||
31 | #include <QStandardItemModel> | 31 | #include <QStandardItemModel> | ||
32 | #include <QStandardPaths> | 32 | #include <QStandardPaths> | ||
33 | #include <QQuickItem> | 33 | #include <QQuickItem> | ||
34 | #include <QQuickRenderControl> | 34 | #include <QQuickRenderControl> | ||
35 | #include <QQuickWindow> | 35 | #include <QQuickWindow> | ||
36 | 36 | | |||
37 | #include <KAboutData> | 37 | #include <KAboutData> | ||
38 | #include <KColorUtils> | ||||
38 | #include <KColorScheme> | 39 | #include <KColorScheme> | ||
39 | #include <KConfigGroup> | 40 | #include <KConfigGroup> | ||
40 | #include <KLocalizedString> | 41 | #include <KLocalizedString> | ||
41 | #include <KPluginFactory> | 42 | #include <KPluginFactory> | ||
42 | #include <KWindowSystem> | 43 | #include <KWindowSystem> | ||
43 | 44 | | |||
44 | #include <KIO/FileCopyJob> | 45 | #include <KIO/FileCopyJob> | ||
45 | #include <KIO/DeleteJob> | 46 | #include <KIO/DeleteJob> | ||
▲ Show 20 Lines • Show All 268 Lines • ▼ Show 20 Line(s) | 295 | { | |||
314 | 315 | | |||
315 | { | 316 | { | ||
316 | KConfig cfg(QStringLiteral("kcmdisplayrc"), KConfig::NoGlobals); | 317 | KConfig cfg(QStringLiteral("kcmdisplayrc"), KConfig::NoGlobals); | ||
317 | group = KConfigGroup(&cfg, "X11"); | 318 | group = KConfigGroup(&cfg, "X11"); | ||
318 | m_applyToAlien = group.readEntry("exportKDEColors", true); | 319 | m_applyToAlien = group.readEntry("exportKDEColors", true); | ||
319 | } | 320 | } | ||
320 | } | 321 | } | ||
321 | 322 | | |||
322 | void KCMColors::save() | 323 | void KCMColors::save() | ||
broulik: Pass by const-ref `const QString &name, ..` | |||||
323 | { | 324 | { | ||
324 | if (m_selectedSchemeDirty) { | 325 | if (m_selectedSchemeDirty) { | ||
broulik: `return QStringLiteral("@define-color %1 %2").arg(name, color);\n"`; | |||||
325 | saveColors(); | 326 | saveColors(); | ||
326 | } | 327 | } | ||
327 | 328 | | |||
328 | processPendingDeletions(); | 329 | processPendingDeletions(); | ||
329 | 330 | | |||
330 | setNeedsSave(false); | 331 | setNeedsSave(false); | ||
331 | } | 332 | } | ||
332 | 333 | | |||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 422 | for (const QString &groupName : groupNameList) { | |||
424 | 425 | | |||
425 | for (const QString &effect : effectList) { | 426 | for (const QString &effect : effectList) { | ||
426 | groupEffectOut.writeEntry(effect, groupEffectTheme.readEntry(effect)); | 427 | groupEffectOut.writeEntry(effect, groupEffectTheme.readEntry(effect)); | ||
427 | } | 428 | } | ||
428 | } | 429 | } | ||
429 | 430 | | |||
430 | m_config->sync(); | 431 | m_config->sync(); | ||
431 | 432 | | |||
432 | runRdb(KRdbExportQtColors | KRdbExportGtkTheme | (m_applyToAlien ? KRdbExportColors : 0)); | 433 | runRdb(KRdbExportQtColors | KRdbExportGtkTheme | KRdbExportGtkColors | (m_applyToAlien ? KRdbExportColors : 0)); | ||
434 | | ||||
435 | saveGtkColors(config); | ||||
433 | 436 | | |||
434 | QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KGlobalSettings"), | 437 | QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KGlobalSettings"), | ||
435 | QStringLiteral("org.kde.KGlobalSettings"), | 438 | QStringLiteral("org.kde.KGlobalSettings"), | ||
436 | QStringLiteral("notifyChange")); | 439 | QStringLiteral("notifyChange")); | ||
437 | message.setArguments({ | 440 | message.setArguments({ | ||
438 | 0, //previous KGlobalSettings::PaletteChanged. This is now private API in khintsettings | 441 | 0, //previous KGlobalSettings::PaletteChanged. This is now private API in khintsettings | ||
439 | 0 //unused in palette changed but needed for the DBus signature | 442 | 0 //unused in palette changed but needed for the DBus signature | ||
440 | }); | 443 | }); | ||
441 | QDBusConnection::sessionBus().send(message); | 444 | QDBusConnection::sessionBus().send(message); | ||
442 | 445 | | |||
443 | if (KWindowSystem::isPlatformX11()) { | 446 | if (KWindowSystem::isPlatformX11()) { | ||
444 | // Send signal to all kwin instances | 447 | // Send signal to all kwin instances | ||
445 | QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig")); | 448 | QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig")); | ||
446 | QDBusConnection::sessionBus().send(message); | 449 | QDBusConnection::sessionBus().send(message); | ||
447 | } | 450 | } | ||
448 | 451 | | |||
449 | m_selectedSchemeDirty = false; | 452 | m_selectedSchemeDirty = false; | ||
You probably want to be using QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) or something along the lines instead of hardcoding ~/.config broulik: You probably want to be using `QStandardPaths::writableLocation(QStandardPaths… | |||||
450 | } | 453 | } | ||
451 | 454 | | |||
452 | void KCMColors::processPendingDeletions() | 455 | void KCMColors::processPendingDeletions() | ||
453 | { | 456 | { | ||
broulik: Coding style, brace on same line as `if` | |||||
454 | const QStringList pendingDeletions = m_model->pendingDeletions(); | 457 | const QStringList pendingDeletions = m_model->pendingDeletions(); | ||
455 | 458 | | |||
456 | for (const QString &schemeName : pendingDeletions) { | 459 | for (const QString &schemeName : pendingDeletions) { | ||
457 | Q_ASSERT(schemeName != m_model->selectedScheme()); | 460 | Q_ASSERT(schemeName != m_model->selectedScheme()); | ||
458 | 461 | | |||
459 | const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, | 462 | const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, | ||
460 | QStringLiteral("color-schemes/%1.colors").arg(schemeName)); | 463 | QStringLiteral("color-schemes/%1.colors").arg(schemeName)); | ||
461 | 464 | | |||
462 | auto *job = KIO::del(QUrl::fromLocalFile(path), KIO::HideProgressInfo); | 465 | auto *job = KIO::del(QUrl::fromLocalFile(path), KIO::HideProgressInfo); | ||
463 | // needs to block for it to work on "OK" where the dialog (kcmshell) closes | 466 | // needs to block for it to work on "OK" where the dialog (kcmshell) closes | ||
464 | job->exec(); | 467 | job->exec(); | ||
465 | } | 468 | } | ||
466 | 469 | | |||
broulik: Not just `WriteOnly`? | |||||
467 | m_model->removeItemsPendingDeletion(); | 470 | m_model->removeItemsPendingDeletion(); | ||
468 | } | 471 | } | ||
469 | 472 | | |||
470 | void KCMColors::defaults() | 473 | void KCMColors::defaults() | ||
471 | { | 474 | { | ||
472 | m_model->setSelectedScheme(s_defaultColorSchemeName); | 475 | m_model->setSelectedScheme(s_defaultColorSchemeName); | ||
473 | 476 | | |||
474 | setNeedsSave(true); | 477 | setNeedsSave(true); | ||
475 | } | 478 | } | ||
476 | 479 | | |||
480 | QString KCMColors::gtkColorsHelper(const QString &name, const QString &color) | ||||
481 | { | ||||
482 | return QStringLiteral("@define-color %1 %2;\n").arg(name, color); | ||||
483 | } | ||||
484 | | ||||
477 | #include "colors.moc" | 485 | #include "colors.moc" |
Pass by const-ref const QString &name, ..