3 * Copyright (c) 1998 Matthias Ettrich <ettrich@kde.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 #include <QSizePolicy>
29 #include <QVBoxLayout>
30 #include <QHBoxLayout>
35 #include <kglobalsettings.h>
36 #include <kcolorscheme.h>
37 #include <kseparator.h>
38 #include <QtDBus/QtDBus>
42 #include <X11/Xutil.h>
51 char const * const cnf_Max
[] = {
52 "MaximizeButtonLeftClickCommand",
53 "MaximizeButtonMiddleClickCommand",
54 "MaximizeButtonRightClickCommand",
57 char const * const tbl_Max
[] = {
59 "Maximize (vertical only)",
60 "Maximize (horizontal only)",
63 QPixmap maxButtonPixmaps
[3];
65 void createMaxButtonPixmaps()
67 char const * maxButtonXpms
[][3 + 13] = {
112 QByteArray
baseColor(". c " + KColorScheme(QPalette::Active
, KColorScheme::View
).background().color().name().toAscii());
113 QByteArray
textColor("# c " + KColorScheme(QPalette::Active
, KColorScheme::View
).foreground().color().name().toAscii());
114 for (int t
= 0; t
< 3; ++t
)
116 maxButtonXpms
[t
][0] = "15 13 2 1";
117 maxButtonXpms
[t
][1] = baseColor
.constData();
118 maxButtonXpms
[t
][2] = textColor
.constData();
119 maxButtonPixmaps
[t
] = QPixmap(maxButtonXpms
[t
]);
120 maxButtonPixmaps
[t
].setMask(maxButtonPixmaps
[t
].createHeuristicMask());
126 void KTitleBarActionsConfig::paletteChanged()
128 createMaxButtonPixmaps();
129 for (int b
= 0; b
< 3; ++b
)
130 for (int t
= 0; t
< 3; ++t
)
131 coMax
[b
]->setItemIcon(t
, maxButtonPixmaps
[t
]);
135 KTitleBarActionsConfig::KTitleBarActionsConfig (bool _standAlone
, KConfig
*_config
, const KComponentData
&inst
, QWidget
* parent
)
136 : KCModule(inst
, parent
), config(_config
), standAlone(_standAlone
)
138 QString strWin1
, strWin2
, strWin3
, strAllKey
, strAll1
, strAll2
, strAll3
;
142 QString strMouseButton1
, strMouseButton3
, strMouseWheel
;
143 QString txtButton1
, txtButton3
, txtButton4
;
145 bool leftHandedMouse
= ( KGlobalSettings::mouseSettings().handed
== KGlobalSettings::KMouseSettings::LeftHanded
);
147 QVBoxLayout
*layout
= new QVBoxLayout(this);
148 layout
->setMargin(0);
149 layout
->setSpacing(KDialog::spacingHint());
151 /** Titlebar doubleclick ************/
153 QHBoxLayout
*hlayout
= new QHBoxLayout();
154 layout
->addLayout( hlayout
);
156 label
= new QLabel(i18n("&Titlebar double-click:"), this);
157 hlayout
->addWidget(label
);
158 label
->setWhatsThis( i18n("Here you can customize mouse click behavior when double clicking on the"
159 " titlebar of a window.") );
161 QComboBox
* combo
= new QComboBox(this);
162 combo
->addItem(i18n("Maximize"));
163 combo
->addItem(i18n("Maximize (vertical only)"));
164 combo
->addItem(i18n("Maximize (horizontal only)"));
165 combo
->addItem(i18n("Minimize"));
166 combo
->addItem(i18n("Shade"));
167 combo
->addItem(i18n("Lower"));
168 combo
->addItem(i18n("On All Desktops"));
169 combo
->addItem(i18n("Nothing"));
170 combo
->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding
, QSizePolicy::Fixed
));
171 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
172 hlayout
->addWidget(combo
);
174 combo
->setWhatsThis( i18n("Behavior on <em>double</em> click into the titlebar."));
176 label
->setBuddy(combo
);
178 /** Mouse Wheel Events **************/
179 QHBoxLayout
*hlayoutW
= new QHBoxLayout();
180 layout
->addLayout( hlayoutW
);
181 strMouseWheel
= i18n("Titlebar wheel event:");
182 label
= new QLabel(strMouseWheel
, this);
183 hlayoutW
->addWidget(label
);
184 txtButton4
= i18n("Handle mouse wheel events");
185 label
->setWhatsThis( txtButton4
);
187 // Titlebar and frame mouse Wheel
188 QComboBox
* comboW
= new QComboBox(this);
189 comboW
->addItem(i18n("Raise/Lower"));
190 comboW
->addItem(i18n("Shade/Unshade"));
191 comboW
->addItem(i18n("Maximize/Restore"));
192 comboW
->addItem(i18n("Keep Above/Below"));
193 comboW
->addItem(i18n("Move to Previous/Next Desktop"));
194 comboW
->addItem(i18n("Change Opacity"));
195 comboW
->addItem(i18n("Nothing"));
196 comboW
->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding
, QSizePolicy::Fixed
));
197 connect(comboW
, SIGNAL(activated(int)), SLOT(changed()));
198 hlayoutW
->addWidget(comboW
);
200 comboW
->setWhatsThis( txtButton4
);
201 label
->setBuddy(comboW
);
203 /** Titlebar and frame **************/
205 box
= new QGroupBox(i18n("Titlebar && Frame"), this);
206 layout
->addWidget(box
);
207 box
->setObjectName(QString::fromLatin1("Titlebar and Frame"));
208 box
->setWhatsThis( i18n("Here you can customize mouse click behavior when clicking on the"
209 " titlebar or the frame of a window.") );
211 grid
= new QGridLayout(box
);
212 grid
->setMargin(KDialog::marginHint());
213 grid
->setSpacing(KDialog::spacingHint());
216 strMouseButton1
= i18n("Left button:");
217 txtButton1
= i18n("In this row you can customize left click behavior when clicking into"
218 " the titlebar or the frame.");
220 strMouseButton3
= i18n("Right button:");
221 txtButton3
= i18n("In this row you can customize right click behavior when clicking into"
222 " the titlebar or the frame." );
224 if ( leftHandedMouse
)
226 qSwap(strMouseButton1
, strMouseButton3
);
227 qSwap(txtButton1
, txtButton3
);
230 label
= new QLabel(strMouseButton1
, box
);
231 grid
->addWidget(label
, 1, 0);
232 label
->setWhatsThis( txtButton1
);
234 label
= new QLabel(i18n("Middle button:"), box
);
235 grid
->addWidget(label
, 2, 0);
236 label
->setWhatsThis( i18n("In this row you can customize middle click behavior when clicking into"
237 " the titlebar or the frame.") );
239 label
= new QLabel(strMouseButton3
, box
);
240 grid
->addWidget(label
, 3, 0);
241 label
->setWhatsThis( txtButton3
);
244 label
= new QLabel(i18n("Active"), box
);
245 grid
->addWidget(label
, 0, 1);
246 label
->setAlignment(Qt::AlignCenter
);
247 label
->setWhatsThis( i18n("In this column you can customize mouse clicks into the titlebar"
248 " or the frame of an active window.") );
250 // Titlebar and frame, active, mouse button 1
251 combo
= new QComboBox(box
);
252 grid
->addWidget(combo
, 1, 1);
253 combo
->addItem(i18n("Raise"));
254 combo
->addItem(i18n("Lower"));
255 combo
->addItem(i18n("Operations Menu"));
256 combo
->addItem(i18n("Toggle Raise & Lower"));
257 combo
->addItem(i18n("Nothing"));
258 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
261 txtButton1
= i18n("Behavior on <em>left</em> click into the titlebar or frame of an "
262 "<em>active</em> window.");
264 txtButton3
= i18n("Behavior on <em>right</em> click into the titlebar or frame of an "
265 "<em>active</em> window.");
267 // Be nice to left handed users
268 if ( leftHandedMouse
) qSwap(txtButton1
, txtButton3
);
270 combo
->setWhatsThis( txtButton1
);
272 // Titlebar and frame, active, mouse button 2
274 items
<< i18n("Raise")
276 << i18n("Operations Menu")
277 << i18n("Toggle Raise & Lower")
281 combo
= new QComboBox(box
);
282 grid
->addWidget(combo
, 2, 1);
283 combo
->addItems(items
);
284 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
286 combo
->setWhatsThis( i18n("Behavior on <em>middle</em> click into the titlebar or frame of an <em>active</em> window."));
288 // Titlebar and frame, active, mouse button 3
289 combo
= new QComboBox(box
);
290 grid
->addWidget(combo
, 3, 1);
291 combo
->addItems(items
);
292 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
294 combo
->setWhatsThis( txtButton3
);
296 txtButton1
= i18n("Behavior on <em>left</em> click into the titlebar or frame of an "
297 "<em>inactive</em> window.");
299 txtButton3
= i18n("Behavior on <em>right</em> click into the titlebar or frame of an "
300 "<em>inactive</em> window.");
302 // Be nice to left handed users
303 if ( leftHandedMouse
) qSwap(txtButton1
, txtButton3
);
305 label
= new QLabel(i18n("Inactive"), box
);
306 grid
->addWidget(label
, 0, 2);
307 label
->setAlignment(Qt::AlignCenter
);
308 label
->setWhatsThis( i18n("In this column you can customize mouse clicks into the titlebar"
309 " or the frame of an inactive window.") );
312 items
<< i18n("Activate & Raise")
313 << i18n("Activate & Lower")
316 << i18n("Operations Menu")
321 combo
= new QComboBox(box
);
322 grid
->addWidget(combo
, 1, 2);
323 combo
->addItems(items
);
324 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
326 combo
->setWhatsThis( txtButton1
);
328 combo
= new QComboBox(box
);
329 grid
->addWidget(combo
, 2, 2);
330 combo
->addItems(items
);
331 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
333 combo
->setWhatsThis( i18n("Behavior on <em>middle</em> click into the titlebar or frame of an <em>inactive</em> window."));
335 combo
= new QComboBox(box
);
336 grid
->addWidget(combo
, 3, 2);
337 combo
->addItems(items
);
338 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
340 combo
->setWhatsThis( txtButton3
);
342 /** Maximize Button ******************/
344 box
= new QGroupBox(i18n("Maximize Button"), this);
345 layout
->addWidget(box
);
346 box
->setObjectName(QString::fromLatin1("Maximize Button"));
348 i18n("Here you can customize behavior when clicking on the maximize button.") );
350 hlayout
= new QHBoxLayout(box
);
351 hlayout
->setMargin(KDialog::marginHint());
352 hlayout
->setSpacing(KDialog::spacingHint());
354 QString strMouseButton
[] = {
355 i18n("Left button:"),
356 i18n("Middle button:"),
357 i18n("Right button:")};
359 QString txtButton
[] = {
360 i18n("Behavior on <em>left</em> click onto the maximize button." ),
361 i18n("Behavior on <em>middle</em> click onto the maximize button." ),
362 i18n("Behavior on <em>right</em> click onto the maximize button." )};
364 if ( leftHandedMouse
) // Be nice to lefties
366 qSwap(strMouseButton
[0], strMouseButton
[2]);
367 qSwap(txtButton
[0], txtButton
[2]);
370 createMaxButtonPixmaps();
371 for (int b
= 0; b
< 3; ++b
)
373 if (b
!= 0) hlayout
->addItem(new QSpacerItem(5, 5, QSizePolicy::MinimumExpanding
, QSizePolicy::Minimum
)); // Spacer
375 QLabel
* label
= new QLabel(strMouseButton
[b
], box
);
376 hlayout
->addWidget(label
);
377 label
->setWhatsThis( txtButton
[b
] );
378 label
->setSizePolicy( QSizePolicy( QSizePolicy::Fixed
, QSizePolicy::Minimum
));
380 coMax
[b
] = new ToolTipComboBox(box
, tbl_Max
);
381 hlayout
->addWidget(coMax
[b
]);
382 for (int t
= 0; t
< 3; ++t
) coMax
[b
]->addItem(maxButtonPixmaps
[t
], QString());
383 connect(coMax
[b
], SIGNAL(activated(int)), SLOT(changed()));
384 connect(coMax
[b
], SIGNAL(activated(int)), coMax
[b
], SLOT(changed()));
385 coMax
[b
]->setWhatsThis( txtButton
[b
] );
386 coMax
[b
]->setSizePolicy( QSizePolicy( QSizePolicy::Fixed
, QSizePolicy::Minimum
));
389 connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), SLOT(paletteChanged()));
391 layout
->addStretch();
396 KTitleBarActionsConfig::~KTitleBarActionsConfig()
402 // do NOT change the texts below, they are written to config file
403 // and are not shown in the GUI
404 // they have to match the order of items in GUI elements though
405 const char* const tbl_TiDbl
[] = {
407 "Maximize (vertical only)",
408 "Maximize (horizontal only)",
416 const char* const tbl_TiAc
[] = {
420 "Toggle raise and lower",
425 const char* const tbl_TiInAc
[] = {
426 "Activate and raise",
427 "Activate and lower",
436 const char* const tbl_Win
[] = {
437 "Activate, raise and pass click",
438 "Activate and pass click",
440 "Activate and raise",
443 const char* const tbl_AllKey
[] = {
448 const char* const tbl_All
[] = {
450 "Activate, raise and move",
451 "Toggle raise and lower",
459 const char* tbl_TiWAc
[] = {
464 "Previous/Next Desktop",
469 const char* tbl_AllW
[] = {
474 "Previous/Next Desktop",
479 static const char* tbl_num_lookup( const char* const arr
[], int pos
)
482 arr
[ i
][ 0 ] != '\0' && pos
>= 0;
489 abort(); // should never happen this way
492 static int tbl_txt_lookup( const char* const arr
[], const char* txt
)
496 arr
[ i
][ 0 ] != '\0';
499 if( qstricmp( txt
, arr
[ i
] ) == 0 )
506 void KTitleBarActionsConfig::setComboText( QComboBox
* combo
, const char*txt
)
508 if( combo
== coTiDbl
)
509 combo
->setCurrentIndex( tbl_txt_lookup( tbl_TiDbl
, txt
));
510 else if( combo
== coTiAct1
|| combo
== coTiAct2
|| combo
== coTiAct3
)
511 combo
->setCurrentIndex( tbl_txt_lookup( tbl_TiAc
, txt
));
512 else if( combo
== coTiInAct1
|| combo
== coTiInAct2
|| combo
== coTiInAct3
)
513 combo
->setCurrentIndex( tbl_txt_lookup( tbl_TiInAc
, txt
));
514 else if( combo
== coTiAct4
)
515 combo
->setCurrentIndex( tbl_txt_lookup( tbl_TiWAc
, txt
));
516 else if( combo
== coMax
[0] || combo
== coMax
[1] || combo
== coMax
[2] )
518 combo
->setCurrentIndex( tbl_txt_lookup( tbl_Max
, txt
));
519 static_cast<ToolTipComboBox
*>(combo
)->changed();
525 const char* KTitleBarActionsConfig::functionTiDbl( int i
)
527 return tbl_num_lookup( tbl_TiDbl
, i
);
530 const char* KTitleBarActionsConfig::functionTiAc( int i
)
532 return tbl_num_lookup( tbl_TiAc
, i
);
535 const char* KTitleBarActionsConfig::functionTiInAc( int i
)
537 return tbl_num_lookup( tbl_TiInAc
, i
);
540 const char* KTitleBarActionsConfig::functionTiWAc(int i
)
542 return tbl_num_lookup( tbl_TiWAc
, i
);
545 const char* KTitleBarActionsConfig::functionMax( int i
)
547 return tbl_num_lookup( tbl_Max
, i
);
550 void KTitleBarActionsConfig::load()
552 KConfigGroup
windowsConfig(config
, "Windows");
553 setComboText(coTiDbl
, windowsConfig
.readEntry("TitlebarDoubleClickCommand","Shade").toAscii());
554 for (int t
= 0; t
< 3; ++t
)
555 setComboText(coMax
[t
],windowsConfig
.readEntry(cnf_Max
[t
], tbl_Max
[t
]).toAscii());
557 KConfigGroup
cg(config
, "MouseBindings");
558 setComboText(coTiAct1
,cg
.readEntry("CommandActiveTitlebar1","Raise").toAscii());
559 setComboText(coTiAct2
,cg
.readEntry("CommandActiveTitlebar2","Lower").toAscii());
560 setComboText(coTiAct3
,cg
.readEntry("CommandActiveTitlebar3","Operations menu").toAscii());
561 setComboText(coTiAct4
,cg
.readEntry("CommandTitlebarWheel","Nothing").toAscii());
562 setComboText(coTiInAct1
,cg
.readEntry("CommandInactiveTitlebar1","Activate and raise").toAscii());
563 setComboText(coTiInAct2
,cg
.readEntry("CommandInactiveTitlebar2","Activate and lower").toAscii());
564 setComboText(coTiInAct3
,cg
.readEntry("CommandInactiveTitlebar3","Operations menu").toAscii());
567 void KTitleBarActionsConfig::save()
569 KConfigGroup
windowsConfig(config
, "Windows");
570 windowsConfig
.writeEntry("TitlebarDoubleClickCommand", functionTiDbl( coTiDbl
->currentIndex() ) );
571 for (int t
= 0; t
< 3; ++t
)
572 windowsConfig
.writeEntry(cnf_Max
[t
], functionMax(coMax
[t
]->currentIndex()));
574 KConfigGroup
cg(config
, "MouseBindings");
575 cg
.writeEntry("CommandActiveTitlebar1", functionTiAc(coTiAct1
->currentIndex()));
576 cg
.writeEntry("CommandActiveTitlebar2", functionTiAc(coTiAct2
->currentIndex()));
577 cg
.writeEntry("CommandActiveTitlebar3", functionTiAc(coTiAct3
->currentIndex()));
578 cg
.writeEntry("CommandInactiveTitlebar1", functionTiInAc(coTiInAct1
->currentIndex()));
579 cg
.writeEntry("CommandTitlebarWheel", functionTiWAc(coTiAct4
->currentIndex()));
580 cg
.writeEntry("CommandInactiveTitlebar2", functionTiInAc(coTiInAct2
->currentIndex()));
581 cg
.writeEntry("CommandInactiveTitlebar3", functionTiInAc(coTiInAct3
->currentIndex()));
586 // Send signal to all kwin instances
587 QDBusMessage message
=
588 QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
589 QDBusConnection::sessionBus().send(message
);
594 void KTitleBarActionsConfig::defaults()
596 setComboText(coTiDbl
, "Shade");
597 setComboText(coTiAct1
,"Raise");
598 setComboText(coTiAct2
,"Lower");
599 setComboText(coTiAct3
,"Operations menu");
600 setComboText(coTiAct4
,"Nothing");
601 setComboText(coTiInAct1
,"Activate and raise");
602 setComboText(coTiInAct2
,"Activate and lower");
603 setComboText(coTiInAct3
,"Operations menu");
604 for (int t
= 0; t
< 3; ++t
)
605 setComboText(coMax
[t
], tbl_Max
[t
]);
609 KWindowActionsConfig::KWindowActionsConfig (bool _standAlone
, KConfig
*_config
, const KComponentData
&inst
, QWidget
* parent
)
610 : KCModule(inst
, parent
), config(_config
), standAlone(_standAlone
)
612 QString strWin1
, strWin2
, strWin3
, strAllKey
, strAll1
, strAll2
, strAll3
, strAllW
;
616 QString strMouseButton1
, strMouseButton3
;
617 QString txtButton1
, txtButton3
;
619 bool leftHandedMouse
= ( KGlobalSettings::mouseSettings().handed
== KGlobalSettings::KMouseSettings::LeftHanded
);
621 QVBoxLayout
*layout
= new QVBoxLayout(this);
622 layout
->setMargin(0);
623 layout
->setSpacing(KDialog::spacingHint());
625 /** Inactive inner window ******************/
627 box
= new QGroupBox(i18n("Inactive Inner Window"), this);
628 layout
->addWidget(box
);
629 box
->setObjectName(QString::fromLatin1("Inactive Inner Window"));
630 box
->setWhatsThis( i18n("Here you can customize mouse click behavior when clicking on an inactive"
631 " inner window ('inner' means: not titlebar, not frame).") );
633 grid
= new QGridLayout(box
);
634 grid
->setMargin(KDialog::marginHint());
635 grid
->setSpacing(KDialog::spacingHint());
637 strMouseButton1
= i18n("Left button:");
638 txtButton1
= i18n("In this row you can customize left click behavior when clicking into"
639 " the titlebar or the frame.");
641 strMouseButton3
= i18n("Right button:");
642 txtButton3
= i18n("In this row you can customize right click behavior when clicking into"
643 " the titlebar or the frame." );
645 if ( leftHandedMouse
)
647 qSwap(strMouseButton1
, strMouseButton3
);
648 qSwap(txtButton1
, txtButton3
);
651 strWin1
= i18n("In this row you can customize left click behavior when clicking into"
652 " an inactive inner window ('inner' means: not titlebar, not frame).");
654 strWin3
= i18n("In this row you can customize right click behavior when clicking into"
655 " an inactive inner window ('inner' means: not titlebar, not frame).");
657 // Be nice to lefties
658 if ( leftHandedMouse
) qSwap(strWin1
, strWin3
);
660 label
= new QLabel(strMouseButton1
, box
);
661 grid
->addWidget(label
, 0, 0);
662 label
->setWhatsThis( strWin1
);
664 label
= new QLabel(i18n("Middle button:"), box
);
665 grid
->addWidget(label
, 1, 0);
666 strWin2
= i18n("In this row you can customize middle click behavior when clicking into"
667 " an inactive inner window ('inner' means: not titlebar, not frame).");
668 label
->setWhatsThis( strWin2
);
670 label
= new QLabel(strMouseButton3
, box
);
671 grid
->addWidget(label
, 2, 0);
672 label
->setWhatsThis( strWin3
);
675 items
<< i18n("Activate, Raise & Pass Click")
676 << i18n("Activate & Pass Click")
678 << i18n("Activate & Raise");
680 QComboBox
* combo
= new QComboBox(box
);
681 grid
->addWidget(combo
, 0, 1);
682 combo
->addItems(items
);
683 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
685 combo
->setWhatsThis( strWin1
);
687 combo
= new QComboBox(box
);
688 grid
->addWidget(combo
, 1, 1);
689 combo
->addItems(items
);
690 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
692 combo
->setWhatsThis( strWin2
);
694 combo
= new QComboBox(box
);
695 grid
->addWidget(combo
, 2, 1);
696 combo
->addItems(items
);
697 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
699 combo
->setWhatsThis( strWin3
);
702 /** Inner window, titlebar and frame **************/
704 box
= new QGroupBox(i18n("Inner Window, Titlebar && Frame"), this);
705 layout
->addWidget(box
);
706 box
->setObjectName(QString::fromLatin1("Inner Window, Titlebar and Frame"));
707 box
->setWhatsThis( i18n("Here you can customize KDE's behavior when clicking somewhere into"
708 " a window while pressing a modifier key."));
710 grid
= new QGridLayout(box
);
711 grid
->setMargin(KDialog::marginHint());
712 grid
->setSpacing(KDialog::spacingHint());
715 label
= new QLabel(i18n("Modifier key:"), box
);
716 grid
->addWidget(label
, 0, 0);
718 strAllKey
= i18n("Here you select whether holding the Meta key or Alt key "
719 "will allow you to perform the following actions.");
720 label
->setWhatsThis( strAllKey
);
723 strMouseButton1
= i18n("Modifier key + left button:");
724 strAll1
= i18n("In this row you can customize left click behavior when clicking into"
725 " the titlebar or the frame.");
727 strMouseButton3
= i18n("Modifier key + right button:");
728 strAll3
= i18n("In this row you can customize right click behavior when clicking into"
729 " the titlebar or the frame." );
731 if ( leftHandedMouse
)
733 qSwap(strMouseButton1
, strMouseButton3
);
734 qSwap(strAll1
, strAll3
);
737 label
= new QLabel(strMouseButton1
, box
);
738 grid
->addWidget(label
, 1, 0);
739 label
->setWhatsThis( strAll1
);
741 label
= new QLabel(i18n("Modifier key + middle button:"), box
);
742 grid
->addWidget(label
, 2, 0);
743 strAll2
= i18n("Here you can customize KDE's behavior when middle clicking into a window"
744 " while pressing the modifier key.");
745 label
->setWhatsThis( strAll2
);
747 label
= new QLabel(strMouseButton3
, box
);
748 grid
->addWidget(label
, 3, 0);
749 label
->setWhatsThis( strAll3
);
751 label
= new QLabel(i18n("Modifier key + mouse wheel:"), box
);
752 grid
->addWidget(label
, 4, 0);
753 strAllW
= i18n("Here you can customize KDE's behavior when scrolling with the mouse wheel"
754 " in a window while pressing the modifier key.");
755 label
->setWhatsThis( strAllW
);
758 combo
= new QComboBox(box
);
759 grid
->addWidget(combo
, 0, 1);
760 combo
->addItem(i18n("Meta"));
761 combo
->addItem(i18n("Alt"));
762 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
764 combo
->setWhatsThis( strAllKey
);
767 items
<< i18n("Move")
768 << i18n("Activate, Raise and Move")
769 << i18n("Toggle Raise & Lower")
776 combo
= new QComboBox(box
);
777 grid
->addWidget(combo
, 1, 1);
778 combo
->addItems(items
);
779 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
781 combo
->setWhatsThis( strAll1
);
783 combo
= new QComboBox(box
);
784 grid
->addWidget(combo
, 2, 1);
785 combo
->addItems(items
);
786 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
788 combo
->setWhatsThis( strAll2
);
790 combo
= new QComboBox(box
);
791 grid
->addWidget(combo
, 3, 1);
792 combo
->addItems(items
);
793 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
795 combo
->setWhatsThis( strAll3
);
797 combo
= new QComboBox(box
);
798 grid
->addWidget(combo
, 4, 1);
799 combo
->addItem(i18n("Raise/Lower"));
800 combo
->addItem(i18n("Shade/Unshade"));
801 combo
->addItem(i18n("Maximize/Restore"));
802 combo
->addItem(i18n("Keep Above/Below"));
803 combo
->addItem(i18n("Move to Previous/Next Desktop"));
804 combo
->addItem(i18n("Change Opacity"));
805 combo
->addItem(i18n("Nothing"));
806 connect(combo
, SIGNAL(activated(int)), SLOT(changed()));
808 combo
->setWhatsThis( strAllW
);
810 layout
->addStretch();
815 KWindowActionsConfig::~KWindowActionsConfig()
821 void KWindowActionsConfig::setComboText( QComboBox
* combo
, const char*txt
)
823 if( combo
== coWin1
|| combo
== coWin2
|| combo
== coWin3
)
824 combo
->setCurrentIndex( tbl_txt_lookup( tbl_Win
, txt
));
825 else if( combo
== coAllKey
)
826 combo
->setCurrentIndex( tbl_txt_lookup( tbl_AllKey
, txt
));
827 else if( combo
== coAll1
|| combo
== coAll2
|| combo
== coAll3
)
828 combo
->setCurrentIndex( tbl_txt_lookup( tbl_All
, txt
));
829 else if( combo
== coAllW
)
830 combo
->setCurrentIndex( tbl_txt_lookup( tbl_AllW
, txt
));
835 const char* KWindowActionsConfig::functionWin( int i
)
837 return tbl_num_lookup( tbl_Win
, i
);
840 const char* KWindowActionsConfig::functionAllKey( int i
)
842 return tbl_num_lookup( tbl_AllKey
, i
);
845 const char* KWindowActionsConfig::functionAll( int i
)
847 return tbl_num_lookup( tbl_All
, i
);
850 const char* KWindowActionsConfig::functionAllW(int i
)
852 return tbl_num_lookup( tbl_AllW
, i
);
855 void KWindowActionsConfig::load()
857 KConfigGroup
cg(config
, "MouseBindings");
858 setComboText(coWin1
,cg
.readEntry("CommandWindow1","Activate, raise and pass click").toAscii());
859 setComboText(coWin2
,cg
.readEntry("CommandWindow2","Activate and pass click").toAscii());
860 setComboText(coWin3
,cg
.readEntry("CommandWindow3","Activate and pass click").toAscii());
861 setComboText(coAllKey
,cg
.readEntry("CommandAllKey","Alt").toAscii());
862 setComboText(coAll1
,cg
.readEntry("CommandAll1","Move").toAscii());
863 setComboText(coAll2
,cg
.readEntry("CommandAll2","Toggle raise and lower").toAscii());
864 setComboText(coAll3
,cg
.readEntry("CommandAll3","Resize").toAscii());
865 setComboText(coAllW
,cg
.readEntry("CommandAllWheel","Nothing").toAscii());
868 void KWindowActionsConfig::save()
870 KConfigGroup
cg(config
, "MouseBindings");
871 cg
.writeEntry("CommandWindow1", functionWin(coWin1
->currentIndex()));
872 cg
.writeEntry("CommandWindow2", functionWin(coWin2
->currentIndex()));
873 cg
.writeEntry("CommandWindow3", functionWin(coWin3
->currentIndex()));
874 cg
.writeEntry("CommandAllKey", functionAllKey(coAllKey
->currentIndex()));
875 cg
.writeEntry("CommandAll1", functionAll(coAll1
->currentIndex()));
876 cg
.writeEntry("CommandAll2", functionAll(coAll2
->currentIndex()));
877 cg
.writeEntry("CommandAll3", functionAll(coAll3
->currentIndex()));
878 cg
.writeEntry("CommandAllWheel", functionAllW(coAllW
->currentIndex()));
883 // Send signal to all kwin instances
884 QDBusMessage message
=
885 QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
886 QDBusConnection::sessionBus().send(message
);
890 void KWindowActionsConfig::defaults()
892 setComboText(coWin1
,"Activate, raise and pass click");
893 setComboText(coWin2
,"Activate and pass click");
894 setComboText(coWin3
,"Activate and pass click");
895 setComboText(coAllKey
,"Alt");
896 setComboText (coAll1
,"Move");
897 setComboText(coAll2
,"Toggle raise and lower");
898 setComboText(coAll3
,"Resize");
899 setComboText(coAllW
,"Nothing");