kwin Library API Documentation

quartz/config/config.cpp

00001 /*  
00002  *
00003  *  This file contains the quartz 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 <klocale.h>
00014 
00015 
00016 extern "C"
00017 {
00018     KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
00019     {
00020         return(new QuartzConfig(conf, parent));
00021     }
00022 }
00023 
00024 
00025 /* NOTE: 
00026  * 'conf'   is a pointer to the kwindecoration modules open kwin config,
00027  *          and is by default set to the "Style" group.
00028  *
00029  * 'parent' is the parent of the QObject, which is a VBox inside the
00030  *          Configure tab in kwindecoration
00031  */
00032 
00033 QuartzConfig::QuartzConfig( KConfig* conf, QWidget* parent )
00034     : QObject( parent )
00035 {
00036     quartzConfig = new KConfig("kwinquartzrc");
00037     KGlobal::locale()->insertCatalogue("kwin_clients");
00038     gb = new QVBox( parent );
00039     cbColorBorder = new QCheckBox( 
00040                         i18n("Draw window frames using &titlebar colors"), gb );
00041     QWhatsThis::add( cbColorBorder, 
00042                         i18n("When selected, the window decoration borders "
00043                         "are drawn using the titlebar colors; otherwise, they are "
00044                         "drawn using normal border colors instead.") );
00045     cbExtraSmall = new QCheckBox( i18n("Quartz &extra slim"), gb );
00046     QWhatsThis::add( cbExtraSmall,
00047         i18n("Quartz window decorations with extra-small title bar.") );
00048     // Load configuration options
00049     load( conf );
00050 
00051     // Ensure we track user changes properly
00052     connect( cbColorBorder, SIGNAL(clicked()), this, SLOT(slotSelectionChanged()) );
00053     connect( cbExtraSmall,  SIGNAL(clicked()), this, SLOT(slotSelectionChanged()) );
00054 
00055     // Make the widgets visible in kwindecoration
00056     gb->show();
00057 }
00058 
00059 
00060 QuartzConfig::~QuartzConfig()
00061 {
00062     delete gb;
00063     delete quartzConfig;
00064 }
00065 
00066 
00067 void QuartzConfig::slotSelectionChanged()
00068 {
00069     emit changed();
00070 }
00071 
00072 
00073 // Loads the configurable options from the kwinrc config file
00074 // It is passed the open config from kwindecoration to improve efficiency
00075 void QuartzConfig::load( KConfig* /*conf*/ )
00076 {
00077     quartzConfig->setGroup("General");
00078     bool override = quartzConfig->readBoolEntry( "UseTitleBarBorderColors", true );
00079     cbColorBorder->setChecked( override );
00080     override = quartzConfig->readBoolEntry( "UseQuartzExtraSlim", false );
00081     cbExtraSmall->setChecked( override );
00082 }
00083 
00084 
00085 // Saves the configurable options to the kwinrc config file
00086 void QuartzConfig::save( KConfig* /*conf*/ )
00087 {
00088     quartzConfig->setGroup("General");
00089     quartzConfig->writeEntry( "UseTitleBarBorderColors", cbColorBorder->isChecked() );
00090     quartzConfig->writeEntry( "UseQuartzExtraSlim", cbExtraSmall->isChecked() );
00091     // Ensure others trying to read this config get updated
00092     quartzConfig->sync();
00093 }
00094 
00095 
00096 // Sets UI widget defaults which must correspond to style defaults
00097 void QuartzConfig::defaults()
00098 {
00099     cbColorBorder->setChecked( true );
00100     cbExtraSmall->setChecked( false );
00101 }
00102 
00103 #include "config.moc"
00104 // vim: ts=4
KDE Logo
This file is part of the documentation for kwin Library Version 3.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jun 14 19:06:09 2006 by doxygen 1.4.4 written by Dimitri van Heesch, © 1997-2003