~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/clients/plastik/config/config.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Plastik KWin window decoration
 
2
  Copyright (C) 2003 Sandro Giessl <ceebx@users.sourceforge.net>
 
3
 
 
4
  based on the window decoration "Web":
 
5
  Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
 
6
 
 
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.
 
11
 
 
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.
 
16
 
 
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.
 
21
 */
 
22
 
 
23
#include <QButtonGroup>
 
24
#include <QCheckBox>
 
25
#include <QRadioButton>
 
26
#include <QSlider>
 
27
#include <QSpinBox>
 
28
#include <QWhatsThis>
 
29
 
 
30
#include <kconfig.h>
 
31
#include <klocale.h>
 
32
#include <kglobal.h>
 
33
 
 
34
#include "config.h"
 
35
 
 
36
PlastikConfig::PlastikConfig(KConfig* config, QWidget* parent)
 
37
    : QObject(parent), m_config(0), m_dialog(0)
 
38
{
 
39
    Q_UNUSED( config );
 
40
    // create the configuration object
 
41
    m_config = new KConfig("kwinplastikrc");
 
42
    KConfigGroup cg(m_config, "General");
 
43
    KGlobal::locale()->insertCatalog("kwin_clients");
 
44
 
 
45
    // create and show the configuration dialog
 
46
    m_dialog = new PlastikConfigDialog(parent);
 
47
    m_dialog->show();
 
48
 
 
49
    // load the configuration
 
50
    load(cg);
 
51
 
 
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()));
 
63
}
 
64
 
 
65
PlastikConfig::~PlastikConfig()
 
66
{
 
67
    delete m_dialog;
 
68
    delete m_config;
 
69
}
 
70
 
 
71
void PlastikConfig::load(const KConfigGroup&)
 
72
{
 
73
    KConfigGroup cg(m_config, "General");
 
74
 
 
75
 
 
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);
 
87
}
 
88
 
 
89
void PlastikConfig::save(KConfigGroup&)
 
90
{
 
91
    KConfigGroup cg(m_config, "General");
 
92
 
 
93
    QList<QRadioButton *> buttons = m_dialog->titleAlign->findChildren<QRadioButton *>();
 
94
    for(QList<QRadioButton *>::ConstIterator it = buttons.constBegin(); it != buttons.constEnd(); ++it)
 
95
    {
 
96
        if((*it)->isChecked())
 
97
            cg.writeEntry("TitleAlignment", QString((*it)->objectName()));
 
98
    }
 
99
 
 
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() );
 
104
    m_config->sync();
 
105
}
 
106
 
 
107
void PlastikConfig::defaults()
 
108
{
 
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);
 
115
}
 
116
 
 
117
//////////////////////////////////////////////////////////////////////////////
 
118
// Plugin Stuff                                                             //
 
119
//////////////////////////////////////////////////////////////////////////////
 
120
 
 
121
extern "C"
 
122
{
 
123
    KDE_EXPORT QObject* allocate_config(KConfig* config, QWidget* parent) {
 
124
        return (new PlastikConfig(config, parent));
 
125
    }
 
126
}
 
127
 
 
128
#include "config.moc"