Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / kwin / effects / magnifier_config.cpp
blob40150ce6381c7d572e7dbf00050c92069bf8f46b
1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2007 Christian Nitschkowski <christian.nitschkowski@kdemail.net>
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 "magnifier_config.h"
23 #include <kwineffects.h>
25 #include <klocale.h>
26 #include <kdebug.h>
27 #include <kconfiggroup.h>
28 #include <KActionCollection>
29 #include <kaction.h>
30 #include <KShortcutsEditor>
31 #include <KGlobalAccel>
33 #include <QWidget>
34 #include <QGridLayout>
35 #include <QLabel>
36 #include <QComboBox>
38 KWIN_EFFECT_CONFIG_FACTORY
40 namespace KWin
43 MagnifierEffectConfigForm::MagnifierEffectConfigForm(QWidget* parent) : QWidget(parent)
45 setupUi(this);
48 MagnifierEffectConfig::MagnifierEffectConfig(QWidget* parent, const QVariantList& args) :
49 KCModule(EffectFactory::componentData(), parent, args)
51 kDebug() ;
53 m_ui = new MagnifierEffectConfigForm(this);
55 QGridLayout* layout = new QGridLayout(this);
57 layout->addWidget(m_ui, 0, 0);
59 connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
60 connect(m_ui->spinWidth, SIGNAL(valueChanged(int)), this, SLOT(changed()));
62 // Shortcut config
63 KGlobalAccel::self()->overrideMainComponentData(componentData());
64 m_actionCollection = new KActionCollection( this, componentData() );
65 m_actionCollection->setConfigGroup("Magnifier");
66 m_actionCollection->setConfigGlobal(true);
68 KAction* a;
69 a = static_cast< KAction* >( m_actionCollection->addAction( KStandardAction::ZoomIn));
70 a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Plus));
71 a = static_cast< KAction* >( m_actionCollection->addAction( KStandardAction::ZoomOut));
72 a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Minus));
73 a = static_cast< KAction* >( m_actionCollection->addAction( KStandardAction::ActualSize));
74 a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_0));
76 load();
79 void MagnifierEffectConfig::load()
81 kDebug() ;
82 KCModule::load();
84 KConfigGroup conf = EffectsHandler::effectConfig("Magnifier");
86 int width = conf.readEntry("Width", 200);
87 int height = conf.readEntry("Height", 200);
88 m_ui->spinWidth->setValue(width);
89 m_ui->spinHeight->setValue(height);
91 m_actionCollection->readSettings();
92 m_ui->editor->addCollection(m_actionCollection);
94 emit changed(false);
97 void MagnifierEffectConfig::save()
99 kDebug() << "Saving config of Magnifier" ;
100 //KCModule::save();
102 KConfigGroup conf = EffectsHandler::effectConfig("Magnifier");
104 conf.writeEntry("Width", m_ui->spinWidth->value());
105 conf.writeEntry("Height", m_ui->spinHeight->value());
107 m_actionCollection->writeSettings();
109 conf.sync();
111 emit changed(false);
112 EffectsHandler::sendReloadMessage( "magnifier" );
115 void MagnifierEffectConfig::defaults()
117 kDebug() ;
118 m_ui->spinWidth->setValue(200);
119 m_ui->spinHeight->setValue(200);
120 emit changed(true);
124 } // namespace
126 #include "magnifier_config.moc"