1919#include < QStandardPaths>
2020#include < QFile>
2121#include < QTextStream>
22+ #include < QScrollBar>
2223
2324TerminalPane::TerminalPane (QWidget *parent)
2425 : QWidget(parent)
@@ -269,7 +270,10 @@ void TerminalPane::createTerminalWidget(QTermWidget* &terminal, bool isTopTermin
269270
270271void TerminalPane::styleTerminal (QTermWidget* terminal)
271272{
272- // Apply the standard Tau5 scrollbar styling but with gray colors
273+ // Apply the exact same Tau5 scrollbar styling used across the application
274+ // This matches the styling from StyleManager::tau5Scrollbar()
275+
276+ // Normal style when there's content to scroll
273277 QString scrollbarStyle = QString (
274278 " QScrollBar:vertical { "
275279 " background: transparent; "
@@ -279,7 +283,7 @@ void TerminalPane::styleTerminal(QTermWidget* terminal)
279283 " }"
280284 " QScrollBar::handle:vertical { "
281285 " background: %1; "
282- " border-radius: 0px; "
286+ " border-radius: 0px; " // Squared ends, not rounded
283287 " min-height: 30px; "
284288 " margin: 0px; "
285289 " border: none; "
@@ -303,9 +307,57 @@ void TerminalPane::styleTerminal(QTermWidget* terminal)
303307 " background: transparent; "
304308 " border: none; "
305309 " }" )
306- .arg (StyleManager::Colors::SCROLLBAR_THUMB)
307- .arg (StyleManager::Colors::SCROLLBAR_THUMB_HOVER);
310+ .arg (StyleManager::Colors::primaryOrangeAlpha (240 )) // Same as tau5Scrollbar()
311+ .arg (StyleManager::Colors::primaryOrangeAlpha (255 )); // Same as tau5Scrollbar()
312+
313+ // Style when there's nothing to scroll (transparent handle)
314+ QString noScrollStyle = QString (
315+ " QScrollBar:vertical { "
316+ " background: transparent; "
317+ " width: 8px; "
318+ " border: none; "
319+ " margin: 0px; "
320+ " }"
321+ " QScrollBar::handle:vertical { "
322+ " background: transparent; " // Hide the handle when nothing to scroll
323+ " border: none; "
324+ " }"
325+ " QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical { "
326+ " height: 0px; "
327+ " background: transparent; "
328+ " border: none; "
329+ " }"
330+ " QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical { "
331+ " background: transparent; "
332+ " border: none; "
333+ " }"
334+ " QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { "
335+ " background: transparent; "
336+ " border: none; "
337+ " }" );
338+
339+ terminal->setScrollBarPosition (QTermWidget::ScrollBarRight);
308340 terminal->setStyleSheet (scrollbarStyle);
341+
342+ // When there's nothing to scroll, hide the scrollbar handle to avoid
343+ // showing a full-height orange bar
344+ QList<QScrollBar*> scrollBars = terminal->findChildren <QScrollBar*>();
345+ for (QScrollBar* scrollBar : scrollBars) {
346+ if (scrollBar->orientation () == Qt::Vertical) {
347+ // Update scrollbar stylesheet based on range
348+ auto updateScrollbarStyle = [scrollBar, scrollbarStyle, noScrollStyle]() {
349+ bool hasScrollRange = (scrollBar->maximum () != scrollBar->minimum ());
350+ scrollBar->setStyleSheet (hasScrollRange ? scrollbarStyle : noScrollStyle);
351+ };
352+
353+ // Connect to range changes
354+ connect (scrollBar, &QScrollBar::rangeChanged, terminal, updateScrollbarStyle);
355+
356+ // Initial check
357+ updateScrollbarStyle ();
358+ break ;
359+ }
360+ }
309361}
310362
311363void TerminalPane::setWorkingDirectory (const QString &dir)
0 commit comments