From c8a550a07440e4bf14033334d5cde50fd7a3f566 Mon Sep 17 00:00:00 2001 From: Fatih Uzunoglu <fuzun54@outlook.com> Date: Wed, 2 Apr 2025 17:58:23 +0300 Subject: [PATCH] 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. --- modules/gui/qt/style/VLCStyle.qml | 23 ++++++--------------- modules/gui/qt/widgets/qml/ScrollBarExt.qml | 4 ++-- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/modules/gui/qt/style/VLCStyle.qml b/modules/gui/qt/style/VLCStyle.qml index ac29f94864f6..35beaa007b8d 100644 --- a/modules/gui/qt/style/VLCStyle.qml +++ b/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) diff --git a/modules/gui/qt/widgets/qml/ScrollBarExt.qml b/modules/gui/qt/widgets/qml/ScrollBarExt.qml index 847293536c2a..42ecd147552a 100644 --- a/modules/gui/qt/widgets/qml/ScrollBarExt.qml +++ b/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 -- GitLab