kwin/effects/boxswitch/boxswitch_config.cpp

105 lines
2.8 KiB
C++
Raw Normal View History

/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "boxswitch_config.h"
#include <kwineffects.h>
#include <kconfiggroup.h>
#include <QVBoxLayout>
namespace KWin
{
KWIN_EFFECT_CONFIG_FACTORY
BoxSwitchEffectConfigForm::BoxSwitchEffectConfigForm(QWidget* parent) : QWidget(parent)
{
2011-01-30 14:34:42 +00:00
setupUi(this);
}
BoxSwitchEffectConfig::BoxSwitchEffectConfig(QWidget* parent, const QVariantList& args)
2011-01-30 14:34:42 +00:00
: KCModule(EffectFactory::componentData(), parent, args)
{
m_ui = new BoxSwitchEffectConfigForm(this);
2011-01-30 14:34:42 +00:00
QVBoxLayout* layout = new QVBoxLayout(this);
2011-01-30 14:34:42 +00:00
layout->addWidget(m_ui);
2011-01-30 14:34:42 +00:00
connect(m_ui->opacitySpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(m_ui->elevateBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->animateBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
load();
2011-01-30 14:34:42 +00:00
}
BoxSwitchEffectConfig::~BoxSwitchEffectConfig()
2011-01-30 14:34:42 +00:00
{
}
void BoxSwitchEffectConfig::load()
2011-01-30 14:34:42 +00:00
{
KCModule::load();
2011-01-30 14:34:42 +00:00
KConfigGroup conf = EffectsHandler::effectConfig("BoxSwitch");
int opacity = conf.readEntry("BackgroundOpacity", 25);
m_ui->opacitySpin->setValue(opacity);
2011-01-30 14:34:42 +00:00
bool elevate = conf.readEntry("ElevateSelected", true);
m_ui->elevateBox->setChecked(elevate);
2011-01-30 14:34:42 +00:00
bool animate = conf.readEntry("AnimateSwitch", false);
m_ui->animateBox->setChecked(animate);
emit changed(false);
2011-01-30 14:34:42 +00:00
}
void BoxSwitchEffectConfig::save()
2011-01-30 14:34:42 +00:00
{
KCModule::save();
2011-01-30 14:34:42 +00:00
KConfigGroup conf = EffectsHandler::effectConfig("BoxSwitch");
2011-01-30 14:34:42 +00:00
conf.writeEntry("BackgroundOpacity", m_ui->opacitySpin->value());
2011-01-30 14:34:42 +00:00
conf.writeEntry("ElevateSelected", m_ui->elevateBox->isChecked());
2011-01-30 14:34:42 +00:00
conf.writeEntry("AnimateSwitch", m_ui->animateBox->isChecked());
conf.sync();
emit changed(false);
2011-01-30 14:34:42 +00:00
EffectsHandler::sendReloadMessage("boxswitch");
}
void BoxSwitchEffectConfig::defaults()
2011-01-30 14:34:42 +00:00
{
m_ui->opacitySpin->setValue(25);
m_ui->elevateBox->setChecked(true);
m_ui->animateBox->setChecked(false);
emit changed(true);
2011-01-30 14:34:42 +00:00
}
} // namespace
#include "boxswitch_config.moc"