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>
|
2005-07-28 14:59:42 +00:00
|
|
|
|
|
|
|
//Added by qt3to4:
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QGridLayout>
|
2005-09-18 14:52:14 +00:00
|
|
|
#include <kvbox.h>
|
2001-10-10 10:50:07 +00:00
|
|
|
#include "config.h"
|
2001-06-19 15:26:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
2005-01-08 22:25:07 +00:00
|
|
|
KDE_EXPORT QObject* 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)
|
2006-04-30 21:18:53 +00:00
|
|
|
{
|
2001-06-19 15:26:48 +00:00
|
|
|
clientrc = new KConfig("kwinmodernsysrc");
|
2005-10-03 15:13:54 +00:00
|
|
|
KGlobal::locale()->insertCatalog("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);
|
2006-04-30 21:18:53 +00:00
|
|
|
QGridLayout* layout = new QGridLayout(handleBox );
|
|
|
|
layout->setSpacing( 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);
|
2005-07-28 14:59:42 +00:00
|
|
|
cbShowHandle->setWhatsThis(
|
2001-10-10 10:50:07 +00:00
|
|
|
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."));
|
2006-04-20 12:41:37 +00:00
|
|
|
layout->addWidget(cbShowHandle, 0, 0, 1, 2 );
|
2001-06-19 15:26:48 +00:00
|
|
|
connect(cbShowHandle, SIGNAL(clicked()), this, SLOT(slotSelectionChanged()));
|
2001-10-10 10:50:07 +00:00
|
|
|
|
2005-09-18 14:52:14 +00:00
|
|
|
sliderBox = new KVBox(handleBox);
|
2006-04-12 15:34:39 +00:00
|
|
|
//handleSizeSlider = new QSlider(0, 4, 1, 0, Qt::Horizontal, sliderBox);
|
|
|
|
handleSizeSlider = new QSlider(Qt::Horizontal, sliderBox);
|
|
|
|
handleSizeSlider->setMinimum(0);
|
|
|
|
handleSizeSlider->setMaximum(4);
|
|
|
|
handleSizeSlider->setPageStep(1);
|
2005-07-28 14:59:42 +00:00
|
|
|
handleSizeSlider->setWhatsThis(
|
2001-10-10 10:50:07 +00:00
|
|
|
i18n("Here you can change the size of the resize handle."));
|
|
|
|
handleSizeSlider->setTickInterval(1);
|
2006-04-12 15:34:39 +00:00
|
|
|
handleSizeSlider->setTickPosition(QSlider::TicksBelow);
|
2001-10-10 10:50:07 +00:00
|
|
|
connect(handleSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSelectionChanged()));
|
|
|
|
|
2005-09-18 14:52:14 +00:00
|
|
|
hbox = new KHBox(sliderBox);
|
2001-10-10 10:50:07 +00:00
|
|
|
hbox->setSpacing(6);
|
2003-02-03 11:55:34 +00:00
|
|
|
|
2006-02-22 14:56:03 +00:00
|
|
|
bool rtl = kapp->layoutDirection() == Qt::RightToLeft;
|
2001-10-10 10:50:07 +00:00
|
|
|
label1 = new QLabel(i18n("Small"), hbox);
|
2005-07-28 14:59:42 +00:00
|
|
|
label1->setAlignment(rtl ? Qt::AlignRight : Qt::AlignLeft);
|
2001-10-10 10:50:07 +00:00
|
|
|
label2 = new QLabel(i18n("Medium"), hbox);
|
2005-07-28 14:59:42 +00:00
|
|
|
label2->setAlignment( Qt::AlignHCenter );
|
2001-10-10 10:50:07 +00:00
|
|
|
label3 = new QLabel(i18n("Large"), hbox);
|
2005-07-28 14:59:42 +00:00
|
|
|
label3->setAlignment(rtl ? Qt::AlignLeft : Qt::AlignRight);
|
2006-04-30 21:18:53 +00:00
|
|
|
|
2001-10-10 10:50:07 +00:00
|
|
|
vbox->addWidget(handleBox);
|
|
|
|
vbox->addStretch(1);
|
2003-06-30 08:16:28 +00:00
|
|
|
|
2006-04-21 17:30:21 +00:00
|
|
|
// layout->setColumnMinimumWidth(0, 30);
|
2003-07-01 02:54:32 +00:00
|
|
|
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);
|
2006-04-30 21:18:53 +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");
|
2006-01-03 14:01:15 +00:00
|
|
|
bool i = clientrc->readEntry("ShowHandle", QVariant(true )).toBool();
|
2001-06-19 15:26:48 +00:00
|
|
|
cbShowHandle->setChecked(i);
|
2001-10-10 10:50:07 +00:00
|
|
|
hbox->setEnabled(i);
|
|
|
|
handleSizeSlider->setEnabled(i);
|
2006-01-21 19:36:31 +00:00
|
|
|
handleWidth = clientrc->readEntry("HandleWidth", 6);
|
|
|
|
handleSize = clientrc->readEntry("HandleSize", 30);
|
2006-02-17 21:54:55 +00:00
|
|
|
handleSizeSlider->setValue(qMin((handleWidth - 6) / 2, (uint)4));
|
2006-04-30 21:18:53 +00:00
|
|
|
|
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"
|