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>
27 #include <KActionCollection>
29 #include <KShortcutsEditor>
30 #include <KGlobalAccel>
31 #include <kconfiggroup.h>
33 #include <QVBoxLayout>
34 #include <QHBoxLayout>
39 KWIN_EFFECT_CONFIG_FACTORY
44 DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget
* parent
, const QVariantList
& args
) :
45 KCModule(EffectFactory::componentData(), parent
, args
)
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
);
90 DesktopGridEffectConfig::~DesktopGridEffectConfig()
95 void DesktopGridEffectConfig::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
)
106 mActivateCombo
->setCurrentIndex(activateBorder
);
111 void DesktopGridEffectConfig::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
);
126 EffectsHandler::sendReloadMessage( "desktopgrid" );
129 void DesktopGridEffectConfig::defaults()
132 mSlide
->setChecked(true);
133 mActivateCombo
->setCurrentIndex( (int)ElectricNone
);
139 #include "desktopgrid_config.moc"