diff --git a/kcms/lookandfeel/kcm.h b/kcms/lookandfeel/kcm.h --- a/kcms/lookandfeel/kcm.h +++ b/kcms/lookandfeel/kcm.h @@ -87,6 +87,7 @@ void setLockScreen(const QString &theme); void setWindowSwitcher(const QString &theme); void setDesktopSwitcher(const QString &theme); + void setWindowDecoration(const QString &library, const QString &theme, const QString &leftButtons, const QString &rightButtons); void setApplyColors(bool apply); bool applyColors() const; @@ -142,6 +143,7 @@ bool m_applyWindowSwitcher : 1; bool m_applyDesktopSwitcher : 1; bool m_resetDefaultLayout : 1; + bool m_applyWindowDecoration : 1; }; #endif diff --git a/kcms/lookandfeel/kcm.cpp b/kcms/lookandfeel/kcm.cpp --- a/kcms/lookandfeel/kcm.cpp +++ b/kcms/lookandfeel/kcm.cpp @@ -68,6 +68,7 @@ , m_applyWindowSwitcher(true) , m_applyDesktopSwitcher(true) , m_resetDefaultLayout(false) + , m_applyWindowDecoration(true) { //This flag seems to be needed in order for QQuickWidget to work //see https://bugreports.qt-project.org/browse/QTBUG-40765 @@ -329,6 +330,14 @@ cg = KConfigGroup(&cg, "DesktopSwitcher"); setDesktopSwitcher(cg.readEntry("LayoutName", QString())); } + + if (m_applyWindowDecoration) { + cg = KConfigGroup(conf, "kwinrc"); + cg = KConfigGroup(&cg, "org.kde.kdecoration2"); + setWindowDecoration(cg.readEntry("library", QStringLiteral("org.kde.breeze")), cg.readEntry("theme", QString()), + cg.readEntry("ButtonsOnLeft", QStringLiteral("MS")), + cg.readEntry("ButtonsOnRight", QStringLiteral("HIAX"))); + } } //TODO: option to enable/disable apply? they don't seem required by UI design @@ -620,6 +629,27 @@ QDBusConnection::sessionBus().send(message); } +void KCMLookandFeel::setWindowDecoration(const QString &library, const QString &theme, const QString &leftButtons, const QString &rightButtons) +{ + if (library.isEmpty()) { + return; + } + + KConfig config(QStringLiteral("kwinrc")); + KConfigGroup cg(&config, "org.kde.kdecoration2"); + cg.writeEntry("library", library); + cg.writeEntry("theme", theme); + + cg.writeEntry("ButtonsOnLeft", leftButtons); + cg.writeEntry("ButtonsOnRight", rightButtons); + + cg.sync(); + // Reload KWin. + QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"), + QStringLiteral("org.kde.KWin"), + QStringLiteral("reloadConfig")); + QDBusConnection::sessionBus().send(message); +} void KCMLookandFeel::setApplyColors(bool apply) {