forked from qt-creator/qt-creator
Add "center cursor on scroll" option for the base text editor
This commit is contained in:
@@ -5328,6 +5328,7 @@ void BaseTextEditor::setDisplaySettings(const DisplaySettings &ds)
|
|||||||
setCodeFoldingVisible(ds.m_displayFoldingMarkers);
|
setCodeFoldingVisible(ds.m_displayFoldingMarkers);
|
||||||
setHighlightCurrentLine(ds.m_highlightCurrentLine);
|
setHighlightCurrentLine(ds.m_highlightCurrentLine);
|
||||||
setRevisionsVisible(ds.m_markTextChanges);
|
setRevisionsVisible(ds.m_markTextChanges);
|
||||||
|
setCenterOnScroll(ds.m_centerCursorOnScroll);
|
||||||
|
|
||||||
if (d->m_displaySettings.m_visualizeWhitespace != ds.m_visualizeWhitespace) {
|
if (d->m_displaySettings.m_visualizeWhitespace != ds.m_visualizeWhitespace) {
|
||||||
if (QSyntaxHighlighter *highlighter = baseTextDocument()->syntaxHighlighter())
|
if (QSyntaxHighlighter *highlighter = baseTextDocument()->syntaxHighlighter())
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ static const char * const highlightCurrentLineKey = "HighlightCurrentLine2Key";
|
|||||||
static const char * const highlightBlocksKey = "HighlightBlocksKey";
|
static const char * const highlightBlocksKey = "HighlightBlocksKey";
|
||||||
static const char * const animateMatchingParenthesesKey= "AnimateMatchingParenthesesKey";
|
static const char * const animateMatchingParenthesesKey= "AnimateMatchingParenthesesKey";
|
||||||
static const char * const markTextChangesKey = "MarkTextChanges";
|
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";
|
static const char * const groupPostfix = "DisplaySettings";
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
@@ -58,7 +59,8 @@ DisplaySettings::DisplaySettings() :
|
|||||||
m_highlightBlocks(false),
|
m_highlightBlocks(false),
|
||||||
m_animateMatchingParentheses(true),
|
m_animateMatchingParentheses(true),
|
||||||
m_markTextChanges(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(animateMatchingParenthesesKey), m_animateMatchingParentheses);
|
||||||
s->setValue(QLatin1String(markTextChangesKey), m_markTextChanges);
|
s->setValue(QLatin1String(markTextChangesKey), m_markTextChanges);
|
||||||
s->setValue(QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment);
|
s->setValue(QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment);
|
||||||
|
s->setValue(QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll);
|
||||||
s->endGroup();
|
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_animateMatchingParentheses = s->value(group + QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses).toBool();
|
||||||
m_markTextChanges = s->value(group + QLatin1String(markTextChangesKey), m_markTextChanges).toBool();
|
m_markTextChanges = s->value(group + QLatin1String(markTextChangesKey), m_markTextChanges).toBool();
|
||||||
m_autoFoldFirstComment = s->value(group + QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment).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
|
bool DisplaySettings::equals(const DisplaySettings &ds) const
|
||||||
@@ -117,6 +121,7 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const
|
|||||||
&& m_animateMatchingParentheses == ds.m_animateMatchingParentheses
|
&& m_animateMatchingParentheses == ds.m_animateMatchingParentheses
|
||||||
&& m_markTextChanges == ds.m_markTextChanges
|
&& m_markTextChanges == ds.m_markTextChanges
|
||||||
&& m_autoFoldFirstComment== ds.m_autoFoldFirstComment
|
&& m_autoFoldFirstComment== ds.m_autoFoldFirstComment
|
||||||
|
&& m_centerCursorOnScroll == ds.m_centerCursorOnScroll
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ struct TEXTEDITOR_EXPORT DisplaySettings
|
|||||||
bool m_animateMatchingParentheses;
|
bool m_animateMatchingParentheses;
|
||||||
bool m_markTextChanges;
|
bool m_markTextChanges;
|
||||||
bool m_autoFoldFirstComment;
|
bool m_autoFoldFirstComment;
|
||||||
|
bool m_centerCursorOnScroll;
|
||||||
|
|
||||||
bool equals(const DisplaySettings &ds) const;
|
bool equals(const DisplaySettings &ds) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ QWidget *DisplaySettingsPage::createPage(QWidget *parent)
|
|||||||
<< ' ' << m_d->m_page.visualizeWhitespace->text()
|
<< ' ' << m_d->m_page.visualizeWhitespace->text()
|
||||||
<< ' ' << m_d->m_page.animateMatchingParentheses->text()
|
<< ' ' << m_d->m_page.animateMatchingParentheses->text()
|
||||||
<< ' ' << m_d->m_page.enableTextWrapping->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('&'));
|
m_d->m_searchKeywords.remove(QLatin1Char('&'));
|
||||||
}
|
}
|
||||||
return w;
|
return w;
|
||||||
@@ -119,6 +120,7 @@ void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const
|
|||||||
displaySettings.m_animateMatchingParentheses = m_d->m_page.animateMatchingParentheses->isChecked();
|
displaySettings.m_animateMatchingParentheses = m_d->m_page.animateMatchingParentheses->isChecked();
|
||||||
displaySettings.m_markTextChanges = m_d->m_page.markTextChanges->isChecked();
|
displaySettings.m_markTextChanges = m_d->m_page.markTextChanges->isChecked();
|
||||||
displaySettings.m_autoFoldFirstComment = m_d->m_page.autoFoldFirstComment->isChecked();
|
displaySettings.m_autoFoldFirstComment = m_d->m_page.autoFoldFirstComment->isChecked();
|
||||||
|
displaySettings.m_centerCursorOnScroll = m_d->m_page.centerOnScroll->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplaySettingsPage::settingsToUI()
|
void DisplaySettingsPage::settingsToUI()
|
||||||
@@ -135,6 +137,7 @@ void DisplaySettingsPage::settingsToUI()
|
|||||||
m_d->m_page.animateMatchingParentheses->setChecked(displaySettings.m_animateMatchingParentheses);
|
m_d->m_page.animateMatchingParentheses->setChecked(displaySettings.m_animateMatchingParentheses);
|
||||||
m_d->m_page.markTextChanges->setChecked(displaySettings.m_markTextChanges);
|
m_d->m_page.markTextChanges->setChecked(displaySettings.m_markTextChanges);
|
||||||
m_d->m_page.autoFoldFirstComment->setChecked(displaySettings.m_autoFoldFirstComment);
|
m_d->m_page.autoFoldFirstComment->setChecked(displaySettings.m_autoFoldFirstComment);
|
||||||
|
m_d->m_page.centerOnScroll->setChecked(displaySettings.m_centerCursorOnScroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
const DisplaySettings &DisplaySettingsPage::displaySettings() const
|
const DisplaySettings &DisplaySettingsPage::displaySettings() const
|
||||||
|
|||||||
@@ -89,6 +89,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QCheckBox" name="centerOnScroll">
|
||||||
|
<property name="text">
|
||||||
|
<string>Center &cursor on scroll</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user