1 /* Plastik KWin window decoration
2 Copyright (C) 2003 Sandro Giessl <ceebx@users.sourceforge.net>
4 based on the window decoration "Web":
5 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
23 #include <QButtonGroup>
25 #include <QRadioButton>
36 PlastikConfig::PlastikConfig(KConfig
* config
, QWidget
* parent
)
37 : QObject(parent
), m_config(0), m_dialog(0)
39 // create the configuration object
40 m_config
= new KConfig("kwinplastikrc");
41 KConfigGroup
cg(m_config
, "General");
42 KGlobal::locale()->insertCatalog("kwin_clients");
44 // create and show the configuration dialog
45 m_dialog
= new ConfigDialog(parent
);
48 // load the configuration
51 // setup the connections
52 connect(m_dialog
->titleAlign
, SIGNAL(clicked(int)),
53 this, SIGNAL(changed()));
54 connect(m_dialog
->animateButtons
, SIGNAL(toggled(bool)),
55 this, SIGNAL(changed()));
56 connect(m_dialog
->menuClose
, SIGNAL(toggled(bool)),
57 this, SIGNAL(changed()));
58 connect(m_dialog
->titleShadow
, SIGNAL(toggled(bool)),
59 this, SIGNAL(changed()));
60 connect(m_dialog
->coloredBorder
, SIGNAL(toggled(bool)),
61 this, SIGNAL(changed()));
64 PlastikConfig::~PlastikConfig()
70 void PlastikConfig::load(const KConfigGroup
&)
72 KConfigGroup
cg(m_config
, "General");
75 QString value
= cg
.readEntry("TitleAlignment", "AlignLeft");
76 QRadioButton
*button
= m_dialog
->titleAlign
->findChild
<QRadioButton
*>(value
.toLatin1());
77 if (button
) button
->setChecked(true);
78 bool animateButtons
= cg
.readEntry("AnimateButtons", true);
79 m_dialog
->animateButtons
->setChecked(animateButtons
);
80 bool menuClose
= cg
.readEntry("CloseOnMenuDoubleClick", true);
81 m_dialog
->menuClose
->setChecked(menuClose
);
82 bool titleShadow
= cg
.readEntry("TitleShadow", true);
83 m_dialog
->titleShadow
->setChecked(titleShadow
);
84 bool coloredBorder
= cg
.readEntry("ColoredBorder", true);
85 m_dialog
->coloredBorder
->setChecked(coloredBorder
);
88 void PlastikConfig::save(KConfigGroup
&)
90 KConfigGroup
cg(m_config
, "General");
92 QList
<QRadioButton
*> buttons
= m_dialog
->titleAlign
->findChildren
<QRadioButton
*>();
93 for(QList
<QRadioButton
*>::ConstIterator it
= buttons
.constBegin(); it
!= buttons
.constEnd(); ++it
)
95 if((*it
)->isChecked())
96 cg
.writeEntry("TitleAlignment", QString((*it
)->objectName()));
99 cg
.writeEntry("AnimateButtons", m_dialog
->animateButtons
->isChecked() );
100 cg
.writeEntry("CloseOnMenuDoubleClick", m_dialog
->menuClose
->isChecked() );
101 cg
.writeEntry("TitleShadow", m_dialog
->titleShadow
->isChecked() );
102 cg
.writeEntry("ColoredBorder", m_dialog
->coloredBorder
->isChecked() );
106 void PlastikConfig::defaults()
108 QRadioButton
*button
= m_dialog
->titleAlign
->findChild
<QRadioButton
*>("AlignLeft");
109 if (button
) button
->setChecked(true);
110 m_dialog
->animateButtons
->setChecked(true);
111 m_dialog
->menuClose
->setChecked(false);
112 m_dialog
->titleShadow
->setChecked(true);
113 m_dialog
->coloredBorder
->setChecked(true);
116 //////////////////////////////////////////////////////////////////////////////
118 //////////////////////////////////////////////////////////////////////////////
122 KDE_EXPORT QObject
* allocate_config(KConfig
* config
, QWidget
* parent
) {
123 return (new PlastikConfig(config
, parent
));
127 #include "config.moc"