/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2008 Martin Gräßlin .
*********************************************************************/
#include "flipswitch_config.h"
#include
#include
#include
#ifndef KDE_USE_FINAL
KWIN_EFFECT_CONFIG_FACTORY
#endif
namespace KWin
{
FlipSwitchEffectConfigForm::FlipSwitchEffectConfigForm(QWidget* parent) : QWidget(parent)
{
setupUi(this);
}
FlipSwitchEffectConfig::FlipSwitchEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
m_ui = new FlipSwitchEffectConfigForm(this);
QGridLayout* layout = new QGridLayout(this);
layout->addWidget(m_ui, 0, 0);
connect(m_ui->checkAnimateFlip, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->spinFlipDuration, SIGNAL(valueChanged(int)), this, SLOT(changed()));
load();
}
FlipSwitchEffectConfig::~FlipSwitchEffectConfig()
{
}
void FlipSwitchEffectConfig::load()
{
KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig( "FlipSwitch" );
int flipDuration = conf.readEntry( "FlipDuration", 200 );
bool animateFlip = conf.readEntry( "AnimateFlip", true );
m_ui->spinFlipDuration->setValue( flipDuration );
if( animateFlip )
{
m_ui->checkAnimateFlip->setCheckState( Qt::Checked );
}
else
{
m_ui->checkAnimateFlip->setCheckState( Qt::Unchecked );
}
emit changed(false);
}
void FlipSwitchEffectConfig::save()
{
KConfigGroup conf = EffectsHandler::effectConfig( "FlipSwitch" );
conf.writeEntry( "FlipDuration", m_ui->spinFlipDuration->value() );
conf.writeEntry( "AnimateFlip", m_ui->checkAnimateFlip->checkState() == Qt::Checked ? true : false );
conf.sync();
emit changed(false);
EffectsHandler::sendReloadMessage( "flipswitch" );
}
void FlipSwitchEffectConfig::defaults()
{
m_ui->spinFlipDuration->setValue( 200 );
m_ui->checkAnimateFlip->setCheckState( Qt::Checked );
emit changed(true);
}
} // namespace
#include "flipswitch_config.moc"