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>
27 KWIN_EFFECT_CONFIG_FACTORY
33 CoverSwitchEffectConfigForm::CoverSwitchEffectConfigForm(QWidget
* parent
) : QWidget(parent
)
38 CoverSwitchEffectConfig::CoverSwitchEffectConfig(QWidget
* parent
, const QVariantList
& args
) :
39 KCModule(EffectFactory::componentData(), parent
, args
)
41 m_ui
= new CoverSwitchEffectConfigForm(this);
43 QVBoxLayout
* layout
= new QVBoxLayout(this);
45 layout
->addWidget(m_ui
);
47 connect(m_ui
->checkAnimateSwitch
, SIGNAL(stateChanged(int)), this, SLOT(changed()));
48 connect(m_ui
->checkAnimateStart
, SIGNAL(stateChanged(int)), this, SLOT(changed()));
49 connect(m_ui
->checkAnimateStop
, SIGNAL(stateChanged(int)), this, SLOT(changed()));
50 connect(m_ui
->checkReflection
, SIGNAL(stateChanged(int)), this, SLOT(changed()));
51 connect(m_ui
->checkThumbnails
, SIGNAL(stateChanged(int)), this, SLOT(changed()));
52 connect(m_ui
->checkDynamicThumbnails
, SIGNAL(stateChanged(int)), this, SLOT(changed()));
53 connect(m_ui
->spinThumbnailWindows
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
54 connect(m_ui
->spinDuration
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
55 connect(m_ui
->zPositionSlider
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
57 connect(m_ui
->checkThumbnails
, SIGNAL(stateChanged(int)), this, SLOT(thumbnailsChanged()));
58 connect(m_ui
->checkDynamicThumbnails
, SIGNAL(stateChanged(int)), this, SLOT(thumbnailsChanged()));
63 void CoverSwitchEffectConfig::load()
67 KConfigGroup conf
= EffectsHandler::effectConfig( "CoverSwitch" );
69 m_ui
->spinDuration
->setValue( conf
.readEntry( "Duration", 0 ) );
70 m_ui
->checkAnimateSwitch
->setChecked( conf
.readEntry( "AnimateSwitch", true ));
71 m_ui
->checkAnimateStart
->setChecked( conf
.readEntry( "AnimateStart", true ));
72 m_ui
->checkAnimateStop
->setChecked( conf
.readEntry( "AnimateStop", true ));
73 m_ui
->checkReflection
->setChecked( conf
.readEntry( "Reflection", true ));
74 m_ui
->checkThumbnails
->setChecked( conf
.readEntry( "Thumbnails", true ));
75 m_ui
->checkDynamicThumbnails
->setChecked( conf
.readEntry( "DynamicThumbnails", true ));
76 m_ui
->spinThumbnailWindows
->setValue( conf
.readEntry( "ThumbnailWindows", 8 ));
77 m_ui
->zPositionSlider
->setValue( conf
.readEntry( "ZPosition", 900 ));
84 void CoverSwitchEffectConfig::save()
86 KConfigGroup conf
= EffectsHandler::effectConfig( "CoverSwitch" );
88 conf
.writeEntry( "Duration", m_ui
->spinDuration
->value() );
89 conf
.writeEntry( "AnimateSwitch", m_ui
->checkAnimateSwitch
->isChecked() );
90 conf
.writeEntry( "AnimateStart", m_ui
->checkAnimateStart
->isChecked() );
91 conf
.writeEntry( "AnimateStop", m_ui
->checkAnimateStop
->isChecked() );
92 conf
.writeEntry( "Reflection", m_ui
->checkReflection
->isChecked() );
93 conf
.writeEntry( "Thumbnails", m_ui
->checkThumbnails
->isChecked() );
94 conf
.writeEntry( "DynamicThumbnails", m_ui
->checkDynamicThumbnails
->isChecked() );
95 conf
.writeEntry( "ThumbnailWindows", m_ui
->spinThumbnailWindows
->value() );
96 conf
.writeEntry( "ZPosition", m_ui
->zPositionSlider
->value() );
101 EffectsHandler::sendReloadMessage( "coverswitch" );
104 void CoverSwitchEffectConfig::defaults()
106 m_ui
->spinDuration
->setValue( 0 );
107 m_ui
->checkAnimateSwitch
->setCheckState( Qt::Checked
);
108 m_ui
->checkAnimateStart
->setCheckState( Qt::Checked
);
109 m_ui
->checkAnimateStop
->setCheckState( Qt::Checked
);
110 m_ui
->checkReflection
->setCheckState( Qt::Checked
);
111 m_ui
->checkThumbnails
->setCheckState( Qt::Checked
);
112 m_ui
->checkDynamicThumbnails
->setCheckState( Qt::Checked
);
113 m_ui
->spinThumbnailWindows
->setValue( 8 );
114 m_ui
->zPositionSlider
->setValue( 900 );
118 void CoverSwitchEffectConfig::thumbnailsChanged()
120 bool enabled
= m_ui
->checkThumbnails
->isChecked() && m_ui
->checkDynamicThumbnails
->isChecked();
121 m_ui
->checkDynamicThumbnails
->setEnabled( m_ui
->checkThumbnails
->isChecked() );
122 m_ui
->spinThumbnailWindows
->setEnabled( enabled
);
123 m_ui
->labelThumbnailWindows
->setEnabled( enabled
);
128 #include "coverswitch_config.moc"