1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

LocationBar: Fixed drawing cursor at correct position with popup opened.

This commit is contained in:
nowrep 2013-02-22 00:25:13 +01:00
parent 2a5ff86972
commit 64e6c36ed4

View File

@ -552,7 +552,6 @@ void LocationBar::hideProgress()
void LocationBar::paintEvent(QPaintEvent* event) void LocationBar::paintEvent(QPaintEvent* event)
{ {
#ifndef Q_OS_MAC
if (m_completer.isPopupVisible() && !m_completer.showingMostVisited()) { if (m_completer.isPopupVisible() && !m_completer.showingMostVisited()) {
// We need to draw cursor when popup is visible // We need to draw cursor when popup is visible
// But don't paint it if we are just showing most visited sites // But don't paint it if we are just showing most visited sites
@ -569,8 +568,8 @@ void LocationBar::paintEvent(QPaintEvent* event)
const QFontMetrics &fm = fontMetrics(); const QFontMetrics &fm = fontMetrics();
QString textPart = text().left(cursorPosition()) + " "; QString textPart = text().left(cursorPosition());
int cursorXpos = lm + fontMetrics().width(textPart); int cursorXpos = lm + fontMetrics().width(textPart) + 3;
int cursorYpos = contentsRect.y() + (contentsRect.height() - fm.height() + 1) / 2; int cursorYpos = contentsRect.y() + (contentsRect.height() - fm.height() + 1) / 2;
int cursorWidth = style()->pixelMetric(QStyle::PM_TextCursorWidth, &option, this); int cursorWidth = style()->pixelMetric(QStyle::PM_TextCursorWidth, &option, this);
int cursorHeight = fontMetrics().height(); int cursorHeight = fontMetrics().height();
@ -583,7 +582,6 @@ void LocationBar::paintEvent(QPaintEvent* event)
p.fillRect(cursorRect, option.palette.text().color()); p.fillRect(cursorRect, option.palette.text().color());
return; return;
} }
#endif
if (hasFocus() || text().isEmpty() || m_forceLineEditPaintEvent) { if (hasFocus() || text().isEmpty() || m_forceLineEditPaintEvent) {
LineEdit::paintEvent(event); LineEdit::paintEvent(event);