summaryrefslogtreecommitdiffstats
path: root/kwin/clients/modernsystem/config
diff options
context:
space:
mode:
Diffstat (limited to 'kwin/clients/modernsystem/config')
-rw-r--r--kwin/clients/modernsystem/config/Makefile.am14
-rw-r--r--kwin/clients/modernsystem/config/config.cpp130
-rw-r--r--kwin/clients/modernsystem/config/config.h50
3 files changed, 194 insertions, 0 deletions
diff --git a/kwin/clients/modernsystem/config/Makefile.am b/kwin/clients/modernsystem/config/Makefile.am
new file mode 100644
index 000000000..79bf21290
--- /dev/null
+++ b/kwin/clients/modernsystem/config/Makefile.am
@@ -0,0 +1,14 @@
+
+INCLUDES = $(all_includes)
+
+kde_module_LTLIBRARIES = kwin_modernsys_config.la
+
+kwin_modernsys_config_la_SOURCES = config.cpp
+kwin_modernsys_config_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module
+kwin_modernsys_config_la_LIBADD = $(LIB_KDEUI)
+
+METASOURCES = AUTO
+noinst_HEADERS = config.h
+
+lnkdir = $(kde_datadir)/kwin/
+
diff --git a/kwin/clients/modernsystem/config/config.cpp b/kwin/clients/modernsystem/config/config.cpp
new file mode 100644
index 000000000..542494d28
--- /dev/null
+++ b/kwin/clients/modernsystem/config/config.cpp
@@ -0,0 +1,130 @@
+// Melchior FRANZ <mfranz@kde.org> -- 2001-04-22
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdialog.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <qlayout.h>
+#include <qwhatsthis.h>
+#include "config.h"
+
+
+extern "C"
+{
+ KDE_EXPORT 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.
+//
+// 'parent' is the parent of the QObject, which is a VBox inside the
+// Configure tab in kwindecoration
+
+ModernSysConfig::ModernSysConfig(KConfig* conf, QWidget* parent) : QObject(parent)
+{
+ clientrc = new KConfig("kwinmodernsysrc");
+ KGlobal::locale()->insertCatalogue("kwin_clients");
+ mainw = new QWidget(parent);
+ vbox = new QVBoxLayout(mainw);
+ vbox->setSpacing(6);
+ vbox->setMargin(0);
+
+ handleBox = new QWidget(mainw);
+ QGridLayout* layout = new QGridLayout(handleBox, 0, KDialog::spacingHint());
+
+ cbShowHandle = new QCheckBox(i18n("&Show window resize 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."));
+ layout->addMultiCellWidget(cbShowHandle, 0, 0, 0, 1);
+ 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);
+
+ bool rtl = kapp->reverseLayout();
+ label1 = new QLabel(i18n("Small"), hbox);
+ label1->setAlignment(rtl ? AlignRight : AlignLeft);
+ label2 = new QLabel(i18n("Medium"), hbox);
+ label2->setAlignment(AlignHCenter);
+ label3 = new QLabel(i18n("Large"), hbox);
+ label3->setAlignment(rtl ? AlignLeft : AlignRight);
+
+ vbox->addWidget(handleBox);
+ vbox->addStretch(1);
+
+// layout->setColSpacing(0, 30);
+ layout->addItem(new QSpacerItem(30, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
+ layout->addWidget(sliderBox, 1, 1);
+
+ load(conf);
+ mainw->show();
+}
+
+
+ModernSysConfig::~ModernSysConfig()
+{
+ delete mainw;
+ delete clientrc;
+}
+
+
+void ModernSysConfig::slotSelectionChanged()
+{
+ bool i = cbShowHandle->isChecked();
+ if (i != hbox->isEnabled()) {
+ hbox->setEnabled(i);
+ handleSizeSlider->setEnabled(i);
+ }
+ emit changed();
+}
+
+
+void ModernSysConfig::load(KConfig* /*conf*/)
+{
+ clientrc->setGroup("General");
+ bool i = clientrc->readBoolEntry("ShowHandle", true );
+ cbShowHandle->setChecked(i);
+ hbox->setEnabled(i);
+ handleSizeSlider->setEnabled(i);
+ handleWidth = clientrc->readUnsignedNumEntry("HandleWidth", 6);
+ handleSize = clientrc->readUnsignedNumEntry("HandleSize", 30);
+ handleSizeSlider->setValue(QMIN((handleWidth - 6) / 2, 4));
+
+}
+
+
+void ModernSysConfig::save(KConfig* /*conf*/)
+{
+ clientrc->setGroup("General");
+ clientrc->writeEntry("ShowHandle", cbShowHandle->isChecked());
+ clientrc->writeEntry("HandleWidth", 6 + 2 * handleSizeSlider->value());
+ clientrc->writeEntry("HandleSize", 30 + 4 * handleSizeSlider->value());
+ clientrc->sync();
+}
+
+
+void ModernSysConfig::defaults()
+{
+ cbShowHandle->setChecked(true);
+ hbox->setEnabled(true);
+ handleSizeSlider->setEnabled(true);
+ handleSizeSlider->setValue(0);
+}
+
+#include "config.moc"
diff --git a/kwin/clients/modernsystem/config/config.h b/kwin/clients/modernsystem/config/config.h
new file mode 100644
index 000000000..4f4b97123
--- /dev/null
+++ b/kwin/clients/modernsystem/config/config.h
@@ -0,0 +1,50 @@
+#ifndef __KDE_MODSYSTEMCONFIG_H
+#define __KDE_MODSYSTEMCONFIG_H
+
+#include <qcheckbox.h>
+#include <qgroupbox.h>
+#include <qlayout.h>
+#include <qvbox.h>
+#include <qslider.h>
+#include <qlabel.h>
+
+class ModernSysConfig : public QObject
+{
+ Q_OBJECT
+
+ public:
+ ModernSysConfig(KConfig* conf, QWidget* parent);
+ ~ModernSysConfig();
+
+ // These public signals/slots work similar to KCM modules
+ signals:
+ void changed();
+
+ public slots:
+ void load(KConfig* conf);
+ void save(KConfig* conf);
+ void defaults();
+
+ protected slots:
+ void slotSelectionChanged(); // Internal use
+
+ private:
+ KConfig *clientrc;
+ QWidget *mainw;
+ QVBoxLayout *vbox;
+ QWidget *handleBox;
+ QCheckBox *cbShowHandle;
+ QVBox *sliderBox;
+ QSlider *handleSizeSlider;
+ QHBox *hbox;
+ QLabel *label1;
+ QLabel *label2;
+ QLabel *label3;
+
+ unsigned handleWidth;
+ unsigned handleSize;
+
+};
+
+
+#endif