diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-03-22 16:17:31 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2016-03-23 18:07:23 +0000 |
commit | e947d362f87534027e6daa75aae531901e077e31 (patch) | |
tree | 631493cc2132eb4f714e37b8c32e06779f7cb710 /ui | |
parent | aedc4af6c11817c186771c9ae3ba2fe1f49567cb (diff) |
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>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/syntax_line_edit.cpp | 15 | ||||
-rw-r--r-- | ui/qt/syntax_line_edit.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/ui/qt/syntax_line_edit.cpp b/ui/qt/syntax_line_edit.cpp index 789cef8048..1439be29d8 100644 --- a/ui/qt/syntax_line_edit.cpp +++ b/ui/qt/syntax_line_edit.cpp @@ -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... diff --git a/ui/qt/syntax_line_edit.h b/ui/qt/syntax_line_edit.h index 013f69dd62..a8c70163e3 100644 --- a/ui/qt/syntax_line_edit.h +++ b/ui/qt/syntax_line_edit.h @@ -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); |