From 003eab093bf25917d379e916acb18c772ba97dd9 Mon Sep 17 00:00:00 2001 From: Karol Szwed Date: Wed, 10 Oct 2001 10:50:07 +0000 Subject: [PATCH] Adding resize handle configuration patch by Melchior Franz. svn path=/trunk/kdebase/kwin/; revision=117114 --- clients/modernsystem/config/config.cpp | 74 ++++++++++++++++++++------ clients/modernsystem/config/config.h | 37 ++++++++----- 2 files changed, 83 insertions(+), 28 deletions(-) diff --git a/clients/modernsystem/config/config.cpp b/clients/modernsystem/config/config.cpp index 3769766ef3..54fa36357b 100644 --- a/clients/modernsystem/config/config.cpp +++ b/clients/modernsystem/config/config.cpp @@ -1,52 +1,87 @@ // $Id$ // Melchior FRANZ -- 2001-04-22 -#include "config.h" #include #include #include #include +#include "config.h" extern "C" { - QObject* allocate_config( KConfig* conf, QWidget* parent ) + QObject* allocate_config(KConfig* conf, QWidget* parent) { return(new ModernSysConfig(conf, parent)); } } -// 'conf' is a pointer to the kwindecoration modules open kwin config, -// and is by default set to the "Style" group. +// '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 +// Configure tab in kwindecoration ModernSysConfig::ModernSysConfig(KConfig* conf, QWidget* parent) : QObject(parent) { clientrc = new KConfig("kwinmodernsysrc"); KGlobal::locale()->insertCatalogue("libkwinmodernsys_config"); - gb = new QGroupBox(1, Qt::Horizontal, i18n("Decoration Settings"), parent); - cbShowHandle = new QCheckBox(i18n("&Show resize handle"), gb); - QWhatsThis::add(cbShowHandle, i18n("When selected, all windows are drawn with a resize " - "handle at the lower right corner.")); + mainw = new QWidget(parent); + vbox = new QVBoxLayout(mainw); + vbox->setSpacing(6); + vbox->setMargin(0); + + handleBox = new QGroupBox( 1, Qt::Vertical, i18n("Window Resize Handle"), mainw); + handleBox->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1, (QSizePolicy::SizeType)4)); + + cbShowHandle = new QCheckBox(i18n("&Show Handle"), handleBox); + 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.")); + handleBox->addSpace(20); connect(cbShowHandle, SIGNAL(clicked()), this, SLOT(slotSelectionChanged())); + + sliderBox = new QVBox(handleBox); + 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); + label1 = new QLabel(i18n("Small"), hbox); + label2 = new QLabel(i18n("Medium"), hbox); + label2->setAlignment(AlignHCenter); + label3 = new QLabel(i18n("Large"), hbox); + label3->setAlignment(AlignRight); + + vbox->addWidget(handleBox); + vbox->addStretch(1); + load(conf); - gb->show(); + mainw->show(); } ModernSysConfig::~ModernSysConfig() { - delete cbShowHandle; - delete gb; + delete mainw; delete clientrc; } void ModernSysConfig::slotSelectionChanged() { + bool i = cbShowHandle->isChecked(); + if (i != hbox->isEnabled()) { + hbox->setEnabled(i); + handleSizeSlider->setEnabled(i); + } emit changed(); } @@ -56,8 +91,12 @@ void ModernSysConfig::load(KConfig* /*conf*/) clientrc->setGroup("General"); bool i = clientrc->readBoolEntry("ShowHandle", true ); cbShowHandle->setChecked(i); - handle_width = clientrc->readUnsignedNumEntry("HandleWidth", 6); - handle_size = clientrc->readUnsignedNumEntry("HandleSize", 30); + hbox->setEnabled(i); + handleSizeSlider->setEnabled(i); + handleWidth = clientrc->readUnsignedNumEntry("HandleWidth", 6); + handleSize = clientrc->readUnsignedNumEntry("HandleSize", 30); + handleSizeSlider->setValue(QMIN((handleWidth - 6) / 2, 4)); + } @@ -65,8 +104,8 @@ void ModernSysConfig::save(KConfig* /*conf*/) { clientrc->setGroup("General"); clientrc->writeEntry("ShowHandle", cbShowHandle->isChecked()); - clientrc->writeEntry("HandleWidth", handle_width); - clientrc->writeEntry("HandleSize", handle_size); + clientrc->writeEntry("HandleWidth", 6 + 2 * handleSizeSlider->value()); + clientrc->writeEntry("HandleSize", 30 + 4 * handleSizeSlider->value()); clientrc->sync(); } @@ -74,6 +113,9 @@ void ModernSysConfig::save(KConfig* /*conf*/) void ModernSysConfig::defaults() { cbShowHandle->setChecked(true); + hbox->setEnabled(true); + handleSizeSlider->setEnabled(true); + handleSizeSlider->setValue(0); } #include "config.moc" diff --git a/clients/modernsystem/config/config.h b/clients/modernsystem/config/config.h index 4c79ce6d08..cff01e4e53 100644 --- a/clients/modernsystem/config/config.h +++ b/clients/modernsystem/config/config.h @@ -4,34 +4,47 @@ #include #include -#include +#include +#include +#include +#include class ModernSysConfig : public QObject { Q_OBJECT public: - ModernSysConfig( KConfig* conf, QWidget* parent ); + ModernSysConfig(KConfig* conf, QWidget* parent); ~ModernSysConfig(); // These public signals/slots work similar to KCM modules signals: - void changed(); + void changed(); public slots: - void load( KConfig* conf ); - void save( KConfig* conf ); - void defaults(); + void load(KConfig* conf); + void save(KConfig* conf); + void defaults(); protected slots: - void slotSelectionChanged(); // Internal use + void slotSelectionChanged(); // Internal use private: - KConfig *clientrc; - QGroupBox *gb; - QCheckBox *cbShowHandle; - unsigned handle_width; - unsigned handle_size; + KConfig *clientrc; + QWidget *mainw; + QVBoxLayout *vbox; + QGroupBox *handleBox; + QCheckBox *cbShowHandle; + QVBox *sliderBox; + QSlider *handleSizeSlider; + QHBox *hbox; + QLabel *label1; + QLabel *label2; + QLabel *label3; + + unsigned handleWidth; + unsigned handleSize; + };