Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / kwin / effects / desktopgrid_config.cpp
blob19c4b48a6ab95e7fe18c390f0c58f990248a65e2
1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
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 "desktopgrid_config.h"
23 #include <kwineffects.h>
25 #include <klocale.h>
26 #include <kdebug.h>
27 #include <KActionCollection>
28 #include <kaction.h>
29 #include <KShortcutsEditor>
30 #include <KGlobalAccel>
31 #include <kconfiggroup.h>
33 #include <QVBoxLayout>
34 #include <QHBoxLayout>
35 #include <QCheckBox>
36 #include <QComboBox>
37 #include <QLabel>
38 #ifndef KDE_USE_FINAL
39 KWIN_EFFECT_CONFIG_FACTORY
40 #endif
41 namespace KWin
44 DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget* parent, const QVariantList& args) :
45 KCModule(EffectFactory::componentData(), parent, args)
47 kDebug() ;
49 QVBoxLayout* layout = new QVBoxLayout(this);
51 mSlide = new QCheckBox(i18n("Animate desktop changes"), this);
52 connect(mSlide, SIGNAL(toggled(bool)), this, SLOT(changed()));
53 layout->addWidget(mSlide);
55 QHBoxLayout* comboLayout = new QHBoxLayout();
56 QLabel* label = new QLabel(i18n("Activate when cursor is at a specific edge "
57 "or corner of the screen:"), this);
59 mActivateCombo = new QComboBox;
60 mActivateCombo->addItem(i18n("Top"));
61 mActivateCombo->addItem(i18n("Top-right"));
62 mActivateCombo->addItem(i18n("Right"));
63 mActivateCombo->addItem(i18n("Bottom-right"));
64 mActivateCombo->addItem(i18n("Bottom"));
65 mActivateCombo->addItem(i18n("Bottom-left"));
66 mActivateCombo->addItem(i18n("Left"));
67 mActivateCombo->addItem(i18n("Top-left"));
68 mActivateCombo->addItem(i18n("None"));
69 connect(mActivateCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
70 comboLayout->addWidget(label);
71 comboLayout->addWidget(mActivateCombo);
72 layout->addLayout(comboLayout);
74 KGlobalAccel::self()->overrideMainComponentData(componentData());
75 KActionCollection* actionCollection = new KActionCollection( this, KComponentData("kwin") );
76 KAction* show = static_cast<KAction*>(actionCollection->addAction( "ShowDesktopGrid" ));
77 show->setText( i18n("Show Desktop Grid" ));
78 show->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F8 ));
80 KShortcutsEditor* shortcutEditor = new KShortcutsEditor(actionCollection, this,
81 KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed);
82 connect(shortcutEditor, SIGNAL(keyChange()), this, SLOT(changed()));
83 layout->addWidget(shortcutEditor);
85 layout->addStretch();
87 load();
90 DesktopGridEffectConfig::~DesktopGridEffectConfig()
92 kDebug() ;
95 void DesktopGridEffectConfig::load()
97 kDebug() ;
98 KCModule::load();
100 KConfigGroup conf = EffectsHandler::effectConfig("DesktopGrid");
101 mSlide->setChecked(conf.readEntry("Slide", true));
103 int activateBorder = conf.readEntry("BorderActivate", (int)ElectricNone);
104 if(activateBorder == (int)ElectricNone)
105 activateBorder--;
106 mActivateCombo->setCurrentIndex(activateBorder);
108 emit changed(false);
111 void DesktopGridEffectConfig::save()
113 kDebug() ;
114 KCModule::save();
116 KConfigGroup conf = EffectsHandler::effectConfig("DesktopGrid");
117 conf.writeEntry("Slide", mSlide->isChecked());
119 int activateBorder = mActivateCombo->currentIndex();
120 if(activateBorder == (int)ELECTRIC_COUNT)
121 activateBorder = (int)ElectricNone;
122 conf.writeEntry("BorderActivate", activateBorder);
123 conf.sync();
125 emit changed(false);
126 EffectsHandler::sendReloadMessage( "desktopgrid" );
129 void DesktopGridEffectConfig::defaults()
131 kDebug() ;
132 mSlide->setChecked(true);
133 mActivateCombo->setCurrentIndex( (int)ElectricNone );
134 emit changed(true);
137 } // namespace
139 #include "desktopgrid_config.moc"