[vlc-commits] [Git][videolan/vlc][master] qml: define the scroll bar implicit size in `VLCStyle`

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Apr 7 15:43:29 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
c8a550a0 by Fatih Uzunoglu at 2025-04-07T15:28:58+00:00
qml: define the scroll bar implicit size in `VLCStyle`

Now that we have our own customized scroll bar, we can define
its implicit size in `VLCStyle.qml` directly.

- - - - -


2 changed files:

- modules/gui/qt/style/VLCStyle.qml
- modules/gui/qt/widgets/qml/ScrollBarExt.qml


Changes:

=====================================
modules/gui/qt/style/VLCStyle.qml
=====================================
@@ -17,10 +17,9 @@
  *****************************************************************************/
 pragma Singleton
 import QtQuick
-import QtQuick.Controls
+
 import VLC.MainInterface
 import VLC.Style
-import VLC.Widgets as Widgets
 
 QtObject {
     id: vlc_style
@@ -58,8 +57,7 @@ QtObject {
     readonly property double margin_xlarge: MainCtx.dp(32, scale);
     readonly property double margin_xxlarge: MainCtx.dp(36, scale);
 
-    property Component _scrollBarComponent: Widgets.ScrollBarExt { }
-    property real resizeHandleWidth
+    readonly property real resizeHandleWidth: (scrollBarInteractingSize / 2)
 
     // Borders
     readonly property int border: MainCtx.dp(1, scale)
@@ -320,6 +318,10 @@ QtObject {
     readonly property int controlLayoutHeight: MainCtx.dp(64, scale)
     readonly property int controlLayoutHeightPinned: MainCtx.dp(32, scale)
 
+    // Scroll bar (size means width or height, depending on the orientation):
+    readonly property real scrollBarInteractingSize: MainCtx.dp(5, scale)
+    readonly property real scrollBarNonInteractingSize: MainCtx.dp(2, scale)
+
     function dp(size, scale) {
         if (scale === undefined)
             return MainCtx.dp(size, MainCtx.intfScaleFactor)
@@ -330,19 +332,6 @@ QtObject {
       return nb * VLCStyle.column_width + ( nb - 1 ) * VLCStyle.column_spacing;
     }
 
-    Component.onCompleted: {
-        {
-            // Resize handle width setting:
-            const scrollBarObject = _scrollBarComponent.createObject()
-            console.assert(scrollBarObject)
-            const scrollBarWidth = scrollBarObject.width
-            scrollBarObject.destroy()
-
-            _scrollBarComponent = null
-            resizeHandleWidth = (scrollBarWidth / 2)
-        }
-    }
-
     //dynamic margins based on screen width
     function dynamicAppMargins(width : int) : int {
         if (width < smallWidth)


=====================================
modules/gui/qt/widgets/qml/ScrollBarExt.qml
=====================================
@@ -73,8 +73,8 @@ T.ScrollBar {
     }
 
     contentItem: Rectangle {
-        implicitWidth: VLCStyle.dp(control.interacting ? 5 : 2, VLCStyle.scale)
-        implicitHeight: VLCStyle.dp(control.interacting ? 5 : 2, VLCStyle.scale)
+        implicitWidth: control.interacting ? VLCStyle.scrollBarInteractingSize : VLCStyle.scrollBarNonInteractingSize
+        implicitHeight: control.interacting ? VLCStyle.scrollBarInteractingSize : VLCStyle.scrollBarNonInteractingSize
 
         radius: width / 2
         color: theme.fg.secondary



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

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c8a550a07440e4bf14033334d5cde50fd7a3f566
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