2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-05-28 11:34:12 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-05-28 11:34:12 +00:00
|
|
|
|
|
|
|
#include "presentwindows_config.h"
|
|
|
|
|
|
|
|
#include <kwineffects.h>
|
|
|
|
|
|
|
|
#include <klocale.h>
|
|
|
|
#include <kdebug.h>
|
2007-10-05 22:21:25 +00:00
|
|
|
#include <kconfiggroup.h>
|
2007-09-25 09:41:06 +00:00
|
|
|
#include <KActionCollection>
|
|
|
|
#include <kaction.h>
|
|
|
|
#include <KShortcutsEditor>
|
2007-09-25 17:47:31 +00:00
|
|
|
#include <KGlobalAccel>
|
2007-05-28 11:34:12 +00:00
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QComboBox>
|
2008-03-28 17:26:04 +00:00
|
|
|
#include <QCheckBox>
|
2007-05-28 11:34:12 +00:00
|
|
|
|
2007-09-20 18:06:36 +00:00
|
|
|
KWIN_EFFECT_CONFIG_FACTORY
|
2007-05-28 11:34:12 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2007-09-20 17:48:27 +00:00
|
|
|
PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QVariantList& args) :
|
|
|
|
KCModule(EffectFactory::componentData(), parent, args)
|
2007-05-28 11:34:12 +00:00
|
|
|
{
|
2007-08-20 21:33:48 +00:00
|
|
|
kDebug() ;
|
2007-05-28 11:34:12 +00:00
|
|
|
|
|
|
|
QGridLayout* layout = new QGridLayout(this);
|
|
|
|
|
2008-03-28 17:26:04 +00:00
|
|
|
mDrawWindowText = new QCheckBox(i18n("Draw window caption on top of window."), this);
|
|
|
|
connect(mDrawWindowText, SIGNAL(stateChanged(int)), this, SLOT(changed()));
|
|
|
|
layout->addWidget(mDrawWindowText, 0, 0);
|
|
|
|
|
2007-05-28 11:34:12 +00:00
|
|
|
layout->addWidget(new QLabel(i18n("Activate when cursor is at a specific edge "
|
2008-03-28 17:26:04 +00:00
|
|
|
"or corner of the screen:"), this), 1, 0, 1, 3);
|
|
|
|
layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed), 2, 0, 2, 1);
|
2007-05-28 11:34:12 +00:00
|
|
|
|
2008-03-28 17:26:04 +00:00
|
|
|
layout->addWidget(new QLabel(i18n("for windows on current desktop: "), this), 2, 1);
|
2007-05-28 11:34:12 +00:00
|
|
|
mActivateCombo = new QComboBox;
|
|
|
|
addItems(mActivateCombo);
|
|
|
|
connect(mActivateCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
2008-03-28 17:26:04 +00:00
|
|
|
layout->addWidget(mActivateCombo, 2, 2);
|
2007-05-28 11:34:12 +00:00
|
|
|
|
2008-03-28 17:26:04 +00:00
|
|
|
layout->addWidget(new QLabel(i18n("for windows on all desktops: "), this), 3, 1);
|
2007-05-28 11:34:12 +00:00
|
|
|
mActivateAllCombo = new QComboBox;
|
|
|
|
addItems(mActivateAllCombo);
|
|
|
|
connect(mActivateAllCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
2008-03-28 17:26:04 +00:00
|
|
|
layout->addWidget(mActivateAllCombo, 3, 2);
|
2007-05-28 11:34:12 +00:00
|
|
|
|
2008-03-28 17:26:04 +00:00
|
|
|
layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Fixed, QSizePolicy::Expanding), 4, 0, 1, 3);
|
2007-09-22 12:14:30 +00:00
|
|
|
|
2007-09-25 09:41:06 +00:00
|
|
|
// Shortcut config
|
2007-09-25 17:47:31 +00:00
|
|
|
KGlobalAccel::self()->overrideMainComponentData(componentData());
|
|
|
|
KActionCollection* actionCollection = new KActionCollection( this );
|
|
|
|
KAction* a = (KAction*)actionCollection->addAction( "Expose" );
|
2007-10-16 15:36:27 +00:00
|
|
|
a->setText( i18n("Toggle Expose Effect" ));
|
2008-01-03 19:02:38 +00:00
|
|
|
a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::Key_F9));
|
2007-09-25 17:47:31 +00:00
|
|
|
KAction* b = (KAction*)actionCollection->addAction( "ExposeAll" );
|
2008-01-04 15:26:42 +00:00
|
|
|
b->setText( i18n("Toggle Expose Effect (incl other desktops)" ));
|
2008-01-03 19:02:38 +00:00
|
|
|
b->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::Key_F10));
|
2007-11-13 15:44:52 +00:00
|
|
|
mShortcutEditor = new KShortcutsEditor(actionCollection, this,
|
2007-09-25 09:41:06 +00:00
|
|
|
KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed);
|
2007-11-13 15:44:52 +00:00
|
|
|
connect(mShortcutEditor, SIGNAL(keyChange()), this, SLOT(changed()));
|
2008-03-28 17:26:04 +00:00
|
|
|
layout->addWidget(mShortcutEditor, 5, 0, 1, 3);
|
2007-09-25 09:41:06 +00:00
|
|
|
|
2008-03-28 17:26:04 +00:00
|
|
|
layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 6, 0, 1, 3);
|
2007-09-22 12:14:30 +00:00
|
|
|
|
2007-05-28 11:34:12 +00:00
|
|
|
|
|
|
|
load();
|
|
|
|
}
|
|
|
|
|
|
|
|
PresentWindowsEffectConfig::~PresentWindowsEffectConfig()
|
|
|
|
{
|
2007-08-20 21:33:48 +00:00
|
|
|
kDebug() ;
|
2007-05-28 11:34:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PresentWindowsEffectConfig::addItems(QComboBox* combo)
|
|
|
|
{
|
|
|
|
combo->addItem(i18n("Top"));
|
|
|
|
combo->addItem(i18n("Top-right"));
|
|
|
|
combo->addItem(i18n("Right"));
|
|
|
|
combo->addItem(i18n("Bottom-right"));
|
|
|
|
combo->addItem(i18n("Bottom"));
|
|
|
|
combo->addItem(i18n("Bottom-left"));
|
|
|
|
combo->addItem(i18n("Left"));
|
|
|
|
combo->addItem(i18n("Top-left"));
|
|
|
|
combo->addItem(i18n("None"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PresentWindowsEffectConfig::load()
|
|
|
|
{
|
2007-08-20 21:33:48 +00:00
|
|
|
kDebug() ;
|
2007-05-28 11:34:12 +00:00
|
|
|
KCModule::load();
|
|
|
|
|
2007-05-29 11:48:10 +00:00
|
|
|
KConfigGroup conf = EffectsHandler::effectConfig("PresentWindows");
|
2007-11-08 20:34:25 +00:00
|
|
|
int activateBorder = conf.readEntry("BorderActivate", (int)ElectricNone);
|
2007-05-28 11:34:12 +00:00
|
|
|
if(activateBorder == (int)ElectricNone)
|
|
|
|
activateBorder--;
|
|
|
|
mActivateCombo->setCurrentIndex(activateBorder);
|
|
|
|
|
2007-11-08 20:34:25 +00:00
|
|
|
int activateAllBorder = conf.readEntry("BorderActivateAll", (int)ElectricTopLeft);
|
2007-05-28 11:34:12 +00:00
|
|
|
if(activateAllBorder == (int)ElectricNone)
|
|
|
|
activateAllBorder--;
|
|
|
|
mActivateAllCombo->setCurrentIndex(activateAllBorder);
|
2007-09-25 09:41:06 +00:00
|
|
|
|
2008-03-29 02:38:17 +00:00
|
|
|
bool drawWindowCaptions = conf.readEntry("DrawWindowCaptions", true);
|
2008-03-28 17:26:04 +00:00
|
|
|
mDrawWindowText->setChecked(drawWindowCaptions);
|
|
|
|
|
2007-05-28 11:34:12 +00:00
|
|
|
emit changed(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PresentWindowsEffectConfig::save()
|
|
|
|
{
|
2007-08-20 21:33:48 +00:00
|
|
|
kDebug() ;
|
2007-05-28 11:34:12 +00:00
|
|
|
KCModule::save();
|
|
|
|
|
2007-05-29 11:48:10 +00:00
|
|
|
KConfigGroup conf = EffectsHandler::effectConfig("PresentWindows");
|
2007-05-28 11:34:12 +00:00
|
|
|
|
|
|
|
int activateBorder = mActivateCombo->currentIndex();
|
|
|
|
if(activateBorder == (int)ELECTRIC_COUNT)
|
|
|
|
activateBorder = (int)ElectricNone;
|
|
|
|
conf.writeEntry("BorderActivate", activateBorder);
|
|
|
|
|
|
|
|
int activateAllBorder = mActivateAllCombo->currentIndex();
|
|
|
|
if(activateAllBorder == (int)ELECTRIC_COUNT)
|
|
|
|
activateAllBorder = (int)ElectricNone;
|
|
|
|
conf.writeEntry("BorderActivateAll", activateAllBorder);
|
2007-09-25 09:41:06 +00:00
|
|
|
|
2008-03-28 17:26:04 +00:00
|
|
|
bool drawWindowCaptions = mDrawWindowText->isChecked();
|
|
|
|
conf.writeEntry("DrawWindowCaptions", drawWindowCaptions);
|
|
|
|
|
2007-05-28 11:34:12 +00:00
|
|
|
conf.sync();
|
|
|
|
|
|
|
|
emit changed(false);
|
2007-05-29 11:48:10 +00:00
|
|
|
EffectsHandler::sendReloadMessage( "presentwindows" );
|
2007-05-28 11:34:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PresentWindowsEffectConfig::defaults()
|
|
|
|
{
|
2007-08-20 21:33:48 +00:00
|
|
|
kDebug() ;
|
2007-11-08 20:34:25 +00:00
|
|
|
mActivateCombo->setCurrentIndex( (int)ElectricNone - 1 );
|
|
|
|
mActivateAllCombo->setCurrentIndex( (int)ElectricTopLeft );
|
2008-03-29 02:38:17 +00:00
|
|
|
mDrawWindowText->setChecked(true);
|
2007-11-13 15:44:52 +00:00
|
|
|
mShortcutEditor->allDefault();
|
2007-05-28 11:34:12 +00:00
|
|
|
emit changed(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "presentwindows_config.moc"
|