modernsystem/config/config.cpp
00001
00002
00003 #include <kapplication.h>
00004 #include <kconfig.h>
00005 #include <kdialog.h>
00006 #include <klocale.h>
00007 #include <kglobal.h>
00008 #include <qlayout.h>
00009 #include <qwhatsthis.h>
00010 #include "config.h"
00011
00012
00013 extern "C"
00014 {
00015 KDE_EXPORT QObject* allocate_config(KConfig* conf, QWidget* parent)
00016 {
00017 return(new ModernSysConfig(conf, parent));
00018 }
00019 }
00020
00021
00022
00023
00024
00025
00026
00027
00028 ModernSysConfig::ModernSysConfig(KConfig* conf, QWidget* parent) : QObject(parent)
00029 {
00030 clientrc = new KConfig("kwinmodernsysrc");
00031 KGlobal::locale()->insertCatalogue("kwin_clients");
00032 mainw = new QWidget(parent);
00033 vbox = new QVBoxLayout(mainw);
00034 vbox->setSpacing(6);
00035 vbox->setMargin(0);
00036
00037 handleBox = new QWidget(mainw);
00038 QGridLayout* layout = new QGridLayout(handleBox, 0, KDialog::spacingHint());
00039
00040 cbShowHandle = new QCheckBox(i18n("&Show window resize handle"), handleBox);
00041 QWhatsThis::add(cbShowHandle,
00042 i18n("When selected, all windows are drawn with a resize "
00043 "handle at the lower right corner. This makes window resizing "
00044 "easier, especially for trackballs and other mouse replacements "
00045 "on laptops."));
00046 layout->addMultiCellWidget(cbShowHandle, 0, 0, 0, 1);
00047 connect(cbShowHandle, SIGNAL(clicked()), this, SLOT(slotSelectionChanged()));
00048
00049 sliderBox = new QVBox(handleBox);
00050 handleSizeSlider = new QSlider(0, 4, 1, 0, QSlider::Horizontal, sliderBox);
00051 QWhatsThis::add(handleSizeSlider,
00052 i18n("Here you can change the size of the resize handle."));
00053 handleSizeSlider->setTickInterval(1);
00054 handleSizeSlider->setTickmarks(QSlider::Below);
00055 connect(handleSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSelectionChanged()));
00056
00057 hbox = new QHBox(sliderBox);
00058 hbox->setSpacing(6);
00059
00060 bool rtl = kapp->reverseLayout();
00061 label1 = new QLabel(i18n("Small"), hbox);
00062 label1->setAlignment(rtl ? AlignRight : AlignLeft);
00063 label2 = new QLabel(i18n("Medium"), hbox);
00064 label2->setAlignment(AlignHCenter);
00065 label3 = new QLabel(i18n("Large"), hbox);
00066 label3->setAlignment(rtl ? AlignLeft : AlignRight);
00067
00068 vbox->addWidget(handleBox);
00069 vbox->addStretch(1);
00070
00071
00072 layout->addItem(new QSpacerItem(30, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
00073 layout->addWidget(sliderBox, 1, 1);
00074
00075 load(conf);
00076 mainw->show();
00077 }
00078
00079
00080 ModernSysConfig::~ModernSysConfig()
00081 {
00082 delete mainw;
00083 delete clientrc;
00084 }
00085
00086
00087 void ModernSysConfig::slotSelectionChanged()
00088 {
00089 bool i = cbShowHandle->isChecked();
00090 if (i != hbox->isEnabled()) {
00091 hbox->setEnabled(i);
00092 handleSizeSlider->setEnabled(i);
00093 }
00094 emit changed();
00095 }
00096
00097
00098 void ModernSysConfig::load(KConfig* )
00099 {
00100 clientrc->setGroup("General");
00101 bool i = clientrc->readBoolEntry("ShowHandle", true );
00102 cbShowHandle->setChecked(i);
00103 hbox->setEnabled(i);
00104 handleSizeSlider->setEnabled(i);
00105 handleWidth = clientrc->readUnsignedNumEntry("HandleWidth", 6);
00106 handleSize = clientrc->readUnsignedNumEntry("HandleSize", 30);
00107 handleSizeSlider->setValue(QMIN((handleWidth - 6) / 2, 4));
00108
00109 }
00110
00111
00112 void ModernSysConfig::save(KConfig* )
00113 {
00114 clientrc->setGroup("General");
00115 clientrc->writeEntry("ShowHandle", cbShowHandle->isChecked());
00116 clientrc->writeEntry("HandleWidth", 6 + 2 * handleSizeSlider->value());
00117 clientrc->writeEntry("HandleSize", 30 + 4 * handleSizeSlider->value());
00118 clientrc->sync();
00119 }
00120
00121
00122 void ModernSysConfig::defaults()
00123 {
00124 cbShowHandle->setChecked(true);
00125 hbox->setEnabled(true);
00126 handleSizeSlider->setEnabled(true);
00127 handleSizeSlider->setValue(0);
00128 }
00129
00130 #include "config.moc"
This file is part of the documentation for kwin Library Version 3.4.2.