diff --git a/kcms/lookandfeel/kcm.h b/kcms/lookandfeel/kcm.h --- a/kcms/lookandfeel/kcm.h +++ b/kcms/lookandfeel/kcm.h @@ -45,6 +45,7 @@ Q_PROPERTY(bool applyPlasmaTheme READ applyPlasmaTheme WRITE setApplyPlasmaTheme NOTIFY applyPlasmaThemeChanged) Q_PROPERTY(bool applyWindowSwitcher READ applyWindowSwitcher WRITE setApplyWindowSwitcher NOTIFY applyWindowSwitcherChanged) Q_PROPERTY(bool applyDesktopSwitcher READ applyDesktopSwitcher WRITE setApplyDesktopSwitcher NOTIFY applyDesktopSwitcherChanged) + Q_PROPERTY(bool resetDefaultLayout READ resetDefaultLayout WRITE setResetDefaultLayout NOTIFY resetDefaultLayoutChanged) public: enum Roles { @@ -95,6 +96,8 @@ bool applyWindowSwitcher() const; void setApplyDesktopSwitcher(bool apply); bool applyDesktopSwitcher() const; + bool resetDefaultLayout() const; + void setResetDefaultLayout(bool reset); Q_INVOKABLE void getNewStuff(); @@ -112,6 +115,7 @@ void applyPlasmaThemeChanged(); void applyWindowSwitcherChanged(); void applyDesktopSwitcherChanged(); + void resetDefaultLayoutChanged(); private: QDir cursorThemeDir(const QString &theme, const int depth); @@ -132,6 +136,7 @@ bool m_applyCursors : 1; bool m_applyWindowSwitcher : 1; bool m_applyDesktopSwitcher : 1; + bool m_resetDefaultLayout : 1; }; #endif diff --git a/kcms/lookandfeel/kcm.cpp b/kcms/lookandfeel/kcm.cpp --- a/kcms/lookandfeel/kcm.cpp +++ b/kcms/lookandfeel/kcm.cpp @@ -67,6 +67,7 @@ , m_applyCursors(true) , m_applyWindowSwitcher(true) , m_applyDesktopSwitcher(true) + , m_resetDefaultLayout(false) { //This flag seems to be needed in order for QQuickWidget to work //see https://bugreports.qt-project.org/browse/QTBUG-40765 @@ -241,6 +242,18 @@ m_configGroup.writeEntry("LookAndFeelPackage", m_selectedPlugin); + QDBusMessage message; + if (m_resetDefaultLayout) { + message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"), QStringLiteral("/PlasmaShell"), + QStringLiteral("org.kde.PlasmaShell"), QStringLiteral("loadLookAndFeelDefaultLayout")); + + QList args; + args << m_selectedPlugin; + message.setArguments(args); + + QDBusConnection::sessionBus().call(message, QDBus::NoBlock); + } + if (!package.filePath("defaults").isEmpty()) { KSharedConfigPtr conf = KSharedConfig::openConfig(package.filePath("defaults")); KConfigGroup cg(conf, "kdeglobals"); @@ -683,4 +696,22 @@ return m_applyDesktopSwitcher; } +void KCMLookandFeel::setResetDefaultLayout(bool reset) +{ + if (m_resetDefaultLayout == reset) { + return; + } + m_resetDefaultLayout = reset; + emit resetDefaultLayoutChanged(); + if (reset) { + setNeedsSave(true); + } +} + +bool KCMLookandFeel::resetDefaultLayout() const +{ + return m_resetDefaultLayout; +} + + #include "kcm.moc" diff --git a/kcms/lookandfeel/package/contents/ui/main.qml b/kcms/lookandfeel/package/contents/ui/main.qml --- a/kcms/lookandfeel/package/contents/ui/main.qml +++ b/kcms/lookandfeel/package/contents/ui/main.qml @@ -130,6 +130,7 @@ onClicked: { grid.currentIndex = index kcm.selectedPlugin = model.pluginName + resetCheckbox.checked = false; } Timer { interval: 1000 // FIXME TODO: Use platform value for tooltip activation delay. @@ -155,11 +156,36 @@ } } } - QtControls.Button { - anchors.right: parent.right - text: i18n("Get New Looks...") - iconName: "get-hot-new-stuff" - onClicked: kcm.getNewStuff(); + QtControls.Label { + text: i18nd("kcm_lookandfeel", "Warning: your Plasma Desktop layout will be lost and reset to the default layout provided by the selected theme.") + visible: resetCheckbox.checked + wrapMode: Text.WordWrap + Layout.fillWidth: true + } + Connections { + target: kcm + onNeedsSaveChanged: { + if (!needsSave) { + resetCheckbox.checked = false; + } + } + } + RowLayout { + QtControls.CheckBox { + id: resetCheckbox + checked: kcm.resetDefaultLayout + text: i18n("Use Desktop Layout from theme") + onCheckedChanged: kcm.resetDefaultLayout = checked; + } + Item { + Layout.fillWidth: true + } + QtControls.Button { + anchors.right: parent.right + text: i18n("Get New Looks...") + iconName: "get-hot-new-stuff" + onClicked: kcm.getNewStuff(); + } } } }