kwin/effects/wobblywindows_config.cpp
Lucas Murray 0e84aec582 Setting to disable wobbly windows for resizes or moves separately.
BUG: 167564

svn path=/trunk/KDE/kdebase/workspace/; revision=857060
2008-09-04 15:09:22 +00:00

115 lines
3.1 KiB
C++

/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2008 Cédric Borgese <cedric.borgese@gmail.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 "wobblywindows_config.h"
#include <kwineffects.h>
#include <klocale.h>
#include <kdebug.h>
#include <kaction.h>
#include <kconfiggroup.h>
#ifndef KDE_USE_FINAL
KWIN_EFFECT_CONFIG_FACTORY
#endif
namespace KWin
{
WobblyWindowsEffectConfig::WobblyWindowsEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
m_ui.setupUi(this);
connect(m_ui.slWobblyness, SIGNAL(valueChanged(int)), this, SLOT(slotSlWobblyness(int)));
connect(m_ui.moveBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui.resizeBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
load();
}
WobblyWindowsEffectConfig::~WobblyWindowsEffectConfig()
{
}
void WobblyWindowsEffectConfig::load()
{
KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig("Wobbly");
bool change = true;
unsigned int wobblynessLevel = 1;
QString settingsMode = conf.readEntry("Settings", "Auto");
if (settingsMode != "Custom")
{
wobblynessLevel = conf.readEntry("WobblynessLevel", 1);
change = false;
}
if (wobblynessLevel > 4)
{
wobblynessLevel = 4;
change = true;
}
m_ui.slWobblyness->setSliderPosition(wobblynessLevel);
bool moving = conf.readEntry("MoveWobble", true);
m_ui.moveBox->setChecked(moving);
bool resizing = conf.readEntry("ResizeWobble", true);
m_ui.resizeBox->setChecked(resizing);
emit changed(change);
}
void WobblyWindowsEffectConfig::save()
{
KConfigGroup conf = EffectsHandler::effectConfig("Wobbly");
conf.writeEntry("Settings", "Auto");
conf.writeEntry("WobblynessLevel", m_ui.slWobblyness->value());
conf.writeEntry("MoveWobble", m_ui.moveBox->isChecked());
conf.writeEntry("ResizeWobble", m_ui.resizeBox->isChecked());
emit changed(false);
EffectsHandler::sendReloadMessage("wobblywindows");
}
void WobblyWindowsEffectConfig::defaults()
{
m_ui.slWobblyness->setSliderPosition(2);
m_ui.moveBox->setChecked( true );
m_ui.resizeBox->setChecked( true );
emit changed(true);
}
void WobblyWindowsEffectConfig::slotSlWobblyness(int)
{
emit changed(true);
}
} // namespace
#include "wobblywindows_config.moc"