Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / kwin / effects / snow_config.cpp
blob1ae02ea3d332df785b921f8495c01e740cd0b2cb
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>
24 #include <klocale.h>
25 #include <kdebug.h>
26 #include <KActionCollection>
27 #include <kaction.h>
28 #include <KGlobalAccel>
29 #include <kconfiggroup.h>
31 #include <QGridLayout>
32 #ifndef KDE_USE_FINAL
33 KWIN_EFFECT_CONFIG_FACTORY
34 #endif
35 namespace KWin
38 SnowEffectConfigForm::SnowEffectConfigForm(QWidget* parent) : QWidget(parent)
40 setupUi(this);
43 SnowEffectConfig::SnowEffectConfig(QWidget* parent, const QVariantList& args) :
44 KCModule(EffectFactory::componentData(), parent, args)
46 kDebug() ;
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 ));
68 load();
71 SnowEffectConfig::~SnowEffectConfig()
73 kDebug() ;
76 void SnowEffectConfig::load()
78 kDebug() ;
79 KCModule::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);
93 emit changed(false);
96 void SnowEffectConfig::save()
98 kDebug() ;
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();
107 conf.sync();
109 emit changed(false);
110 EffectsHandler::sendReloadMessage( "snow" );
113 void SnowEffectConfig::defaults()
115 kDebug() ;
116 m_ui->numberFlakes->setValue( 50 );
117 m_ui->minSizeFlake->setValue( 10 );
118 m_ui->maxSizeFlake->setValue( 50 );
119 emit changed(true);
123 } // namespace
125 #include "snow_config.moc"