kwin Library API Documentation

config.cpp

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