Merge remote-tracking branch 'origin/4.11' into 4.12

Change-Id: I7e526857a4d9e63838f76d5e3fbb0db7287d5617
This commit is contained in:
Eike Ziller
2020-02-27 09:35:11 +01:00

View File

@@ -646,6 +646,7 @@ public:
MarginSettings m_marginSettings;
// apply when making visible the first time, for the split case
bool m_fontSettingsNeedsApply = true;
bool m_wasNotYetShown = true;
BehaviorSettings m_behaviorSettings;
int extraAreaSelectionAnchorBlockNumber = -1;
@@ -4331,16 +4332,12 @@ void TextEditorWidgetPrivate::paintCurrentLineHighlight(const PaintEventData &da
QRectF lineRect = data.block.layout()->lineForTextPosition(data.textCursor.positionInBlock()).rect();
lineRect.moveTop(lineRect.top() + blockRect.top());
lineRect.setLeft(0);
lineRect.setRight(data.viewportRect.width() - data.offset.x());
lineRect.setRight(data.viewportRect.width());
QColor color = m_document->fontSettings().toTextCharFormat(C_CURRENT_LINE).background().color();
// set alpha, otherwise we cannot see block highlighting and find scope underneath
color.setAlpha(128);
if (!data.eventRect.contains(lineRect.toRect())) {
QRect updateRect = data.eventRect;
updateRect.setLeft(0);
updateRect.setRight(data.viewportRect.width() - int(data.offset.x()));
q->viewport()->update(updateRect);
}
if (!data.eventRect.contains(lineRect.toRect()))
q->viewport()->update(lineRect.toRect());
painter.fillRect(lineRect, color);
}
@@ -7217,10 +7214,20 @@ void TextEditorWidget::encourageApply()
void TextEditorWidget::showEvent(QShowEvent* e)
{
triggerPendingUpdates();
// QPlainTextEdit::showEvent scrolls to make the cursor visible on first show
// which we don't want, since we restore previous states when
// opening editors, and when splitting/duplicating.
// So restore the previous state after that.
QByteArray state;
if (d->m_wasNotYetShown)
state = saveState();
QPlainTextEdit::showEvent(e);
if (d->m_wasNotYetShown) {
restoreState(state);
d->m_wasNotYetShown = false;
}
}
void TextEditorWidgetPrivate::applyFontSettingsDelayed()
{
m_fontSettingsNeedsApply = true;