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 "lookingglass_config.h"
23 #include <kwineffects.h>
27 #include <kconfiggroup.h>
28 #include <KActionCollection>
30 #include <KShortcutsEditor>
33 #include <QVBoxLayout>
35 KWIN_EFFECT_CONFIG_FACTORY
40 LookingGlassEffectConfigForm::LookingGlassEffectConfigForm(QWidget
* parent
) : QWidget(parent
)
45 LookingGlassEffectConfig::LookingGlassEffectConfig(QWidget
* parent
, const QVariantList
& args
) :
46 KCModule(EffectFactory::componentData(), parent
, args
)
48 m_ui
= new LookingGlassEffectConfigForm(this);
50 QVBoxLayout
* layout
= new QVBoxLayout(this);
52 layout
->addWidget(m_ui
);
54 connect(m_ui
->editor
, SIGNAL(keyChange()), this, SLOT(changed()));
55 connect(m_ui
->radiusSpin
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
58 m_actionCollection
= new KActionCollection( this, componentData() );
59 m_actionCollection
->setConfigGroup("LookingGlass");
60 m_actionCollection
->setConfigGlobal(true);
63 a
= static_cast< KAction
* >( m_actionCollection
->addAction( KStandardAction::ZoomIn
));
64 a
->setProperty("isConfigurationAction", true);
65 a
->setGlobalShortcut(KShortcut(Qt::META
+ Qt::Key_Plus
));
67 a
= static_cast< KAction
* >( m_actionCollection
->addAction( KStandardAction::ZoomOut
));
68 a
->setProperty("isConfigurationAction", true);
69 a
->setGlobalShortcut(KShortcut(Qt::META
+ Qt::Key_Minus
));
71 a
= static_cast< KAction
* >( m_actionCollection
->addAction( KStandardAction::ActualSize
));
72 a
->setProperty("isConfigurationAction", true);
73 a
->setGlobalShortcut(KShortcut(Qt::META
+ Qt::Key_0
));
75 m_ui
->editor
->addCollection(m_actionCollection
);
78 LookingGlassEffectConfig::~LookingGlassEffectConfig()
80 // Undo (only) unsaved changes to global key shortcuts
81 m_ui
->editor
->undoChanges();
84 void LookingGlassEffectConfig::load()
88 KConfigGroup conf
= EffectsHandler::effectConfig("LookingGlass");
90 int radius
= conf
.readEntry("Radius", 200);
91 m_ui
->radiusSpin
->setValue(radius
);
95 void LookingGlassEffectConfig::save()
97 kDebug(1212) << "Saving config of LookingGlass" ;
100 KConfigGroup conf
= EffectsHandler::effectConfig("LookingGlass");
102 conf
.writeEntry("Radius", m_ui
->radiusSpin
->value());
104 m_ui
->editor
->save(); // undo() will restore to this state from now on
109 EffectsHandler::sendReloadMessage( "lookingglass" );
112 void LookingGlassEffectConfig::defaults()
114 m_ui
->radiusSpin
->setValue(200);
115 m_ui
->editor
->allDefault();
122 #include "lookingglass_config.moc"