1
/********************************************************************
2
This file contains the B2 configuration widget
5
Karol Szwed <gallium@kde.org>
8
Luciano Montanaro <mikelima@cirulla.net>
9
Automove titlebar bits Copyright (c) 2009 Jussi Kekkonen <tmt@ubuntu.com>
11
This program is free software; you can redistribute it and/or modify
12
it under the terms of the GNU General Public License as published by
13
the Free Software Foundation; either version 2 of the License, or
14
(at your option) any later version.
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU General Public License for more details.
21
You should have received a copy of the GNU General Public License
22
along with this program. If not, see <http://www.gnu.org/licenses/>.
23
*********************************************************************/
27
#include <kconfiggroup.h>
31
#include <QGridLayout>
32
#include <QSpacerItem>
37
extern "C" KDE_EXPORT QObject *allocate_config(KConfig *conf, QWidget *parent)
39
return(new B2Config(conf, parent));
43
* 'conf' is a pointer to the kwindecoration modules open kwin config,
44
* and is by default set to the "Style" group.
46
* 'parent' is the parent of the QObject, which is a VBox inside the
47
* Configure tab in kwindecoration
50
B2Config::B2Config(KConfig *conf, QWidget *parent)
54
KGlobal::locale()->insertCatalog("kwin_b2_config");
55
b2Config = new KConfig("kwinb2rc");
56
gb = new KVBox(parent);
58
cbColorBorder = new QCheckBox(
59
i18n("Draw window frames using &titlebar colors"), gb);
60
cbColorBorder->setWhatsThis(
61
i18n("When selected, the window borders "
62
"are drawn using the titlebar colors; otherwise, they are "
63
"drawn using normal border colors."));
66
showGrabHandleCb = new QCheckBox(
67
i18n("Draw &resize handle"), gb);
68
showGrabHandleCb->setWhatsThis(
69
i18n("When selected, decorations are drawn with a \"grab handle\" "
70
"in the bottom right corner of the windows; "
71
"otherwise, no grab handle is drawn."));
74
autoMoveTitlebarCb = new QCheckBox(
75
i18n("Auto-move titlebar"), gb);
76
autoMoveTitlebarCb->setWhatsThis(
77
i18n("When selected, titlebars are automatically relocated "
78
"to visible positions; "
79
"otherwise, they are only moved manually using shift+drag."));
81
// Double click menu option support
82
actionsGB = new QGroupBox(i18n("Actions Settings"), gb);
83
//actionsGB->setOrientation(Qt::Horizontal);
84
QLabel *menuDblClickLabel = new QLabel(actionsGB);
85
menuDblClickLabel->setText(i18n("Double click on menu button:"));
86
menuDblClickOp = new KComboBox(actionsGB);
87
menuDblClickOp->addItem(i18n("Do Nothing"));
88
menuDblClickOp->addItem(i18n("Minimize Window"));
89
menuDblClickOp->addItem(i18n("Shade Window"));
90
menuDblClickOp->addItem(i18n("Close Window"));
92
menuDblClickOp->setWhatsThis(
93
i18n("An action can be associated to a double click "
94
"of the menu button. Leave it to none if in doubt."));
96
QGridLayout *actionsLayout = new QGridLayout();
97
QSpacerItem *actionsSpacer = new QSpacerItem(8, 8,
98
QSizePolicy::Expanding, QSizePolicy::Fixed);
99
actionsLayout->addWidget(menuDblClickLabel, 0, 0, Qt::AlignRight);
100
actionsLayout->addWidget(menuDblClickOp, 0, 1);
101
actionsLayout->addItem(actionsSpacer, 0, 2);
102
actionsGB->setLayout(actionsLayout);
103
// Load configuration options
104
KConfigGroup cg(b2Config, "General");
107
// Ensure we track user changes properly
108
connect(cbColorBorder, SIGNAL(clicked()),
109
this, SLOT(slotSelectionChanged()));
110
connect(showGrabHandleCb, SIGNAL(clicked()),
111
this, SLOT(slotSelectionChanged()));
112
connect(autoMoveTitlebarCb, SIGNAL(clicked()),
113
this, SLOT(slotSelectionChanged()));
114
connect(menuDblClickOp, SIGNAL(activated(int)),
115
this, SLOT(slotSelectionChanged()));
116
// Make the widgets visible in kwindecoration
120
B2Config::~B2Config()
126
void B2Config::slotSelectionChanged()
131
// Loads the configurable options from the kwinrc config file
132
// It is passed the open config from kwindecoration to improve efficiency
133
void B2Config::load(const KConfigGroup & /*conf*/)
135
KConfigGroup cg(b2Config, "General");
137
bool override = cg.readEntry("UseTitleBarBorderColors", false);
138
cbColorBorder->setChecked(override);
140
override = cg.readEntry("DrawGrabHandle", true);
141
showGrabHandleCb->setChecked(override);
143
override = cg.readEntry( "AutoMoveTitleBar", true );
144
autoMoveTitlebarCb->setChecked(override);
146
QString returnString = cg.readEntry(
147
"MenuButtonDoubleClickOperation", "NoOp");
150
if (returnString == "Close") {
152
} else if (returnString == "Shade") {
154
} else if (returnString == "Minimize") {
160
menuDblClickOp->setCurrentIndex(op);
163
static QString opToString(int op)
178
// Saves the configurable options to the kwinrc config file
179
void B2Config::save(KConfigGroup & /*conf*/)
181
KConfigGroup cg(b2Config, "General");
182
cg.writeEntry("UseTitleBarBorderColors", cbColorBorder->isChecked());
183
cg.writeEntry("DrawGrabHandle", showGrabHandleCb->isChecked());
184
cg.writeEntry("AutoMoveTitleBar", autoMoveTitlebarCb->isChecked());
185
cg.writeEntry("MenuButtonDoubleClickOperation",
186
opToString(menuDblClickOp->currentIndex()));
187
// Ensure others trying to read this config get updated
191
// Sets UI widget defaults which must correspond to style defaults
192
void B2Config::defaults()
194
cbColorBorder->setChecked(false);
195
showGrabHandleCb->setChecked(true);
196
autoMoveTitlebarCb->setChecked(true);
197
menuDblClickOp->setCurrentIndex(0);
200
#include "config.moc"