QToolTip: Hide tooltip on key event on macOS

This brings back Qt 4 behavior. The difference is that we only
ignore modifier-only key events, as it's done natively.

Task-number: QTBUG-49462
Change-Id: I02f2313e1164ba185336d80ac5cc16ce6d883b79
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Gabriel de Dietrich 2018-04-16 13:40:53 -07:00
parent 0c936d7411
commit 84988886a5

View File

@ -317,15 +317,13 @@ void QTipLabel::timerEvent(QTimerEvent *e)
bool QTipLabel::eventFilter(QObject *o, QEvent *e) bool QTipLabel::eventFilter(QObject *o, QEvent *e)
{ {
switch (e->type()) { switch (e->type()) {
#if 0 // Used to be included in Qt4 for Q_WS_MAC #ifdef Q_OS_MACOS
case QEvent::KeyPress: case QEvent::KeyPress:
case QEvent::KeyRelease: { case QEvent::KeyRelease: {
int key = static_cast<QKeyEvent *>(e)->key(); const int key = static_cast<QKeyEvent *>(e)->key();
Qt::KeyboardModifiers mody = static_cast<QKeyEvent *>(e)->modifiers(); // Anything except key modifiers or caps-lock, etc.
if (!(mody & Qt::KeyboardModifierMask) if (key < Qt::Key_Shift || key > Qt::Key_ScrollLock)
&& key != Qt::Key_Shift && key != Qt::Key_Control hideTipImmediately();
&& key != Qt::Key_Alt && key != Qt::Key_Meta)
hideTip();
break; break;
} }
#endif #endif