diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 1599e6790ddb3d6c609ef345577e8e555ffc998c..542d8d42c5fc188320d519a62e90132361d34282 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -5328,6 +5328,7 @@ void BaseTextEditor::setDisplaySettings(const DisplaySettings &ds) setCodeFoldingVisible(ds.m_displayFoldingMarkers); setHighlightCurrentLine(ds.m_highlightCurrentLine); setRevisionsVisible(ds.m_markTextChanges); + setCenterOnScroll(ds.m_centerCursorOnScroll); if (d->m_displaySettings.m_visualizeWhitespace != ds.m_visualizeWhitespace) { if (QSyntaxHighlighter *highlighter = baseTextDocument()->syntaxHighlighter()) diff --git a/src/plugins/texteditor/displaysettings.cpp b/src/plugins/texteditor/displaysettings.cpp index 5fe82f4ceda25354cbe5e5d1ce9c7f184e2fbf9a..5c51b7cb0915c7bda798466799c116269d04836b 100644 --- a/src/plugins/texteditor/displaysettings.cpp +++ b/src/plugins/texteditor/displaysettings.cpp @@ -42,7 +42,8 @@ static const char * const highlightCurrentLineKey = "HighlightCurrentLine2Key"; static const char * const highlightBlocksKey = "HighlightBlocksKey"; static const char * const animateMatchingParenthesesKey= "AnimateMatchingParenthesesKey"; static const char * const markTextChangesKey = "MarkTextChanges"; -static const char * const autoFoldFirstCommentKey= "AutoFoldFirstComment"; +static const char * const autoFoldFirstCommentKey = "AutoFoldFirstComment"; +static const char * const centerCursorOnScrollKey = "CenterCursorOnScroll"; static const char * const groupPostfix = "DisplaySettings"; namespace TextEditor { @@ -58,7 +59,8 @@ DisplaySettings::DisplaySettings() : m_highlightBlocks(false), m_animateMatchingParentheses(true), m_markTextChanges(true), - m_autoFoldFirstComment(true) + m_autoFoldFirstComment(true), + m_centerCursorOnScroll(false) { } @@ -79,6 +81,7 @@ void DisplaySettings::toSettings(const QString &category, QSettings *s) const s->setValue(QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses); s->setValue(QLatin1String(markTextChangesKey), m_markTextChanges); s->setValue(QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment); + s->setValue(QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll); s->endGroup(); } @@ -102,6 +105,7 @@ void DisplaySettings::fromSettings(const QString &category, const QSettings *s) m_animateMatchingParentheses = s->value(group + QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses).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(); } bool DisplaySettings::equals(const DisplaySettings &ds) const @@ -117,6 +121,7 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const && m_animateMatchingParentheses == ds.m_animateMatchingParentheses && 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 2acdc907ddf690afe1d58e559c2737a781bac7ee..374be1696976faf2cec160b0116b44e6c2d702db 100644 --- a/src/plugins/texteditor/displaysettings.h +++ b/src/plugins/texteditor/displaysettings.h @@ -56,6 +56,7 @@ struct TEXTEDITOR_EXPORT DisplaySettings bool m_animateMatchingParentheses; bool m_markTextChanges; bool m_autoFoldFirstComment; + bool m_centerCursorOnScroll; bool equals(const DisplaySettings &ds) const; }; diff --git a/src/plugins/texteditor/displaysettingspage.cpp b/src/plugins/texteditor/displaysettingspage.cpp index 3ae03513c94e0ef44a41778583ea068c81e5db8d..6a30c609c5dade107a1676f8e0dd226b00f7d639 100644 --- a/src/plugins/texteditor/displaysettingspage.cpp +++ b/src/plugins/texteditor/displaysettingspage.cpp @@ -92,7 +92,8 @@ QWidget *DisplaySettingsPage::createPage(QWidget *parent) << ' ' << m_d->m_page.visualizeWhitespace->text() << ' ' << m_d->m_page.animateMatchingParentheses->text() << ' ' << m_d->m_page.enableTextWrapping->text() - << ' ' << m_d->m_page.autoFoldFirstComment->text(); + << ' ' << m_d->m_page.autoFoldFirstComment->text() + << ' ' << m_d->m_page.centerOnScroll->text(); m_d->m_searchKeywords.remove(QLatin1Char('&')); } return w; @@ -119,6 +120,7 @@ void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const displaySettings.m_animateMatchingParentheses = m_d->m_page.animateMatchingParentheses->isChecked(); displaySettings.m_markTextChanges = m_d->m_page.markTextChanges->isChecked(); displaySettings.m_autoFoldFirstComment = m_d->m_page.autoFoldFirstComment->isChecked(); + displaySettings.m_centerCursorOnScroll = m_d->m_page.centerOnScroll->isChecked(); } void DisplaySettingsPage::settingsToUI() @@ -135,6 +137,7 @@ void DisplaySettingsPage::settingsToUI() m_d->m_page.animateMatchingParentheses->setChecked(displaySettings.m_animateMatchingParentheses); m_d->m_page.markTextChanges->setChecked(displaySettings.m_markTextChanges); m_d->m_page.autoFoldFirstComment->setChecked(displaySettings.m_autoFoldFirstComment); + m_d->m_page.centerOnScroll->setChecked(displaySettings.m_centerCursorOnScroll); } const DisplaySettings &DisplaySettingsPage::displaySettings() const diff --git a/src/plugins/texteditor/displaysettingspage.ui b/src/plugins/texteditor/displaysettingspage.ui index 8836a47b4f48bfd6a8fd7c159585db9294991cf5..c402d98a64a804bd959a2875291a39316576c2df 100644 --- a/src/plugins/texteditor/displaysettingspage.ui +++ b/src/plugins/texteditor/displaysettingspage.ui @@ -89,6 +89,13 @@ </property> </widget> </item> + <item row="5" column="0"> + <widget class="QCheckBox" name="centerOnScroll"> + <property name="text"> + <string>Center &cursor on scroll</string> + </property> + </widget> + </item> </layout> </widget> </item>