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