Fix B2 config layout, make it Qt3-free and reindent the sources
svn path=/trunk/KDE/kdebase/workspace/; revision=673175
This commit is contained in:
parent
51107c77b7
commit
768109dcf6
3 changed files with 81 additions and 78 deletions
|
@ -11,7 +11,7 @@ kde4_add_plugin(kwin_b2_config ${kwin_b2_config_PART_SRCS})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
target_link_libraries(kwin_b2_config ${KDE4_KDEUI_LIBS} ${QT_QT3SUPPORT_LIBRARY} ${QT_QTGUI_LIBRARY})
|
target_link_libraries(kwin_b2_config ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY})
|
||||||
|
|
||||||
install(TARGETS kwin_b2_config DESTINATION ${PLUGIN_INSTALL_DIR} )
|
install(TARGETS kwin_b2_config DESTINATION ${PLUGIN_INSTALL_DIR} )
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
* Copyright (c) 2001
|
* Copyright (c) 2001
|
||||||
* Karol Szwed <gallium@kde.org>
|
* Karol Szwed <gallium@kde.org>
|
||||||
* http://gallium.n3.net/
|
* http://gallium.n3.net/
|
||||||
|
* Copyright (c) 2007
|
||||||
|
* Luciano Montanaro <mikelima@cirulla.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -12,19 +14,17 @@
|
||||||
|
|
||||||
//Added by qt3to4:
|
//Added by qt3to4:
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QSpacerItem>
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <kvbox.h>
|
#include <kvbox.h>
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
extern "C" KDE_EXPORT QObject *allocate_config(KConfig *conf, QWidget *parent)
|
||||||
{
|
{
|
||||||
KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
|
return(new B2Config(conf, parent));
|
||||||
{
|
|
||||||
return(new B2Config(conf, parent));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* NOTE:
|
/* NOTE:
|
||||||
* 'conf' is a pointer to the kwindecoration modules open kwin config,
|
* 'conf' is a pointer to the kwindecoration modules open kwin config,
|
||||||
* and is by default set to the "Style" group.
|
* and is by default set to the "Style" group.
|
||||||
|
@ -33,31 +33,31 @@ extern "C"
|
||||||
* Configure tab in kwindecoration
|
* Configure tab in kwindecoration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
B2Config::B2Config( KConfig* conf, QWidget* parent )
|
B2Config::B2Config(KConfig *conf, QWidget *parent)
|
||||||
: QObject( parent )
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
KGlobal::locale()->insertCatalog("kwin_b2_config");
|
KGlobal::locale()->insertCatalog("kwin_b2_config");
|
||||||
b2Config = new KConfig("kwinb2rc");
|
b2Config = new KConfig("kwinb2rc");
|
||||||
gb = new KVBox(parent);
|
gb = new KVBox(parent);
|
||||||
|
|
||||||
cbColorBorder = new QCheckBox(
|
cbColorBorder = new QCheckBox(
|
||||||
i18n("Draw window frames using &titlebar colors"), gb);
|
i18n("Draw window frames using &titlebar colors"), gb);
|
||||||
cbColorBorder->setWhatsThis(
|
cbColorBorder->setWhatsThis(
|
||||||
i18n("When selected, the window borders "
|
i18n("When selected, the window borders "
|
||||||
"are drawn using the titlebar colors; otherwise, they are "
|
"are drawn using the titlebar colors; otherwise, they are "
|
||||||
"drawn using normal border colors."));
|
"drawn using normal border colors."));
|
||||||
|
|
||||||
// Grab Handle
|
// Grab Handle
|
||||||
showGrabHandleCb = new QCheckBox(
|
showGrabHandleCb = new QCheckBox(
|
||||||
i18n("Draw &resize handle"), gb);
|
i18n("Draw &resize handle"), gb);
|
||||||
showGrabHandleCb->setWhatsThis(
|
showGrabHandleCb->setWhatsThis(
|
||||||
i18n("When selected, decorations are drawn with a \"grab handle\" "
|
i18n("When selected, decorations are drawn with a \"grab handle\" "
|
||||||
"in the bottom right corner of the windows; "
|
"in the bottom right corner of the windows; "
|
||||||
"otherwise, no grab handle is drawn."));
|
"otherwise, no grab handle is drawn."));
|
||||||
|
|
||||||
// Double click menu option support
|
// Double click menu option support
|
||||||
actionsGB = new Q3GroupBox(i18n("Actions Settings"), gb);
|
actionsGB = new QGroupBox(i18n("Actions Settings"), gb);
|
||||||
actionsGB->setOrientation(Qt::Horizontal);
|
//actionsGB->setOrientation(Qt::Horizontal);
|
||||||
QLabel *menuDblClickLabel = new QLabel(actionsGB);
|
QLabel *menuDblClickLabel = new QLabel(actionsGB);
|
||||||
menuDblClickLabel->setText(i18n("Double click on menu button:"));
|
menuDblClickLabel->setText(i18n("Double click on menu button:"));
|
||||||
menuDblClickOp = new QComboBox(actionsGB);
|
menuDblClickOp = new QComboBox(actionsGB);
|
||||||
|
@ -68,37 +68,41 @@ B2Config::B2Config( KConfig* conf, QWidget* parent )
|
||||||
|
|
||||||
menuDblClickOp->setWhatsThis(
|
menuDblClickOp->setWhatsThis(
|
||||||
i18n("An action can be associated to a double click "
|
i18n("An action can be associated to a double click "
|
||||||
"of the menu button. Leave it to none if in doubt."));
|
"of the menu button. Leave it to none if in doubt."));
|
||||||
|
|
||||||
// Load configuration options
|
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
|
||||||
KConfigGroup cg(b2Config, "General");
|
KConfigGroup cg(b2Config, "General");
|
||||||
load(cg);
|
load(cg);
|
||||||
|
|
||||||
// Ensure we track user changes properly
|
// Ensure we track user changes properly
|
||||||
connect(cbColorBorder, SIGNAL(clicked()),
|
connect(cbColorBorder, SIGNAL(clicked()),
|
||||||
this, SLOT(slotSelectionChanged()));
|
this, SLOT(slotSelectionChanged()));
|
||||||
connect(showGrabHandleCb, SIGNAL(clicked()),
|
connect(showGrabHandleCb, SIGNAL(clicked()),
|
||||||
this, SLOT(slotSelectionChanged()));
|
this, SLOT(slotSelectionChanged()));
|
||||||
connect(menuDblClickOp, SIGNAL(activated(int)),
|
connect(menuDblClickOp, SIGNAL(activated(int)),
|
||||||
this, SLOT(slotSelectionChanged()));
|
this, SLOT(slotSelectionChanged()));
|
||||||
// Make the widgets visible in kwindecoration
|
// Make the widgets visible in kwindecoration
|
||||||
gb->show();
|
gb->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
B2Config::~B2Config()
|
B2Config::~B2Config()
|
||||||
{
|
{
|
||||||
delete b2Config;
|
delete b2Config;
|
||||||
delete gb;
|
delete gb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void B2Config::slotSelectionChanged()
|
void B2Config::slotSelectionChanged()
|
||||||
{
|
{
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Loads the configurable options from the kwinrc config file
|
// Loads the configurable options from the kwinrc config file
|
||||||
// It is passed the open config from kwindecoration to improve efficiency
|
// It is passed the open config from kwindecoration to improve efficiency
|
||||||
void B2Config::load(const KConfigGroup & /*conf*/)
|
void B2Config::load(const KConfigGroup & /*conf*/)
|
||||||
|
@ -108,43 +112,41 @@ void B2Config::load(const KConfigGroup & /*conf*/)
|
||||||
bool override = cg.readEntry("UseTitleBarBorderColors", false);
|
bool override = cg.readEntry("UseTitleBarBorderColors", false);
|
||||||
cbColorBorder->setChecked(override);
|
cbColorBorder->setChecked(override);
|
||||||
|
|
||||||
override = cg.readEntry( "DrawGrabHandle", true);
|
override = cg.readEntry("DrawGrabHandle", true);
|
||||||
showGrabHandleCb->setChecked(override);
|
showGrabHandleCb->setChecked(override);
|
||||||
|
|
||||||
QString returnString = cg.readEntry(
|
QString returnString = cg.readEntry(
|
||||||
"MenuButtonDoubleClickOperation", "NoOp");
|
"MenuButtonDoubleClickOperation", "NoOp");
|
||||||
|
|
||||||
int op;
|
int op;
|
||||||
if (returnString == "Close") {
|
if (returnString == "Close") {
|
||||||
op = 3;
|
op = 3;
|
||||||
} else if (returnString == "Shade") {
|
} else if (returnString == "Shade") {
|
||||||
op = 2;
|
op = 2;
|
||||||
} else if (returnString == "Minimize") {
|
} else if (returnString == "Minimize") {
|
||||||
op = 1;
|
op = 1;
|
||||||
} else {
|
} else {
|
||||||
op = 0;
|
op = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
menuDblClickOp->setCurrentIndex(op);
|
menuDblClickOp->setCurrentIndex(op);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString opToString(int op)
|
static QString opToString(int op)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case 1:
|
case 1:
|
||||||
return "Minimize";
|
return "Minimize";
|
||||||
case 2:
|
case 2:
|
||||||
return "Shade";
|
return "Shade";
|
||||||
case 3:
|
case 3:
|
||||||
return "Close";
|
return "Close";
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
return "NoOp";
|
return "NoOp";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Saves the configurable options to the kwinrc config file
|
// Saves the configurable options to the kwinrc config file
|
||||||
void B2Config::save(KConfigGroup & /*conf*/)
|
void B2Config::save(KConfigGroup & /*conf*/)
|
||||||
{
|
{
|
||||||
|
@ -152,19 +154,18 @@ void B2Config::save(KConfigGroup & /*conf*/)
|
||||||
cg.writeEntry("UseTitleBarBorderColors", cbColorBorder->isChecked());
|
cg.writeEntry("UseTitleBarBorderColors", cbColorBorder->isChecked());
|
||||||
cg.writeEntry("DrawGrabHandle", showGrabHandleCb->isChecked());
|
cg.writeEntry("DrawGrabHandle", showGrabHandleCb->isChecked());
|
||||||
cg.writeEntry("MenuButtonDoubleClickOperation",
|
cg.writeEntry("MenuButtonDoubleClickOperation",
|
||||||
opToString(menuDblClickOp->currentIndex()));
|
opToString(menuDblClickOp->currentIndex()));
|
||||||
// Ensure others trying to read this config get updated
|
// Ensure others trying to read this config get updated
|
||||||
b2Config->sync();
|
b2Config->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sets UI widget defaults which must correspond to style defaults
|
// Sets UI widget defaults which must correspond to style defaults
|
||||||
void B2Config::defaults()
|
void B2Config::defaults()
|
||||||
{
|
{
|
||||||
cbColorBorder->setChecked(false);
|
cbColorBorder->setChecked(false);
|
||||||
showGrabHandleCb->setChecked(true);
|
showGrabHandleCb->setChecked(true);
|
||||||
menuDblClickOp->setCurrentIndex(0);
|
menuDblClickOp->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "config.moc"
|
#include "config.moc"
|
||||||
// vim: ts=4
|
// vi: sw=4 ts=8
|
||||||
|
|
|
@ -4,46 +4,48 @@
|
||||||
* Copyright (c) 2001
|
* Copyright (c) 2001
|
||||||
* Karol Szwed <gallium@kde.org>
|
* Karol Szwed <gallium@kde.org>
|
||||||
* http://gallium.n3.net/
|
* http://gallium.n3.net/
|
||||||
|
* Copyright (c) 2007
|
||||||
|
* Luciano Montanaro <mikelima@cirulla.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _KDE_B2CONFIG_H
|
#ifndef _KDE_B2CONFIG_H
|
||||||
#define _KDE_B2CONFIG_H
|
#define _KDE_B2CONFIG_H
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <q3groupbox.h>
|
#include <QGroupBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <kconfig.h>
|
#include <kconfig.h>
|
||||||
|
|
||||||
class B2Config: public QObject
|
class B2Config: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
B2Config( KConfig* conf, QWidget* parent );
|
B2Config(KConfig *conf, QWidget *parent);
|
||||||
~B2Config();
|
~B2Config();
|
||||||
|
|
||||||
// These public signals/slots work similar to KCM modules
|
// These public signals/slots work similar to KCM modules
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void load( const KConfigGroup& conf );
|
void load(const KConfigGroup &conf);
|
||||||
void save( KConfigGroup& conf );
|
void save(KConfigGroup &conf);
|
||||||
void defaults();
|
void defaults();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void slotSelectionChanged(); // Internal use
|
void slotSelectionChanged(); // Internal use
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KConfig* b2Config;
|
KConfig *b2Config;
|
||||||
QCheckBox* cbColorBorder;
|
QCheckBox *cbColorBorder;
|
||||||
QCheckBox* showGrabHandleCb;
|
QCheckBox *showGrabHandleCb;
|
||||||
Q3GroupBox* actionsGB;
|
QGroupBox *actionsGB;
|
||||||
QComboBox* menuDblClickOp;
|
QComboBox *menuDblClickOp;
|
||||||
QWidget* gb;
|
QWidget *gb;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// vim: ts=4
|
// vi: sw=4 ts=8
|
||||||
|
|
Loading…
Reference in a new issue