1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com
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.
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.
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>
23
#include <kconfiggroup.h>
25
#include <QVBoxLayout>
30
KWIN_EFFECT_CONFIG_FACTORY
32
CoverSwitchEffectConfigForm::CoverSwitchEffectConfigForm(QWidget* parent) : QWidget(parent)
37
CoverSwitchEffectConfig::CoverSwitchEffectConfig(QWidget* parent, const QVariantList& args) :
38
KCModule(EffectFactory::componentData(), parent, args)
40
m_ui = new CoverSwitchEffectConfigForm(this);
42
QVBoxLayout* layout = new QVBoxLayout(this);
44
layout->addWidget(m_ui);
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()));
59
connect(m_ui->checkThumbnails, SIGNAL(stateChanged(int)), this, SLOT(thumbnailsChanged()));
60
connect(m_ui->checkDynamicThumbnails, SIGNAL(stateChanged(int)), this, SLOT(thumbnailsChanged()));
65
void CoverSwitchEffectConfig::load()
69
KConfigGroup conf = EffectsHandler::effectConfig("CoverSwitch");
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));
90
void CoverSwitchEffectConfig::save()
92
KConfigGroup conf = EffectsHandler::effectConfig("CoverSwitch");
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());
110
EffectsHandler::sendReloadMessage("coverswitch");
113
void CoverSwitchEffectConfig::defaults()
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);
130
void CoverSwitchEffectConfig::thumbnailsChanged()
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);
140
#include "coverswitch_config.moc"