2008-01-08 15:47:31 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Martin Gräßlin <ubuntu@martin-graesslin.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 "snow_config.h"
|
|
|
|
#include <kwineffects.h>
|
|
|
|
|
|
|
|
#include <klocale.h>
|
|
|
|
#include <kdebug.h>
|
|
|
|
#include <KActionCollection>
|
|
|
|
#include <kaction.h>
|
|
|
|
#include <kconfiggroup.h>
|
|
|
|
|
2008-09-16 07:41:39 +00:00
|
|
|
#include <QVBoxLayout>
|
2009-02-05 15:35:38 +00:00
|
|
|
|
2008-01-08 15:47:31 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2009-02-05 15:35:38 +00:00
|
|
|
KWIN_EFFECT_CONFIG_FACTORY
|
|
|
|
|
2008-01-08 15:47:31 +00:00
|
|
|
SnowEffectConfigForm::SnowEffectConfigForm(QWidget* parent) : QWidget(parent)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
SnowEffectConfig::SnowEffectConfig(QWidget* parent, const QVariantList& args) :
|
|
|
|
KCModule(EffectFactory::componentData(), parent, args)
|
|
|
|
{
|
|
|
|
m_ui = new SnowEffectConfigForm(this);
|
|
|
|
|
2008-09-16 07:41:39 +00:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
2008-01-08 15:47:31 +00:00
|
|
|
|
2008-09-16 07:41:39 +00:00
|
|
|
layout->addWidget(m_ui);
|
2008-01-08 15:47:31 +00:00
|
|
|
|
|
|
|
connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
|
|
|
|
connect(m_ui->numberFlakes, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
|
|
|
connect(m_ui->minSizeFlake, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
|
|
|
connect(m_ui->maxSizeFlake, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
2008-10-13 03:29:07 +00:00
|
|
|
connect(m_ui->maxVSpeed, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
|
|
|
connect(m_ui->maxHSpeed, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
2008-11-11 11:31:12 +00:00
|
|
|
connect(m_ui->snowBehindWindows, SIGNAL(stateChanged(int)), this, SLOT(changed()));
|
2008-01-08 15:47:31 +00:00
|
|
|
|
2009-02-11 00:34:09 +00:00
|
|
|
// Shortcut config. The shortcut belongs to the component "kwin"!
|
|
|
|
m_actionCollection = new KActionCollection( this, KComponentData("kwin") );
|
|
|
|
|
2008-01-08 15:47:31 +00:00
|
|
|
m_actionCollection->setConfigGroup("Snow");
|
|
|
|
m_actionCollection->setConfigGlobal(true);
|
|
|
|
|
|
|
|
KAction* a = (KAction*)m_actionCollection->addAction( "Snow" );
|
2008-03-04 12:30:15 +00:00
|
|
|
a->setText( i18n("Toggle Snow on Desktop" ));
|
2008-05-25 20:31:33 +00:00
|
|
|
a->setProperty("isConfigurationAction", true);
|
2008-06-06 01:06:21 +00:00
|
|
|
a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::META + Qt::Key_F12 ));
|
2008-01-08 15:47:31 +00:00
|
|
|
|
2008-06-01 17:33:26 +00:00
|
|
|
m_ui->editor->addCollection(m_actionCollection);
|
2008-01-08 15:47:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SnowEffectConfig::~SnowEffectConfig()
|
|
|
|
{
|
2008-05-25 20:31:33 +00:00
|
|
|
// Undo (only) unsaved changes to global key shortcuts
|
|
|
|
m_ui->editor->undoChanges();
|
2008-01-08 15:47:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SnowEffectConfig::load()
|
|
|
|
{
|
|
|
|
KCModule::load();
|
|
|
|
|
|
|
|
KConfigGroup conf = EffectsHandler::effectConfig("Snow");
|
|
|
|
|
2008-10-13 03:29:07 +00:00
|
|
|
int number = conf.readEntry("Number", 200);
|
2008-01-08 15:47:31 +00:00
|
|
|
int minFlake = conf.readEntry("MinFlakes", 10);
|
|
|
|
int maxFlake = conf.readEntry("MaxFlakes", 50);
|
2008-10-13 03:29:07 +00:00
|
|
|
int maxVSpeed = conf.readEntry("MaxVSpeed", 2);
|
|
|
|
int maxHSpeed = conf.readEntry("MaxHSpeed", 1);
|
2008-12-06 09:12:33 +00:00
|
|
|
m_ui->snowBehindWindows->setChecked( conf.readEntry("BehindWindows", true));
|
2008-01-08 15:47:31 +00:00
|
|
|
m_ui->numberFlakes->setValue( number );
|
|
|
|
m_ui->minSizeFlake->setValue( minFlake );
|
|
|
|
m_ui->maxSizeFlake->setValue( maxFlake );
|
2008-10-13 03:29:07 +00:00
|
|
|
m_ui->maxVSpeed->setValue( maxVSpeed );
|
|
|
|
m_ui->maxHSpeed->setValue( maxHSpeed );
|
2008-01-08 15:47:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
emit changed(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SnowEffectConfig::save()
|
|
|
|
{
|
|
|
|
KConfigGroup conf = EffectsHandler::effectConfig("Snow");
|
|
|
|
conf.writeEntry("Number", m_ui->numberFlakes->value());
|
|
|
|
conf.writeEntry("MinFlakes", m_ui->minSizeFlake->value());
|
|
|
|
conf.writeEntry("MaxFlakes", m_ui->maxSizeFlake->value());
|
2008-10-13 03:29:07 +00:00
|
|
|
conf.writeEntry("MaxVSpeed", m_ui->maxVSpeed->value());
|
|
|
|
conf.writeEntry("MaxHSpeed", m_ui->maxHSpeed->value());
|
2008-11-11 11:31:12 +00:00
|
|
|
conf.writeEntry("BehindWindows", m_ui->snowBehindWindows->isChecked());
|
2008-01-08 15:47:31 +00:00
|
|
|
|
2008-05-25 20:31:33 +00:00
|
|
|
m_ui->editor->save(); // undo() will restore to this state from now on
|
2008-01-08 15:47:31 +00:00
|
|
|
|
|
|
|
conf.sync();
|
|
|
|
|
|
|
|
emit changed(false);
|
|
|
|
EffectsHandler::sendReloadMessage( "snow" );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SnowEffectConfig::defaults()
|
|
|
|
{
|
2008-10-13 03:29:07 +00:00
|
|
|
m_ui->numberFlakes->setValue( 200 );
|
2008-01-08 15:47:31 +00:00
|
|
|
m_ui->minSizeFlake->setValue( 10 );
|
|
|
|
m_ui->maxSizeFlake->setValue( 50 );
|
2008-10-13 03:29:07 +00:00
|
|
|
m_ui->maxVSpeed->setValue( 2 );
|
|
|
|
m_ui->maxHSpeed->setValue( 1 );
|
2008-12-06 09:12:33 +00:00
|
|
|
m_ui->snowBehindWindows->setChecked( true );
|
2008-06-02 00:06:54 +00:00
|
|
|
m_ui->editor->allDefault();
|
2008-01-08 15:47:31 +00:00
|
|
|
emit changed(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "snow_config.moc"
|