aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2016-06-24 08:59:48 -0700
committerGerald Combs <gerald@wireshark.org>2016-06-24 21:21:36 +0000
commitcc007e59082ed710b46c75a346ec8defde9574d5 (patch)
tree1edee631f86f30a5aaebd2164cc67f0b9a14643f
parent4adf695a7402aa2f59b72dea91e85c03fae2e6d3 (diff)
Qt: Keep the syntax line edit cursor active.
Ignore focusOutEvents when the syntax line edit completer is active. This keeps it from hiding its cursor. Bug: 12520 Change-Id: I8e25b92c097e039e26e2381c5209be1e27a6a7cd Reviewed-on: https://code.wireshark.org/review/16126 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Tested-by: Jeff Morriss <jeff.morriss.ws@gmail.com> Tested-by: Jim Young <jim.young.ws@gmail.com> Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r--ui/qt/syntax_line_edit.cpp11
-rw-r--r--ui/qt/syntax_line_edit.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/ui/qt/syntax_line_edit.cpp b/ui/qt/syntax_line_edit.cpp
index 4939a9c1f0..432ad3dc49 100644
--- a/ui/qt/syntax_line_edit.cpp
+++ b/ui/qt/syntax_line_edit.cpp
@@ -350,6 +350,17 @@ void SyntaxLineEdit::completionFocusInEvent(QFocusEvent *event)
SyntaxLineEdit::focusInEvent(event);
}
+void SyntaxLineEdit::focusOutEvent(QFocusEvent *event)
+{
+ if (completer_ && completer_->popup()->isVisible() && event->reason() == Qt::PopupFocusReason) {
+ // Pretend we still have focus so that we'll draw our cursor.
+ // If cursorRect() were more precise we could just draw the cursor
+ // during a paintEvent.
+ return;
+ }
+ QLineEdit::focusOutEvent(event);
+}
+
void SyntaxLineEdit::insertFieldCompletion(const QString &completion_text)
{
if (!completer_) return;
diff --git a/ui/qt/syntax_line_edit.h b/ui/qt/syntax_line_edit.h
index a8c70163e3..3429614bbc 100644
--- a/ui/qt/syntax_line_edit.h
+++ b/ui/qt/syntax_line_edit.h
@@ -72,6 +72,7 @@ protected:
virtual bool event(QEvent *event);
void completionKeyPressEvent(QKeyEvent *event);
void completionFocusInEvent(QFocusEvent *event);
+ virtual void focusOutEvent(QFocusEvent *event);
private:
SyntaxState syntax_state_;