2007-04-29 17:35:43 +00:00
|
|
|
/*
|
|
|
|
* This file contains the B2 configuration widget
|
|
|
|
*
|
|
|
|
* Copyright (c) 2001
|
|
|
|
* Karol Szwed <gallium@kde.org>
|
|
|
|
* http://gallium.n3.net/
|
2007-06-09 08:38:23 +00:00
|
|
|
* Copyright (c) 2007
|
|
|
|
* Luciano Montanaro <mikelima@cirulla.net>
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <kglobal.h>
|
|
|
|
|
|
|
|
|
|
|
|
//Added by qt3to4:
|
|
|
|
#include <QLabel>
|
2007-06-09 08:38:23 +00:00
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QSpacerItem>
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <klocale.h>
|
|
|
|
#include <kvbox.h>
|
|
|
|
|
|
|
|
|
2007-06-09 08:38:23 +00:00
|
|
|
extern "C" KDE_EXPORT QObject *allocate_config(KConfig *conf, QWidget *parent)
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2007-06-09 08:38:23 +00:00
|
|
|
return(new B2Config(conf, parent));
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTE:
|
|
|
|
* 'conf' is a pointer to the kwindecoration modules open kwin config,
|
|
|
|
* and is by default set to the "Style" group.
|
|
|
|
*
|
|
|
|
* 'parent' is the parent of the QObject, which is a VBox inside the
|
|
|
|
* Configure tab in kwindecoration
|
|
|
|
*/
|
|
|
|
|
2007-06-09 08:38:23 +00:00
|
|
|
B2Config::B2Config(KConfig *conf, QWidget *parent)
|
|
|
|
: QObject(parent)
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2007-06-09 08:38:23 +00:00
|
|
|
KGlobal::locale()->insertCatalog("kwin_b2_config");
|
|
|
|
b2Config = new KConfig("kwinb2rc");
|
|
|
|
gb = new KVBox(parent);
|
|
|
|
|
|
|
|
cbColorBorder = new QCheckBox(
|
|
|
|
i18n("Draw window frames using &titlebar colors"), gb);
|
|
|
|
cbColorBorder->setWhatsThis(
|
|
|
|
i18n("When selected, the window borders "
|
|
|
|
"are drawn using the titlebar colors; otherwise, they are "
|
|
|
|
"drawn using normal border colors."));
|
|
|
|
|
|
|
|
// Grab Handle
|
2007-04-29 17:35:43 +00:00
|
|
|
showGrabHandleCb = new QCheckBox(
|
|
|
|
i18n("Draw &resize handle"), gb);
|
|
|
|
showGrabHandleCb->setWhatsThis(
|
|
|
|
i18n("When selected, decorations are drawn with a \"grab handle\" "
|
2007-06-09 08:38:23 +00:00
|
|
|
"in the bottom right corner of the windows; "
|
|
|
|
"otherwise, no grab handle is drawn."));
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// Double click menu option support
|
2007-06-09 08:38:23 +00:00
|
|
|
actionsGB = new QGroupBox(i18n("Actions Settings"), gb);
|
|
|
|
//actionsGB->setOrientation(Qt::Horizontal);
|
2007-04-29 17:35:43 +00:00
|
|
|
QLabel *menuDblClickLabel = new QLabel(actionsGB);
|
|
|
|
menuDblClickLabel->setText(i18n("Double click on menu button:"));
|
|
|
|
menuDblClickOp = new QComboBox(actionsGB);
|
|
|
|
menuDblClickOp->addItem(i18n("Do Nothing"));
|
|
|
|
menuDblClickOp->addItem(i18n("Minimize Window"));
|
|
|
|
menuDblClickOp->addItem(i18n("Shade Window"));
|
|
|
|
menuDblClickOp->addItem(i18n("Close Window"));
|
|
|
|
|
|
|
|
menuDblClickOp->setWhatsThis(
|
|
|
|
i18n("An action can be associated to a double click "
|
2007-06-09 08:38:23 +00:00
|
|
|
"of the menu button. Leave it to none if in doubt."));
|
|
|
|
|
|
|
|
QGridLayout *actionsLayout = new QGridLayout();
|
|
|
|
QSpacerItem *actionsSpacer = new QSpacerItem(8, 8,
|
|
|
|
QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
actionsLayout->addWidget(menuDblClickLabel, 0, 0, Qt::AlignRight);
|
|
|
|
actionsLayout->addWidget(menuDblClickOp, 0, 1);
|
|
|
|
actionsLayout->addItem(actionsSpacer, 0, 2);
|
|
|
|
actionsGB->setLayout(actionsLayout);
|
|
|
|
// Load configuration options
|
2007-05-11 15:49:22 +00:00
|
|
|
KConfigGroup cg(b2Config, "General");
|
2007-06-09 08:38:23 +00:00
|
|
|
load(cg);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-06-09 08:38:23 +00:00
|
|
|
// Ensure we track user changes properly
|
|
|
|
connect(cbColorBorder, SIGNAL(clicked()),
|
|
|
|
this, SLOT(slotSelectionChanged()));
|
2007-04-29 17:35:43 +00:00
|
|
|
connect(showGrabHandleCb, SIGNAL(clicked()),
|
2007-06-09 08:38:23 +00:00
|
|
|
this, SLOT(slotSelectionChanged()));
|
2007-04-29 17:35:43 +00:00
|
|
|
connect(menuDblClickOp, SIGNAL(activated(int)),
|
2007-06-09 08:38:23 +00:00
|
|
|
this, SLOT(slotSelectionChanged()));
|
|
|
|
// Make the widgets visible in kwindecoration
|
|
|
|
gb->show();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
B2Config::~B2Config()
|
|
|
|
{
|
|
|
|
delete b2Config;
|
2007-06-09 08:38:23 +00:00
|
|
|
delete gb;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void B2Config::slotSelectionChanged()
|
|
|
|
{
|
2007-06-09 08:38:23 +00:00
|
|
|
emit changed();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Loads the configurable options from the kwinrc config file
|
|
|
|
// It is passed the open config from kwindecoration to improve efficiency
|
2007-05-11 15:49:22 +00:00
|
|
|
void B2Config::load(const KConfigGroup & /*conf*/)
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
KConfigGroup cg(b2Config, "General");
|
|
|
|
|
|
|
|
bool override = cg.readEntry("UseTitleBarBorderColors", false);
|
|
|
|
cbColorBorder->setChecked(override);
|
|
|
|
|
2007-06-09 08:38:23 +00:00
|
|
|
override = cg.readEntry("DrawGrabHandle", true);
|
2007-04-29 17:35:43 +00:00
|
|
|
showGrabHandleCb->setChecked(override);
|
|
|
|
|
|
|
|
QString returnString = cg.readEntry(
|
2007-06-09 08:38:23 +00:00
|
|
|
"MenuButtonDoubleClickOperation", "NoOp");
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int op;
|
|
|
|
if (returnString == "Close") {
|
2007-06-09 08:38:23 +00:00
|
|
|
op = 3;
|
|
|
|
} else if (returnString == "Shade") {
|
|
|
|
op = 2;
|
2007-04-29 17:35:43 +00:00
|
|
|
} else if (returnString == "Minimize") {
|
2007-06-09 08:38:23 +00:00
|
|
|
op = 1;
|
2007-04-29 17:35:43 +00:00
|
|
|
} else {
|
2007-06-09 08:38:23 +00:00
|
|
|
op = 0;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
menuDblClickOp->setCurrentIndex(op);
|
|
|
|
}
|
|
|
|
|
|
|
|
static QString opToString(int op)
|
|
|
|
{
|
|
|
|
switch (op) {
|
|
|
|
case 1:
|
2007-06-09 08:38:23 +00:00
|
|
|
return "Minimize";
|
2007-04-29 17:35:43 +00:00
|
|
|
case 2:
|
2007-06-09 08:38:23 +00:00
|
|
|
return "Shade";
|
2007-04-29 17:35:43 +00:00
|
|
|
case 3:
|
2007-06-09 08:38:23 +00:00
|
|
|
return "Close";
|
2007-04-29 17:35:43 +00:00
|
|
|
case 0:
|
|
|
|
default:
|
2007-06-09 08:38:23 +00:00
|
|
|
return "NoOp";
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Saves the configurable options to the kwinrc config file
|
2007-05-11 15:49:22 +00:00
|
|
|
void B2Config::save(KConfigGroup & /*conf*/)
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
KConfigGroup cg(b2Config, "General");
|
|
|
|
cg.writeEntry("UseTitleBarBorderColors", cbColorBorder->isChecked());
|
|
|
|
cg.writeEntry("DrawGrabHandle", showGrabHandleCb->isChecked());
|
2007-06-09 08:38:23 +00:00
|
|
|
cg.writeEntry("MenuButtonDoubleClickOperation",
|
|
|
|
opToString(menuDblClickOp->currentIndex()));
|
2007-04-29 17:35:43 +00:00
|
|
|
// Ensure others trying to read this config get updated
|
|
|
|
b2Config->sync();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sets UI widget defaults which must correspond to style defaults
|
|
|
|
void B2Config::defaults()
|
|
|
|
{
|
2007-06-09 08:38:23 +00:00
|
|
|
cbColorBorder->setChecked(false);
|
2007-04-29 17:35:43 +00:00
|
|
|
showGrabHandleCb->setChecked(true);
|
|
|
|
menuDblClickOp->setCurrentIndex(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "config.moc"
|
2007-06-09 08:38:23 +00:00
|
|
|
// vi: sw=4 ts=8
|