Changeset View
Changeset View
Standalone View
Standalone View
kcms/workspaceoptions/workspaceoptions.cpp
Show All 15 Lines | |||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | #include "workspaceoptions.h" | 18 | #include "workspaceoptions.h" | ||
19 | 19 | | |||
20 | #include <KPluginFactory> | 20 | #include <KPluginFactory> | ||
21 | #include <KAboutData> | 21 | #include <KAboutData> | ||
22 | #include <KLocalizedString> | 22 | #include <KLocalizedString> | ||
23 | #include <KConfigGroup> | 23 | #include <KConfigGroup> | ||
24 | | ||||
25 | #include <ksharedconfig.h> | 24 | #include <ksharedconfig.h> | ||
25 | #include <../migrationlib/kdelibs4config.h> | ||||
26 | | ||||
27 | #include <QtDBus/QDBusMessage> | ||||
28 | #include <QtDBus/QDBusConnection> | ||||
26 | 29 | | |||
27 | K_PLUGIN_FACTORY_WITH_JSON(KCMWorkspaceOptionsFactory, "kcm_workspace.json", registerPlugin<KCMWorkspaceOptions>();) | 30 | K_PLUGIN_FACTORY_WITH_JSON(KCMWorkspaceOptionsFactory, "kcm_workspace.json", registerPlugin<KCMWorkspaceOptions>();) | ||
28 | 31 | | |||
29 | KCMWorkspaceOptions::KCMWorkspaceOptions(QObject *parent, const QVariantList& args) | 32 | KCMWorkspaceOptions::KCMWorkspaceOptions(QObject *parent, const QVariantList& args) | ||
30 | : KQuickAddons::ConfigModule(parent, args), | 33 | : KQuickAddons::ConfigModule(parent, args), | ||
31 | m_stateToolTip(true), | 34 | m_stateToolTip(true), | ||
32 | m_stateVisualFeedback(true) | 35 | m_stateVisualFeedback(true), | ||
36 | m_stateSingleClick(true) | ||||
romangg: Add `m_stateSingleClick(true)` | |||||
33 | { | 37 | { | ||
34 | KAboutData* about = new KAboutData(QStringLiteral("kcm_workspace"), | 38 | KAboutData* about = new KAboutData(QStringLiteral("kcm_workspace"), | ||
35 | i18n("Plasma Workspace global options"), | 39 | i18n("Plasma Workspace global options"), | ||
36 | QStringLiteral("1.1"), | 40 | QStringLiteral("1.1"), | ||
37 | i18n("System Settings module for managing global options for the Plasma Workspace."), | 41 | i18n("System Settings module for managing global options for the Plasma Workspace."), | ||
38 | KAboutLicense::GPL); | 42 | KAboutLicense::GPL); | ||
39 | 43 | | |||
40 | about->addAuthor(i18n("Furkan Tokac"), QString(), QStringLiteral("furkantokac34@gmail.com")); | 44 | about->addAuthor(i18n("Furkan Tokac"), QString(), QStringLiteral("furkantokac34@gmail.com")); | ||
41 | setAboutData(about); | 45 | setAboutData(about); | ||
42 | 46 | | |||
43 | setButtons( Default | Apply ); | 47 | setButtons( Default | Apply ); | ||
44 | } | 48 | } | ||
45 | 49 | | |||
46 | /*ConfigModule functions*/ | 50 | /*ConfigModule functions*/ | ||
romangg: Unrelated change. Revert pls. | |||||
47 | void KCMWorkspaceOptions::load() | 51 | void KCMWorkspaceOptions::load() | ||
48 | { | 52 | { | ||
49 | bool state = false; | 53 | bool state = false; | ||
50 | KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasmarc")); | 54 | KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasmarc")); | ||
51 | 55 | | |||
52 | // Load toolTip | 56 | // Load toolTip | ||
53 | { | 57 | { | ||
54 | const KConfigGroup cg(config, QStringLiteral("PlasmaToolTips")); | 58 | const KConfigGroup cg(config, QStringLiteral("PlasmaToolTips")); | ||
55 | state = cg.readEntry("Delay", 0.7) > 0; | 59 | state = cg.readEntry("Delay", 0.7) > 0; | ||
56 | setToolTip(state); | 60 | setToolTip(state); | ||
57 | m_ostateToolTip = getToolTip(); | 61 | m_ostateToolTip = getToolTip(); | ||
58 | } | 62 | } | ||
59 | 63 | | |||
60 | // Load visualFeedback | 64 | // Load visualFeedback | ||
61 | { | 65 | { | ||
62 | const KConfigGroup cg(config, QStringLiteral("OSD")); | 66 | const KConfigGroup cg(config, QStringLiteral("OSD")); | ||
63 | state = cg.readEntry(QStringLiteral("Enabled"), true); | 67 | state = cg.readEntry(QStringLiteral("Enabled"), true); | ||
64 | setVisualFeedback(state); | 68 | setVisualFeedback(state); | ||
65 | m_ostateVisualFeedback = getVisualFeedback(); | 69 | m_ostateVisualFeedback = getVisualFeedback(); | ||
66 | } | 70 | } | ||
67 | 71 | | |||
72 | // Load singleClick | ||||
73 | { | ||||
74 | KSharedConfig::Ptr configKdeGlobals = KSharedConfig::openConfig(QStringLiteral("kdeglobals")); | ||||
75 | const KConfigGroup cg(configKdeGlobals, QStringLiteral("KDE")); | ||||
76 | state = cg.readEntry(QStringLiteral("SingleClick"), true); | ||||
77 | setSingleClick(state); | ||||
78 | m_ostateSingleClick = getSingleClick(); | ||||
79 | } | ||||
80 | | ||||
68 | setNeedsSave(false); | 81 | setNeedsSave(false); | ||
69 | } | 82 | } | ||
70 | 83 | | |||
71 | void KCMWorkspaceOptions::save() | 84 | void KCMWorkspaceOptions::save() | ||
72 | { | 85 | { | ||
73 | KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasmarc")); | 86 | KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasmarc")); | ||
74 | 87 | | |||
75 | // Save toolTip | 88 | // Save toolTip | ||
76 | { | 89 | { | ||
77 | KConfigGroup cg(config, QStringLiteral("PlasmaToolTips")); | 90 | KConfigGroup cg(config, QStringLiteral("PlasmaToolTips")); | ||
78 | cg.writeEntry("Delay", getToolTip() ? 0.7 : -1); | 91 | cg.writeEntry("Delay", getToolTip() ? 0.7 : -1); | ||
79 | m_ostateToolTip = getToolTip(); | 92 | m_ostateToolTip = getToolTip(); | ||
80 | } | 93 | } | ||
81 | 94 | | |||
82 | // Save visualFeedback | 95 | // Save visualFeedback | ||
83 | { | 96 | { | ||
84 | KConfigGroup cg(config, QStringLiteral("OSD")); | 97 | KConfigGroup cg(config, QStringLiteral("OSD")); | ||
85 | cg.writeEntry("Enabled", getVisualFeedback()); | 98 | cg.writeEntry("Enabled", getVisualFeedback()); | ||
86 | m_ostateVisualFeedback = getVisualFeedback(); | 99 | m_ostateVisualFeedback = getVisualFeedback(); | ||
87 | } | 100 | } | ||
88 | 101 | | |||
102 | // Save singleClick | ||||
103 | KSharedConfig::Ptr configKdeGlobals = KSharedConfig::openConfig(QStringLiteral("kdeglobals")); | ||||
104 | KConfigGroup cg(configKdeGlobals, QStringLiteral("KDE")); | ||||
105 | cg.writeEntry("SingleClick", getSingleClick()); | ||||
106 | m_ostateSingleClick = getSingleClick(); | ||||
89 | config->sync(); | 107 | config->sync(); | ||
108 | configKdeGlobals->sync(); | ||||
109 | | ||||
110 | Kdelibs4SharedConfig::syncConfigGroup(QLatin1String("KDE"), "kdeglobals"); | ||||
111 | | ||||
112 | // See https://api.kde.org/frameworks/kdelibs4support/html/classKGlobalSettings.html | ||||
113 | const int changeType__SettingsChanged = 3; // 3 comes from KGlobalSettings | ||||
114 | const int arg__SETTINGS_MOUSE = 0; // 0 comes from KGlobalSettings | ||||
115 | QDBusMessage message = QDBusMessage::createSignal("/KGlobalSettings", "org.kde.KGlobalSettings", "notifyChange"); | ||||
116 | QList<QVariant> args; | ||||
117 | args.append(changeType__SettingsChanged); | ||||
118 | args.append(arg__SETTINGS_MOUSE); | ||||
119 | message.setArguments(args); | ||||
120 | QDBusConnection::sessionBus().send(message); | ||||
121 | | ||||
90 | setNeedsSave(false); | 122 | setNeedsSave(false); | ||
91 | } | 123 | } | ||
92 | 124 | | |||
93 | void KCMWorkspaceOptions::defaults() | 125 | void KCMWorkspaceOptions::defaults() | ||
94 | { | 126 | { | ||
95 | setToolTip(true); | 127 | setToolTip(true); | ||
96 | setVisualFeedback(true); | 128 | setVisualFeedback(true); | ||
129 | setSingleClick(true); | ||||
97 | 130 | | |||
98 | handleNeedsSave(); | 131 | handleNeedsSave(); | ||
99 | } | 132 | } | ||
100 | 133 | | |||
101 | /*ToolTip functions*/ | 134 | /*ToolTip functions*/ | ||
romangg: Unrelated change. Revert pls. | |||||
102 | bool KCMWorkspaceOptions::getToolTip() const | 135 | bool KCMWorkspaceOptions::getToolTip() const | ||
103 | { | 136 | { | ||
104 | return m_stateToolTip; | 137 | return m_stateToolTip; | ||
105 | } | 138 | } | ||
106 | 139 | | |||
107 | void KCMWorkspaceOptions::setToolTip(bool state) | 140 | void KCMWorkspaceOptions::setToolTip(bool state) | ||
108 | { | 141 | { | ||
109 | // Prevent from binding loop | 142 | // Prevent from binding loop | ||
Show All 21 Lines | 160 | { | |||
131 | } | 164 | } | ||
132 | 165 | | |||
133 | m_stateVisualFeedback = state; | 166 | m_stateVisualFeedback = state; | ||
134 | 167 | | |||
135 | emit visualFeedbackChanged(); | 168 | emit visualFeedbackChanged(); | ||
136 | handleNeedsSave(); | 169 | handleNeedsSave(); | ||
137 | } | 170 | } | ||
138 | 171 | | |||
172 | /*SingleClick functions*/ | ||||
173 | bool KCMWorkspaceOptions::getSingleClick() const | ||||
174 | { | ||||
175 | return m_stateSingleClick; | ||||
176 | } | ||||
177 | | ||||
178 | void KCMWorkspaceOptions::setSingleClick(bool state) | ||||
179 | { | ||||
180 | // Prevent from binding loop | ||||
181 | if( m_stateSingleClick == state ) { | ||||
182 | return; | ||||
183 | } | ||||
184 | | ||||
185 | m_stateSingleClick = state; | ||||
186 | | ||||
187 | emit singleClickChanged(); | ||||
188 | handleNeedsSave(); | ||||
189 | } | ||||
190 | | ||||
139 | /*Other functions*/ | 191 | /*Other functions*/ | ||
romangg: Remove | |||||
140 | // Checks if the current states are different than the first states. | 192 | // Checks if the current states are different than the first states. | ||
141 | // If yes, setNeedsSave(true). | 193 | // If yes, setNeedsSave(true). | ||
142 | void KCMWorkspaceOptions::handleNeedsSave() | 194 | void KCMWorkspaceOptions::handleNeedsSave() | ||
143 | { | 195 | { | ||
144 | setNeedsSave(m_ostateToolTip != getToolTip() || | 196 | setNeedsSave(m_ostateToolTip != getToolTip() || | ||
145 | m_ostateVisualFeedback != getVisualFeedback()); | 197 | m_ostateVisualFeedback != getVisualFeedback() || | ||
198 | m_ostateSingleClick != getSingleClick()); | ||||
146 | } | 199 | } | ||
147 | 200 | | |||
romangg: Remove | |||||
148 | #include "workspaceoptions.moc" | 201 | #include "workspaceoptions.moc" |
Add m_stateSingleClick(true)