kwin Library API Documentation

config.cpp

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