Override shortcuts in SyntaxLineEdit.

Add an ::event member function to SyntaxLineEdit that looks for
ShortcutOverride events and accepts them. This keeps them from being
interpreted as shortcuts in the main window.

Note that the current code accepts everything, and that we should probably
restrict this to AltGr only.

Bug: 12270
Change-Id: I01765ce2447d220a102d97fcbbe47579341ce075
Reviewed-on: https://code.wireshark.org/review/14570
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2016-03-22 16:17:31 -07:00
parent aedc4af6c1
commit e947d362f8
2 changed files with 16 additions and 0 deletions

View File

@ -261,6 +261,21 @@ bool SyntaxLineEdit::isComplexFilter(const QString &filter)
return false;
}
bool SyntaxLineEdit::event(QEvent *event)
{
if (event->type() == QEvent::ShortcutOverride) {
// Keep shortcuts in the main window from stealing keyPressEvents from
// from us. This is a particular problem for many AltGr combinations
// since they tend to match the time display format shortcuts. Ideally
// we should only accept the event if we detect Qt::Key_AltGr but that
// doesn't seem to work too well in practice.
event->accept();
return true;
}
return QLineEdit::event(event);
}
void SyntaxLineEdit::completionKeyPressEvent(QKeyEvent *event)
{
// Forward to the completer if needed...

View File

@ -69,6 +69,7 @@ protected:
// x = Start position, y = length
QPoint getTokenUnderCursor();
virtual bool event(QEvent *event);
void completionKeyPressEvent(QKeyEvent *event);
void completionFocusInEvent(QFocusEvent *event);