Display shortcut badges while holding Super

Summary:
Use `KModifierKeyInfo` to display shortcut badges while holding Super

BUG: 401768

Test Plan:
Just playing with it.
I still don't understand the `GlobalShortcut` class very well, correct me if I make any mistake.

Reviewers: #latte_dock, mvourlakos

Reviewed By: #latte_dock, mvourlakos

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D18620
pull/4/head
Michail Vourlakos 6 years ago
parent f31df4ee71
commit 6f1c66f7d2

@ -19,7 +19,7 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED NO_MODULE COMPONENTS DBus Gui Qml Quick) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED NO_MODULE COMPONENTS DBus Gui Qml Quick)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Activities Archive CoreAddons Crash DBusAddons Declarative GlobalAccel I18n Activities Archive CoreAddons GuiAddons Crash DBusAddons Declarative GlobalAccel I18n
IconThemes NewStuff Notifications Plasma PlasmaQuick Wayland WindowSystem XmlGui) IconThemes NewStuff Notifications Plasma PlasmaQuick Wayland WindowSystem XmlGui)
find_package(X11 REQUIRED) find_package(X11 REQUIRED)

@ -28,6 +28,7 @@ We recommend that you use at least **Plasma 5.12.0**
KF5PlasmaQuick >= 5.38.0 KF5PlasmaQuick >= 5.38.0
KF5Activities >= 5.38.0 KF5Activities >= 5.38.0
KF5CoreAddons >= 5.38.0 KF5CoreAddons >= 5.38.0
KF5GuiAddons >= 5.38.0
KF5DBusAddons >= 5.38.0 KF5DBusAddons >= 5.38.0
KF5Declarative >= 5.38.0 KF5Declarative >= 5.38.0
KF5Wayland >= 5.38.0 KF5Wayland >= 5.38.0

@ -54,6 +54,7 @@ target_link_libraries(latte-dock
KF5::DBusAddons KF5::DBusAddons
KF5::Declarative KF5::Declarative
KF5::CoreAddons KF5::CoreAddons
KF5::GuiAddons
KF5::GlobalAccel KF5::GlobalAccel
KF5::Archive KF5::Archive
KF5::Crash KF5::Crash

@ -273,6 +273,19 @@ void GlobalShortcuts::init()
m_singleMetaAction = new QAction(this); m_singleMetaAction = new QAction(this);
m_singleMetaAction->setShortcut(QKeySequence(Qt::META)); m_singleMetaAction->setShortcut(QKeySequence(Qt::META));
//display shortcut badges while holding Meta
m_mKeyInfoTimer.setInterval(1000);
connect(&m_mKeyInfoTimer, &QTimer::timeout, this, [&]() {
showDocks();
});
connect(&m_keyInfo, &KModifierKeyInfo::keyPressed, this, [&](Qt::Key key, bool state) {
if (key == Qt::Key_Super_L && state) {
m_mKeyInfoTimer.start();
} else if (key == Qt::Key_Super_L && !state) {
m_mKeyInfoTimer.stop();
}
});
} }
//! Activate launcher menu through dbus interface //! Activate launcher menu through dbus interface
@ -563,6 +576,10 @@ int GlobalShortcuts::applicationLauncherId(const Plasma::Containment *c)
void GlobalShortcuts::showDocks() void GlobalShortcuts::showDocks()
{ {
m_lastInvokedAction = dynamic_cast<QAction *>(sender()); m_lastInvokedAction = dynamic_cast<QAction *>(sender());
if (!m_lastInvokedAction) {
// when holding Meta
m_lastInvokedAction = m_singleMetaAction;
}
auto invokeShowNumbers = [this](const Plasma::Containment * c) { auto invokeShowNumbers = [this](const Plasma::Containment * c) {
if (QQuickItem *containmentInterface = c->property("_plasma_graphicObject").value<QQuickItem *>()) { if (QQuickItem *containmentInterface = c->property("_plasma_graphicObject").value<QQuickItem *>()) {

@ -29,6 +29,9 @@
#include <QQuickItem> #include <QQuickItem>
#include <QTimer> #include <QTimer>
// KDE
#include <kmodifierkeyinfo.h>
namespace Plasma { namespace Plasma {
class Containment; class Containment;
} }
@ -82,6 +85,9 @@ private:
QList<QMetaMethod> m_methodsShowNumbers; QList<QMetaMethod> m_methodsShowNumbers;
Latte::Corona *m_corona{nullptr}; Latte::Corona *m_corona{nullptr};
KModifierKeyInfo m_keyInfo;
QTimer m_mKeyInfoTimer;
}; };
} }

Loading…
Cancel
Save