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