kwin Library API Documentation

keramik/config/config.cpp

00001 /*
00002  * 
00003  * Keramik KWin client configuration module
00004  *
00005  * Copyright (C) 2002 Fredrik Höglund <fredrik@kde.org>
00006  *
00007  * Based on the Quartz configuration module,
00008  *     Copyright (c) 2001 Karol Szwed <gallium@kde.org>
00009  * 
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the license, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; see the file COPYING.  If not, write to
00022  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023  * Boston, MA 02111-1307, USA.
00024  */
00025  
00026 #include <kglobal.h>
00027 #include <klocale.h>
00028 
00029 #include <qcheckbox.h>
00030 
00031 #include "config.h"
00032 #include "config.moc"
00033 
00034 extern "C"
00035 {
00036     KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
00037     {
00038         return ( new KeramikConfig( conf, parent ) );
00039     }
00040 }
00041 
00042 
00043 /* NOTE: 
00044  * 'conf'   is a pointer to the kwindecoration modules open kwin config,
00045  *          and is by default set to the "Style" group.
00046  *
00047  * 'parent' is the parent of the QObject, which is a VBox inside the
00048  *          Configure tab in kwindecoration
00049  */
00050 
00051 KeramikConfig::KeramikConfig( KConfig* conf, QWidget* parent )
00052     : QObject( parent )
00053 {
00054     KGlobal::locale()->insertCatalogue("kwin_clients");
00055     c = new KConfig( "kwinkeramikrc" );
00056     
00057     ui = new KeramikConfigUI( parent );
00058     connect( ui->showAppIcons,    SIGNAL(clicked()), SIGNAL(changed()) );
00059     connect( ui->smallCaptions,   SIGNAL(clicked()), SIGNAL(changed()) );
00060     connect( ui->largeGrabBars,   SIGNAL(clicked()), SIGNAL(changed()) );
00061     connect( ui->useShadowedText, SIGNAL(clicked()), SIGNAL(changed()) );
00062 
00063     load( conf );
00064     ui->show();
00065 }
00066 
00067 
00068 KeramikConfig::~KeramikConfig()
00069 {
00070     delete ui;
00071     delete c;
00072 }
00073 
00074 
00075 // Loads the configurable options from the kwinrc config file
00076 // It is passed the open config from kwindecoration to improve efficiency
00077 void KeramikConfig::load( KConfig* )
00078 {
00079     c->setGroup("General");
00080     ui->showAppIcons->setChecked( c->readBoolEntry("ShowAppIcons", true) );
00081     ui->smallCaptions->setChecked( c->readBoolEntry("SmallCaptionBubbles", false) );
00082     ui->largeGrabBars->setChecked( c->readBoolEntry("LargeGrabBars", true) );
00083     ui->useShadowedText->setChecked( c->readBoolEntry("UseShadowedText", true) );
00084 }
00085 
00086 
00087 // Saves the configurable options to the kwinrc config file
00088 void KeramikConfig::save( KConfig* )
00089 {
00090     c->setGroup( "General" );
00091     c->writeEntry( "ShowAppIcons", ui->showAppIcons->isChecked() );
00092     c->writeEntry( "SmallCaptionBubbles", ui->smallCaptions->isChecked() );
00093     c->writeEntry( "LargeGrabBars", ui->largeGrabBars->isChecked() );
00094     c->writeEntry( "UseShadowedText", ui->useShadowedText->isChecked() );
00095     c->sync();
00096 }
00097 
00098 
00099 // Sets UI widget defaults which must correspond to style defaults
00100 void KeramikConfig::defaults()
00101 {
00102     ui->showAppIcons->setChecked( true );
00103     ui->smallCaptions->setChecked( false );
00104     ui->largeGrabBars->setChecked( true );
00105     ui->useShadowedText->setChecked( true );
00106     
00107     emit changed();
00108 }
00109 
00110 // vim: set noet ts=4 sw=4:
KDE Logo
This file is part of the documentation for kwin Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Apr 6 02:41:04 2005 by doxygen 1.4.0 written by Dimitri van Heesch, © 1997-2003