[vlc-commits] [Git][videolan/vlc][master] qml: create the scroll bar depending on the orientation in `ListViewExt`

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Apr 7 16:23:28 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
e80f981c by Fatih Uzunoglu at 2025-04-07T16:09:28+00:00
qml: create the scroll bar depending on the orientation in `ListViewExt`

By default we expect the viewport to cover the content width or height
depending on the orientation, so in normal cases we only need one scroll
bar. This behavior can obviously be overridden where the list view is
reused.

This fixes multiple things:
- Not being able to interact with the bottom part of the list view even
if the orientation is vertical and the viewport covers the whole content
width, because the scroll bar may still be technically visible and consume
events even though it does not display anything visually.
- Flashing scroll bar upon creation of the view until the content and
viewport sizes are determined (regarding the orientation where scroll bar
is not wanted).

- - - - -


1 changed file:

- modules/gui/qt/widgets/qml/ListViewExt.qml


Changes:

=====================================
modules/gui/qt/widgets/qml/ListViewExt.qml
=====================================
@@ -44,6 +44,10 @@ ListView {
     property var isDropAcceptableFunc
     property var acceptDropFunc
 
+    property Component defaultScrollBar: Component {
+        ScrollBarExt { }
+    }
+
     // Private
 
     property bool _keyPressed: false
@@ -81,8 +85,18 @@ ListView {
     keyNavigationEnabled: false
     keyNavigationWraps: false
 
-    ScrollBar.vertical: ScrollBarExt { }
-    ScrollBar.horizontal: ScrollBarExt { }
+    ScrollBar.vertical: {
+        // By default vertical scroll bar is only used when the orientation is vertical.
+        if (root.defaultScrollBar && (root.orientation === ListView.Vertical))
+            return root.defaultScrollBar.createObject() // rely on JS/QML engine's garbage collection
+        return null
+    }
+    ScrollBar.horizontal: {
+        // By default horizontal scroll bar is only used when the orientation is horizontal.
+        if (root.defaultScrollBar && (root.orientation === ListView.Horizontal))
+            return root.defaultScrollBar.createObject() // rely on JS/QML engine's garbage collection
+        return null
+    }
 
     flickableDirection: Flickable.AutoFlickIfNeeded
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e80f981cca98f4fbf16dfed6e2f93748de6415d0

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e80f981cca98f4fbf16dfed6e2f93748de6415d0
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list