61f452723e
REVIEW: 111898
143 lines
5.7 KiB
C++
143 lines
5.7 KiB
C++
/********************************************************************
|
|
KWin - the KDE window manager
|
|
This file is part of the KDE project.
|
|
|
|
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
|
|
Copyright (C) 2010 Sebastian Sauer <sebsauer@kdab.com>
|
|
|
|
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/>.
|
|
*********************************************************************/
|
|
|
|
#include "zoom_config.h"
|
|
// KConfigSkeleton
|
|
#include "zoomconfig.h"
|
|
|
|
#include <QAction>
|
|
#include <kwineffects.h>
|
|
|
|
#include <KDE/KGlobalAccel>
|
|
#include <KDE/KLocalizedString>
|
|
#include <kdebug.h>
|
|
#include <KActionCollection>
|
|
#include <KDE/KAboutData>
|
|
#include <KDE/KIcon>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
namespace KWin
|
|
{
|
|
|
|
KWIN_EFFECT_CONFIG_FACTORY
|
|
|
|
ZoomEffectConfigForm::ZoomEffectConfigForm(QWidget* parent) : QWidget(parent)
|
|
{
|
|
setupUi(this);
|
|
}
|
|
|
|
ZoomEffectConfig::ZoomEffectConfig(QWidget* parent, const QVariantList& args) :
|
|
KCModule(KAboutData::pluginData(QStringLiteral("zoom")), parent, args)
|
|
{
|
|
m_ui = new ZoomEffectConfigForm(this);
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
|
layout->addWidget(m_ui);
|
|
|
|
addConfig(ZoomConfig::self(), m_ui);
|
|
|
|
connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
|
|
|
|
// Shortcut config. The shortcut belongs to the component "kwin"!
|
|
KActionCollection *actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
|
|
actionCollection->setConfigGroup(QStringLiteral("Zoom"));
|
|
actionCollection->setConfigGlobal(true);
|
|
|
|
QAction* a;
|
|
a = actionCollection->addAction(KStandardAction::ZoomIn);
|
|
a->setProperty("isConfigurationAction", true);
|
|
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Equal);
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Equal);
|
|
|
|
a = actionCollection->addAction(KStandardAction::ZoomOut);
|
|
a->setProperty("isConfigurationAction", true);
|
|
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Minus);
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Minus);
|
|
|
|
a = actionCollection->addAction(KStandardAction::ActualSize);
|
|
a->setProperty("isConfigurationAction", true);
|
|
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_0);
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_0);
|
|
|
|
a = actionCollection->addAction(QStringLiteral("MoveZoomLeft"));
|
|
a->setIcon(KIcon(QStringLiteral("go-previous")));
|
|
a->setText(i18n("Move Left"));
|
|
a->setProperty("isConfigurationAction", true);
|
|
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Left);
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Left);
|
|
|
|
a = actionCollection->addAction(QStringLiteral("MoveZoomRight"));
|
|
a->setIcon(KIcon(QStringLiteral("go-next")));
|
|
a->setText(i18n("Move Right"));
|
|
a->setProperty("isConfigurationAction", true);
|
|
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Right);
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Right);
|
|
|
|
a = actionCollection->addAction(QStringLiteral("MoveZoomUp"));
|
|
a->setIcon(KIcon(QStringLiteral("go-up")));
|
|
a->setText(i18n("Move Up"));
|
|
a->setProperty("isConfigurationAction", true);
|
|
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Up);
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Up);
|
|
|
|
a = actionCollection->addAction(QStringLiteral("MoveZoomDown"));
|
|
a->setIcon(KIcon(QStringLiteral("go-down")));
|
|
a->setText(i18n("Move Down"));
|
|
a->setProperty("isConfigurationAction", true);
|
|
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Down);
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_Down);
|
|
|
|
a = actionCollection->addAction(QStringLiteral("MoveMouseToFocus"));
|
|
a->setIcon(KIcon(QStringLiteral("view-restore")));
|
|
a->setText(i18n("Move Mouse to Focus"));
|
|
a->setProperty("isConfigurationAction", true);
|
|
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_F5);
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_F5);
|
|
|
|
a = actionCollection->addAction(QStringLiteral("MoveMouseToCenter"));
|
|
a->setIcon(KIcon(QStringLiteral("view-restore")));
|
|
a->setText(i18n("Move Mouse to Center"));
|
|
a->setProperty("isConfigurationAction", true);
|
|
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_F6);
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::Key_F6);
|
|
|
|
m_ui->editor->addCollection(actionCollection);
|
|
|
|
load();
|
|
}
|
|
|
|
ZoomEffectConfig::~ZoomEffectConfig()
|
|
{
|
|
// Undo (only) unsaved changes to global key shortcuts
|
|
m_ui->editor->undoChanges();
|
|
}
|
|
|
|
void ZoomEffectConfig::save()
|
|
{
|
|
m_ui->editor->save(); // undo() will restore to this state from now on
|
|
KCModule::save();
|
|
EffectsHandler::sendReloadMessage(QStringLiteral("zoom"));
|
|
}
|
|
|
|
} // namespace
|
|
|
|
#include "moc_zoom_config.cpp"
|