2003-02-03 11:55:34 +00:00
|
|
|
// Melchior FRANZ <mfranz@kde.org> -- 2001-04-22
|
2001-06-19 15:26:48 +00:00
|
|
|
|
2003-02-03 11:55:34 +00:00
|
|
|
#include <kapplication.h>
|
2001-06-19 15:26:48 +00:00
|
|
|
#include <kconfig.h>
|
2003-06-30 08:16:28 +00:00
|
|
|
#include <kdialog.h>
|
2001-06-19 15:26:48 +00:00
|
|
|
#include <klocale.h>
|
2001-07-15 12:14:54 +00:00
|
|
|
#include <kglobal.h>
|
2003-06-30 08:16:28 +00:00
|
|
|
#include <qlayout.h>
|
2001-06-19 15:26:48 +00:00
|
|
|
#include <qwhatsthis.h>
|
2001-10-10 10:50:07 +00:00
|
|
|
#include "config.h"
|
2001-06-19 15:26:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
2005-01-06 22:37:53 +00:00
|
|
|
QObject* KDE_EXPORT allocate_config(KConfig* conf, QWidget* parent)
|
2001-06-19 15:26:48 +00:00
|
|
|
{
|
|
|
|
return(new ModernSysConfig(conf, parent));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-10 10:50:07 +00:00
|
|
|
// 'conf' is a pointer to the kwindecoration modules open kwin config,
|
|
|
|
// and is by default set to the "Style" group.
|
2001-06-19 15:26:48 +00:00
|
|
|
//
|
|
|
|
// 'parent' is the parent of the QObject, which is a VBox inside the
|
2001-10-10 10:50:07 +00:00
|
|
|
// Configure tab in kwindecoration
|
2001-06-19 15:26:48 +00:00
|
|
|
|
|
|
|
ModernSysConfig::ModernSysConfig(KConfig* conf, QWidget* parent) : QObject(parent)
|
|
|
|
{
|
|
|
|
clientrc = new KConfig("kwinmodernsysrc");
|
2004-09-20 11:20:12 +00:00
|
|
|
KGlobal::locale()->insertCatalogue("kwin_clients");
|
2001-10-10 10:50:07 +00:00
|
|
|
mainw = new QWidget(parent);
|
|
|
|
vbox = new QVBoxLayout(mainw);
|
|
|
|
vbox->setSpacing(6);
|
|
|
|
vbox->setMargin(0);
|
2003-02-03 11:55:34 +00:00
|
|
|
|
2003-06-30 08:16:28 +00:00
|
|
|
handleBox = new QWidget(mainw);
|
|
|
|
QGridLayout* layout = new QGridLayout(handleBox, 0, KDialog::spacingHint());
|
2001-10-10 10:50:07 +00:00
|
|
|
|
2003-06-30 08:16:28 +00:00
|
|
|
cbShowHandle = new QCheckBox(i18n("&Show window resize handle"), handleBox);
|
2001-10-10 10:50:07 +00:00
|
|
|
QWhatsThis::add(cbShowHandle,
|
|
|
|
i18n("When selected, all windows are drawn with a resize "
|
|
|
|
"handle at the lower right corner. This makes window resizing "
|
|
|
|
"easier, especially for trackballs and other mouse replacements "
|
|
|
|
"on laptops."));
|
2003-06-30 08:16:28 +00:00
|
|
|
layout->addMultiCellWidget(cbShowHandle, 0, 0, 0, 1);
|
2001-06-19 15:26:48 +00:00
|
|
|
connect(cbShowHandle, SIGNAL(clicked()), this, SLOT(slotSelectionChanged()));
|
2001-10-10 10:50:07 +00:00
|
|
|
|
2003-02-03 11:55:34 +00:00
|
|
|
sliderBox = new QVBox(handleBox);
|
2001-10-10 10:50:07 +00:00
|
|
|
handleSizeSlider = new QSlider(0, 4, 1, 0, QSlider::Horizontal, sliderBox);
|
|
|
|
QWhatsThis::add(handleSizeSlider,
|
|
|
|
i18n("Here you can change the size of the resize handle."));
|
|
|
|
handleSizeSlider->setTickInterval(1);
|
|
|
|
handleSizeSlider->setTickmarks(QSlider::Below);
|
|
|
|
connect(handleSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSelectionChanged()));
|
|
|
|
|
|
|
|
hbox = new QHBox(sliderBox);
|
|
|
|
hbox->setSpacing(6);
|
2003-02-03 11:55:34 +00:00
|
|
|
|
|
|
|
bool rtl = kapp->reverseLayout();
|
2001-10-10 10:50:07 +00:00
|
|
|
label1 = new QLabel(i18n("Small"), hbox);
|
2003-02-03 11:55:34 +00:00
|
|
|
label1->setAlignment(rtl ? AlignRight : AlignLeft);
|
2001-10-10 10:50:07 +00:00
|
|
|
label2 = new QLabel(i18n("Medium"), hbox);
|
|
|
|
label2->setAlignment(AlignHCenter);
|
|
|
|
label3 = new QLabel(i18n("Large"), hbox);
|
2003-02-03 11:55:34 +00:00
|
|
|
label3->setAlignment(rtl ? AlignLeft : AlignRight);
|
2001-10-10 10:50:07 +00:00
|
|
|
|
|
|
|
vbox->addWidget(handleBox);
|
|
|
|
vbox->addStretch(1);
|
2003-06-30 08:16:28 +00:00
|
|
|
|
2003-07-01 02:54:32 +00:00
|
|
|
// layout->setColSpacing(0, 30);
|
|
|
|
layout->addItem(new QSpacerItem(30, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
|
2003-06-30 08:16:28 +00:00
|
|
|
layout->addWidget(sliderBox, 1, 1);
|
2001-10-10 10:50:07 +00:00
|
|
|
|
2001-06-19 15:26:48 +00:00
|
|
|
load(conf);
|
2001-10-10 10:50:07 +00:00
|
|
|
mainw->show();
|
2001-06-19 15:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ModernSysConfig::~ModernSysConfig()
|
|
|
|
{
|
2001-10-10 10:50:07 +00:00
|
|
|
delete mainw;
|
2001-06-19 15:26:48 +00:00
|
|
|
delete clientrc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ModernSysConfig::slotSelectionChanged()
|
|
|
|
{
|
2001-10-10 10:50:07 +00:00
|
|
|
bool i = cbShowHandle->isChecked();
|
|
|
|
if (i != hbox->isEnabled()) {
|
|
|
|
hbox->setEnabled(i);
|
|
|
|
handleSizeSlider->setEnabled(i);
|
|
|
|
}
|
2001-06-19 15:26:48 +00:00
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ModernSysConfig::load(KConfig* /*conf*/)
|
|
|
|
{
|
|
|
|
clientrc->setGroup("General");
|
|
|
|
bool i = clientrc->readBoolEntry("ShowHandle", true );
|
|
|
|
cbShowHandle->setChecked(i);
|
2001-10-10 10:50:07 +00:00
|
|
|
hbox->setEnabled(i);
|
|
|
|
handleSizeSlider->setEnabled(i);
|
|
|
|
handleWidth = clientrc->readUnsignedNumEntry("HandleWidth", 6);
|
|
|
|
handleSize = clientrc->readUnsignedNumEntry("HandleSize", 30);
|
|
|
|
handleSizeSlider->setValue(QMIN((handleWidth - 6) / 2, 4));
|
|
|
|
|
2001-06-19 15:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ModernSysConfig::save(KConfig* /*conf*/)
|
|
|
|
{
|
|
|
|
clientrc->setGroup("General");
|
|
|
|
clientrc->writeEntry("ShowHandle", cbShowHandle->isChecked());
|
2001-10-10 10:50:07 +00:00
|
|
|
clientrc->writeEntry("HandleWidth", 6 + 2 * handleSizeSlider->value());
|
|
|
|
clientrc->writeEntry("HandleSize", 30 + 4 * handleSizeSlider->value());
|
2001-06-19 15:26:48 +00:00
|
|
|
clientrc->sync();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ModernSysConfig::defaults()
|
|
|
|
{
|
|
|
|
cbShowHandle->setChecked(true);
|
2001-10-10 10:50:07 +00:00
|
|
|
hbox->setEnabled(true);
|
|
|
|
handleSizeSlider->setEnabled(true);
|
|
|
|
handleSizeSlider->setValue(0);
|
2001-06-19 15:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "config.moc"
|