From c9e0641fe471852d59eb62e63613a2bd4c394d96 Mon Sep 17 00:00:00 2001
From: Fatih Uzunoglu <fuzun54@outlook.com>
Date: Sat, 29 Mar 2025 20:30:51 +0200
Subject: [PATCH] qml: make scroll bar invisible if it does not show anything

This makes it possible to not consume the events when there
is nothing shown. We can do this because in this scroll bar
style when `size` is smaller than 1.0, the handle is always
visible. So this change is mostly relevant when `size` is
1.0, which means viewport size covers the content size.

This is useful for situations such as, playlist height is
equal or greater than the combined height of the items added
to it. With this patch, clicking on the items where the scroll
bar would be shown makes it possible for items to react to
the events (such as, selecting or showing the context menu).

I did not use `background.visible` or `contentItem.visible`
because they already depend on the control's visibility (as
if parent is invisible the children would be invisible).
---
 modules/gui/qt/widgets/qml/ScrollBarExt.qml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/gui/qt/widgets/qml/ScrollBarExt.qml b/modules/gui/qt/widgets/qml/ScrollBarExt.qml
index 92fd86c1a1ae..847293536c2a 100644
--- a/modules/gui/qt/widgets/qml/ScrollBarExt.qml
+++ b/modules/gui/qt/widgets/qml/ScrollBarExt.qml
@@ -30,10 +30,10 @@ T.ScrollBar {
                              implicitContentHeight + topPadding + bottomPadding)
 
     padding: VLCStyle.dp(2, VLCStyle.scale)
-    visible: policy !== T.ScrollBar.AlwaysOff
+    visible: policy !== T.ScrollBar.AlwaysOff && ((background && background.opacity > 0.0) || (contentItem && contentItem.opacity > 0.0))
     minimumSize: horizontal ? (height / width) : (width / height)
 
-    // We don't want to show anything is scrolling is not possible (content size less than
+    // We don't want to show anything if scrolling is not possible (content size less than
     // or equal to flickable size), unless `ScrollBar.AlwaysOn` is used (not by default):
     readonly property bool _shown: (policy === T.ScrollBar.AlwaysOn) || (control.size < 1.0)
 
-- 
GitLab