diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index ccc7e7b138a..b5fec116fda 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -4071,7 +4071,14 @@ void BaseTextEditorWidget::updateHighlights() && d->m_animator == 0) { d->m_parenthesesMatchingTimer->start(50); } else { - // use 0-timer, not direct call, to give the syntax highlighter a chance + // when we uncheck "highlight matching parentheses" + // we need clear current selection before viewport update + // otherwise we get sticky highlighted parentheses + if (!d->m_displaySettings.m_highlightMatchingParentheses) { + setExtraSelections(ParenthesesMatchingSelection, QList()); + } + + // use 0-timer, not direct call, to give the syntax highlighter a chance // to update the parentheses information d->m_parenthesesMatchingTimer->start(0); } @@ -5060,7 +5067,9 @@ void BaseTextEditorAnimator::finish() void BaseTextEditorWidget::_q_matchParentheses() { - if (isReadOnly()) + if (isReadOnly() + || !(d->m_displaySettings.m_highlightMatchingParentheses + || d->m_displaySettings.m_animateMatchingParentheses)) return; QTextCursor backwardMatch = textCursor(); @@ -5149,8 +5158,8 @@ void BaseTextEditorWidget::_q_matchParentheses() connect(d->m_animator, SIGNAL(updateRequest(int,QPointF,QRectF)), this, SLOT(_q_animateUpdate(int,QPointF,QRectF))); } - - setExtraSelections(ParenthesesMatchingSelection, extraSelections); + if (d->m_displaySettings.m_highlightMatchingParentheses) + setExtraSelections(ParenthesesMatchingSelection, extraSelections); } void BaseTextEditorWidget::_q_highlightBlocks() diff --git a/src/plugins/texteditor/displaysettings.cpp b/src/plugins/texteditor/displaysettings.cpp index 49288d1bb58..be5e6f81a95 100644 --- a/src/plugins/texteditor/displaysettings.cpp +++ b/src/plugins/texteditor/displaysettings.cpp @@ -41,6 +41,7 @@ static const char displayFoldingMarkersKey[] = "DisplayFoldingMarkers"; static const char highlightCurrentLineKey[] = "HighlightCurrentLine2Key"; static const char highlightBlocksKey[] = "HighlightBlocksKey"; static const char animateMatchingParenthesesKey[] = "AnimateMatchingParenthesesKey"; +static const char highlightMatchingParenthesesKey[] = "HightlightMatchingParenthesesKey"; static const char markTextChangesKey[] = "MarkTextChanges"; static const char autoFoldFirstCommentKey[] = "AutoFoldFirstComment"; static const char centerCursorOnScrollKey[] = "CenterCursorOnScroll"; @@ -58,6 +59,7 @@ DisplaySettings::DisplaySettings() : m_highlightCurrentLine(false), m_highlightBlocks(false), m_animateMatchingParentheses(true), + m_highlightMatchingParentheses(true), m_markTextChanges(true), m_autoFoldFirstComment(true), m_centerCursorOnScroll(false) @@ -79,6 +81,7 @@ void DisplaySettings::toSettings(const QString &category, QSettings *s) const s->setValue(QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine); s->setValue(QLatin1String(highlightBlocksKey), m_highlightBlocks); s->setValue(QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses); + s->setValue(QLatin1String(highlightMatchingParenthesesKey), m_highlightMatchingParentheses); s->setValue(QLatin1String(markTextChangesKey), m_markTextChanges); s->setValue(QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment); s->setValue(QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll); @@ -103,6 +106,7 @@ void DisplaySettings::fromSettings(const QString &category, const QSettings *s) m_highlightCurrentLine = s->value(group + QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine).toBool(); m_highlightBlocks = s->value(group + QLatin1String(highlightBlocksKey), m_highlightBlocks).toBool(); m_animateMatchingParentheses = s->value(group + QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses).toBool(); + m_highlightMatchingParentheses = s->value(group + QLatin1String(highlightMatchingParenthesesKey), m_highlightMatchingParentheses).toBool(); m_markTextChanges = s->value(group + QLatin1String(markTextChangesKey), m_markTextChanges).toBool(); m_autoFoldFirstComment = s->value(group + QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment).toBool(); m_centerCursorOnScroll = s->value(group + QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll).toBool(); @@ -119,6 +123,7 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const && m_highlightCurrentLine == ds.m_highlightCurrentLine && m_highlightBlocks == ds.m_highlightBlocks && m_animateMatchingParentheses == ds.m_animateMatchingParentheses + && m_highlightMatchingParentheses == ds.m_highlightMatchingParentheses && m_markTextChanges == ds.m_markTextChanges && m_autoFoldFirstComment== ds.m_autoFoldFirstComment && m_centerCursorOnScroll == ds.m_centerCursorOnScroll diff --git a/src/plugins/texteditor/displaysettings.h b/src/plugins/texteditor/displaysettings.h index 26e284a4e06..c64c63f3abf 100644 --- a/src/plugins/texteditor/displaysettings.h +++ b/src/plugins/texteditor/displaysettings.h @@ -55,6 +55,7 @@ public: bool m_highlightCurrentLine; bool m_highlightBlocks; bool m_animateMatchingParentheses; + bool m_highlightMatchingParentheses; bool m_markTextChanges; bool m_autoFoldFirstComment; bool m_centerCursorOnScroll; diff --git a/src/plugins/texteditor/displaysettingspage.cpp b/src/plugins/texteditor/displaysettingspage.cpp index 930d7133e98..a95c434ba7f 100644 --- a/src/plugins/texteditor/displaysettingspage.cpp +++ b/src/plugins/texteditor/displaysettingspage.cpp @@ -82,6 +82,7 @@ QWidget *DisplaySettingsPage::createPage(QWidget *parent) << ' ' << d->m_page->highlightBlocks->text() << ' ' << d->m_page->visualizeWhitespace->text() << ' ' << d->m_page->animateMatchingParentheses->text() + << ' ' << d->m_page->highlightMatchingParentheses->text() << ' ' << d->m_page->enableTextWrapping->text() << ' ' << d->m_page->autoFoldFirstComment->text() << ' ' << d->m_page->centerOnScroll->text(); @@ -119,6 +120,7 @@ void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const displaySettings.m_highlightCurrentLine = d->m_page->highlightCurrentLine->isChecked(); displaySettings.m_highlightBlocks = d->m_page->highlightBlocks->isChecked(); displaySettings.m_animateMatchingParentheses = d->m_page->animateMatchingParentheses->isChecked(); + displaySettings.m_highlightMatchingParentheses = d->m_page->highlightMatchingParentheses->isChecked(); displaySettings.m_markTextChanges = d->m_page->markTextChanges->isChecked(); displaySettings.m_autoFoldFirstComment = d->m_page->autoFoldFirstComment->isChecked(); displaySettings.m_centerCursorOnScroll = d->m_page->centerOnScroll->isChecked(); @@ -136,6 +138,7 @@ void DisplaySettingsPage::settingsToUI() d->m_page->highlightCurrentLine->setChecked(displaySettings.m_highlightCurrentLine); d->m_page->highlightBlocks->setChecked(displaySettings.m_highlightBlocks); d->m_page->animateMatchingParentheses->setChecked(displaySettings.m_animateMatchingParentheses); + d->m_page->highlightMatchingParentheses->setChecked(displaySettings.m_highlightMatchingParentheses); d->m_page->markTextChanges->setChecked(displaySettings.m_markTextChanges); d->m_page->autoFoldFirstComment->setChecked(displaySettings.m_autoFoldFirstComment); d->m_page->centerOnScroll->setChecked(displaySettings.m_centerCursorOnScroll); diff --git a/src/plugins/texteditor/displaysettingspage.ui b/src/plugins/texteditor/displaysettingspage.ui index c136ebaece9..6a1f7b46f59 100644 --- a/src/plugins/texteditor/displaysettingspage.ui +++ b/src/plugins/texteditor/displaysettingspage.ui @@ -6,11 +6,61 @@ 0 0 - 450 + 471 288 + + + + Text Wrapping + + + + + + Enable text &wrapping + + + + + + + + + Display right &margin at column: + + + + + + + false + + + 999 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + @@ -82,13 +132,6 @@ - - - - Auto-fold first &comment - - - @@ -96,55 +139,19 @@ - - - - - - - Text Wrapping - - - - + + - Enable text &wrapping + Auto-fold first &comment - - - - - - Display right &margin at column: - - - - - - - false - - - 999 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + + + &Highlight matching parentheses + +