diff --git a/kcms/workspaceoptions/CMakeLists.txt b/kcms/workspaceoptions/CMakeLists.txt --- a/kcms/workspaceoptions/CMakeLists.txt +++ b/kcms/workspaceoptions/CMakeLists.txt @@ -13,6 +13,9 @@ KF5::I18n KF5::ConfigWidgets KF5::Declarative + KF5::KDELibs4Support + + Qt5::DBus ) kcoreaddons_desktop_to_json(kcm_workspace "kcm_workspace.desktop" SERVICE_TYPES kcmodule.desktop) diff --git a/kcms/workspaceoptions/package/contents/ui/main.qml b/kcms/workspaceoptions/package/contents/ui/main.qml --- a/kcms/workspaceoptions/package/contents/ui/main.qml +++ b/kcms/workspaceoptions/package/contents/ui/main.qml @@ -39,7 +39,6 @@ leftPadding: units.smallSpacing Controls.Label { - id: generalSettings text: i18n("General Settings") } @@ -63,6 +62,39 @@ onVisualFeedbackChanged: showVisualFeedback.checked = kcm.visualFeedback } } + + // ClickBehaviour Settings + Column { + spacing: units.smallSpacing + leftPadding: units.smallSpacing + Controls.ExclusiveGroup { id: clickBehaviourGroup } + + Controls.Label { + text: i18n("Click Behaviour") + } + + Controls.RadioButton { + id: singleClick + text: i18n("Single-click to open files and folders") + checked: kcm.singleClick + exclusiveGroup: clickBehaviourGroup + onCheckedChanged: kcm.singleClick = checked + } + + Controls.RadioButton { + id: doubleClick + text: i18n("Double-click to open files and folders (select icons on first click)") + exclusiveGroup: clickBehaviourGroup + } + + Connections { + target: kcm + onSingleClickChanged: { + singleClick.checked = kcm.singleClick + doubleClick.checked = !singleClick.checked + } + } + } } // END Layouts.ColumnLayout } // END Controls.ScrollView } // END Item diff --git a/kcms/workspaceoptions/workspaceoptions.h b/kcms/workspaceoptions/workspaceoptions.h --- a/kcms/workspaceoptions/workspaceoptions.h +++ b/kcms/workspaceoptions/workspaceoptions.h @@ -25,6 +25,7 @@ Q_OBJECT Q_PROPERTY(bool toolTip READ getToolTip WRITE setToolTip NOTIFY toolTipChanged) Q_PROPERTY(bool visualFeedback READ getVisualFeedback WRITE setVisualFeedback NOTIFY visualFeedbackChanged) + Q_PROPERTY(bool singleClick READ getSingleClick WRITE setSingleClick NOTIFY singleClickChanged) public: KCMWorkspaceOptions(QObject* parent, const QVariantList& args); @@ -37,14 +38,18 @@ bool getVisualFeedback() const; void setVisualFeedback(bool state); + bool getSingleClick() const; + void setSingleClick(bool state); + public Q_SLOTS: void load(); void save(); void defaults(); Q_SIGNALS: void toolTipChanged(); void visualFeedbackChanged(); + void singleClickChanged(); private: void handleNeedsSave(); @@ -55,6 +60,9 @@ bool m_ostateVisualFeedback; bool m_stateVisualFeedback; + + bool m_ostateSingleClick; + bool m_stateSingleClick; }; #endif // _KCM_WORKSPACEOPTIONS_H diff --git a/kcms/workspaceoptions/workspaceoptions.cpp b/kcms/workspaceoptions/workspaceoptions.cpp --- a/kcms/workspaceoptions/workspaceoptions.cpp +++ b/kcms/workspaceoptions/workspaceoptions.cpp @@ -21,15 +21,20 @@ #include #include #include - #include +#include +#include <../migrationlib/kdelibs4config.h> + +#include +#include K_PLUGIN_FACTORY_WITH_JSON(KCMWorkspaceOptionsFactory, "kcm_workspace.json", registerPlugin();) KCMWorkspaceOptions::KCMWorkspaceOptions(QObject *parent, const QVariantList& args) : KQuickAddons::ConfigModule(parent, args), m_stateToolTip(true), - m_stateVisualFeedback(true) + m_stateVisualFeedback(true), + m_stateSingleClick(true) { KAboutData* about = new KAboutData(QStringLiteral("kcm_workspace"), i18n("Plasma Workspace global options"), @@ -65,6 +70,15 @@ m_ostateVisualFeedback = getVisualFeedback(); } + // Load singleClick + { + KSharedConfig::Ptr configKdeGlobals = KSharedConfig::openConfig(QStringLiteral("kdeglobals")); + const KConfigGroup cg(configKdeGlobals, QStringLiteral("KDE")); + state = cg.readEntry(QStringLiteral("SingleClick"), true); + setSingleClick(state); + m_ostateSingleClick = getSingleClick(); + } + setNeedsSave(false); } @@ -86,14 +100,31 @@ m_ostateVisualFeedback = getVisualFeedback(); } + // Save singleClick + KSharedConfig::Ptr configKdeGlobals = KSharedConfig::openConfig(QStringLiteral("kdeglobals")); + KConfigGroup cg(configKdeGlobals, QStringLiteral("KDE")); + cg.writeEntry("SingleClick", getSingleClick()); + m_ostateSingleClick = getSingleClick(); config->sync(); + configKdeGlobals->sync(); + + Kdelibs4SharedConfig::syncConfigGroup(QLatin1String("KDE"), "kdeglobals"); + + QDBusMessage message = QDBusMessage::createSignal("/KGlobalSettings", "org.kde.KGlobalSettings", "notifyChange"); + QList args; + args.append(KGlobalSettings::SettingsChanged); + args.append(KGlobalSettings::SETTINGS_MOUSE); + message.setArguments(args); + QDBusConnection::sessionBus().send(message); + setNeedsSave(false); } void KCMWorkspaceOptions::defaults() { setToolTip(true); setVisualFeedback(true); + setSingleClick(true); handleNeedsSave(); } @@ -136,13 +167,33 @@ handleNeedsSave(); } +/*SingleClick functions*/ +bool KCMWorkspaceOptions::getSingleClick() const +{ + return m_stateSingleClick; +} + +void KCMWorkspaceOptions::setSingleClick(bool state) +{ + // Prevent from binding loop + if( m_stateSingleClick == state ) { + return; + } + + m_stateSingleClick = state; + + emit singleClickChanged(); + handleNeedsSave(); +} + /*Other functions*/ // Checks if the current states are different than the first states. // If yes, setNeedsSave(true). void KCMWorkspaceOptions::handleNeedsSave() { setNeedsSave(m_ostateToolTip != getToolTip() || - m_ostateVisualFeedback != getVisualFeedback()); + m_ostateVisualFeedback != getVisualFeedback() || + m_ostateSingleClick != getSingleClick()); } #include "workspaceoptions.moc"