diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 82a4201b264576bdc79dacc33b6488bc32695357..168e843150109cf0d66cee4e8210e2ca71d5dab0 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -1635,6 +1635,20 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) QRect er = e->rect(); QRect viewportRect = viewport()->rect(); + const QColor baseColor = palette().base().color(); + const int blendBase = (baseColor.value() > 128) ? 0 : 255; + // Darker backgrounds may need a bit more contrast + // (this calculation is temporary solution until we have a setting for this color) + const int blendFactor = (baseColor.value() > 128) ? 8 : 16; + const QColor blendColor( + (blendBase * blendFactor + baseColor.blue() * (256 - blendFactor)) / 256, + (blendBase * blendFactor + baseColor.green() * (256 - blendFactor)) / 256, + (blendBase * blendFactor + baseColor.blue() * (256 - blendFactor)) / 256); + if (d->m_visibleWrapColumn > 0) { + qreal lineX = fontMetrics().averageCharWidth() * d->m_visibleWrapColumn + offset.x() + 4; + painter.fillRect(QRectF(lineX, 0, viewportRect.width() - lineX, viewportRect.height()), blendColor); + } + // keep right margin clean from full-width selection int maxX = offset.x() + qMax((qreal)viewportRect.width(), documentLayout->documentSize().width()) - doc->documentMargin(); @@ -1647,7 +1661,6 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) QAbstractTextDocumentLayout::PaintContext context = getPaintContext(); - if (!d->m_findScope.isNull()) { QAbstractTextDocumentLayout::Selection selection; selection.format.setBackground(d->m_searchScopeFormat.background()); @@ -1672,20 +1685,6 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) blockSelection->lastColumn = qMax(columnA, columnB) + d->m_blockSelectionExtraX; } - const QColor baseColor = palette().base().color(); - const int blendBase = (baseColor.value() > 128) ? 0 : 255; - // Darker backgrounds may need a bit more contrast - // (this calculation is temporary solution until we have a setting for this color) - const int blendFactor = (baseColor.value() > 128) ? 8 : 16; - const QColor blendColor( - (blendBase * blendFactor + baseColor.blue() * (256 - blendFactor)) / 256, - (blendBase * blendFactor + baseColor.green() * (256 - blendFactor)) / 256, - (blendBase * blendFactor + baseColor.blue() * (256 - blendFactor)) / 256); - if (d->m_visibleWrapColumn > 0) { - qreal lineX = fontMetrics().averageCharWidth() * d->m_visibleWrapColumn + offset.x() + 4; - painter.fillRect(QRectF(lineX, 0, viewportRect.width() - lineX, viewportRect.height()), blendColor); - } - QTextBlock visibleCollapsedBlock; QPointF visibleCollapsedBlockOffset;