[Containment Interface] Trigger context menus on pressing "Menu" key

When pressing the "Menu" key, pretend a right-click happened and show the containment context menu.

Differential Revision: https://phabricator.kde.org/D4924
This commit is contained in:
Kai Uwe Broulik 2017-03-06 15:14:15 +01:00
parent badf8acfe2
commit 94a6a168cf
2 changed files with 10 additions and 0 deletions

View File

@ -1045,6 +1045,15 @@ void ContainmentInterface::wheelEvent(QWheelEvent *event)
}
}
void ContainmentInterface::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Menu) {
QMouseEvent me(QEvent::MouseButtonRelease, QPoint(), Qt::RightButton, Qt::RightButton, event->modifiers());
mousePressEvent(&me);
event->accept();
}
}
void ContainmentInterface::addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event)
{
foreach (QAction *action, applet->contextualActions()) {

View File

@ -151,6 +151,7 @@ protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
void addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event);
void addContainmentActions(QMenu *desktopMenu, QEvent *event);