add more spacing
[personal-kdebase.git] / workspace / kwin / clients / ozone / config / config.cpp
blobb65818fb08ee50fac9141b39381d85905d02930e
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 Ozone::Oxygen::OxygenConfig( conf, parent ) );
42 namespace Ozone {
43 namespace Oxygen {
45 OxygenConfig::OxygenConfig( KConfig*, QWidget* parent )
46 : QObject( parent )
48 KGlobal::locale()->insertCatalog("kwin_clients");
49 c = new KConfig( "oxygenrc" );
50 KConfigGroup cg(c, "Windeco");
51 ui = new OxygenConfigUI( parent );
52 connect( ui->showStripes, SIGNAL(clicked()), SIGNAL(changed()) );
53 connect( ui->blendTitlebarColors, SIGNAL(clicked()), SIGNAL(changed()) );
54 connect( ui->titleAlignmentLeft, SIGNAL(clicked()), SIGNAL(changed()) );
55 connect( ui->titleAlignmentCenter, SIGNAL(clicked()), SIGNAL(changed()) );
56 connect( ui->titleAlignmentRight, SIGNAL(clicked()), SIGNAL(changed()) );
58 load( cg );
59 ui->show();
63 OxygenConfig::~OxygenConfig()
65 delete ui;
66 delete c;
70 // Loads the configurable options from the kwinrc config file
71 // It is passed the open config from kwindecoration to improve efficiency
72 void OxygenConfig::load( const KConfigGroup& )
74 KConfigGroup cg(c, "Windeco");
75 ui->showStripes->setChecked( cg.readEntry("ShowStripes", true) );
76 ui->blendTitlebarColors->setChecked( cg.readEntry("BlendTitlebarColors", true) );
78 QString titleAlignment = cg.readEntry("TitleAlignment", "Left");
79 ui->titleAlignmentLeft->setChecked( titleAlignment == "Left" );
80 ui->titleAlignmentCenter->setChecked( titleAlignment == "Center" );
81 ui->titleAlignmentRight->setChecked( titleAlignment == "Right" );
85 // Saves the configurable options to the kwinrc config file
86 void OxygenConfig::save( KConfigGroup& )
88 KConfigGroup cg(c, "Windeco");
89 cg.writeEntry( "ShowStripes", ui->showStripes->isChecked() );
90 cg.writeEntry( "BlendTitlebarColors", ui->blendTitlebarColors->isChecked() );
92 QString titleAlignment = "Left";
93 if (ui->titleAlignmentCenter->isChecked())
95 titleAlignment = "Center";
97 else if (ui->titleAlignmentRight->isChecked())
99 titleAlignment = "Right";
101 cg.writeEntry( "TitleAlignment", titleAlignment);
102 c->sync();
106 // Sets UI widget defaults which must correspond to style defaults
107 void OxygenConfig::defaults()
109 ui->showStripes->setChecked( true );
110 ui->titleAlignmentLeft->setChecked( true );
111 ui->blendTitlebarColors->setChecked( true );
113 emit changed();
116 } //namespace Oxygen
117 } //namespace Ozone