diff --git a/src/lib/navigation/completer/locationcompleter.cpp b/src/lib/navigation/completer/locationcompleter.cpp index d7849e422..91fa55ece 100644 --- a/src/lib/navigation/completer/locationcompleter.cpp +++ b/src/lib/navigation/completer/locationcompleter.cpp @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,6 +43,11 @@ void LocationCompleter::setLocationBar(LocationBar* locationBar) m_locationBar = locationBar; } +bool LocationCompleter::isPopupVisible() +{ + return s_view->isVisible(); +} + void LocationCompleter::closePopup() { s_view->close(); diff --git a/src/lib/navigation/completer/locationcompleter.h b/src/lib/navigation/completer/locationcompleter.h index 1c54fd2ff..51f61756b 100644 --- a/src/lib/navigation/completer/locationcompleter.h +++ b/src/lib/navigation/completer/locationcompleter.h @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,6 +35,8 @@ class QT_QUPZILLA_EXPORT LocationCompleter : public QObject explicit LocationCompleter(QObject* parent = 0); void setLocationBar(LocationBar* locationBar); + + bool isPopupVisible(); void closePopup(); signals: diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index f09bf3793..548a318a7 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -591,6 +591,33 @@ void LocationBar::hideProgress() void LocationBar::paintEvent(QPaintEvent* event) { + if (m_completer.isPopupVisible()) { + // We need to draw cursor + LineEdit::paintEvent(event); + + QStyleOptionFrameV3 option; + initStyleOption(&option); + + int lm, tm, rm, bm; + getTextMargins(&lm, &tm, &rm, &bm); + + QRect contentsRect = style()->subElementRect(QStyle::SE_LineEditContents, &option, this); + contentsRect.adjust(lm, tm, -rm, -bm); + + const QFontMetrics &fm = fontMetrics(); + + QString textPart = text().left(cursorPosition()) + " "; + int cursorXpos = lm + fontMetrics().width(textPart); + int cursorYpos = contentsRect.y() + (contentsRect.height() - fm.height() + 1) / 2; + int cursorWidth = style()->pixelMetric(QStyle::PM_TextCursorWidth, &option, this); + int cursorHeight = fontMetrics().height(); + + QPainter p(this); + QRect cursorRect(cursorXpos, cursorYpos, cursorWidth, cursorHeight); + p.fillRect(cursorRect, option.palette.text().color()); + return; + } + if (hasFocus() || text().isEmpty() || m_forceLineEditPaintEvent) { LineEdit::paintEvent(event); if (m_forceLineEditPaintEvent) {