From e08428a6d1306b245a3a93cbc59a8411eae81e31 Mon Sep 17 00:00:00 2001 From: Franz Fellner Date: Sun, 7 Oct 2012 13:22:45 +0200 Subject: [PATCH] Force a LineEdit::paintEvent after a setCursorPosition, in order to trigger a recalculation of the visible text rect. --- src/lib/navigation/locationbar.cpp | 9 ++++++++- src/lib/navigation/locationbar.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index cecad6830..0a9e64074 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -55,6 +55,7 @@ LocationBar::LocationBar(QupZilla* mainClass) , m_holdingAlt(false) , m_loadProgress(0) , m_progressVisible(false) + , m_forceLineEditPaintEvent(false) { setObjectName("locationbar"); setDragEnabled(true); @@ -110,6 +111,7 @@ void LocationBar::setWebView(TabbedWebView* view) void LocationBar::setText(const QString &text) { LineEdit::setText(text); + m_forceLineEditPaintEvent = true; setCursorPosition(0); } @@ -423,6 +425,7 @@ void LocationBar::focusOutEvent(QFocusEvent* event) return; } + m_forceLineEditPaintEvent = true; setCursorPosition(0); hideGoButton(); @@ -590,8 +593,12 @@ void LocationBar::hideProgress() void LocationBar::paintEvent(QPaintEvent* event) { - if (hasFocus() || text().isEmpty()) { + if (hasFocus() || text().isEmpty() || m_forceLineEditPaintEvent) { LineEdit::paintEvent(event); + if(m_forceLineEditPaintEvent) { + m_forceLineEditPaintEvent = false; + update(); + } return; } diff --git a/src/lib/navigation/locationbar.h b/src/lib/navigation/locationbar.h index a6c16b271..a7cd1b0f6 100644 --- a/src/lib/navigation/locationbar.h +++ b/src/lib/navigation/locationbar.h @@ -126,6 +126,8 @@ private: bool m_progressVisible; ProgressStyle m_progressStyle; QColor m_progressColor; + + bool m_forceLineEditPaintEvent; }; #endif // LOCATIONBAR_H