HighlightScrollBar: Always show the current line

Also when the scrollbar handle occupies the whole scrollbar area.

Change-Id: I124950e3f0898f853a187ea393731ddb0800aa99
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Jarek Kobus
2018-05-16 09:04:49 +02:00
parent d4c7814e9e
commit df50dd7353

View File

@@ -5363,15 +5363,13 @@ void TextEditorWidgetPrivate::updateCurrentLineInScrollbar()
{
if (m_highlightCurrentLine && m_highlightScrollBarController) {
m_highlightScrollBarController->removeHighlights(Constants::SCROLL_BAR_CURRENT_LINE);
if (m_highlightScrollBarController->scrollBar()->maximum() > 0) {
const QTextCursor &tc = q->textCursor();
if (QTextLayout *layout = tc.block().layout()) {
const int pos = q->textCursor().block().firstLineNumber() +
layout->lineForTextPosition(tc.positionInBlock()).lineNumber();
m_highlightScrollBarController->addHighlight({Constants::SCROLL_BAR_CURRENT_LINE, pos,
Theme::TextEditor_CurrentLine_ScrollBarColor,
Highlight::HighestPriority});
}
const QTextCursor &tc = q->textCursor();
if (QTextLayout *layout = tc.block().layout()) {
const int pos = q->textCursor().block().firstLineNumber() +
layout->lineForTextPosition(tc.positionInBlock()).lineNumber();
m_highlightScrollBarController->addHighlight({Constants::SCROLL_BAR_CURRENT_LINE, pos,
Theme::TextEditor_CurrentLine_ScrollBarColor,
Highlight::HighestPriority});
}
}
}