From ab3d3cf413955afabe845bd80676cd468ebbaa80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= <thorbjorn.lindeijer@nokia.com> Date: Mon, 25 Jan 2010 14:25:00 +0100 Subject: [PATCH] Don't draw the right margin border on top of the text Better to draw it explicitly under the text, together with the associated background color. --- src/plugins/texteditor/basetexteditor.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 7825941ea53..dad53a0c59f 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -1997,9 +1997,18 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) if (d->m_visibleWrapColumn > 0) { lineX = fontMetrics().averageCharWidth() * d->m_visibleWrapColumn + offset.x() + 4; - if (lineX < viewportRect.width()) - painter.fillRect(QRectF(lineX, 0, viewportRect.width() - lineX, viewportRect.height()), - d->m_ifdefedOutFormat.background()); + + if (lineX < viewportRect.width()) { + const QColor backgroundColor = d->m_ifdefedOutFormat.background().color(); + painter.fillRect(QRectF(lineX, er.top(), viewportRect.width() - lineX, er.height()), + backgroundColor); + + const QColor col = (palette().base().color().value() > 128) ? Qt::black : Qt::white; + const QPen pen = painter.pen(); + painter.setPen(blendColors(backgroundColor, col, 32)); + painter.drawLine(QPointF(lineX, er.top()), QPointF(lineX, er.bottom())); + painter.setPen(pen); + } } // Set a brush origin so that the WaveUnderline knows where the wave started @@ -2379,14 +2388,6 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) cursor.setPosition(d->m_animator->position()); d->m_animator->draw(&painter, cursorRect(cursor).topLeft()); } - - - if (lineX > 0) { - const QColor bg = palette().base().color(); - const QColor col = (bg.value() > 128) ? Qt::black : Qt::white; - painter.setPen(blendColors(d->m_ifdefedOutFormat.background().color(), col, 32)); - painter.drawLine(QPointF(lineX, er.top()), QPointF(lineX, er.bottom())); - } } QWidget *BaseTextEditor::extraArea() const -- GitLab