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

« back to all changes in this revision

Viewing changes to kwin/effects/boxswitch/boxswitch_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
/********************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.com>
 
6
 
 
7
This program is free software; you can redistribute it and/or modify
 
8
it under the terms of the GNU General Public License as published by
 
9
the Free Software Foundation; either version 2 of the License, or
 
10
(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
 
15
GNU 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.  If not, see <http://www.gnu.org/licenses/>.
 
19
*********************************************************************/
 
20
 
 
21
#include "boxswitch_config.h"
 
22
#include <kwineffects.h>
 
23
 
 
24
#include <kconfiggroup.h>
 
25
 
 
26
#include <QVBoxLayout>
 
27
 
 
28
namespace KWin
 
29
{
 
30
 
 
31
KWIN_EFFECT_CONFIG_FACTORY
 
32
 
 
33
BoxSwitchEffectConfigForm::BoxSwitchEffectConfigForm(QWidget* parent) : QWidget(parent)
 
34
{
 
35
    setupUi(this);
 
36
}
 
37
 
 
38
BoxSwitchEffectConfig::BoxSwitchEffectConfig(QWidget* parent, const QVariantList& args)
 
39
    :   KCModule(EffectFactory::componentData(), parent, args)
 
40
{
 
41
    m_ui = new BoxSwitchEffectConfigForm(this);
 
42
 
 
43
    QVBoxLayout* layout = new QVBoxLayout(this);
 
44
 
 
45
    layout->addWidget(m_ui);
 
46
 
 
47
    connect(m_ui->opacitySpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
48
    connect(m_ui->elevateBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
 
49
    connect(m_ui->animateBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
 
50
 
 
51
    load();
 
52
}
 
53
 
 
54
BoxSwitchEffectConfig::~BoxSwitchEffectConfig()
 
55
{
 
56
}
 
57
 
 
58
void BoxSwitchEffectConfig::load()
 
59
{
 
60
    KCModule::load();
 
61
 
 
62
    KConfigGroup conf = EffectsHandler::effectConfig("BoxSwitch");
 
63
 
 
64
    int opacity = conf.readEntry("BackgroundOpacity", 25);
 
65
    m_ui->opacitySpin->setValue(opacity);
 
66
 
 
67
    bool elevate = conf.readEntry("ElevateSelected", true);
 
68
    m_ui->elevateBox->setChecked(elevate);
 
69
 
 
70
    bool animate = conf.readEntry("AnimateSwitch", false);
 
71
    m_ui->animateBox->setChecked(animate);
 
72
 
 
73
    emit changed(false);
 
74
}
 
75
 
 
76
void BoxSwitchEffectConfig::save()
 
77
{
 
78
    KCModule::save();
 
79
 
 
80
    KConfigGroup conf = EffectsHandler::effectConfig("BoxSwitch");
 
81
 
 
82
    conf.writeEntry("BackgroundOpacity", m_ui->opacitySpin->value());
 
83
 
 
84
    conf.writeEntry("ElevateSelected", m_ui->elevateBox->isChecked());
 
85
 
 
86
    conf.writeEntry("AnimateSwitch", m_ui->animateBox->isChecked());
 
87
 
 
88
    conf.sync();
 
89
 
 
90
    emit changed(false);
 
91
    EffectsHandler::sendReloadMessage("boxswitch");
 
92
}
 
93
 
 
94
void BoxSwitchEffectConfig::defaults()
 
95
{
 
96
    m_ui->opacitySpin->setValue(25);
 
97
    m_ui->elevateBox->setChecked(true);
 
98
    m_ui->animateBox->setChecked(false);
 
99
    emit changed(true);
 
100
}
 
101
 
 
102
} // namespace
 
103
 
 
104
#include "boxswitch_config.moc"