not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kwin / clients / kde2 / config / config.cpp
blob011d524d0aef02acff0e561ecbec7d69935babcf
1 /*********************************************************************
3 KDE2 Default configuration widget
5 Copyright (c) 2001
6 Karol Szwed <gallium@kde.org>
7 http://gallium.n3.net/
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
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************/
23 #include "config.h"
25 #include <QWhatsThis>
26 #include <QPixmap>
28 #include <kglobal.h>
29 #include <kdialog.h>
30 #include <klocale.h>
31 #include <kvbox.h>
33 extern "C"
35 KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
37 return(new KDE2Config(conf, parent));
41 // NOTE:
42 // 'conf' is a pointer to the kwindecoration modules open kwin config,
43 // and is by default set to the "Style" group.
44 // 'parent' is the parent of the QObject, which is a VBox inside the
45 // Configure tab in kwindecoration
47 KDE2Config::KDE2Config( KConfig* conf, QWidget* parent )
48 : QObject( parent ), c(conf)
50 KGlobal::locale()->insertCatalog("kwin_clients");
51 highcolor = QPixmap::defaultDepth() > 8;
52 gb = new KVBox( parent );
53 gb->setSpacing( KDialog::spacingHint() );
55 cbShowStipple = new QCheckBox( i18n("Draw titlebar &stipple effect"), gb );
56 cbShowStipple->setWhatsThis(
57 i18n("When selected, active titlebars are drawn "
58 "with a stipple (dotted) effect; otherwise, they are "
59 "drawn without the stipple."));
61 cbShowGrabBar = new QCheckBox( i18n("Draw g&rab bar below windows"), gb );
62 cbShowGrabBar->setWhatsThis(
63 i18n("When selected, decorations are drawn with a \"grab bar\" "
64 "below windows; otherwise, no grab bar is drawn."));
66 // Only show the gradient checkbox for highcolor displays
67 if (highcolor)
69 cbUseGradients = new QCheckBox( i18n("Draw &gradients"), gb );
70 cbUseGradients->setWhatsThis(
71 i18n("When selected, decorations are drawn with gradients "
72 "for high-color displays; otherwise, no gradients are drawn.") );
75 // Load configuration options
76 c = new KConfig("kwinKDE2rc");
77 KConfigGroup cg(c, "General");
78 load( cg );
80 // Ensure we track user changes properly
81 connect( cbShowStipple, SIGNAL(clicked()),
82 this, SLOT(slotSelectionChanged()) );
83 connect( cbShowGrabBar, SIGNAL(clicked()),
84 this, SLOT(slotSelectionChanged()) );
85 if (highcolor)
86 connect( cbUseGradients, SIGNAL(clicked()),
87 this, SLOT(slotSelectionChanged()) );
89 // Make the widgets visible in kwindecoration
90 gb->show();
94 KDE2Config::~KDE2Config()
96 delete gb;
100 void KDE2Config::slotSelectionChanged()
102 emit changed();
106 // Loads the configurable options from the kwinrc config file
107 // It is passed the open config from kwindecoration to improve efficiency
108 void KDE2Config::load( const KConfigGroup& )
110 KConfigGroup cg(c, "KDE2");
111 bool override = cg.readEntry( "ShowTitleBarStipple", true);
112 cbShowStipple->setChecked( override );
114 override = cg.readEntry( "ShowGrabBar", true);
115 cbShowGrabBar->setChecked( override );
117 if (highcolor) {
118 override = cg.readEntry( "UseGradients", true);
119 cbUseGradients->setChecked( override );
124 // Saves the configurable options to the kwinrc config file
125 void KDE2Config::save( KConfigGroup& )
127 KConfigGroup cg(c, "KDE2");
128 cg.writeEntry( "ShowTitleBarStipple", cbShowStipple->isChecked() );
129 cg.writeEntry( "ShowGrabBar", cbShowGrabBar->isChecked() );
131 if (highcolor)
132 cg.writeEntry( "UseGradients", cbUseGradients->isChecked() );
133 // No need to conf->sync() - kwindecoration will do it for us
137 // Sets UI widget defaults which must correspond to style defaults
138 void KDE2Config::defaults()
140 cbShowStipple->setChecked( true );
141 cbShowGrabBar->setChecked( true );
143 if (highcolor)
144 cbUseGradients->setChecked( true );
147 #include "config.moc"
148 // vim: ts=4
149 // kate: space-indent off; tab-width 4;