kwin Library API Documentation

plastik/config/config.cpp

00001 /* Plastik KWin window decoration
00002   Copyright (C) 2003 Sandro Giessl <ceebx@users.sourceforge.net>
00003 
00004   based on the window decoration "Web":
00005   Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
00006 
00007   This program is free software; you can redistribute it and/or
00008   modify it under the terms of the GNU General Public
00009   License as published by the Free Software Foundation; either
00010   version 2 of the License, or (at your option) any later version.
00011 
00012   This program is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015   General Public License for more details.
00016 
00017   You should have received a copy of the GNU General Public License
00018   along with this program; see the file COPYING.  If not, write to
00019   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020   Boston, MA 02111-1307, USA.
00021  */
00022 
00023 #include <qbuttongroup.h>
00024 #include <qcheckbox.h>
00025 #include <qradiobutton.h>
00026 #include <qslider.h>
00027 #include <qspinbox.h>
00028 #include <qwhatsthis.h>
00029 
00030 #include <kconfig.h>
00031 #include <klocale.h>
00032 #include <kglobal.h>
00033 
00034 #include "config.h"
00035 #include "configdialog.h"
00036 
00037 PlastikConfig::PlastikConfig(KConfig* config, QWidget* parent)
00038     : QObject(parent), m_config(0), m_dialog(0)
00039 {
00040     // create the configuration object
00041     m_config = new KConfig("kwinplastikrc");
00042     KGlobal::locale()->insertCatalogue("kwin_clients");
00043 
00044     // create and show the configuration dialog
00045     m_dialog = new ConfigDialog(parent);
00046     m_dialog->show();
00047 
00048     // load the configuration
00049     load(config);
00050 
00051     // setup the connections
00052     connect(m_dialog->titleAlign, SIGNAL(clicked(int)),
00053             this, SIGNAL(changed()));
00054     connect(m_dialog->animateButtons, SIGNAL(toggled(bool)),
00055             this, SIGNAL(changed()));
00056     connect(m_dialog->menuClose, SIGNAL(toggled(bool)),
00057             this, SIGNAL(changed()));
00058     connect(m_dialog->titleShadow, SIGNAL(toggled(bool)),
00059             this, SIGNAL(changed()));
00060 
00061 }
00062 
00063 PlastikConfig::~PlastikConfig()
00064 {
00065     if (m_dialog) delete m_dialog;
00066     if (m_config) delete m_config;
00067 }
00068 
00069 void PlastikConfig::load(KConfig*)
00070 {
00071     m_config->setGroup("General");
00072 
00073 
00074     QString value = m_config->readEntry("TitleAlignment", "AlignHCenter");
00075     QRadioButton *button = (QRadioButton*)m_dialog->titleAlign->child(value.latin1());
00076     if (button) button->setChecked(true);
00077     bool animateButtons = m_config->readBoolEntry("AnimateButtons", true);
00078     m_dialog->animateButtons->setChecked(animateButtons);
00079     bool menuClose = m_config->readBoolEntry("CloseOnMenuDoubleClick", true);
00080     m_dialog->menuClose->setChecked(menuClose);
00081     bool titleShadow = m_config->readBoolEntry("TitleShadow", true);
00082     m_dialog->titleShadow->setChecked(titleShadow);
00083 }
00084 
00085 void PlastikConfig::save(KConfig*)
00086 {
00087     m_config->setGroup("General");
00088 
00089     QRadioButton *button = (QRadioButton*)m_dialog->titleAlign->selected();
00090     if (button) m_config->writeEntry("TitleAlignment", QString(button->name()));
00091     m_config->writeEntry("AnimateButtons", m_dialog->animateButtons->isChecked() );
00092     m_config->writeEntry("CloseOnMenuDoubleClick", m_dialog->menuClose->isChecked() );
00093     m_config->writeEntry("TitleShadow", m_dialog->titleShadow->isChecked() );
00094     m_config->sync();
00095 }
00096 
00097 void PlastikConfig::defaults()
00098 {
00099     QRadioButton *button =
00100         (QRadioButton*)m_dialog->titleAlign->child("AlignHCenter");
00101     if (button) button->setChecked(true);
00102     m_dialog->animateButtons->setChecked(true);
00103     m_dialog->menuClose->setChecked(false);
00104     m_dialog->titleShadow->setChecked(true);
00105 }
00106 
00108 // Plugin Stuff                                                             //
00110 
00111 extern "C"
00112 {
00113     KDE_EXPORT QObject* allocate_config(KConfig* config, QWidget* parent) {
00114         return (new PlastikConfig(config, parent));
00115     }
00116 }
00117 
00118 #include "config.moc"
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 16:47:02 2006 by doxygen 1.4.4 written by Dimitri van Heesch, © 1997-2003