Commit 6a90a1a7 authored by Vasiliy Sorokin's avatar Vasiliy Sorokin Committed by David Schulz
Browse files

Add Highlight Matching Parentheses setting



Task-number: QTCREATORBUG-8008

Change-Id: If1989eb850e82636c735a319bc7c4950a01dd33c
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent f1cd57e2
......@@ -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<QTextEdit::ExtraSelection>());
}
// 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()
......
......@@ -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
......
......@@ -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;
......
......@@ -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);
......
......@@ -6,11 +6,61 @@
<rect>
<x>0</x>
<y>0</y>
<width>450</width>
<width>471</width>
<height>288</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBoxText">
<property name="title">
<string>Text Wrapping</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="enableTextWrapping">
<property name="text">
<string>Enable text &amp;wrapping</string>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="showWrapColumn">
<property name="text">
<string>Display right &amp;margin at column:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="wrapColumn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
......@@ -82,13 +132,6 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="autoFoldFirstComment">
<property name="text">
<string>Auto-fold first &amp;comment</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="centerOnScroll">
<property name="text">
......@@ -96,55 +139,19 @@
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBoxText">
<property name="title">
<string>Text Wrapping</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="enableTextWrapping">
<item row="5" column="1">
<widget class="QCheckBox" name="autoFoldFirstComment">
<property name="text">
<string>Enable text &amp;wrapping</string>
<string>Auto-fold first &amp;comment</string>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="showWrapColumn">
<property name="text">
<string>Display right &amp;margin at column:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="wrapColumn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<item row="4" column="1">
<widget class="QCheckBox" name="highlightMatchingParentheses">
<property name="text">
<string>&amp;Highlight matching parentheses</string>
</property>
</widget>
</item>
</layout>
</widget>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment