1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2007 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 *********************************************************************/
21 #include "snow_config.h"
22 #include <kwineffects.h>
26 #include <KActionCollection>
28 #include <KGlobalAccel>
29 #include <kconfiggroup.h>
31 #include <QGridLayout>
33 KWIN_EFFECT_CONFIG_FACTORY
38 SnowEffectConfigForm::SnowEffectConfigForm(QWidget
* parent
) : QWidget(parent
)
43 SnowEffectConfig::SnowEffectConfig(QWidget
* parent
, const QVariantList
& args
) :
44 KCModule(EffectFactory::componentData(), parent
, args
)
48 m_ui
= new SnowEffectConfigForm(this);
50 QGridLayout
* layout
= new QGridLayout(this);
52 layout
->addWidget(m_ui
, 0, 0);
54 connect(m_ui
->editor
, SIGNAL(keyChange()), this, SLOT(changed()));
55 connect(m_ui
->numberFlakes
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
56 connect(m_ui
->minSizeFlake
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
57 connect(m_ui
->maxSizeFlake
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
59 KGlobalAccel::self()->overrideMainComponentData(componentData());
60 m_actionCollection
= new KActionCollection( this, componentData() );
61 m_actionCollection
->setConfigGroup("Snow");
62 m_actionCollection
->setConfigGlobal(true);
64 KAction
* a
= (KAction
*)m_actionCollection
->addAction( "Snow" );
65 a
->setText( i18n("Toggle Snow on the desktop" ));
66 a
->setGlobalShortcut( KShortcut( Qt::CTRL
+ Qt::META
+ Qt::Key_F12
));
71 SnowEffectConfig::~SnowEffectConfig()
76 void SnowEffectConfig::load()
81 KConfigGroup conf
= EffectsHandler::effectConfig("Snow");
83 int number
= conf
.readEntry("Number", 50);
84 int minFlake
= conf
.readEntry("MinFlakes", 10);
85 int maxFlake
= conf
.readEntry("MaxFlakes", 50);
86 m_ui
->numberFlakes
->setValue( number
);
87 m_ui
->minSizeFlake
->setValue( minFlake
);
88 m_ui
->maxSizeFlake
->setValue( maxFlake
);
90 m_actionCollection
->readSettings();
91 m_ui
->editor
->addCollection(m_actionCollection
);
96 void SnowEffectConfig::save()
100 KConfigGroup conf
= EffectsHandler::effectConfig("Snow");
101 conf
.writeEntry("Number", m_ui
->numberFlakes
->value());
102 conf
.writeEntry("MinFlakes", m_ui
->minSizeFlake
->value());
103 conf
.writeEntry("MaxFlakes", m_ui
->maxSizeFlake
->value());
105 m_actionCollection
->writeSettings();
110 EffectsHandler::sendReloadMessage( "snow" );
113 void SnowEffectConfig::defaults()
116 m_ui
->numberFlakes
->setValue( 50 );
117 m_ui
->minSizeFlake
->setValue( 10 );
118 m_ui
->maxSizeFlake
->setValue( 50 );
125 #include "snow_config.moc"