From 05f2469c1a0052939fa7db4fa429d6d8f05aab99 Mon Sep 17 00:00:00 2001 From: Alex Nemeth Date: Fri, 15 Jun 2018 22:05:32 -0400 Subject: [PATCH] Show the scrollbar only when needed Summary: It hides the scrollbar when there isn't enough lines to scroll. This also affects KParts like Yakuake or Dolphin and others. Test Plan: {F5780078} Reviewers: hindenburg, #konsole, #vdg Reviewed By: hindenburg, #konsole, #vdg Subscribers: konsole-devel, mglb, zzag, Pitel, ngraham, #konsole Tags: #konsole Differential Revision: https://phabricator.kde.org/D11843 --- src/TerminalDisplay.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index 3f91a5de..c32e0653 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -2118,7 +2118,12 @@ void TerminalDisplay::setScrollBarPosition(Enum::ScrollBarPositionEnum position) return; } - _scrollBar->setVisible(position != Enum::ScrollBarHidden); + if (position == Enum::ScrollBarHidden) { + _scrollBar->hide(); + } else if (_scrollBar->maximum() != 0) { + _scrollBar->show(); + } + _scrollbarLocation = position; propagateSize(); @@ -2150,10 +2155,14 @@ void TerminalDisplay::setScroll(int cursor, int slines) // // setting the range or value of a _scrollBar will always trigger // a repaint, so it should be avoided if it is not necessary - if (_scrollBar->minimum() == 0 && - _scrollBar->maximum() == (slines - _lines) && - _scrollBar->value() == cursor) { + + if (_scrollBar->maximum() == 0 && _scrollBar->value() == cursor) { + // hide the scrollbar if it's not needed + _scrollBar->hide(); return; + + } else if (_scrollbarLocation != Enum::ScrollBarHidden){ + _scrollBar->show(); } disconnect(_scrollBar, &QScrollBar::valueChanged, this, &Konsole::TerminalDisplay::scrollBarPositionChanged);