diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 4d344fd05e6871961cc1f806b643eeeecd171f0f..3f2d1ef98502861445df520fd2d075e6330688f7 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -2884,6 +2884,10 @@ void BaseTextEditor::slotUpdateRequest(const QRect &r, int dy) d->m_extraArea->scroll(0, dy); else if (r.width() > 4) { // wider than cursor width, not just cursor blinking d->m_extraArea->update(0, r.y(), d->m_extraArea->width(), r.height()); + if (!d->m_searchExpr.isEmpty()) { + const int m = d->m_searchResultOverlay->dropShadowWidth(); + viewport()->update(r.adjusted(-m, -m, m, m)); + } } if (r.contains(viewport()->rect())) diff --git a/src/plugins/texteditor/texteditoroverlay.cpp b/src/plugins/texteditor/texteditoroverlay.cpp index 162ff3157abc4001a6c0f2941d44afc3b25c7ccb..e2ea55a4cc1e54890b4a5c9406e987a6c613b7f5 100644 --- a/src/plugins/texteditor/texteditoroverlay.cpp +++ b/src/plugins/texteditor/texteditoroverlay.cpp @@ -40,6 +40,7 @@ TextEditorOverlay::TextEditorOverlay(BaseTextEditor *editor) :QObject(editor) { m_visible = false; m_borderWidth = 1; + m_dropShadowWidth = 2; m_editor = editor; m_viewport = editor->viewport(); } @@ -328,9 +329,9 @@ void TextEditorOverlay::fillSelection(QPainter *painter, painter->translate(-.5, -.5); painter->setRenderHint(QPainter::Antialiasing); if (selection.m_dropShadow) { - painter->translate(2, 2); + painter->translate(m_dropShadowWidth, m_dropShadowWidth); painter->fillPath(path, QColor(0, 0, 0, 100)); - painter->translate(-2, -2); + painter->translate(-m_dropShadowWidth, -m_dropShadowWidth); } painter->fillPath(path, color); painter->restore(); @@ -364,65 +365,3 @@ void TextEditorOverlay::fill(QPainter *painter, const QColor &color, const QRect } } -void TextEditorOverlay::paintInverted(QPainter *painter, const QRect &clip, const QColor &color) -{ - QPainterPath path; - for (int i = 0; i < m_selections.size(); ++i) { - const OverlaySelection &selection = m_selections.at(i); - if (selection.m_fixedLength >= 0 - && selection.m_cursor_end.position() - selection.m_cursor_begin.position() - != selection.m_fixedLength) - continue; - path.addPath(createSelectionPath(selection.m_cursor_begin, selection.m_cursor_end, clip)); - } - - QRect viewportRect = m_editor->viewport()->rect(); - QColor background = Qt::black; - background.setAlpha(30); - - if (path.isEmpty()) { - painter->fillRect(viewportRect, background); - return; - } - -// QPainterPath all; -// all.addRect(viewportRect); -// QPainterPath inversion = all.subtracted(path); - - painter->save(); - QColor penColor = color; - penColor.setAlpha(220); - QPen pen(penColor, m_borderWidth); - QColor brush = color; - brush.setAlpha(30); - painter->translate(-.5, -.5); - -// painter->setRenderHint(QPainter::Antialiasing); - //pen.setJoinStyle(Qt::RoundJoin); - painter->setPen(pen); - painter->setBrush(QBrush()); - painter->drawPath(path); - - painter->translate(.5, .5); - - QPixmap shadow(clip.size()); - shadow.fill(background); - QPainter pmp(&shadow); - pmp.translate(-.5, -.5); - pmp.setRenderHint(QPainter::Antialiasing); - pmp.setCompositionMode(QPainter::CompositionMode_Source); - path.translate(-clip.topLeft()); - pen.setColor(Qt::transparent); - pmp.setPen(pen); - pmp.setBrush(Qt::transparent); - pmp.drawPath(path); - pmp.end(); - - painter->drawPixmap(clip.topLeft(), shadow); - -// painter->fillPath(inversion, background); - painter->restore(); -} - - - diff --git a/src/plugins/texteditor/texteditoroverlay.h b/src/plugins/texteditor/texteditoroverlay.h index e40c9f86b182e1db7fd5255f49e913ba75ba2689..26e45b0755e0339596b6334940c7fb6fb89a107e 100644 --- a/src/plugins/texteditor/texteditoroverlay.h +++ b/src/plugins/texteditor/texteditoroverlay.h @@ -58,6 +58,7 @@ private: bool m_visible; int m_borderWidth; +int m_dropShadowWidth; public: TextEditorOverlay(BaseTextEditor *editor); @@ -66,8 +67,6 @@ public: void paint(QPainter *painter, const QRect &clip); void fill(QPainter *painter, const QColor &color, const QRect &clip); - void paintInverted(QPainter *painter, const QRect &clip, const QColor &color); - bool isVisible() const { return m_visible; } void setVisible(bool b); @@ -81,6 +80,8 @@ public: inline bool isEmpty() const { return m_selections.isEmpty(); } + inline int dropShadowWidth() const { return m_dropShadowWidth; } + private: QPainterPath createSelectionPath(const QTextCursor &begin, const QTextCursor &end, const QRect& clip); void paintSelection(QPainter *painter, const OverlaySelection &selection);