Commit d3ef8955 authored by Furkan Tokac's avatar Furkan Tokac 💬
Browse files

Single/Double Click Option at Workspace KCM

Summary:
This patch adds the single/double click option to
the Workspace KCM.

BUG: 393547
BUG: 377310

Reviewers: romangg, ngraham, #plasma, mart

Reviewed By: romangg, #plasma, mart

Subscribers: mart, davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D12946
parent 86dd0c2e
......@@ -13,6 +13,9 @@ target_link_libraries(kcm_workspace
KF5::I18n
KF5::ConfigWidgets
KF5::Declarative
KF5::KDELibs4Support
Qt5::DBus
)
kcoreaddons_desktop_to_json(kcm_workspace "kcm_workspace.desktop" SERVICE_TYPES kcmodule.desktop)
......
......@@ -39,7 +39,6 @@ Item {
leftPadding: units.smallSpacing
Controls.Label {
id: generalSettings
text: i18n("General Settings")
}
......@@ -63,6 +62,39 @@ Item {
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
......@@ -21,15 +21,20 @@
#include <KAboutData>
#include <KLocalizedString>
#include <KConfigGroup>
#include <ksharedconfig.h>
#include <KDELibs4Support/KDE/KGlobalSettings>
#include <../migrationlib/kdelibs4config.h>
#include <QtDBus/QDBusMessage>
#include <QtDBus/QDBusConnection>
K_PLUGIN_FACTORY_WITH_JSON(KCMWorkspaceOptionsFactory, "kcm_workspace.json", registerPlugin<KCMWorkspaceOptions>();)
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 @@ void KCMWorkspaceOptions::load()
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,7 +100,23 @@ void KCMWorkspaceOptions::save()
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<QVariant> args;
args.append(KGlobalSettings::SettingsChanged);
args.append(KGlobalSettings::SETTINGS_MOUSE);
message.setArguments(args);
QDBusConnection::sessionBus().send(message);
setNeedsSave(false);
}
......@@ -94,6 +124,7 @@ void KCMWorkspaceOptions::defaults()
{
setToolTip(true);
setVisualFeedback(true);
setSingleClick(true);
handleNeedsSave();
}
......@@ -136,13 +167,33 @@ void KCMWorkspaceOptions::setVisualFeedback(bool state)
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"
......@@ -25,6 +25,7 @@ class KCMWorkspaceOptions : public KQuickAddons::ConfigModule
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,6 +38,9 @@ public:
bool getVisualFeedback() const;
void setVisualFeedback(bool state);
bool getSingleClick() const;
void setSingleClick(bool state);
public Q_SLOTS:
void load();
void save();
......@@ -45,6 +49,7 @@ public Q_SLOTS:
Q_SIGNALS:
void toolTipChanged();
void visualFeedbackChanged();
void singleClickChanged();
private:
void handleNeedsSave();
......@@ -55,6 +60,9 @@ private:
bool m_ostateVisualFeedback;
bool m_stateVisualFeedback;
bool m_ostateSingleClick;
bool m_stateSingleClick;
};
#endif // _KCM_WORKSPACEOPTIONS_H
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment