kwin Library API Documentation

config.cpp

00001 /*  
00002  * $Id: config.cpp,v 1.7 2003/06/30 08:16:15 aseigo Exp $
00003  *
00004  *  This file contains the quartz 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 <klocale.h>
00015 
00016 
00017 extern "C"
00018 {
00019     QObject* allocate_config( KConfig* conf, QWidget* parent )
00020     {
00021         return(new QuartzConfig(conf, parent));
00022     }
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  *
00030  * 'parent' is the parent of the QObject, which is a VBox inside the
00031  *          Configure tab in kwindecoration
00032  */
00033 
00034 QuartzConfig::QuartzConfig( KConfig* conf, QWidget* parent )
00035     : QObject( parent )
00036 {
00037     quartzConfig = new KConfig("kwinquartzrc");
00038     KGlobal::locale()->insertCatalogue("kwin_quartz_config");
00039     gb = new QVBox( parent );
00040     cbColorBorder = new QCheckBox( 
00041                         i18n("Draw window frames using &titlebar colors"), gb );
00042     QWhatsThis::add( cbColorBorder, 
00043                         i18n("When selected, the window decoration borders "
00044                         "are drawn using the titlebar colors. Otherwise, they are "
00045                         "drawn using normal border colors instead.") );
00046     // Load configuration options
00047     load( conf );
00048 
00049     // Ensure we track user changes properly
00050     connect( cbColorBorder, SIGNAL(clicked()), this, SLOT(slotSelectionChanged()) );
00051 
00052     // Make the widgets visible in kwindecoration
00053     gb->show();
00054 }
00055 
00056 
00057 QuartzConfig::~QuartzConfig()
00058 {
00059     delete gb;
00060     delete quartzConfig;
00061 }
00062 
00063 
00064 void QuartzConfig::slotSelectionChanged()
00065 {
00066     emit changed();
00067 }
00068 
00069 
00070 // Loads the configurable options from the kwinrc config file
00071 // It is passed the open config from kwindecoration to improve efficiency
00072 void QuartzConfig::load( KConfig* /*conf*/ )
00073 {
00074     quartzConfig->setGroup("General");
00075     bool override = quartzConfig->readBoolEntry( "UseTitleBarBorderColors", true );
00076     cbColorBorder->setChecked( override );
00077 }
00078 
00079 
00080 // Saves the configurable options to the kwinrc config file
00081 void QuartzConfig::save( KConfig* /*conf*/ )
00082 {
00083     quartzConfig->setGroup("General");
00084     quartzConfig->writeEntry( "UseTitleBarBorderColors", cbColorBorder->isChecked() );
00085     // Ensure others trying to read this config get updated
00086     quartzConfig->sync();
00087 }
00088 
00089 
00090 // Sets UI widget defaults which must correspond to style defaults
00091 void QuartzConfig::defaults()
00092 {
00093     cbColorBorder->setChecked( true );
00094 }
00095 
00096 #include "config.moc"
00097 // 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 Thu Apr 29 21:20:49 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003