Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwinoptions/mouse.cpp
Show All 26 Lines | |||||
27 | #include <QBitmap> | 27 | #include <QBitmap> | ||
28 | 28 | | |||
29 | #include <QGroupBox> | 29 | #include <QGroupBox> | ||
30 | #include <QPixmap> | 30 | #include <QPixmap> | ||
31 | #include <QVBoxLayout> | 31 | #include <QVBoxLayout> | ||
32 | #include <QHBoxLayout> | 32 | #include <QHBoxLayout> | ||
33 | #include <QFormLayout> | 33 | #include <QFormLayout> | ||
34 | 34 | | |||
35 | #include <kconfig.h> | | |||
36 | #include <kconfiggroup.h> | | |||
37 | #include <QDebug> | 35 | #include <QDebug> | ||
38 | #include <kcolorscheme.h> | 36 | #include <kcolorscheme.h> | ||
39 | #include <kseparator.h> | 37 | #include <kseparator.h> | ||
40 | #include <QtDBus> | 38 | #include <QtDBus> | ||
41 | 39 | | |||
42 | #include <cstdlib> | 40 | #include <cstdlib> | ||
43 | 41 | | |||
42 | #include "kwinoptions_settings.h" | ||||
43 | | ||||
44 | 44 | | |||
45 | namespace | 45 | namespace | ||
46 | { | 46 | { | ||
47 | 47 | | |||
48 | char const * const cnf_Max[] = { | | |||
49 | "MaximizeButtonLeftClickCommand", | | |||
50 | "MaximizeButtonMiddleClickCommand", | | |||
51 | "MaximizeButtonRightClickCommand", | | |||
52 | }; | | |||
53 | | ||||
54 | char const * const tbl_Max[] = { | | |||
55 | "Maximize", | | |||
56 | "Maximize (vertical only)", | | |||
57 | "Maximize (horizontal only)", | | |||
58 | "" | | |||
59 | }; | | |||
60 | | ||||
61 | QPixmap maxButtonPixmaps[3]; | 48 | QPixmap maxButtonPixmaps[3]; | ||
62 | 49 | | |||
63 | void createMaxButtonPixmaps() | 50 | void createMaxButtonPixmaps() | ||
64 | { | 51 | { | ||
65 | char const * maxButtonXpms[][3 + 13] = { | 52 | char const *maxButtonXpms[][3 + 13] = { | ||
66 | { | 53 | { | ||
67 | nullptr, nullptr, nullptr, | 54 | nullptr, nullptr, nullptr, | ||
68 | "...............", | 55 | "...............", | ||
69 | ".......#.......", | 56 | ".......#.......", | ||
70 | "......###......", | 57 | "......###......", | ||
71 | ".....#####.....", | 58 | ".....#####.....", | ||
72 | "..#....#....#..", | 59 | "..#....#....#..", | ||
73 | ".##....#....##.", | 60 | ".##....#....##.", | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | |||||
137 | { | 124 | { | ||
138 | setupUi(parent); | 125 | setupUi(parent); | ||
139 | } | 126 | } | ||
140 | 127 | | |||
141 | void KTitleBarActionsConfig::paletteChanged() | 128 | void KTitleBarActionsConfig::paletteChanged() | ||
142 | { | 129 | { | ||
143 | createMaxButtonPixmaps(); | 130 | createMaxButtonPixmaps(); | ||
144 | for (int i=0; i<3; ++i) { | 131 | for (int i=0; i<3; ++i) { | ||
145 | m_ui->leftClickMaximizeButton->setItemIcon(i, maxButtonPixmaps[i]); | 132 | m_ui->kcfg_MaximizeButtonLeftClickCommand->setItemIcon(i, maxButtonPixmaps[i]); | ||
146 | m_ui->middleClickMaximizeButton->setItemIcon(i, maxButtonPixmaps[i]); | 133 | m_ui->kcfg_MaximizeButtonMiddleClickCommand->setItemIcon(i, maxButtonPixmaps[i]); | ||
147 | m_ui->rightClickMaximizeButton->setItemIcon(i, maxButtonPixmaps[i]); | 134 | m_ui->kcfg_MaximizeButtonRightClickCommand->setItemIcon(i, maxButtonPixmaps[i]); | ||
148 | } | 135 | } | ||
149 | 136 | | |||
150 | } | 137 | } | ||
151 | 138 | | |||
152 | KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, KConfig *_config, QWidget * parent) | 139 | KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, QWidget *parent) | ||
153 | : KCModule(parent), config(_config), standAlone(_standAlone) | 140 | : KCModule(parent), standAlone(_standAlone) | ||
ervin: Please use the opportunity to remove the space after the * | |||||
154 | , m_ui(new KWinMouseConfigForm(this)) | 141 | , m_ui(new KWinMouseConfigForm(this)) | ||
155 | { | 142 | { | ||
143 | addConfig(KWinOptionsSettings::self(), this); | ||||
144 | | ||||
156 | // create the items for the maximize button actions | 145 | // create the items for the maximize button actions | ||
157 | createMaxButtonPixmaps(); | 146 | createMaxButtonPixmaps(); | ||
158 | for (int i=0; i<3; ++i) { | 147 | for (int i=0; i<3; ++i) { | ||
159 | m_ui->leftClickMaximizeButton->addItem(maxButtonPixmaps[i], QString()); | 148 | m_ui->kcfg_MaximizeButtonLeftClickCommand->addItem(maxButtonPixmaps[i], QString()); | ||
160 | m_ui->middleClickMaximizeButton->addItem(maxButtonPixmaps[i], QString()); | 149 | m_ui->kcfg_MaximizeButtonMiddleClickCommand->addItem(maxButtonPixmaps[i], QString()); | ||
161 | m_ui->rightClickMaximizeButton->addItem(maxButtonPixmaps[i], QString()); | 150 | m_ui->kcfg_MaximizeButtonRightClickCommand->addItem(maxButtonPixmaps[i], QString()); | ||
162 | } | 151 | } | ||
163 | createMaximizeButtonTooltips(m_ui->leftClickMaximizeButton); | 152 | createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonLeftClickCommand); | ||
164 | createMaximizeButtonTooltips(m_ui->middleClickMaximizeButton); | 153 | createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonMiddleClickCommand); | ||
165 | createMaximizeButtonTooltips(m_ui->rightClickMaximizeButton); | 154 | createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonRightClickCommand); | ||
166 | | ||||
167 | connect(m_ui->coTiDbl, SIGNAL(activated(int)), SLOT(changed())); | | |||
168 | connect(m_ui->coTiAct1, SIGNAL(activated(int)), SLOT(changed())); | | |||
169 | connect(m_ui->coTiAct2, SIGNAL(activated(int)), SLOT(changed())); | | |||
170 | connect(m_ui->coTiAct3, SIGNAL(activated(int)), SLOT(changed())); | | |||
171 | connect(m_ui->coTiAct4, SIGNAL(activated(int)), SLOT(changed())); | | |||
172 | connect(m_ui->coTiInAct1, SIGNAL(activated(int)), SLOT(changed())); | | |||
173 | connect(m_ui->coTiInAct2, SIGNAL(activated(int)), SLOT(changed())); | | |||
174 | connect(m_ui->coTiInAct3, SIGNAL(activated(int)), SLOT(changed())); | | |||
175 | connect(m_ui->leftClickMaximizeButton, SIGNAL(activated(int)), SLOT(changed())); | | |||
176 | connect(m_ui->middleClickMaximizeButton, SIGNAL(activated(int)), SLOT(changed())); | | |||
177 | connect(m_ui->rightClickMaximizeButton, SIGNAL(activated(int)), SLOT(changed())); | | |||
178 | 155 | | |||
179 | load(); | 156 | load(); | ||
180 | } | 157 | } | ||
181 | 158 | | |||
bport: I don't think we need a t variable there | |||||
182 | KTitleBarActionsConfig::~KTitleBarActionsConfig() | | |||
183 | { | | |||
184 | if (standAlone) | | |||
185 | delete config; | | |||
186 | } | | |||
187 | | ||||
188 | void KTitleBarActionsConfig::createMaximizeButtonTooltips(KComboBox *combo) | 159 | void KTitleBarActionsConfig::createMaximizeButtonTooltips(KComboBox *combo) | ||
ervin: I guess it could be completely removed | |||||
189 | { | 160 | { | ||
190 | combo->setItemData(0, i18n("Maximize"), Qt::ToolTipRole); | 161 | combo->setItemData(0, i18n("Maximize"), Qt::ToolTipRole); | ||
191 | combo->setItemData(1, i18n("Maximize (vertical only)"), Qt::ToolTipRole); | 162 | combo->setItemData(1, i18n("Maximize (vertical only)"), Qt::ToolTipRole); | ||
192 | combo->setItemData(2, i18n("Maximize (horizontal only)"), Qt::ToolTipRole); | 163 | combo->setItemData(2, i18n("Maximize (horizontal only)"), Qt::ToolTipRole); | ||
193 | } | 164 | } | ||
194 | 165 | | |||
195 | // do NOT change the texts below, they are written to config file | | |||
196 | // and are not shown in the GUI | | |||
197 | // they have to match the order of items in GUI elements though | | |||
198 | const char* const tbl_TiDbl[] = { | | |||
199 | "Maximize", | | |||
200 | "Maximize (vertical only)", | | |||
201 | "Maximize (horizontal only)", | | |||
202 | "Minimize", | | |||
203 | "Shade", | | |||
204 | "Lower", | | |||
205 | "Close", | | |||
206 | "OnAllDesktops", | | |||
207 | "Nothing", | | |||
208 | "" | | |||
209 | }; | | |||
210 | | ||||
211 | const char* const tbl_TiAc[] = { | | |||
212 | "Raise", | | |||
213 | "Lower", | | |||
214 | "Toggle raise and lower", | | |||
215 | "Minimize", | | |||
216 | "Shade", | | |||
217 | "Close", | | |||
218 | "Operations menu", | | |||
219 | "Nothing", | | |||
220 | "" | | |||
221 | }; | | |||
222 | | ||||
223 | const char* const tbl_TiInAc[] = { | | |||
224 | "Activate and raise", | | |||
225 | "Activate and lower", | | |||
226 | "Activate", | | |||
227 | "Raise", | | |||
228 | "Lower", | | |||
229 | "Toggle raise and lower", | | |||
230 | "Minimize", | | |||
231 | "Shade", | | |||
232 | "Close", | | |||
233 | "Operations menu", | | |||
234 | "Nothing", | | |||
235 | "" | | |||
236 | }; | | |||
237 | | ||||
238 | const char* const tbl_Win[] = { | | |||
239 | "Activate, raise and pass click", | | |||
240 | "Activate and pass click", | | |||
241 | "Activate", | | |||
242 | "Activate and raise", | | |||
243 | "" | | |||
244 | }; | | |||
245 | | ||||
246 | const char* const tbl_WinWheel[] = { | | |||
247 | "Scroll", | | |||
248 | "Activate and scroll", | | |||
249 | "Activate, raise and scroll", | | |||
250 | "" | | |||
251 | }; | | |||
252 | | ||||
253 | const char* const tbl_AllKey[] = { | | |||
254 | "Alt", | | |||
255 | "Meta", | | |||
256 | "" | | |||
257 | }; | | |||
258 | | ||||
259 | const char* const tbl_All[] = { | | |||
260 | "Move", | | |||
261 | "Activate, raise and move", | | |||
262 | "Toggle raise and lower", | | |||
263 | "Resize", | | |||
264 | "Raise", | | |||
265 | "Lower", | | |||
266 | "Minimize", | | |||
267 | "Decrease Opacity", | | |||
268 | "Increase Opacity", | | |||
269 | "Nothing", | | |||
270 | "" | | |||
271 | }; | | |||
272 | | ||||
273 | const char* const tbl_TiWAc[] = { | | |||
274 | "Raise/Lower", | | |||
275 | "Shade/Unshade", | | |||
276 | "Maximize/Restore", | | |||
277 | "Above/Below", | | |||
278 | "Previous/Next Desktop", | | |||
279 | "Change Opacity", | | |||
280 | "Nothing", | | |||
281 | "" | | |||
282 | }; | | |||
283 | | ||||
284 | const char* const tbl_AllW[] = { | | |||
285 | "Raise/Lower", | | |||
286 | "Shade/Unshade", | | |||
287 | "Maximize/Restore", | | |||
288 | "Above/Below", | | |||
289 | "Previous/Next Desktop", | | |||
290 | "Change Opacity", | | |||
291 | "Nothing", | | |||
292 | "" | | |||
293 | }; | | |||
294 | | ||||
295 | static const char* tbl_num_lookup(const char* const arr[], int pos) | | |||
296 | { | | |||
297 | for (int i = 0; | | |||
298 | arr[ i ][ 0 ] != '\0' && pos >= 0; | | |||
299 | ++i) { | | |||
300 | if (pos == 0) | | |||
301 | return arr[ i ]; | | |||
302 | --pos; | | |||
303 | } | | |||
304 | abort(); // should never happen this way | | |||
305 | } | | |||
306 | | ||||
307 | static int tbl_txt_lookup(const char* const arr[], const char* txt) | | |||
308 | { | | |||
309 | int pos = 0; | | |||
310 | for (int i = 0; | | |||
311 | arr[ i ][ 0 ] != '\0'; | | |||
312 | ++i) { | | |||
313 | if (qstricmp(txt, arr[ i ]) == 0) | | |||
314 | return pos; | | |||
315 | ++pos; | | |||
316 | } | | |||
317 | return 0; | | |||
318 | } | | |||
319 | | ||||
320 | void KTitleBarActionsConfig::setComboText(KComboBox* combo, const char*txt) | | |||
321 | { | | |||
322 | if (combo == m_ui->coTiDbl) | | |||
323 | combo->setCurrentIndex(tbl_txt_lookup(tbl_TiDbl, txt)); | | |||
324 | else if (combo == m_ui->coTiAct1 || combo == m_ui->coTiAct2 || combo == m_ui->coTiAct3) | | |||
325 | combo->setCurrentIndex(tbl_txt_lookup(tbl_TiAc, txt)); | | |||
326 | else if (combo == m_ui->coTiInAct1 || combo == m_ui->coTiInAct2 || combo == m_ui->coTiInAct3) | | |||
327 | combo->setCurrentIndex(tbl_txt_lookup(tbl_TiInAc, txt)); | | |||
328 | else if (combo == m_ui->coTiAct4) | | |||
329 | combo->setCurrentIndex(tbl_txt_lookup(tbl_TiWAc, txt)); | | |||
330 | else if (combo == m_ui->leftClickMaximizeButton || | | |||
331 | combo == m_ui->middleClickMaximizeButton || | | |||
332 | combo == m_ui->rightClickMaximizeButton) { | | |||
333 | combo->setCurrentIndex(tbl_txt_lookup(tbl_Max, txt)); | | |||
334 | } else | | |||
335 | abort(); | | |||
336 | } | | |||
337 | | ||||
338 | const char* KTitleBarActionsConfig::functionTiDbl(int i) | | |||
339 | { | | |||
340 | return tbl_num_lookup(tbl_TiDbl, i); | | |||
341 | } | | |||
342 | | ||||
343 | const char* KTitleBarActionsConfig::functionTiAc(int i) | | |||
344 | { | | |||
345 | return tbl_num_lookup(tbl_TiAc, i); | | |||
346 | } | | |||
347 | | ||||
348 | const char* KTitleBarActionsConfig::functionTiInAc(int i) | | |||
349 | { | | |||
350 | return tbl_num_lookup(tbl_TiInAc, i); | | |||
351 | } | | |||
352 | | ||||
353 | const char* KTitleBarActionsConfig::functionTiWAc(int i) | | |||
354 | { | | |||
355 | return tbl_num_lookup(tbl_TiWAc, i); | | |||
356 | } | | |||
357 | | ||||
358 | const char* KTitleBarActionsConfig::functionMax(int i) | | |||
359 | { | | |||
360 | return tbl_num_lookup(tbl_Max, i); | | |||
361 | } | | |||
362 | | ||||
363 | void KTitleBarActionsConfig::showEvent(QShowEvent *ev) | 166 | void KTitleBarActionsConfig::showEvent(QShowEvent *ev) | ||
364 | { | 167 | { | ||
365 | if (!standAlone) { | 168 | if (!standAlone) { | ||
366 | // Workaround KCModule::showEvent() calling load(), see bug 163817 | 169 | // Workaround KCModule::showEvent() calling load(), see bug 163817 | ||
367 | QWidget::showEvent(ev); | 170 | QWidget::showEvent(ev); | ||
368 | return; | 171 | return; | ||
369 | } | 172 | } | ||
370 | KCModule::showEvent(ev); | 173 | KCModule::showEvent(ev); | ||
371 | } | 174 | } | ||
372 | 175 | | |||
373 | void KTitleBarActionsConfig::changeEvent(QEvent *ev) | 176 | void KTitleBarActionsConfig::changeEvent(QEvent *ev) | ||
374 | { | 177 | { | ||
375 | if (ev->type() == QEvent::PaletteChange) { | 178 | if (ev->type() == QEvent::PaletteChange) { | ||
376 | paletteChanged(); | 179 | paletteChanged(); | ||
377 | } | 180 | } | ||
378 | ev->accept(); | 181 | ev->accept(); | ||
379 | } | 182 | } | ||
380 | 183 | | |||
381 | | ||||
382 | void KTitleBarActionsConfig::load() | | |||
383 | { | | |||
384 | KConfigGroup windowsConfig(config, "Windows"); | | |||
385 | setComboText(m_ui->coTiDbl, windowsConfig.readEntry("TitlebarDoubleClickCommand", "Maximize").toLatin1()); | | |||
386 | setComboText(m_ui->leftClickMaximizeButton, windowsConfig.readEntry(cnf_Max[0], tbl_Max[0]).toLatin1()); | | |||
387 | setComboText(m_ui->middleClickMaximizeButton, windowsConfig.readEntry(cnf_Max[1], tbl_Max[1]).toLatin1()); | | |||
388 | setComboText(m_ui->rightClickMaximizeButton, windowsConfig.readEntry(cnf_Max[2], tbl_Max[2]).toLatin1()); | | |||
389 | | ||||
390 | KConfigGroup cg(config, "MouseBindings"); | | |||
391 | setComboText(m_ui->coTiAct1, cg.readEntry("CommandActiveTitlebar1", "Raise").toLatin1()); | | |||
392 | setComboText(m_ui->coTiAct2, cg.readEntry("CommandActiveTitlebar2", "Nothing").toLatin1()); | | |||
393 | setComboText(m_ui->coTiAct3, cg.readEntry("CommandActiveTitlebar3", "Operations menu").toLatin1()); | | |||
394 | setComboText(m_ui->coTiAct4, cg.readEntry("CommandTitlebarWheel", "Nothing").toLatin1()); | | |||
395 | setComboText(m_ui->coTiInAct1, cg.readEntry("CommandInactiveTitlebar1", "Activate and raise").toLatin1()); | | |||
396 | setComboText(m_ui->coTiInAct2, cg.readEntry("CommandInactiveTitlebar2", "Nothing").toLatin1()); | | |||
397 | setComboText(m_ui->coTiInAct3, cg.readEntry("CommandInactiveTitlebar3", "Operations menu").toLatin1()); | | |||
398 | } | | |||
399 | | ||||
400 | void KTitleBarActionsConfig::save() | 184 | void KTitleBarActionsConfig::save() | ||
401 | { | 185 | { | ||
402 | KConfigGroup windowsConfig(config, "Windows"); | 186 | KCModule::save(); | ||
403 | windowsConfig.writeEntry("TitlebarDoubleClickCommand", functionTiDbl(m_ui->coTiDbl->currentIndex())); | | |||
404 | windowsConfig.writeEntry(cnf_Max[0], functionMax(m_ui->leftClickMaximizeButton->currentIndex())); | | |||
405 | windowsConfig.writeEntry(cnf_Max[1], functionMax(m_ui->middleClickMaximizeButton->currentIndex())); | | |||
406 | windowsConfig.writeEntry(cnf_Max[2], functionMax(m_ui->rightClickMaximizeButton->currentIndex())); | | |||
407 | | ||||
408 | KConfigGroup cg(config, "MouseBindings"); | | |||
409 | cg.writeEntry("CommandActiveTitlebar1", functionTiAc(m_ui->coTiAct1->currentIndex())); | | |||
410 | cg.writeEntry("CommandActiveTitlebar2", functionTiAc(m_ui->coTiAct2->currentIndex())); | | |||
411 | cg.writeEntry("CommandActiveTitlebar3", functionTiAc(m_ui->coTiAct3->currentIndex())); | | |||
412 | cg.writeEntry("CommandInactiveTitlebar1", functionTiInAc(m_ui->coTiInAct1->currentIndex())); | | |||
413 | cg.writeEntry("CommandTitlebarWheel", functionTiWAc(m_ui->coTiAct4->currentIndex())); | | |||
414 | cg.writeEntry("CommandInactiveTitlebar2", functionTiInAc(m_ui->coTiInAct2->currentIndex())); | | |||
415 | cg.writeEntry("CommandInactiveTitlebar3", functionTiInAc(m_ui->coTiInAct3->currentIndex())); | | |||
416 | 187 | | |||
417 | if (standAlone) { | 188 | if (standAlone) { | ||
418 | config->sync(); | | |||
419 | // Send signal to all kwin instances | 189 | // Send signal to all kwin instances | ||
420 | QDBusMessage message = | 190 | QDBusMessage message = | ||
421 | QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); | 191 | QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); | ||
422 | QDBusConnection::sessionBus().send(message); | 192 | QDBusConnection::sessionBus().send(message); | ||
423 | | ||||
424 | } | | |||
425 | } | 193 | } | ||
426 | | ||||
427 | void KTitleBarActionsConfig::defaults() | | |||
428 | { | | |||
429 | setComboText(m_ui->coTiDbl, "Maximize"); | | |||
430 | setComboText(m_ui->coTiAct1, "Raise"); | | |||
431 | setComboText(m_ui->coTiAct2, "Nothing"); | | |||
432 | setComboText(m_ui->coTiAct3, "Operations menu"); | | |||
433 | setComboText(m_ui->coTiAct4, "Nothing"); | | |||
434 | setComboText(m_ui->coTiInAct1, "Activate and raise"); | | |||
435 | setComboText(m_ui->coTiInAct2, "Nothing"); | | |||
436 | setComboText(m_ui->coTiInAct3, "Operations menu"); | | |||
437 | setComboText(m_ui->leftClickMaximizeButton, tbl_Max[0]); | | |||
438 | setComboText(m_ui->middleClickMaximizeButton, tbl_Max[1]); | | |||
439 | setComboText(m_ui->rightClickMaximizeButton, tbl_Max[2]); | | |||
440 | } | 194 | } | ||
441 | 195 | | |||
442 | 196 | KWindowActionsConfig::KWindowActionsConfig(bool _standAlone, QWidget *parent) | |||
443 | KWindowActionsConfig::KWindowActionsConfig(bool _standAlone, KConfig *_config, QWidget * parent) | 197 | : KCModule(parent), standAlone(_standAlone) | ||
444 | : KCModule(parent), config(_config), standAlone(_standAlone) | | |||
445 | , m_ui(new KWinActionsConfigForm(this)) | 198 | , m_ui(new KWinActionsConfigForm(this)) | ||
446 | { | 199 | { | ||
447 | connect(m_ui->coWin1, SIGNAL(activated(int)), SLOT(changed())); | 200 | addConfig(KWinOptionsSettings::self(), this); | ||
448 | connect(m_ui->coWin2, SIGNAL(activated(int)), SLOT(changed())); | | |||
449 | connect(m_ui->coWin3, SIGNAL(activated(int)), SLOT(changed())); | | |||
450 | connect(m_ui->coWinWheel, SIGNAL(activated(int)), SLOT(changed())); | | |||
451 | connect(m_ui->coAllKey, SIGNAL(activated(int)), SLOT(changed())); | | |||
452 | connect(m_ui->coAll1, SIGNAL(activated(int)), SLOT(changed())); | | |||
453 | connect(m_ui->coAll2, SIGNAL(activated(int)), SLOT(changed())); | | |||
454 | connect(m_ui->coAll3, SIGNAL(activated(int)), SLOT(changed())); | | |||
455 | connect(m_ui->coAllW, SIGNAL(activated(int)), SLOT(changed())); | | |||
456 | load(); | 201 | load(); | ||
457 | } | 202 | } | ||
458 | 203 | | |||
459 | KWindowActionsConfig::~KWindowActionsConfig() | | |||
460 | { | | |||
461 | if (standAlone) | | |||
462 | delete config; | | |||
463 | } | | |||
464 | | ||||
465 | void KWindowActionsConfig::setComboText(KComboBox* combo, const char*txt) | | |||
466 | { | | |||
467 | if (combo == m_ui->coWin1 || combo == m_ui->coWin2 || combo == m_ui->coWin3) | | |||
468 | combo->setCurrentIndex(tbl_txt_lookup(tbl_Win, txt)); | | |||
469 | else if (combo == m_ui->coWinWheel) | | |||
470 | combo->setCurrentIndex(tbl_txt_lookup(tbl_WinWheel, txt)); | | |||
471 | else if (combo == m_ui->coAllKey) | | |||
472 | combo->setCurrentIndex(tbl_txt_lookup(tbl_AllKey, txt)); | | |||
473 | else if (combo == m_ui->coAll1 || combo == m_ui->coAll2 || combo == m_ui->coAll3) | | |||
474 | combo->setCurrentIndex(tbl_txt_lookup(tbl_All, txt)); | | |||
475 | else if (combo == m_ui->coAllW) | | |||
476 | combo->setCurrentIndex(tbl_txt_lookup(tbl_AllW, txt)); | | |||
477 | else | | |||
478 | abort(); | | |||
479 | } | | |||
480 | | ||||
481 | const char* KWindowActionsConfig::functionWin(int i) | | |||
482 | { | | |||
483 | return tbl_num_lookup(tbl_Win, i); | | |||
484 | } | | |||
485 | | ||||
486 | const char* KWindowActionsConfig::functionWinWheel(int i) | | |||
487 | { | | |||
488 | return tbl_num_lookup(tbl_WinWheel, i); | | |||
489 | } | | |||
490 | | ||||
491 | const char* KWindowActionsConfig::functionAllKey(int i) | | |||
492 | { | | |||
493 | return tbl_num_lookup(tbl_AllKey, i); | | |||
494 | } | | |||
495 | | ||||
496 | const char* KWindowActionsConfig::functionAll(int i) | | |||
497 | { | | |||
498 | return tbl_num_lookup(tbl_All, i); | | |||
499 | } | | |||
500 | | ||||
501 | const char* KWindowActionsConfig::functionAllW(int i) | | |||
502 | { | | |||
503 | return tbl_num_lookup(tbl_AllW, i); | | |||
504 | } | | |||
505 | | ||||
506 | void KWindowActionsConfig::showEvent(QShowEvent *ev) | 204 | void KWindowActionsConfig::showEvent(QShowEvent *ev) | ||
ervin: ditto | |||||
507 | { | 205 | { | ||
508 | if (!standAlone) { | 206 | if (!standAlone) { | ||
509 | QWidget::showEvent(ev); | 207 | QWidget::showEvent(ev); | ||
510 | return; | 208 | return; | ||
511 | } | 209 | } | ||
512 | KCModule::showEvent(ev); | 210 | KCModule::showEvent(ev); | ||
513 | } | 211 | } | ||
514 | 212 | | |||
515 | void KWindowActionsConfig::load() | | |||
516 | { | | |||
517 | KConfigGroup cg(config, "MouseBindings"); | | |||
518 | setComboText(m_ui->coWin1, cg.readEntry("CommandWindow1", "Activate, raise and pass click").toLatin1()); | | |||
519 | setComboText(m_ui->coWin2, cg.readEntry("CommandWindow2", "Activate and pass click").toLatin1()); | | |||
520 | setComboText(m_ui->coWin3, cg.readEntry("CommandWindow3", "Activate and pass click").toLatin1()); | | |||
521 | setComboText(m_ui->coWinWheel, cg.readEntry("CommandWindowWheel", "Scroll").toLatin1()); | | |||
522 | setComboText(m_ui->coAllKey, cg.readEntry("CommandAllKey", "Alt").toLatin1()); | | |||
523 | setComboText(m_ui->coAll1, cg.readEntry("CommandAll1", "Move").toLatin1()); | | |||
524 | setComboText(m_ui->coAll2, cg.readEntry("CommandAll2", "Toggle raise and lower").toLatin1()); | | |||
525 | setComboText(m_ui->coAll3, cg.readEntry("CommandAll3", "Resize").toLatin1()); | | |||
526 | setComboText(m_ui->coAllW, cg.readEntry("CommandAllWheel", "Nothing").toLatin1()); | | |||
527 | } | | |||
528 | | ||||
529 | void KWindowActionsConfig::save() | 213 | void KWindowActionsConfig::save() | ||
530 | { | 214 | { | ||
531 | KConfigGroup cg(config, "MouseBindings"); | 215 | KCModule::save(); | ||
532 | cg.writeEntry("CommandWindow1", functionWin(m_ui->coWin1->currentIndex())); | | |||
533 | cg.writeEntry("CommandWindow2", functionWin(m_ui->coWin2->currentIndex())); | | |||
534 | cg.writeEntry("CommandWindow3", functionWin(m_ui->coWin3->currentIndex())); | | |||
535 | cg.writeEntry("CommandWindowWheel", functionWinWheel(m_ui->coWinWheel->currentIndex())); | | |||
536 | cg.writeEntry("CommandAllKey", functionAllKey(m_ui->coAllKey->currentIndex())); | | |||
537 | cg.writeEntry("CommandAll1", functionAll(m_ui->coAll1->currentIndex())); | | |||
538 | cg.writeEntry("CommandAll2", functionAll(m_ui->coAll2->currentIndex())); | | |||
539 | cg.writeEntry("CommandAll3", functionAll(m_ui->coAll3->currentIndex())); | | |||
540 | cg.writeEntry("CommandAllWheel", functionAllW(m_ui->coAllW->currentIndex())); | | |||
541 | 216 | | |||
542 | if (standAlone) { | 217 | if (standAlone) { | ||
543 | config->sync(); | | |||
544 | // Send signal to all kwin instances | 218 | // Send signal to all kwin instances | ||
545 | QDBusMessage message = | 219 | QDBusMessage message = | ||
546 | QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); | 220 | QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); | ||
547 | QDBusConnection::sessionBus().send(message); | 221 | QDBusConnection::sessionBus().send(message); | ||
548 | } | 222 | } | ||
549 | } | 223 | } | ||
550 | | ||||
551 | void KWindowActionsConfig::defaults() | | |||
552 | { | | |||
553 | setComboText(m_ui->coWin1, "Activate, raise and pass click"); | | |||
554 | setComboText(m_ui->coWin2, "Activate and pass click"); | | |||
555 | setComboText(m_ui->coWin3, "Activate and pass click"); | | |||
556 | setComboText(m_ui->coWinWheel, "Scroll"); | | |||
557 | setComboText(m_ui->coAllKey, "Alt"); | | |||
558 | setComboText(m_ui->coAll1, "Move"); | | |||
559 | setComboText(m_ui->coAll2, "Toggle raise and lower"); | | |||
560 | setComboText(m_ui->coAll3, "Resize"); | | |||
561 | setComboText(m_ui->coAllW, "Nothing"); | | |||
562 | } | |
Please use the opportunity to remove the space after the *