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 <KActionCollection>
25 #include <KGlobalAccel>
26 #include <kconfiggroup.h>
28 #include <QGridLayout>
30 KWIN_EFFECT_CONFIG_FACTORY
36 CoverSwitchEffectConfigForm::CoverSwitchEffectConfigForm(QWidget
* parent
) : QWidget(parent
)
41 CoverSwitchEffectConfig::CoverSwitchEffectConfig(QWidget
* parent
, const QVariantList
& args
) :
42 KCModule(EffectFactory::componentData(), parent
, args
)
44 m_ui
= new CoverSwitchEffectConfigForm(this);
46 QGridLayout
* layout
= new QGridLayout(this);
48 layout
->addWidget(m_ui
, 0, 0);
50 connect(m_ui
->editor
, SIGNAL(keyChange()), this, SLOT(changed()));
51 connect(m_ui
->checkAnimateSwitch
, SIGNAL(stateChanged(int)), this, SLOT(changed()));
52 connect(m_ui
->checkAnimateStart
, SIGNAL(stateChanged(int)), this, SLOT(changed()));
53 connect(m_ui
->checkAnimateStop
, SIGNAL(stateChanged(int)), this, SLOT(changed()));
54 connect(m_ui
->checkReflection
, SIGNAL(stateChanged(int)), this, SLOT(changed()));
55 connect(m_ui
->spinDuration
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
56 connect(m_ui
->spinSlowMotionFactor
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
58 KGlobalAccel::self()->overrideMainComponentData( componentData() );
59 m_actionCollection
= new KActionCollection( this, componentData() );
60 m_actionCollection
->setConfigGroup( "CoverSwitch" );
61 m_actionCollection
->setConfigGlobal( true );
63 KAction
* a
= (KAction
*)m_actionCollection
->addAction( "SlowMotion" );
64 a
->setText( i18n("Slow Motion" ) );
65 a
->setGlobalShortcut( KShortcut( Qt::META
+ Qt::Key_S
) );
70 CoverSwitchEffectConfig::~CoverSwitchEffectConfig()
74 void CoverSwitchEffectConfig::load()
78 KConfigGroup conf
= EffectsHandler::effectConfig( "CoverSwitch" );
80 int duration
= conf
.readEntry( "Duration", 300 );
81 int slowMotionFactor
= conf
.readEntry( "SlowMotionFactor", 4 );
82 bool animateSwitch
= conf
.readEntry( "AnimateSwitch", true );
83 bool animateStart
= conf
.readEntry( "AnimateStart", true );
84 bool animateStop
= conf
.readEntry( "AnimateStop", true );
85 bool reflection
= conf
.readEntry( "Reflection", true );
86 m_ui
->spinDuration
->setValue( duration
);
87 m_ui
->spinSlowMotionFactor
->setValue( slowMotionFactor
);
90 m_ui
->checkAnimateSwitch
->setCheckState( Qt::Checked
);
94 m_ui
->checkAnimateSwitch
->setCheckState( Qt::Unchecked
);
98 m_ui
->checkAnimateStart
->setCheckState( Qt::Checked
);
102 m_ui
->checkAnimateStart
->setCheckState( Qt::Unchecked
);
106 m_ui
->checkAnimateStop
->setCheckState( Qt::Checked
);
110 m_ui
->checkAnimateStop
->setCheckState( Qt::Unchecked
);
114 m_ui
->checkReflection
->setCheckState( Qt::Checked
);
118 m_ui
->checkReflection
->setCheckState( Qt::Unchecked
);
121 m_actionCollection
->readSettings();
122 m_ui
->editor
->addCollection(m_actionCollection
);
127 void CoverSwitchEffectConfig::save()
129 KConfigGroup conf
= EffectsHandler::effectConfig( "CoverSwitch" );
131 conf
.writeEntry( "Duration", m_ui
->spinDuration
->value() );
132 conf
.writeEntry( "SlowMotionFactor", m_ui
->spinSlowMotionFactor
->value() );
133 conf
.writeEntry( "AnimateSwitch", m_ui
->checkAnimateSwitch
->checkState() == Qt::Checked
? true : false );
134 conf
.writeEntry( "AnimateStart", m_ui
->checkAnimateStart
->checkState() == Qt::Checked
? true : false );
135 conf
.writeEntry( "AnimateStop", m_ui
->checkAnimateStop
->checkState() == Qt::Checked
? true : false );
136 conf
.writeEntry( "Reflection", m_ui
->checkReflection
->checkState() == Qt::Checked
? true : false );
138 m_actionCollection
->writeSettings();
143 EffectsHandler::sendReloadMessage( "coverswitch" );
146 void CoverSwitchEffectConfig::defaults()
148 m_ui
->spinDuration
->setValue( 300 );
149 m_ui
->spinSlowMotionFactor
->setValue( 4 );
150 m_ui
->checkAnimateSwitch
->setCheckState( Qt::Checked
);
151 m_ui
->checkAnimateStart
->setCheckState( Qt::Checked
);
152 m_ui
->checkAnimateStop
->setCheckState( Qt::Checked
);
153 m_ui
->checkReflection
->setCheckState( Qt::Checked
);
160 #include "coverswitch_config.moc"