forked from qt-creator/qt-creator
Editor: Do not use the editor palette to store editor scheme colors
Otherwise all editor ancestors like scrollbars might get an incorrect palette. Fixes: QTCREATORBUG-24270 Change-Id: I133cd1dbe284282122972130666c280ea412ea1a Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -433,7 +433,8 @@ struct PaintEventData
|
|||||||
, searchResultFormat(fontSettings.toTextCharFormat(C_SEARCH_RESULT))
|
, searchResultFormat(fontSettings.toTextCharFormat(C_SEARCH_RESULT))
|
||||||
, visualWhitespaceFormat(fontSettings.toTextCharFormat(C_VISUAL_WHITESPACE))
|
, visualWhitespaceFormat(fontSettings.toTextCharFormat(C_VISUAL_WHITESPACE))
|
||||||
, ifdefedOutFormat(fontSettings.toTextCharFormat(C_DISABLED_CODE))
|
, ifdefedOutFormat(fontSettings.toTextCharFormat(C_DISABLED_CODE))
|
||||||
, suppressSyntaxInIfdefedOutBlock(ifdefedOutFormat.foreground() != editor->palette().windowText())
|
, suppressSyntaxInIfdefedOutBlock(ifdefedOutFormat.foreground()
|
||||||
|
!= fontSettings.toTextCharFormat(C_TEXT).foreground())
|
||||||
{ }
|
{ }
|
||||||
QPointF offset;
|
QPointF offset;
|
||||||
const QRect viewportRect;
|
const QRect viewportRect;
|
||||||
@@ -1171,7 +1172,7 @@ void TextEditorWidgetPrivate::print(QPrinter *printer)
|
|||||||
(void)doc->documentLayout(); // make sure that there is a layout
|
(void)doc->documentLayout(); // make sure that there is a layout
|
||||||
|
|
||||||
|
|
||||||
QColor background = q->palette().color(QPalette::Base);
|
QColor background = m_document->fontSettings().toTextCharFormat(C_TEXT).background().color();
|
||||||
bool backgroundIsDark = background.value() < 128;
|
bool backgroundIsDark = background.value() < 128;
|
||||||
|
|
||||||
for (QTextBlock srcBlock = q->document()->firstBlock(), dstBlock = doc->firstBlock();
|
for (QTextBlock srcBlock = q->document()->firstBlock(), dstBlock = doc->firstBlock();
|
||||||
@@ -1305,8 +1306,7 @@ int TextEditorWidgetPrivate::visualIndent(const QTextBlock &block) const
|
|||||||
|
|
||||||
void TextEditorWidgetPrivate::updateAutoCompleteHighlight()
|
void TextEditorWidgetPrivate::updateAutoCompleteHighlight()
|
||||||
{
|
{
|
||||||
const QTextCharFormat &matchFormat
|
const QTextCharFormat matchFormat = m_document->fontSettings().toTextCharFormat(C_AUTOCOMPLETE);
|
||||||
= q->textDocument()->fontSettings().toTextCharFormat(C_AUTOCOMPLETE);
|
|
||||||
|
|
||||||
QList<QTextEdit::ExtraSelection> extraSelections;
|
QList<QTextEdit::ExtraSelection> extraSelections;
|
||||||
for (const QTextCursor &cursor : qAsConst(m_autoCompleteHighlightPos)) {
|
for (const QTextCursor &cursor : qAsConst(m_autoCompleteHighlightPos)) {
|
||||||
@@ -4006,13 +4006,15 @@ static QColor calcBlendColor(const QColor &baseColor, int level, int count)
|
|||||||
return blendColors(color80, color90, blendFactor);
|
return blendColors(color80, color90, blendFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QTextLayout::FormatRange createBlockCursorCharFormatRange(int pos, const QPalette &palette)
|
static QTextLayout::FormatRange createBlockCursorCharFormatRange(int pos,
|
||||||
|
const QColor &textColor,
|
||||||
|
const QColor &baseColor)
|
||||||
{
|
{
|
||||||
QTextLayout::FormatRange o;
|
QTextLayout::FormatRange o;
|
||||||
o.start = pos;
|
o.start = pos;
|
||||||
o.length = 1;
|
o.length = 1;
|
||||||
o.format.setForeground(palette.base());
|
o.format.setForeground(baseColor);
|
||||||
o.format.setBackground(palette.text());
|
o.format.setBackground(textColor);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4166,11 +4168,10 @@ void TextEditorWidgetPrivate::paintRightMarginLine(const PaintEventData &data,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const QBrush background = data.ifdefedOutFormat.background();
|
const QBrush background = data.ifdefedOutFormat.background();
|
||||||
const QColor col = (q->palette().base().color().value() > 128) ? Qt::black : Qt::white;
|
const QColor baseColor = m_document->fontSettings().toTextCharFormat(C_TEXT).background().color();
|
||||||
|
const QColor col = (baseColor.value() > 128) ? Qt::black : Qt::white;
|
||||||
const QPen pen = painter.pen();
|
const QPen pen = painter.pen();
|
||||||
painter.setPen(blendColors(background.isOpaque() ? background.color()
|
painter.setPen(blendColors(background.isOpaque() ? background.color() : baseColor, col, 32));
|
||||||
: q->palette().base().color(),
|
|
||||||
col, 32));
|
|
||||||
painter.drawLine(QPointF(data.rightMargin, data.eventRect.top()),
|
painter.drawLine(QPointF(data.rightMargin, data.eventRect.top()),
|
||||||
QPointF(data.rightMargin, data.eventRect.bottom()));
|
QPointF(data.rightMargin, data.eventRect.bottom()));
|
||||||
painter.setPen(pen);
|
painter.setPen(pen);
|
||||||
@@ -4197,7 +4198,7 @@ void TextEditorWidgetPrivate::paintBlockHighlight(const PaintEventData &data,
|
|||||||
if (m_highlightBlocksInfo.isEmpty())
|
if (m_highlightBlocksInfo.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QColor baseColor = q->palette().base().color();
|
const QColor baseColor = m_document->fontSettings().toTextCharFormat(C_TEXT).background().color();
|
||||||
|
|
||||||
// extra pass for the block highlight
|
// extra pass for the block highlight
|
||||||
|
|
||||||
@@ -4425,12 +4426,20 @@ void TextEditorWidgetPrivate::paintBlockSelection(const PaintEventData &data, QP
|
|||||||
const QTextLine eline = layout->lineForTextPosition(endRelativePos);
|
const QTextLine eline = layout->lineForTextPosition(endRelativePos);
|
||||||
const qreal endX = eline.cursorToX(endRelativePos) + endOffset * spacew;
|
const qreal endX = eline.cursorToX(endRelativePos) + endOffset * spacew;
|
||||||
|
|
||||||
|
const QTextCharFormat textFormat = data.fontSettings.toTextCharFormat(C_TEXT);
|
||||||
|
const QColor &textColor = textFormat.foreground().color();
|
||||||
|
const QColor &baseColor = textFormat.background().color();
|
||||||
|
const QTextCharFormat selectionFormat = data.fontSettings.toTextCharFormat(C_SELECTION);
|
||||||
|
const QBrush &highlight = selectionFormat.background().style() != Qt::NoBrush
|
||||||
|
? selectionFormat.background()
|
||||||
|
: QApplication::palette().brush(QPalette::Highlight);
|
||||||
|
|
||||||
QRectF lineRect = line.naturalTextRect();
|
QRectF lineRect = line.naturalTextRect();
|
||||||
lineRect.moveTop(lineRect.top() + blockBoundingRect.top());
|
lineRect.moveTop(lineRect.top() + blockBoundingRect.top());
|
||||||
lineRect.setLeft(blockBoundingRect.left() + startX);
|
lineRect.setLeft(blockBoundingRect.left() + startX);
|
||||||
if (line.lineNumber() == eline.lineNumber())
|
if (line.lineNumber() == eline.lineNumber())
|
||||||
lineRect.setRight(blockBoundingRect.left() + endX);
|
lineRect.setRight(blockBoundingRect.left() + endX);
|
||||||
painter.fillRect(lineRect, q->palette().highlight());
|
painter.fillRect(lineRect, highlight);
|
||||||
if (m_cursorVisible
|
if (m_cursorVisible
|
||||||
&& m_blockSelection.firstVisualColumn()
|
&& m_blockSelection.firstVisualColumn()
|
||||||
== m_blockSelection.positionColumn) {
|
== m_blockSelection.positionColumn) {
|
||||||
@@ -4438,7 +4447,7 @@ void TextEditorWidgetPrivate::paintBlockSelection(const PaintEventData &data, QP
|
|||||||
&& relativePos < text.length()
|
&& relativePos < text.length()
|
||||||
&& text.at(relativePos) != QLatin1Char('\t')
|
&& text.at(relativePos) != QLatin1Char('\t')
|
||||||
&& text.at(relativePos) != QLatin1Char('\n')) {
|
&& text.at(relativePos) != QLatin1Char('\n')) {
|
||||||
blockData.selections.append(createBlockCursorCharFormatRange(relativePos, q->palette()));
|
blockData.selections.append(createBlockCursorCharFormatRange(relativePos, textColor, baseColor));
|
||||||
} else {
|
} else {
|
||||||
blockData.blockSelectionCursorRect = lineRect;
|
blockData.blockSelectionCursorRect = lineRect;
|
||||||
blockData.blockSelectionCursorRect.setRight(lineRect.left() + cursorw);
|
blockData.blockSelectionCursorRect.setRight(lineRect.left() + cursorw);
|
||||||
@@ -4447,14 +4456,14 @@ void TextEditorWidgetPrivate::paintBlockSelection(const PaintEventData &data, QP
|
|||||||
for (int i = line.lineNumber() + 1; i < eline.lineNumber(); ++i) {
|
for (int i = line.lineNumber() + 1; i < eline.lineNumber(); ++i) {
|
||||||
lineRect = layout->lineAt(i).naturalTextRect();
|
lineRect = layout->lineAt(i).naturalTextRect();
|
||||||
lineRect.moveTop(lineRect.top() + blockBoundingRect.top());
|
lineRect.moveTop(lineRect.top() + blockBoundingRect.top());
|
||||||
painter.fillRect(lineRect, q->palette().highlight());
|
painter.fillRect(lineRect, highlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
lineRect = eline.naturalTextRect();
|
lineRect = eline.naturalTextRect();
|
||||||
lineRect.moveTop(lineRect.top() + blockBoundingRect.top());
|
lineRect.moveTop(lineRect.top() + blockBoundingRect.top());
|
||||||
lineRect.setRight(blockBoundingRect.left() + endX);
|
lineRect.setRight(blockBoundingRect.left() + endX);
|
||||||
if (line.lineNumber() != eline.lineNumber())
|
if (line.lineNumber() != eline.lineNumber())
|
||||||
painter.fillRect(lineRect, q->palette().highlight());
|
painter.fillRect(lineRect, highlight);
|
||||||
if (m_cursorVisible
|
if (m_cursorVisible
|
||||||
&& m_blockSelection.lastVisualColumn()
|
&& m_blockSelection.lastVisualColumn()
|
||||||
== m_blockSelection.positionColumn) {
|
== m_blockSelection.positionColumn) {
|
||||||
@@ -4462,7 +4471,7 @@ void TextEditorWidgetPrivate::paintBlockSelection(const PaintEventData &data, QP
|
|||||||
&& endRelativePos < text.length()
|
&& endRelativePos < text.length()
|
||||||
&& text.at(endRelativePos) != QLatin1Char('\t')
|
&& text.at(endRelativePos) != QLatin1Char('\t')
|
||||||
&& text.at(endRelativePos) != QLatin1Char('\n')) {
|
&& text.at(endRelativePos) != QLatin1Char('\n')) {
|
||||||
blockData.selections.append(createBlockCursorCharFormatRange(endRelativePos, q->palette()));
|
blockData.selections.append(createBlockCursorCharFormatRange(endRelativePos, textColor, baseColor));
|
||||||
} else {
|
} else {
|
||||||
blockData.blockSelectionCursorRect = lineRect;
|
blockData.blockSelectionCursorRect = lineRect;
|
||||||
blockData.blockSelectionCursorRect.setLeft(lineRect.right());
|
blockData.blockSelectionCursorRect.setLeft(lineRect.right());
|
||||||
@@ -4497,9 +4506,14 @@ void TextEditorWidgetPrivate::paintCursorAsBlock(const PaintEventData &data, QPa
|
|||||||
lineRect.moveTop(lineRect.top() + blockData.boundingRect.top());
|
lineRect.moveTop(lineRect.top() + blockData.boundingRect.top());
|
||||||
lineRect.moveLeft(blockData.boundingRect.left() + x);
|
lineRect.moveLeft(blockData.boundingRect.left() + x);
|
||||||
lineRect.setWidth(w);
|
lineRect.setWidth(w);
|
||||||
painter.fillRect(lineRect, q->palette().text());
|
const QTextCharFormat textFormat = data.fontSettings.toTextCharFormat(C_TEXT);
|
||||||
if (doSelection)
|
painter.fillRect(lineRect, textFormat.foreground());
|
||||||
blockData.selections.append(createBlockCursorCharFormatRange(relativePos, q->palette()));
|
if (doSelection) {
|
||||||
|
blockData.selections.append(
|
||||||
|
createBlockCursorCharFormatRange(relativePos,
|
||||||
|
textFormat.foreground().color(),
|
||||||
|
textFormat.background().color()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorWidgetPrivate::paintAdditionalVisualWhitespaces(PaintEventData &data,
|
void TextEditorWidgetPrivate::paintAdditionalVisualWhitespaces(PaintEventData &data,
|
||||||
@@ -4550,9 +4564,15 @@ void TextEditorWidgetPrivate::paintReplacement(PaintEventData &data, QPainter &p
|
|||||||
const bool selectThis = (data.textCursor.hasSelection()
|
const bool selectThis = (data.textCursor.hasSelection()
|
||||||
&& nextBlock.position() >= data.textCursor.selectionStart()
|
&& nextBlock.position() >= data.textCursor.selectionStart()
|
||||||
&& nextBlock.position() < data.textCursor.selectionEnd());
|
&& nextBlock.position() < data.textCursor.selectionEnd());
|
||||||
|
|
||||||
|
|
||||||
|
const QTextCharFormat selectionFormat = data.fontSettings.toTextCharFormat(C_SELECTION);
|
||||||
|
|
||||||
painter.save();
|
painter.save();
|
||||||
if (selectThis) {
|
if (selectThis) {
|
||||||
painter.setBrush(q->palette().highlight());
|
painter.setBrush(selectionFormat.background().style() != Qt::NoBrush
|
||||||
|
? selectionFormat.background()
|
||||||
|
: QApplication::palette().brush(QPalette::Highlight));
|
||||||
} else {
|
} else {
|
||||||
QColor rc = q->replacementPenColor(data.block.blockNumber());
|
QColor rc = q->replacementPenColor(data.block.blockNumber());
|
||||||
if (rc.isValid())
|
if (rc.isValid())
|
||||||
@@ -4601,7 +4621,7 @@ void TextEditorWidgetPrivate::paintReplacement(PaintEventData &data, QPainter &p
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selectThis)
|
if (selectThis)
|
||||||
painter.setPen(q->palette().highlightedText().color());
|
painter.setPen(selectionFormat.foreground().color());
|
||||||
painter.drawText(collapseRect, Qt::AlignCenter, replacement);
|
painter.drawText(collapseRect, Qt::AlignCenter, replacement);
|
||||||
painter.restore();
|
painter.restore();
|
||||||
}
|
}
|
||||||
@@ -4610,14 +4630,7 @@ void TextEditorWidgetPrivate::paintReplacement(PaintEventData &data, QPainter &p
|
|||||||
void TextEditorWidgetPrivate::paintWidgetBackground(const PaintEventData &data,
|
void TextEditorWidgetPrivate::paintWidgetBackground(const PaintEventData &data,
|
||||||
QPainter &painter) const
|
QPainter &painter) const
|
||||||
{
|
{
|
||||||
if (q->backgroundVisible()
|
painter.fillRect(data.eventRect, data.fontSettings.toTextCharFormat(C_TEXT).background());
|
||||||
&& !data.block.isValid()
|
|
||||||
&& data.offset.y() <= data.eventRect.bottom()
|
|
||||||
&& (q->centerOnScroll() || q->verticalScrollBar()->maximum() == q->verticalScrollBar()->minimum())) {
|
|
||||||
const QRect backGroundRect(QPoint(data.eventRect.left(), int(data.offset.y())),
|
|
||||||
data.eventRect.bottomRight());
|
|
||||||
painter.fillRect(backGroundRect, q->palette().window());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorWidgetPrivate::paintOverlays(const PaintEventData &data, QPainter &painter) const
|
void TextEditorWidgetPrivate::paintOverlays(const PaintEventData &data, QPainter &painter) const
|
||||||
@@ -4765,10 +4778,14 @@ void TextEditorWidget::paintEvent(QPaintEvent *e)
|
|||||||
|
|
||||||
data.block = firstVisibleBlock();
|
data.block = firstVisibleBlock();
|
||||||
data.context = getPaintContext();
|
data.context = getPaintContext();
|
||||||
|
const QTextCharFormat textFormat = textDocument()->fontSettings().toTextCharFormat(C_TEXT);
|
||||||
|
data.context.palette.setBrush(QPalette::Text, textFormat.foreground());
|
||||||
|
data.context.palette.setBrush(QPalette::Base, textFormat.background());
|
||||||
// clear the back ground of the normal selection when in block selection mode
|
// clear the back ground of the normal selection when in block selection mode
|
||||||
d->clearSelectionBackground(data);
|
d->clearSelectionBackground(data);
|
||||||
|
|
||||||
{ // paint background
|
{ // paint background
|
||||||
|
d->paintWidgetBackground(data, painter);
|
||||||
// draw backgrond to the right of the wrap column before everything else
|
// draw backgrond to the right of the wrap column before everything else
|
||||||
d->paintRightMarginArea(data, painter);
|
d->paintRightMarginArea(data, painter);
|
||||||
// paint a blended background color depending on scope depth
|
// paint a blended background color depending on scope depth
|
||||||
@@ -4817,7 +4834,8 @@ void TextEditorWidget::paintEvent(QPaintEvent *e)
|
|||||||
if ((!HostOsInfo::isMacHost()
|
if ((!HostOsInfo::isMacHost()
|
||||||
|| d->m_blockSelection.positionColumn == d->m_blockSelection.anchorColumn)
|
|| d->m_blockSelection.positionColumn == d->m_blockSelection.anchorColumn)
|
||||||
&& blockData.blockSelectionCursorRect.isValid()) {
|
&& blockData.blockSelectionCursorRect.isValid()) {
|
||||||
painter.fillRect(blockData.blockSelectionCursorRect, palette().text());
|
const QTextCharFormat textFormat = data.fontSettings.toTextCharFormat(C_TEXT);
|
||||||
|
painter.fillRect(blockData.blockSelectionCursorRect, textFormat.foreground());
|
||||||
}
|
}
|
||||||
|
|
||||||
d->paintAdditionalVisualWhitespaces(data, painter, blockData.boundingRect.top());
|
d->paintAdditionalVisualWhitespaces(data, painter, blockData.boundingRect.top());
|
||||||
@@ -4847,9 +4865,6 @@ void TextEditorWidget::paintEvent(QPaintEvent *e)
|
|||||||
|
|
||||||
painter.setPen(data.context.palette.text().color());
|
painter.setPen(data.context.palette.text().color());
|
||||||
|
|
||||||
// paint background of the widget that is not covered by the document
|
|
||||||
d->paintWidgetBackground(data, painter);
|
|
||||||
|
|
||||||
d->updateAnimator(d->m_bracketsAnimator, painter);
|
d->updateAnimator(d->m_bracketsAnimator, painter);
|
||||||
d->updateAnimator(d->m_autocompleteAnimator, painter);
|
d->updateAnimator(d->m_autocompleteAnimator, painter);
|
||||||
|
|
||||||
@@ -4908,9 +4923,9 @@ void TextEditorWidget::drawCollapsedBlockPopup(QPainter &painter,
|
|||||||
painter.save();
|
painter.save();
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.translate(.5, .5);
|
painter.translate(.5, .5);
|
||||||
QBrush brush = palette().base();
|
QBrush brush = textDocument()->fontSettings().toTextCharFormat(C_TEXT).background();
|
||||||
const QTextCharFormat &ifdefedOutFormat
|
const QTextCharFormat ifdefedOutFormat = textDocument()->fontSettings().toTextCharFormat(
|
||||||
= textDocument()->fontSettings().toTextCharFormat(C_DISABLED_CODE);
|
C_DISABLED_CODE);
|
||||||
if (ifdefedOutFormat.hasProperty(QTextFormat::BackgroundBrush))
|
if (ifdefedOutFormat.hasProperty(QTextFormat::BackgroundBrush))
|
||||||
brush = ifdefedOutFormat.background();
|
brush = ifdefedOutFormat.background();
|
||||||
painter.setBrush(brush);
|
painter.setBrush(brush);
|
||||||
@@ -4959,7 +4974,7 @@ int TextEditorWidget::extraAreaWidth(int *markWidthPtr) const
|
|||||||
QFont fnt = d->m_extraArea->font();
|
QFont fnt = d->m_extraArea->font();
|
||||||
// this works under the assumption that bold or italic
|
// this works under the assumption that bold or italic
|
||||||
// can only make a font wider
|
// can only make a font wider
|
||||||
const QTextCharFormat ¤tLineNumberFormat
|
const QTextCharFormat currentLineNumberFormat
|
||||||
= textDocument()->fontSettings().toTextCharFormat(C_CURRENT_LINE_NUMBER);
|
= textDocument()->fontSettings().toTextCharFormat(C_CURRENT_LINE_NUMBER);
|
||||||
fnt.setBold(currentLineNumberFormat.font().bold());
|
fnt.setBold(currentLineNumberFormat.font().bold());
|
||||||
fnt.setItalic(currentLineNumberFormat.font().italic());
|
fnt.setItalic(currentLineNumberFormat.font().italic());
|
||||||
@@ -5290,8 +5305,8 @@ void TextEditorWidgetPrivate::updateCurrentLineHighlight()
|
|||||||
|
|
||||||
if (m_highlightCurrentLine) {
|
if (m_highlightCurrentLine) {
|
||||||
QTextEdit::ExtraSelection sel;
|
QTextEdit::ExtraSelection sel;
|
||||||
sel.format.setBackground(q->textDocument()->fontSettings()
|
sel.format.setBackground(
|
||||||
.toTextCharFormat(C_CURRENT_LINE).background());
|
m_document->fontSettings().toTextCharFormat(C_CURRENT_LINE).background());
|
||||||
sel.format.setProperty(QTextFormat::FullWidthSelection, true);
|
sel.format.setProperty(QTextFormat::FullWidthSelection, true);
|
||||||
sel.cursor = q->textCursor();
|
sel.cursor = q->textCursor();
|
||||||
sel.cursor.clearSelection();
|
sel.cursor.clearSelection();
|
||||||
@@ -6259,7 +6274,7 @@ void TextEditorWidgetPrivate::showLink(const Utils::Link &link)
|
|||||||
sel.cursor = q->textCursor();
|
sel.cursor = q->textCursor();
|
||||||
sel.cursor.setPosition(link.linkTextStart);
|
sel.cursor.setPosition(link.linkTextStart);
|
||||||
sel.cursor.setPosition(link.linkTextEnd, QTextCursor::KeepAnchor);
|
sel.cursor.setPosition(link.linkTextEnd, QTextCursor::KeepAnchor);
|
||||||
sel.format = q->textDocument()->fontSettings().toTextCharFormat(C_LINK);
|
sel.format = m_document->fontSettings().toTextCharFormat(C_LINK);
|
||||||
sel.format.setFontUnderline(true);
|
sel.format.setFontUnderline(true);
|
||||||
q->setExtraSelections(TextEditorWidget::OtherSelection, QList<QTextEdit::ExtraSelection>() << sel);
|
q->setExtraSelections(TextEditorWidget::OtherSelection, QList<QTextEdit::ExtraSelection>() << sel);
|
||||||
q->viewport()->setCursor(Qt::PointingHandCursor);
|
q->viewport()->setCursor(Qt::PointingHandCursor);
|
||||||
@@ -6587,10 +6602,9 @@ void TextEditorWidgetPrivate::_q_matchParentheses()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QTextCharFormat &matchFormat
|
const QTextCharFormat matchFormat = m_document->fontSettings().toTextCharFormat(C_PARENTHESES);
|
||||||
= q->textDocument()->fontSettings().toTextCharFormat(C_PARENTHESES);
|
const QTextCharFormat mismatchFormat = m_document->fontSettings().toTextCharFormat(
|
||||||
const QTextCharFormat &mismatchFormat
|
C_PARENTHESES_MISMATCH);
|
||||||
= q->textDocument()->fontSettings().toTextCharFormat(C_PARENTHESES_MISMATCH);
|
|
||||||
int animatePosition = -1;
|
int animatePosition = -1;
|
||||||
if (backwardMatch.hasSelection()) {
|
if (backwardMatch.hasSelection()) {
|
||||||
QTextEdit::ExtraSelection sel;
|
QTextEdit::ExtraSelection sel;
|
||||||
@@ -6738,8 +6752,8 @@ void TextEditorWidgetPrivate::autocompleterHighlight(const QTextCursor &cursor)
|
|||||||
m_autoCompleteHighlightPos.push_back(cursor);
|
m_autoCompleteHighlightPos.push_back(cursor);
|
||||||
}
|
}
|
||||||
if (m_animateAutoComplete) {
|
if (m_animateAutoComplete) {
|
||||||
const QTextCharFormat &matchFormat
|
const QTextCharFormat matchFormat = m_document->fontSettings().toTextCharFormat(
|
||||||
= q->textDocument()->fontSettings().toTextCharFormat(C_AUTOCOMPLETE);
|
C_AUTOCOMPLETE);
|
||||||
cancelCurrentAnimations();// one animation is enough
|
cancelCurrentAnimations();// one animation is enough
|
||||||
QPalette pal;
|
QPalette pal;
|
||||||
pal.setBrush(QPalette::Text, matchFormat.foreground());
|
pal.setBrush(QPalette::Text, matchFormat.foreground());
|
||||||
@@ -7318,26 +7332,9 @@ void TextEditorWidget::applyFontSettings()
|
|||||||
d->m_fontSettingsNeedsApply = false;
|
d->m_fontSettingsNeedsApply = false;
|
||||||
const FontSettings &fs = textDocument()->fontSettings();
|
const FontSettings &fs = textDocument()->fontSettings();
|
||||||
const QTextCharFormat textFormat = fs.toTextCharFormat(C_TEXT);
|
const QTextCharFormat textFormat = fs.toTextCharFormat(C_TEXT);
|
||||||
const QTextCharFormat selectionFormat = fs.toTextCharFormat(C_SELECTION);
|
|
||||||
const QTextCharFormat lineNumberFormat = fs.toTextCharFormat(C_LINE_NUMBER);
|
const QTextCharFormat lineNumberFormat = fs.toTextCharFormat(C_LINE_NUMBER);
|
||||||
QFont font(textFormat.font());
|
QFont font(textFormat.font());
|
||||||
|
|
||||||
const QColor foreground = textFormat.foreground().color();
|
|
||||||
const QColor background = textFormat.background().color();
|
|
||||||
QPalette p = palette();
|
|
||||||
p.setColor(QPalette::Text, foreground);
|
|
||||||
p.setColor(QPalette::WindowText, foreground);
|
|
||||||
p.setColor(QPalette::Base, background);
|
|
||||||
p.setColor(QPalette::Highlight, (selectionFormat.background().style() != Qt::NoBrush) ?
|
|
||||||
selectionFormat.background().color() :
|
|
||||||
QApplication::palette().color(QPalette::Highlight));
|
|
||||||
|
|
||||||
p.setBrush(QPalette::HighlightedText, selectionFormat.foreground());
|
|
||||||
|
|
||||||
p.setBrush(QPalette::Inactive, QPalette::Highlight, p.highlight());
|
|
||||||
p.setBrush(QPalette::Inactive, QPalette::HighlightedText, p.highlightedText());
|
|
||||||
if (p != palette())
|
|
||||||
setPalette(p);
|
|
||||||
if (font != this->font()) {
|
if (font != this->font()) {
|
||||||
setFont(font);
|
setFont(font);
|
||||||
d->updateTabStops(); // update tab stops, they depend on the font
|
d->updateTabStops(); // update tab stops, they depend on the font
|
||||||
@@ -7347,7 +7344,7 @@ void TextEditorWidget::applyFontSettings()
|
|||||||
QPalette ep;
|
QPalette ep;
|
||||||
ep.setColor(QPalette::Dark, lineNumberFormat.foreground().color());
|
ep.setColor(QPalette::Dark, lineNumberFormat.foreground().color());
|
||||||
ep.setColor(QPalette::Window, lineNumberFormat.background().style() != Qt::NoBrush ?
|
ep.setColor(QPalette::Window, lineNumberFormat.background().style() != Qt::NoBrush ?
|
||||||
lineNumberFormat.background().color() : background);
|
lineNumberFormat.background().color() : textFormat.background().color());
|
||||||
if (ep != d->m_extraArea->palette()) {
|
if (ep != d->m_extraArea->palette()) {
|
||||||
d->m_extraArea->setPalette(ep);
|
d->m_extraArea->setPalette(ep);
|
||||||
d->slotUpdateExtraAreaWidth(); // Adjust to new font width
|
d->slotUpdateExtraAreaWidth(); // Adjust to new font width
|
||||||
|
Reference in New Issue
Block a user