From ed8ec5ab4acf5ed03c680d1afbb89828d7a593db Mon Sep 17 00:00:00 2001 From: nowrep Date: Mon, 23 Dec 2013 19:21:47 +0100 Subject: [PATCH] [LocationBar] Fixed rendering selected text with visible popup completer. --- src/lib/navigation/locationbar.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index 5f253112e..ea449960e 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -442,6 +442,14 @@ void LocationBar::keyPressEvent(QKeyEvent* event) } break; + case Qt::Key_A: + if (event->modifiers() == Qt::ControlModifier) { + if (m_inlineCompletionVisible) { + m_inlineCompletionVisible = false; + } + } + break; + case Qt::Key_Down: m_completer.complete(text()); break; @@ -664,7 +672,17 @@ void LocationBar::paintEvent(QPaintEvent* event) cursor.setHeight(cursorHeight); style()->drawPrimitive(QStyle::PE_PanelLineEdit, &option, &p, this); - p.drawText(textRect, text(), opt); + + QRect actualTextRect = textRect; + actualTextRect.setWidth(fontMetrics().width(text()) + 1); + + // When popup is visible, Ctrl + A (Select All) is the only way to select text + if (selectedText() == text()) { + p.fillRect(actualTextRect, palette().color(QPalette::Highlight)); + p.setPen(palette().color(QPalette::HighlightedText)); + } + + p.drawText(actualTextRect, text(), opt); if (textRect.contains(cursor.center().x(), cursor.center().y())) { p.fillRect(cursor, option.palette.text().color());