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)
40
// create the configuration object
41
m_config = new KConfig("kwinplastikrc");
42
KConfigGroup cg(m_config, "General");
43
KGlobal::locale()->insertCatalog("kwin_clients");
45
// create and show the configuration dialog
46
m_dialog = new PlastikConfigDialog(parent);
49
// load the configuration
52
// setup the connections
53
connect(m_dialog->titleAlign, SIGNAL(clicked(int)),
54
this, SIGNAL(changed()));
55
connect(m_dialog->animateButtons, SIGNAL(toggled(bool)),
56
this, SIGNAL(changed()));
57
connect(m_dialog->menuClose, SIGNAL(toggled(bool)),
58
this, SIGNAL(changed()));
59
connect(m_dialog->titleShadow, SIGNAL(toggled(bool)),
60
this, SIGNAL(changed()));
61
connect(m_dialog->coloredBorder, SIGNAL(toggled(bool)),
62
this, SIGNAL(changed()));
65
PlastikConfig::~PlastikConfig()
71
void PlastikConfig::load(const KConfigGroup&)
73
KConfigGroup cg(m_config, "General");
76
QString value = cg.readEntry("TitleAlignment", "AlignLeft");
77
QRadioButton *button = m_dialog->titleAlign->findChild<QRadioButton*>(value.toLatin1());
78
if (button) button->setChecked(true);
79
bool animateButtons = cg.readEntry("AnimateButtons", true);
80
m_dialog->animateButtons->setChecked(animateButtons);
81
bool menuClose = cg.readEntry("CloseOnMenuDoubleClick", true);
82
m_dialog->menuClose->setChecked(menuClose);
83
bool titleShadow = cg.readEntry("TitleShadow", true);
84
m_dialog->titleShadow->setChecked(titleShadow);
85
bool coloredBorder = cg.readEntry("ColoredBorder", true);
86
m_dialog->coloredBorder->setChecked(coloredBorder);
89
void PlastikConfig::save(KConfigGroup&)
91
KConfigGroup cg(m_config, "General");
93
QList<QRadioButton *> buttons = m_dialog->titleAlign->findChildren<QRadioButton *>();
94
for(QList<QRadioButton *>::ConstIterator it = buttons.constBegin(); it != buttons.constEnd(); ++it)
96
if((*it)->isChecked())
97
cg.writeEntry("TitleAlignment", QString((*it)->objectName()));
100
cg.writeEntry("AnimateButtons", m_dialog->animateButtons->isChecked() );
101
cg.writeEntry("CloseOnMenuDoubleClick", m_dialog->menuClose->isChecked() );
102
cg.writeEntry("TitleShadow", m_dialog->titleShadow->isChecked() );
103
cg.writeEntry("ColoredBorder", m_dialog->coloredBorder->isChecked() );
107
void PlastikConfig::defaults()
109
QRadioButton *button = m_dialog->titleAlign->findChild<QRadioButton*>("AlignLeft");
110
if (button) button->setChecked(true);
111
m_dialog->animateButtons->setChecked(true);
112
m_dialog->menuClose->setChecked(false);
113
m_dialog->titleShadow->setChecked(true);
114
m_dialog->coloredBorder->setChecked(true);
117
//////////////////////////////////////////////////////////////////////////////
119
//////////////////////////////////////////////////////////////////////////////
123
KDE_EXPORT QObject* allocate_config(KConfig* config, QWidget* parent) {
124
return (new PlastikConfig(config, parent));
128
#include "config.moc"