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 "thumbnailaside_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 ThumbnailAsideEffectConfigForm::ThumbnailAsideEffectConfigForm(QWidget
* parent
) : QWidget(parent
)
45 ThumbnailAsideEffectConfig::ThumbnailAsideEffectConfig(QWidget
* parent
, const QVariantList
& args
) :
46 KCModule(EffectFactory::componentData(), parent
, args
)
48 m_ui
= new ThumbnailAsideEffectConfigForm(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
->spinSpacing
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
57 connect(m_ui
->spinOpacity
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
60 m_actionCollection
= new KActionCollection( this, componentData() );
61 m_actionCollection
->setConfigGroup("ThumbnailAside");
62 m_actionCollection
->setConfigGlobal(true);
64 KAction
* a
= (KAction
*)m_actionCollection
->addAction( "ToggleCurrentThumbnail" );
65 a
->setText( i18n("Toggle Thumbnail for Current Window" ));
66 a
->setProperty("isConfigurationAction", true);
67 a
->setGlobalShortcut(KShortcut(Qt::META
+ Qt::CTRL
+ Qt::Key_T
));
69 m_ui
->editor
->addCollection(m_actionCollection
);
73 ThumbnailAsideEffectConfig::~ThumbnailAsideEffectConfig()
75 // Undo (only) unsaved changes to global key shortcuts
76 m_ui
->editor
->undoChanges();
79 void ThumbnailAsideEffectConfig::load()
83 KConfigGroup conf
= EffectsHandler::effectConfig("ThumbnailAside");
85 int width
= conf
.readEntry("MaxWidth", 200);
86 int spacing
= conf
.readEntry("Spacing", 10);
87 int opacity
= conf
.readEntry("Opacity", 50);
88 m_ui
->spinWidth
->setValue(width
);
89 m_ui
->spinSpacing
->setValue(spacing
);
90 m_ui
->spinOpacity
->setValue(opacity
);
95 void ThumbnailAsideEffectConfig::save()
97 kDebug(1212) << "Saving config of ThumbnailAside" ;
100 KConfigGroup conf
= EffectsHandler::effectConfig("ThumbnailAside");
102 conf
.writeEntry("MaxWidth", m_ui
->spinWidth
->value());
103 conf
.writeEntry("Spacing", m_ui
->spinSpacing
->value());
104 conf
.writeEntry("Opacity", m_ui
->spinOpacity
->value());
106 m_actionCollection
->writeSettings();
107 m_ui
->editor
->save(); // undo() will restore to this state from now on
112 EffectsHandler::sendReloadMessage( "thumbnailaside" );
115 void ThumbnailAsideEffectConfig::defaults()
117 m_ui
->spinWidth
->setValue(200);
118 m_ui
->spinSpacing
->setValue(10);
119 m_ui
->spinOpacity
->setValue(50);
120 m_ui
->editor
->allDefault();
129 #include "thumbnailaside_config.moc"