2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2007-11-13 21:50:00 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2007 Rivo Laks <rivolaks@hot.ee>
|
|
|
|
SPDX-FileCopyrightText: 2010 Jorge Mata <matamax123@gmail.com>
|
2007-11-13 21:50:00 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2007-11-13 21:50:00 +00:00
|
|
|
|
2013-08-14 19:13:12 +00:00
|
|
|
#include <QAction>
|
2016-12-02 19:27:43 +00:00
|
|
|
#include <config-kwin.h>
|
2014-03-18 15:09:20 +00:00
|
|
|
#include <kwineffects_interface.h>
|
2007-11-13 21:50:00 +00:00
|
|
|
|
2014-03-17 15:24:10 +00:00
|
|
|
#include <KLocalizedString>
|
2010-01-21 14:56:24 +00:00
|
|
|
#include <KActionCollection>
|
2014-03-17 15:24:10 +00:00
|
|
|
#include <KAboutData>
|
|
|
|
#include <KGlobalAccel>
|
2014-03-18 15:09:20 +00:00
|
|
|
#include <KPluginFactory>
|
2007-11-13 21:50:00 +00:00
|
|
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QLabel>
|
2009-02-05 15:35:38 +00:00
|
|
|
|
2010-01-21 14:56:24 +00:00
|
|
|
#include "trackmouse_config.h"
|
|
|
|
|
2012-09-12 17:24:20 +00:00
|
|
|
// KConfigSkeleton
|
|
|
|
#include "trackmouseconfig.h"
|
|
|
|
|
2014-03-17 13:56:11 +00:00
|
|
|
K_PLUGIN_FACTORY_WITH_JSON(TrackMouseEffectConfigFactory,
|
|
|
|
"trackmouse_config.json",
|
|
|
|
registerPlugin<KWin::TrackMouseEffectConfig>();)
|
|
|
|
|
2007-11-13 21:50:00 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
[effects/trackmouse] Allow to use both modifiers and shortcut
Summary:
The Track Mouse effect can be toggled either by pressing modifier keys
and moving mouse or by pressing a shortcut. It's not possible to use
the latter and then the former without changing config.
But there is one caveat, in order to use shortcut, you have to uncheck
all modifier keys. This seems to be not very intuitive.
In addition to that, the KCM allows to change shortcut even if there is
some checked modifier.
As the title says, this change makes possible to use both modifier keys
and shortcut to activate this effect without changing config.
KCM:
{F6237308, layout=center, size=full}
BUG: 398124
FIXED-IN: 5.14.0
Reviewers: #kwin, #plasma, #vdg, davidedmundson
Reviewed By: #kwin, #plasma, #vdg, davidedmundson
Subscribers: broulik, abetts, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15272
2018-09-04 12:08:27 +00:00
|
|
|
static const QString s_toggleTrackMouseActionName = QStringLiteral("TrackMouse");
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
TrackMouseEffectConfigForm::TrackMouseEffectConfigForm(QWidget* parent) : QWidget(parent)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackMouseEffectConfig::TrackMouseEffectConfig(QWidget* parent, const QVariantList& args) :
|
2020-10-21 17:03:07 +00:00
|
|
|
KCModule(parent, args)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2016-12-02 19:27:43 +00:00
|
|
|
TrackMouseConfig::instance(KWIN_CONFIG);
|
2011-01-30 14:34:42 +00:00
|
|
|
m_ui = new TrackMouseEffectConfigForm(this);
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
|
|
|
layout->addWidget(m_ui);
|
2012-09-12 17:24:20 +00:00
|
|
|
|
|
|
|
addConfig(TrackMouseConfig::self(), m_ui);
|
2012-04-19 19:06:11 +00:00
|
|
|
|
2013-08-14 19:13:12 +00:00
|
|
|
m_actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
|
2015-08-12 07:19:05 +00:00
|
|
|
m_actionCollection->setComponentDisplayName(i18n("KWin"));
|
2013-07-23 05:02:52 +00:00
|
|
|
m_actionCollection->setConfigGroup(QStringLiteral("TrackMouse"));
|
2011-01-30 14:34:42 +00:00
|
|
|
m_actionCollection->setConfigGlobal(true);
|
|
|
|
|
[effects/trackmouse] Allow to use both modifiers and shortcut
Summary:
The Track Mouse effect can be toggled either by pressing modifier keys
and moving mouse or by pressing a shortcut. It's not possible to use
the latter and then the former without changing config.
But there is one caveat, in order to use shortcut, you have to uncheck
all modifier keys. This seems to be not very intuitive.
In addition to that, the KCM allows to change shortcut even if there is
some checked modifier.
As the title says, this change makes possible to use both modifier keys
and shortcut to activate this effect without changing config.
KCM:
{F6237308, layout=center, size=full}
BUG: 398124
FIXED-IN: 5.14.0
Reviewers: #kwin, #plasma, #vdg, davidedmundson
Reviewed By: #kwin, #plasma, #vdg, davidedmundson
Subscribers: broulik, abetts, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15272
2018-09-04 12:08:27 +00:00
|
|
|
QAction *a = m_actionCollection->addAction(s_toggleTrackMouseActionName);
|
2012-04-19 19:06:11 +00:00
|
|
|
a->setText(i18n("Track mouse"));
|
|
|
|
a->setProperty("isConfigurationAction", true);
|
2013-08-14 19:13:12 +00:00
|
|
|
|
|
|
|
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>());
|
|
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>());
|
|
|
|
|
2019-01-01 20:48:53 +00:00
|
|
|
connect(m_ui->shortcut, &KKeySequenceWidget::keySequenceChanged,
|
|
|
|
this, &TrackMouseEffectConfig::shortcutChanged);
|
2007-11-13 21:50:00 +00:00
|
|
|
|
|
|
|
load();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-13 21:50:00 +00:00
|
|
|
|
|
|
|
TrackMouseEffectConfig::~TrackMouseEffectConfig()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2007-11-13 21:50:00 +00:00
|
|
|
|
|
|
|
void TrackMouseEffectConfig::load()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-11-13 21:50:00 +00:00
|
|
|
KCModule::load();
|
2012-09-12 17:24:20 +00:00
|
|
|
|
[effects/trackmouse] Allow to use both modifiers and shortcut
Summary:
The Track Mouse effect can be toggled either by pressing modifier keys
and moving mouse or by pressing a shortcut. It's not possible to use
the latter and then the former without changing config.
But there is one caveat, in order to use shortcut, you have to uncheck
all modifier keys. This seems to be not very intuitive.
In addition to that, the KCM allows to change shortcut even if there is
some checked modifier.
As the title says, this change makes possible to use both modifier keys
and shortcut to activate this effect without changing config.
KCM:
{F6237308, layout=center, size=full}
BUG: 398124
FIXED-IN: 5.14.0
Reviewers: #kwin, #plasma, #vdg, davidedmundson
Reviewed By: #kwin, #plasma, #vdg, davidedmundson
Subscribers: broulik, abetts, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15272
2018-09-04 12:08:27 +00:00
|
|
|
if (QAction *a = m_actionCollection->action(s_toggleTrackMouseActionName)) {
|
|
|
|
auto shortcuts = KGlobalAccel::self()->shortcut(a);
|
|
|
|
if (!shortcuts.isEmpty()) {
|
|
|
|
m_ui->shortcut->setKeySequence(shortcuts.first());
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-13 21:50:00 +00:00
|
|
|
|
|
|
|
void TrackMouseEffectConfig::save()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-09-12 17:24:20 +00:00
|
|
|
KCModule::save();
|
2012-04-19 19:06:11 +00:00
|
|
|
m_actionCollection->writeSettings();
|
2014-05-15 06:39:42 +00:00
|
|
|
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
|
2014-03-18 15:09:20 +00:00
|
|
|
QStringLiteral("/Effects"),
|
|
|
|
QDBusConnection::sessionBus());
|
2014-04-04 09:49:31 +00:00
|
|
|
interface.reconfigureEffect(QStringLiteral("trackmouse"));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-13 21:50:00 +00:00
|
|
|
|
|
|
|
void TrackMouseEffectConfig::defaults()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-09-12 17:24:20 +00:00
|
|
|
KCModule::defaults();
|
2012-04-19 19:06:11 +00:00
|
|
|
m_ui->shortcut->clearKeySequence();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 19:06:11 +00:00
|
|
|
void TrackMouseEffectConfig::shortcutChanged(const QKeySequence &seq)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-14 19:13:12 +00:00
|
|
|
if (QAction *a = m_actionCollection->action(QStringLiteral("TrackMouse"))) {
|
|
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << seq, KGlobalAccel::NoAutoloading);
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
emit changed(true);
|
|
|
|
}
|
2007-11-13 21:50:00 +00:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2014-03-17 13:56:11 +00:00
|
|
|
#include "trackmouse_config.moc"
|