not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kwin / effects / mousemark_config.cpp
blob9a8b143275e4bec586c5cbf7fc8e1944fe798e00
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 "mousemark_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>
32 #include <QWidget>
33 #include <QGridLayout>
35 KWIN_EFFECT_CONFIG_FACTORY
37 namespace KWin
40 MouseMarkEffectConfigForm::MouseMarkEffectConfigForm(QWidget* parent) : QWidget(parent)
42 setupUi(this);
45 MouseMarkEffectConfig::MouseMarkEffectConfig(QWidget* parent, const QVariantList& args) :
46 KCModule(EffectFactory::componentData(), parent, args)
48 m_ui = new MouseMarkEffectConfigForm(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->spinWidth, SIGNAL(valueChanged(int)), this, SLOT(changed()));
56 connect(m_ui->comboColors, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
58 // Shortcut config
59 m_actionCollection = new KActionCollection( this, componentData() );
61 KAction* a = static_cast< KAction* >( m_actionCollection->addAction( "ClearMouseMarks" ));
62 a->setText( i18n( "Clear Mouse Marks" ));
63 a->setProperty("isConfigurationAction", true);
64 a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F11 ));
66 a = static_cast< KAction* >( m_actionCollection->addAction( "ClearLastMouseMark" ));
67 a->setText( i18n( "Clear Last Mouse Mark" ));
68 a->setProperty("isConfigurationAction", true);
69 a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F12 ));
71 m_ui->editor->addCollection(m_actionCollection);
73 load();
76 MouseMarkEffectConfig::~MouseMarkEffectConfig()
78 // Undo (only) unsaved changes to global key shortcuts
79 m_ui->editor->undoChanges();
82 void MouseMarkEffectConfig::load()
84 KCModule::load();
86 KConfigGroup conf = EffectsHandler::effectConfig("MouseMark");
88 int width = conf.readEntry("LineWidth", 3);
89 QColor color = conf.readEntry("Color", QColor(Qt::red));
90 m_ui->spinWidth->setValue(width);
91 m_ui->comboColors->setColor(color);
93 emit changed(false);
96 void MouseMarkEffectConfig::save()
98 kDebug(1212) << "Saving config of MouseMark" ;
99 //KCModule::save();
101 KConfigGroup conf = EffectsHandler::effectConfig("MouseMark");
103 conf.writeEntry("LineWidth", m_ui->spinWidth->value());
104 conf.writeEntry("Color", m_ui->comboColors->color());
106 m_actionCollection->writeSettings();
107 m_ui->editor->save(); // undo() will restore to this state from now on
109 conf.sync();
111 emit changed(false);
112 EffectsHandler::sendReloadMessage( "mousemark" );
115 void MouseMarkEffectConfig::defaults()
117 m_ui->spinWidth->setValue(3);
118 m_ui->comboColors->setColor(Qt::red);
119 emit changed(true);
123 } // namespace
125 #include "mousemark_config.moc"