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

« back to all changes in this revision

Viewing changes to kwin/effects/coverswitch/coverswitch_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 Martin Gräßlin <ubuntu@martin-graesslin.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
#include "coverswitch_config.h"
 
21
#include <kwineffects.h>
 
22
 
 
23
#include <kconfiggroup.h>
 
24
 
 
25
#include <QVBoxLayout>
 
26
 
 
27
namespace KWin
 
28
{
 
29
 
 
30
KWIN_EFFECT_CONFIG_FACTORY
 
31
 
 
32
CoverSwitchEffectConfigForm::CoverSwitchEffectConfigForm(QWidget* parent) : QWidget(parent)
 
33
{
 
34
    setupUi(this);
 
35
}
 
36
 
 
37
CoverSwitchEffectConfig::CoverSwitchEffectConfig(QWidget* parent, const QVariantList& args) :
 
38
    KCModule(EffectFactory::componentData(), parent, args)
 
39
{
 
40
    m_ui = new CoverSwitchEffectConfigForm(this);
 
41
 
 
42
    QVBoxLayout* layout = new QVBoxLayout(this);
 
43
 
 
44
    layout->addWidget(m_ui);
 
45
 
 
46
    connect(m_ui->checkAnimateSwitch, SIGNAL(stateChanged(int)), this, SLOT(changed()));
 
47
    connect(m_ui->checkAnimateStart, SIGNAL(stateChanged(int)), this, SLOT(changed()));
 
48
    connect(m_ui->checkAnimateStop, SIGNAL(stateChanged(int)), this, SLOT(changed()));
 
49
    connect(m_ui->checkReflection, SIGNAL(stateChanged(int)), this, SLOT(changed()));
 
50
    connect(m_ui->colorFront, SIGNAL(changed(const QColor&)), this, SLOT(changed()));
 
51
    connect(m_ui->colorRear, SIGNAL(changed(const QColor&)), this, SLOT(changed()));
 
52
    connect(m_ui->checkWindowTitle, SIGNAL(stateChanged(int)), this, SLOT(changed()));
 
53
    connect(m_ui->checkThumbnails, SIGNAL(stateChanged(int)), this, SLOT(changed()));
 
54
    connect(m_ui->checkDynamicThumbnails, SIGNAL(stateChanged(int)), this, SLOT(changed()));
 
55
    connect(m_ui->spinThumbnailWindows, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
56
    connect(m_ui->spinDuration, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
57
    connect(m_ui->zPositionSlider, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
58
 
 
59
    connect(m_ui->checkThumbnails, SIGNAL(stateChanged(int)), this, SLOT(thumbnailsChanged()));
 
60
    connect(m_ui->checkDynamicThumbnails, SIGNAL(stateChanged(int)), this, SLOT(thumbnailsChanged()));
 
61
 
 
62
    load();
 
63
}
 
64
 
 
65
void CoverSwitchEffectConfig::load()
 
66
{
 
67
    KCModule::load();
 
68
 
 
69
    KConfigGroup conf = EffectsHandler::effectConfig("CoverSwitch");
 
70
 
 
71
    m_ui->spinDuration->setValue(conf.readEntry("Duration", 0));
 
72
    m_ui->spinDuration->setSuffix(ki18np(" millisecond", " milliseconds"));
 
73
    m_ui->checkAnimateSwitch->setChecked(conf.readEntry("AnimateSwitch", true));
 
74
    m_ui->checkAnimateStart->setChecked(conf.readEntry("AnimateStart", true));
 
75
    m_ui->checkAnimateStop->setChecked(conf.readEntry("AnimateStop", true));
 
76
    m_ui->checkReflection->setChecked(conf.readEntry("Reflection", true));
 
77
    m_ui->colorFront->setColor(conf.readEntry("MirrorFrontColor", QColor(0, 0, 0)));
 
78
    m_ui->colorRear->setColor(conf.readEntry("MirrorRearColor", QColor(0, 0, 0)));
 
79
    m_ui->checkWindowTitle->setChecked(conf.readEntry("WindowTitle", true));
 
80
    m_ui->checkThumbnails->setChecked(conf.readEntry("Thumbnails", true));
 
81
    m_ui->checkDynamicThumbnails->setChecked(conf.readEntry("DynamicThumbnails", true));
 
82
    m_ui->spinThumbnailWindows->setValue(conf.readEntry("ThumbnailWindows", 8));
 
83
    m_ui->zPositionSlider->setValue(conf.readEntry("ZPosition", 900));
 
84
 
 
85
    thumbnailsChanged();
 
86
 
 
87
    emit changed(false);
 
88
}
 
89
 
 
90
void CoverSwitchEffectConfig::save()
 
91
{
 
92
    KConfigGroup conf = EffectsHandler::effectConfig("CoverSwitch");
 
93
 
 
94
    conf.writeEntry("Duration", m_ui->spinDuration->value());
 
95
    conf.writeEntry("AnimateSwitch", m_ui->checkAnimateSwitch->isChecked());
 
96
    conf.writeEntry("AnimateStart", m_ui->checkAnimateStart->isChecked());
 
97
    conf.writeEntry("AnimateStop", m_ui->checkAnimateStop->isChecked());
 
98
    conf.writeEntry("Reflection", m_ui->checkReflection->isChecked());
 
99
    conf.writeEntry("MirrorFrontColor", m_ui->colorFront->color());
 
100
    conf.writeEntry("MirrorRearColor", m_ui->colorRear->color());
 
101
    conf.writeEntry("WindowTitle", m_ui->checkWindowTitle->isChecked());
 
102
    conf.writeEntry("Thumbnails", m_ui->checkThumbnails->isChecked());
 
103
    conf.writeEntry("DynamicThumbnails", m_ui->checkDynamicThumbnails->isChecked());
 
104
    conf.writeEntry("ThumbnailWindows", m_ui->spinThumbnailWindows->value());
 
105
    conf.writeEntry("ZPosition", m_ui->zPositionSlider->value());
 
106
 
 
107
    conf.sync();
 
108
 
 
109
    emit changed(false);
 
110
    EffectsHandler::sendReloadMessage("coverswitch");
 
111
}
 
112
 
 
113
void CoverSwitchEffectConfig::defaults()
 
114
{
 
115
    m_ui->spinDuration->setValue(0);
 
116
    m_ui->checkAnimateSwitch->setCheckState(Qt::Checked);
 
117
    m_ui->checkAnimateStart->setCheckState(Qt::Checked);
 
118
    m_ui->checkAnimateStop->setCheckState(Qt::Checked);
 
119
    m_ui->checkReflection->setCheckState(Qt::Checked);
 
120
    m_ui->colorFront->setColor(QColor(0, 0, 0));
 
121
    m_ui->colorRear->setColor(QColor(0, 0, 0));
 
122
    m_ui->checkWindowTitle->setCheckState(Qt::Checked);
 
123
    m_ui->checkThumbnails->setCheckState(Qt::Checked);
 
124
    m_ui->checkDynamicThumbnails->setCheckState(Qt::Checked);
 
125
    m_ui->spinThumbnailWindows->setValue(8);
 
126
    m_ui->zPositionSlider->setValue(900);
 
127
    emit changed(true);
 
128
}
 
129
 
 
130
void CoverSwitchEffectConfig::thumbnailsChanged()
 
131
{
 
132
    bool enabled = m_ui->checkThumbnails->isChecked() && m_ui->checkDynamicThumbnails->isChecked();
 
133
    m_ui->checkDynamicThumbnails->setEnabled(m_ui->checkThumbnails->isChecked());
 
134
    m_ui->spinThumbnailWindows->setEnabled(enabled);
 
135
    m_ui->labelThumbnailWindows->setEnabled(enabled);
 
136
}
 
137
 
 
138
} // namespace
 
139
 
 
140
#include "coverswitch_config.moc"