dtor first
[personal-kdebase.git] / workspace / kwin / clients / oxygen / config / config.cpp
blob7c2b8c2b691313453adba1cd2db73b744b10651e
1 /*
2 * Oxygen KWin client configuration module
4 * Copyright (C) 2008 Lubos Lunak <l.lunak@kde.org>
6 * Based on the Quartz configuration module,
7 * Copyright (c) 2001 Karol Szwed <gallium@kde.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the license, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; see the file COPYING. If not, write to
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
25 #include "config.h"
27 #include <kglobal.h>
28 #include <klocale.h>
30 #include <QCheckBox>
32 #include "config.moc"
34 extern "C"
36 KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
38 return ( new Oxygen::OxygenConfig( conf, parent ) );
42 namespace Oxygen {
44 OxygenConfig::OxygenConfig( KConfig*, QWidget* parent )
45 : QObject( parent )
47 KGlobal::locale()->insertCatalog("kwin_clients");
48 c = new KConfig( "oxygenrc" );
49 KConfigGroup cg(c, "Windeco");
50 ui = new OxygenConfigUI( parent );
51 connect( ui->showStripes, SIGNAL(clicked()), SIGNAL(changed()) );
52 connect( ui->titleAlignmentLeft, SIGNAL(clicked()), SIGNAL(changed()) );
53 connect( ui->titleAlignmentCenter, SIGNAL(clicked()), SIGNAL(changed()) );
54 connect( ui->titleAlignmentRight, SIGNAL(clicked()), SIGNAL(changed()) );
56 load( cg );
57 ui->show();
61 OxygenConfig::~OxygenConfig()
63 delete ui;
64 delete c;
68 // Loads the configurable options from the kwinrc config file
69 // It is passed the open config from kwindecoration to improve efficiency
70 void OxygenConfig::load( const KConfigGroup& )
72 KConfigGroup cg(c, "Windeco");
73 ui->showStripes->setChecked( cg.readEntry("ShowStripes", true) );
75 QString titleAlignment = cg.readEntry("TitleAlignment", "Left");
76 ui->titleAlignmentLeft->setChecked( titleAlignment == "Left" );
77 ui->titleAlignmentCenter->setChecked( titleAlignment == "Center" );
78 ui->titleAlignmentRight->setChecked( titleAlignment == "Right" );
82 // Saves the configurable options to the kwinrc config file
83 void OxygenConfig::save( KConfigGroup& )
85 KConfigGroup cg(c, "Windeco");
86 cg.writeEntry( "ShowStripes", ui->showStripes->isChecked() );
88 QString titleAlignment = "Left";
89 if (ui->titleAlignmentCenter->isChecked())
91 titleAlignment = "Center";
93 else if (ui->titleAlignmentRight->isChecked())
95 titleAlignment = "Right";
97 cg.writeEntry( "TitleAlignment", titleAlignment);
98 c->sync();
102 // Sets UI widget defaults which must correspond to style defaults
103 void OxygenConfig::defaults()
105 ui->showStripes->setChecked( true );
106 ui->titleAlignmentLeft->setChecked( true );
108 emit changed();
111 } //namespace Oxygen