kwin Library API Documentation

config.cpp

00001 /* 00002 * 00003 * KDE2 Default configuration widget 00004 * 00005 * Copyright (c) 2001 00006 * Karol Szwed <gallium@kde.org> 00007 * http://gallium.n3.net/ 00008 */ 00009 00010 #include "config.h" 00011 #include <kglobal.h> 00012 #include <qwhatsthis.h> 00013 #include <kdialog.h> 00014 #include <klocale.h> 00015 #include <qpixmap.h> 00016 #include <qvbox.h> 00017 00018 extern "C" 00019 { 00020 QObject* allocate_config( KConfig* conf, QWidget* parent ) 00021 { 00022 return(new KDEDefaultConfig(conf, parent)); 00023 } 00024 } 00025 00026 // NOTE: 00027 // 'conf' is a pointer to the kwindecoration modules open kwin config, 00028 // and is by default set to the "Style" group. 00029 // 'parent' is the parent of the QObject, which is a VBox inside the 00030 // Configure tab in kwindecoration 00031 00032 KDEDefaultConfig::KDEDefaultConfig( KConfig* conf, QWidget* parent ) 00033 : QObject( parent ) 00034 { 00035 KGlobal::locale()->insertCatalogue("kwin_default_config"); 00036 highcolor = QPixmap::defaultDepth() > 8; 00037 gb = new QVBox( parent ); 00038 gb->setSpacing( KDialog::spacingHint() ); 00039 00040 cbShowStipple = new QCheckBox( i18n("Draw titlebar &stipple effect"), gb ); 00041 QWhatsThis::add( cbShowStipple, 00042 i18n("When selected, active titlebars are drawn " 00043 "with a stipple (dotted) effect. Otherwise, they are " 00044 "drawn without the stipple.")); 00045 00046 cbShowGrabBar = new QCheckBox( i18n("Draw g&rab bar below windows"), gb ); 00047 QWhatsThis::add( cbShowGrabBar, 00048 i18n("When selected, decorations are drawn with a \"grab bar\" " 00049 "below windows. Otherwise, no grab bar is drawn.")); 00050 00051 // Only show the gradient checkbox for highcolor displays 00052 if (highcolor) 00053 { 00054 cbUseGradients = new QCheckBox( i18n("Draw &gradients"), gb ); 00055 QWhatsThis::add( cbUseGradients, 00056 i18n("When selected, decorations are drawn with gradients " 00057 "for highcolor displays, otherwise no gradients are drawn.") ); 00058 } 00059 00060 // Load configuration options 00061 load( conf ); 00062 00063 // Ensure we track user changes properly 00064 connect( cbShowStipple, SIGNAL(clicked()), 00065 this, SLOT(slotSelectionChanged()) ); 00066 connect( cbShowGrabBar, SIGNAL(clicked()), 00067 this, SLOT(slotSelectionChanged()) ); 00068 if (highcolor) 00069 connect( cbUseGradients, SIGNAL(clicked()), 00070 this, SLOT(slotSelectionChanged()) ); 00071 00072 // Make the widgets visible in kwindecoration 00073 gb->show(); 00074 } 00075 00076 00077 KDEDefaultConfig::~KDEDefaultConfig() 00078 { 00079 delete gb; 00080 } 00081 00082 00083 void KDEDefaultConfig::slotSelectionChanged() 00084 { 00085 emit changed(); 00086 } 00087 00088 00089 // Loads the configurable options from the kwinrc config file 00090 // It is passed the open config from kwindecoration to improve efficiency 00091 void KDEDefaultConfig::load( KConfig* conf ) 00092 { 00093 conf->setGroup("KDEDefault"); 00094 bool override = conf->readBoolEntry( "ShowTitleBarStipple", true ); 00095 cbShowStipple->setChecked( override ); 00096 00097 override = conf->readBoolEntry( "ShowGrabBar", true ); 00098 cbShowGrabBar->setChecked( override ); 00099 00100 if (highcolor) { 00101 override = conf->readBoolEntry( "UseGradients", true ); 00102 cbUseGradients->setChecked( override ); 00103 } 00104 } 00105 00106 00107 // Saves the configurable options to the kwinrc config file 00108 void KDEDefaultConfig::save( KConfig* conf ) 00109 { 00110 conf->setGroup("KDEDefault"); 00111 conf->writeEntry( "ShowTitleBarStipple", cbShowStipple->isChecked() ); 00112 conf->writeEntry( "ShowGrabBar", cbShowGrabBar->isChecked() ); 00113 00114 if (highcolor) 00115 conf->writeEntry( "UseGradients", cbUseGradients->isChecked() ); 00116 // No need to conf->sync() - kwindecoration will do it for us 00117 } 00118 00119 00120 // Sets UI widget defaults which must correspond to style defaults 00121 void KDEDefaultConfig::defaults() 00122 { 00123 cbShowStipple->setChecked( true ); 00124 cbShowGrabBar->setChecked( true ); 00125 00126 if (highcolor) 00127 cbUseGradients->setChecked( true ); 00128 } 00129 00130 #include "config.moc" 00131 // vim: ts=4
KDE Logo
This file is part of the documentation for kwin Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 13 21:47:04 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003