2004-06-22 10:07:48 +00:00
|
|
|
/*
|
2001-09-08 10:12:23 +00:00
|
|
|
* This file contains the B2 configuration widget
|
|
|
|
*
|
|
|
|
* Copyright (c) 2001
|
|
|
|
* Karol Szwed <gallium@kde.org>
|
|
|
|
* http://gallium.n3.net/
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <kglobal.h>
|
2005-07-28 14:59:42 +00:00
|
|
|
|
2005-09-18 14:52:14 +00:00
|
|
|
|
2005-07-28 14:59:42 +00:00
|
|
|
//Added by qt3to4:
|
|
|
|
#include <QLabel>
|
2001-09-08 10:12:23 +00:00
|
|
|
#include <klocale.h>
|
2005-09-18 14:52:14 +00:00
|
|
|
#include <kvbox.h>
|
2001-09-08 10:12:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
2005-01-08 22:25:07 +00:00
|
|
|
KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
|
2001-09-08 10:12:23 +00:00
|
|
|
{
|
|
|
|
return(new B2Config(conf, parent));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-22 10:07:48 +00:00
|
|
|
/* NOTE:
|
2001-09-08 10:12:23 +00:00
|
|
|
* '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
|
|
|
|
*/
|
|
|
|
|
|
|
|
B2Config::B2Config( KConfig* conf, QWidget* parent )
|
|
|
|
: QObject( parent )
|
|
|
|
{
|
2005-10-03 15:13:54 +00:00
|
|
|
KGlobal::locale()->insertCatalog("kwin_b2_config");
|
2001-09-08 10:12:23 +00:00
|
|
|
b2Config = new KConfig("kwinb2rc");
|
2005-09-18 14:52:14 +00:00
|
|
|
gb = new KVBox(parent);
|
2004-06-22 10:07:48 +00:00
|
|
|
|
|
|
|
cbColorBorder = new QCheckBox(
|
2004-05-22 00:31:07 +00:00
|
|
|
i18n("Draw window frames using &titlebar colors"), gb);
|
2005-07-28 14:59:42 +00:00
|
|
|
cbColorBorder->setWhatsThis(
|
2004-06-22 10:07:48 +00:00
|
|
|
i18n("When selected, the window borders "
|
2004-06-23 10:03:01 +00:00
|
|
|
"are drawn using the titlebar colors; otherwise, they are "
|
|
|
|
"drawn using normal border colors."));
|
2004-06-22 10:07:48 +00:00
|
|
|
|
2004-06-20 10:03:04 +00:00
|
|
|
// Grab Handle
|
|
|
|
showGrabHandleCb = new QCheckBox(
|
|
|
|
i18n("Draw &resize handle"), gb);
|
2005-07-28 14:59:42 +00:00
|
|
|
showGrabHandleCb->setWhatsThis(
|
2004-06-22 10:07:48 +00:00
|
|
|
i18n("When selected, decorations are drawn with a \"grab handle\" "
|
2004-06-23 10:03:01 +00:00
|
|
|
"in the bottom right corner of the windows; "
|
2004-06-21 14:26:49 +00:00
|
|
|
"otherwise, no grab handle is drawn."));
|
2004-06-22 10:07:48 +00:00
|
|
|
|
2004-05-22 00:31:07 +00:00
|
|
|
// Double click menu option support
|
2005-07-28 14:59:42 +00:00
|
|
|
actionsGB = new Q3GroupBox(i18n("Actions Settings"), gb);
|
|
|
|
actionsGB->setOrientation(Qt::Horizontal);
|
2004-05-22 00:31:07 +00:00
|
|
|
QLabel *menuDblClickLabel = new QLabel(actionsGB);
|
2004-06-22 10:07:48 +00:00
|
|
|
menuDblClickLabel->setText(i18n("Double click on menu button:"));
|
2004-05-22 00:31:07 +00:00
|
|
|
menuDblClickOp = new QComboBox(actionsGB);
|
2006-04-12 15:13:31 +00:00
|
|
|
menuDblClickOp->addItem(i18n("Do Nothing"));
|
|
|
|
menuDblClickOp->addItem(i18n("Minimize Window"));
|
|
|
|
menuDblClickOp->addItem(i18n("Shade Window"));
|
|
|
|
menuDblClickOp->addItem(i18n("Close Window"));
|
2004-06-22 10:07:48 +00:00
|
|
|
|
2005-07-28 14:59:42 +00:00
|
|
|
menuDblClickOp->setWhatsThis(
|
2004-06-22 10:07:48 +00:00
|
|
|
i18n("An action can be associated to a double click "
|
2004-05-22 00:31:07 +00:00
|
|
|
"of the menu button. Leave it to none if in doubt."));
|
2004-06-20 10:03:04 +00:00
|
|
|
|
2001-09-08 10:12:23 +00:00
|
|
|
// Load configuration options
|
2004-05-22 00:31:07 +00:00
|
|
|
load(conf);
|
2001-09-08 10:12:23 +00:00
|
|
|
|
|
|
|
// Ensure we track user changes properly
|
2004-06-22 10:07:48 +00:00
|
|
|
connect(cbColorBorder, SIGNAL(clicked()),
|
2004-05-22 00:31:07 +00:00
|
|
|
this, SLOT(slotSelectionChanged()));
|
2004-06-22 10:07:48 +00:00
|
|
|
connect(showGrabHandleCb, SIGNAL(clicked()),
|
2004-06-20 10:03:04 +00:00
|
|
|
this, SLOT(slotSelectionChanged()));
|
2004-06-22 10:07:48 +00:00
|
|
|
connect(menuDblClickOp, SIGNAL(activated(int)),
|
2004-05-22 00:31:07 +00:00
|
|
|
this, SLOT(slotSelectionChanged()));
|
2001-09-08 10:12:23 +00:00
|
|
|
// Make the widgets visible in kwindecoration
|
|
|
|
gb->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
B2Config::~B2Config()
|
|
|
|
{
|
2004-05-22 00:31:07 +00:00
|
|
|
delete b2Config;
|
2001-09-08 10:12:23 +00:00
|
|
|
delete gb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void B2Config::slotSelectionChanged()
|
|
|
|
{
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Loads the configurable options from the kwinrc config file
|
|
|
|
// It is passed the open config from kwindecoration to improve efficiency
|
2004-05-22 00:31:07 +00:00
|
|
|
void B2Config::load(KConfig * /*conf*/)
|
2001-09-08 10:12:23 +00:00
|
|
|
{
|
2007-02-21 02:59:04 +00:00
|
|
|
KConfigGroup cg(b2Config, "General");
|
2004-06-22 10:07:48 +00:00
|
|
|
|
2007-02-21 02:59:04 +00:00
|
|
|
bool override = cg.readEntry("UseTitleBarBorderColors", false);
|
|
|
|
cbColorBorder->setChecked(override);
|
2004-06-22 10:07:48 +00:00
|
|
|
|
2007-02-21 02:59:04 +00:00
|
|
|
override = cg.readEntry( "DrawGrabHandle", true);
|
2004-06-20 10:03:04 +00:00
|
|
|
showGrabHandleCb->setChecked(override);
|
|
|
|
|
2007-02-21 02:59:04 +00:00
|
|
|
QString returnString = cg.readEntry(
|
2004-05-22 00:31:07 +00:00
|
|
|
"MenuButtonDoubleClickOperation", "NoOp");
|
2004-06-22 10:07:48 +00:00
|
|
|
|
2004-05-22 00:31:07 +00:00
|
|
|
int op;
|
|
|
|
if (returnString == "Close") {
|
|
|
|
op = 3;
|
|
|
|
} else if (returnString == "Shade") {
|
|
|
|
op = 2;
|
|
|
|
} else if (returnString == "Minimize") {
|
|
|
|
op = 1;
|
|
|
|
} else {
|
|
|
|
op = 0;
|
|
|
|
}
|
|
|
|
|
2006-03-06 16:25:27 +00:00
|
|
|
menuDblClickOp->setCurrentIndex(op);
|
2004-05-22 00:31:07 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-06-22 10:07:48 +00:00
|
|
|
static QString opToString(int op)
|
2004-05-22 00:31:07 +00:00
|
|
|
{
|
|
|
|
switch (op) {
|
|
|
|
case 1:
|
|
|
|
return "Minimize";
|
|
|
|
case 2:
|
|
|
|
return "Shade";
|
|
|
|
case 3:
|
|
|
|
return "Close";
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
return "NoOp";
|
|
|
|
}
|
2001-09-08 10:12:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Saves the configurable options to the kwinrc config file
|
2004-05-22 00:31:07 +00:00
|
|
|
void B2Config::save(KConfig * /*conf*/)
|
2001-09-08 10:12:23 +00:00
|
|
|
{
|
2007-02-21 02:59:04 +00:00
|
|
|
KConfigGroup cg(b2Config, "General");
|
|
|
|
cg.writeEntry("UseTitleBarBorderColors", cbColorBorder->isChecked());
|
|
|
|
cg.writeEntry("DrawGrabHandle", showGrabHandleCb->isChecked());
|
|
|
|
cg.writeEntry("MenuButtonDoubleClickOperation",
|
|
|
|
opToString(menuDblClickOp->currentIndex()));
|
|
|
|
// Ensure others trying to read this config get updated
|
|
|
|
b2Config->sync();
|
2001-09-08 10:12:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Sets UI widget defaults which must correspond to style defaults
|
|
|
|
void B2Config::defaults()
|
|
|
|
{
|
2004-06-20 10:03:04 +00:00
|
|
|
cbColorBorder->setChecked(false);
|
|
|
|
showGrabHandleCb->setChecked(true);
|
2006-03-06 16:25:27 +00:00
|
|
|
menuDblClickOp->setCurrentIndex(0);
|
2001-09-08 10:12:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "config.moc"
|
|
|
|
// vim: ts=4
|