kwin/effects/zoom/zoom_config.cpp

151 lines
6.3 KiB
C++
Raw Normal View History

/********************************************************************
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 <config-kwin.h>
#include <kwineffects_interface.h>
#include <QAction>
#include <KGlobalAccel>
#include <KLocalizedString>
#include <KActionCollection>
#include <KAboutData>
#include <KPluginFactory>
#include <QVBoxLayout>
K_PLUGIN_FACTORY_WITH_JSON(ZoomEffectConfigFactory,
"zoom_config.json",
registerPlugin<KWin::ZoomEffectConfig>();)
namespace KWin
{
ZoomEffectConfigForm::ZoomEffectConfigForm(QWidget* parent) : QWidget(parent)
2011-01-30 14:34:42 +00:00
{
setupUi(this);
2011-01-30 14:34:42 +00:00
}
ZoomEffectConfig::ZoomEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(KAboutData::pluginData(QStringLiteral("zoom")), parent, args)
2011-01-30 14:34:42 +00:00
{
ZoomConfig::instance(KWIN_CONFIG);
m_ui = new ZoomEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_ui);
addConfig(ZoomConfig::self(), m_ui);
connect(m_ui->editor, &KShortcutsEditor::keyChange, this, &ZoomEffectConfig::markAsChanged);
// Shortcut config. The shortcut belongs to the component "kwin"!
KActionCollection *actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
actionCollection->setComponentDisplayName(i18n("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(QIcon::fromTheme(QStringLiteral("go-previous")));
2011-01-30 14:34:42 +00:00
a->setText(i18n("Move Left"));
a->setProperty("isConfigurationAction", true);
Expose more default window management shortcuts Summary: KWin's window management powers are not as discoverable as they could be--particularly tiling, which by default has no visible UI and no keyboard shortcuts. Resolving this issue is highly relevant to {T6831}. This patch re-assigns the {key Meta arrowkeys} shortcuts that are currently used for `move zoomed area` (which are pretty esoteric, infrequently-used actions), adding {key ctrl} to their shortcuts. This allows us to use their valuable {key Meta arrowkeys} for more useful and commonly-used window management actions: - {key Meta Left}: quick tile window to the left - {key Meta Right}: quick tile window to the right - {key Meta Up}: quick-tile window to the top - {key Meta Down}: quick-tile the window to the bottom The patch also sets some default shortctuts for minimize and maximize: - {key Meta PageDown}: minimize window - {key Meta PageUp}: maximize/de-maximize the window Test Plan: Do a clean build `make test` (no new test failures) Reboot Create and log into a new user account - {key meta up} tiles the active window to the top - {key meta down} tiles the active window to the bottom - {key meta left} tiles the active window to the left - {key meta right} tiles the active window to the right - {key meta PageDown} minimizes the active window - {key meta PageUp} maximizes and de-maximizes the active window - {key meta ctrl up} moves the zoomed area up - {key meta ctrl down} moves the zoomed area down - {key meta ctrl left} moves the zoomed area to the left - {key meta ctrl right} moves the zoomed area to the right Reviewers: #kwin, #plasma, romangg Reviewed By: #kwin, #plasma, romangg Subscribers: mart, romangg, broulik, jnoack, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D11377
2018-03-16 04:37:48 +00:00
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::CTRL + Qt::Key_Left);
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::CTRL + Qt::Key_Left);
2011-01-30 14:34:42 +00:00
a = actionCollection->addAction(QStringLiteral("MoveZoomRight"));
a->setIcon(QIcon::fromTheme(QStringLiteral("go-next")));
2011-01-30 14:34:42 +00:00
a->setText(i18n("Move Right"));
a->setProperty("isConfigurationAction", true);
Expose more default window management shortcuts Summary: KWin's window management powers are not as discoverable as they could be--particularly tiling, which by default has no visible UI and no keyboard shortcuts. Resolving this issue is highly relevant to {T6831}. This patch re-assigns the {key Meta arrowkeys} shortcuts that are currently used for `move zoomed area` (which are pretty esoteric, infrequently-used actions), adding {key ctrl} to their shortcuts. This allows us to use their valuable {key Meta arrowkeys} for more useful and commonly-used window management actions: - {key Meta Left}: quick tile window to the left - {key Meta Right}: quick tile window to the right - {key Meta Up}: quick-tile window to the top - {key Meta Down}: quick-tile the window to the bottom The patch also sets some default shortctuts for minimize and maximize: - {key Meta PageDown}: minimize window - {key Meta PageUp}: maximize/de-maximize the window Test Plan: Do a clean build `make test` (no new test failures) Reboot Create and log into a new user account - {key meta up} tiles the active window to the top - {key meta down} tiles the active window to the bottom - {key meta left} tiles the active window to the left - {key meta right} tiles the active window to the right - {key meta PageDown} minimizes the active window - {key meta PageUp} maximizes and de-maximizes the active window - {key meta ctrl up} moves the zoomed area up - {key meta ctrl down} moves the zoomed area down - {key meta ctrl left} moves the zoomed area to the left - {key meta ctrl right} moves the zoomed area to the right Reviewers: #kwin, #plasma, romangg Reviewed By: #kwin, #plasma, romangg Subscribers: mart, romangg, broulik, jnoack, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D11377
2018-03-16 04:37:48 +00:00
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::CTRL + Qt::Key_Right);
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::CTRL + Qt::Key_Right);
a = actionCollection->addAction(QStringLiteral("MoveZoomUp"));
a->setIcon(QIcon::fromTheme(QStringLiteral("go-up")));
2011-01-30 14:34:42 +00:00
a->setText(i18n("Move Up"));
a->setProperty("isConfigurationAction", true);
Expose more default window management shortcuts Summary: KWin's window management powers are not as discoverable as they could be--particularly tiling, which by default has no visible UI and no keyboard shortcuts. Resolving this issue is highly relevant to {T6831}. This patch re-assigns the {key Meta arrowkeys} shortcuts that are currently used for `move zoomed area` (which are pretty esoteric, infrequently-used actions), adding {key ctrl} to their shortcuts. This allows us to use their valuable {key Meta arrowkeys} for more useful and commonly-used window management actions: - {key Meta Left}: quick tile window to the left - {key Meta Right}: quick tile window to the right - {key Meta Up}: quick-tile window to the top - {key Meta Down}: quick-tile the window to the bottom The patch also sets some default shortctuts for minimize and maximize: - {key Meta PageDown}: minimize window - {key Meta PageUp}: maximize/de-maximize the window Test Plan: Do a clean build `make test` (no new test failures) Reboot Create and log into a new user account - {key meta up} tiles the active window to the top - {key meta down} tiles the active window to the bottom - {key meta left} tiles the active window to the left - {key meta right} tiles the active window to the right - {key meta PageDown} minimizes the active window - {key meta PageUp} maximizes and de-maximizes the active window - {key meta ctrl up} moves the zoomed area up - {key meta ctrl down} moves the zoomed area down - {key meta ctrl left} moves the zoomed area to the left - {key meta ctrl right} moves the zoomed area to the right Reviewers: #kwin, #plasma, romangg Reviewed By: #kwin, #plasma, romangg Subscribers: mart, romangg, broulik, jnoack, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D11377
2018-03-16 04:37:48 +00:00
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::CTRL + Qt::Key_Up);
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::CTRL + Qt::Key_Up);
a = actionCollection->addAction(QStringLiteral("MoveZoomDown"));
a->setIcon(QIcon::fromTheme(QStringLiteral("go-down")));
2011-01-30 14:34:42 +00:00
a->setText(i18n("Move Down"));
a->setProperty("isConfigurationAction", true);
Expose more default window management shortcuts Summary: KWin's window management powers are not as discoverable as they could be--particularly tiling, which by default has no visible UI and no keyboard shortcuts. Resolving this issue is highly relevant to {T6831}. This patch re-assigns the {key Meta arrowkeys} shortcuts that are currently used for `move zoomed area` (which are pretty esoteric, infrequently-used actions), adding {key ctrl} to their shortcuts. This allows us to use their valuable {key Meta arrowkeys} for more useful and commonly-used window management actions: - {key Meta Left}: quick tile window to the left - {key Meta Right}: quick tile window to the right - {key Meta Up}: quick-tile window to the top - {key Meta Down}: quick-tile the window to the bottom The patch also sets some default shortctuts for minimize and maximize: - {key Meta PageDown}: minimize window - {key Meta PageUp}: maximize/de-maximize the window Test Plan: Do a clean build `make test` (no new test failures) Reboot Create and log into a new user account - {key meta up} tiles the active window to the top - {key meta down} tiles the active window to the bottom - {key meta left} tiles the active window to the left - {key meta right} tiles the active window to the right - {key meta PageDown} minimizes the active window - {key meta PageUp} maximizes and de-maximizes the active window - {key meta ctrl up} moves the zoomed area up - {key meta ctrl down} moves the zoomed area down - {key meta ctrl left} moves the zoomed area to the left - {key meta ctrl right} moves the zoomed area to the right Reviewers: #kwin, #plasma, romangg Reviewed By: #kwin, #plasma, romangg Subscribers: mart, romangg, broulik, jnoack, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D11377
2018-03-16 04:37:48 +00:00
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::META + Qt::CTRL + Qt::Key_Down);
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::META + Qt::CTRL + Qt::Key_Down);
a = actionCollection->addAction(QStringLiteral("MoveMouseToFocus"));
a->setIcon(QIcon::fromTheme(QStringLiteral("view-restore")));
2011-01-30 14:34:42 +00:00
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(QIcon::fromTheme(QStringLiteral("view-restore")));
2011-01-30 14:34:42 +00:00
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);
2011-01-30 14:34:42 +00:00
m_ui->editor->addCollection(actionCollection);
load();
2011-01-30 14:34:42 +00:00
}
ZoomEffectConfig::~ZoomEffectConfig()
2011-01-30 14:34:42 +00:00
{
// Undo (only) unsaved changes to global key shortcuts
m_ui->editor->undoChanges();
2011-01-30 14:34:42 +00:00
}
void ZoomEffectConfig::save()
2011-01-30 14:34:42 +00:00
{
m_ui->editor->save(); // undo() will restore to this state from now on
KCModule::save();
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
QStringLiteral("/Effects"),
QDBusConnection::sessionBus());
interface.reconfigureEffect(QStringLiteral("zoom"));
2011-01-30 14:34:42 +00:00
}
} // namespace
#include "zoom_config.moc"