[vlc-commits] [Git][videolan/vlc][master] qml: fix buggy BannerTabButton and remove unnecessary logic from CurrentIndicator

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Dec 7 12:43:24 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
a6f0f676 by Fatih Uzunoglu at 2023-12-07T12:24:33+00:00
qml: fix buggy BannerTabButton and remove unnecessary logic from CurrentIndicator

- - - - -


4 changed files:

- modules/gui/qt/medialibrary/qml/MusicArtistDelegate.qml
- modules/gui/qt/playlist/qml/PlaylistDelegate.qml
- modules/gui/qt/widgets/qml/BannerTabButton.qml
- modules/gui/qt/widgets/qml/CurrentIndicator.qml


Changes:

=====================================
modules/gui/qt/medialibrary/qml/MusicArtistDelegate.qml
=====================================
@@ -81,9 +81,13 @@ T.ItemDelegate {
         border.color: visualFocus ? theme.visualFocus : "transparent"
 
         Widgets.CurrentIndicator {
-            length: parent.height - (margin * 2)
+            anchors {
+                left: parent.left
+                leftMargin: VLCStyle.margin_xxxsmall
+                verticalCenter: parent.verticalCenter
+            }
 
-            margin: VLCStyle.dp(2, VLCStyle.scale)
+            implicitHeight: parent.height * 3 / 4
 
             visible: isCurrent
         }


=====================================
modules/gui/qt/playlist/qml/PlaylistDelegate.qml
=====================================
@@ -116,21 +116,13 @@ T.ItemDelegate {
         border.color: delegate.visualFocus ? theme.visualFocus : "transparent"
 
         Widgets.CurrentIndicator {
-            id: currentIndicator
-
             anchors {
                 left: parent.left
-                top: parent.top
-                bottom: parent.bottom
                 leftMargin: VLCStyle.margin_xxsmall
-                topMargin: VLCStyle.margin_xxsmall
-                bottomMargin: anchors.topMargin
+                verticalCenter: parent.verticalCenter
             }
 
-            // disable positioning via CurrentIndicator, manually position according to RowLayout
-            source: null
-
-            implicitWidth: VLCStyle.heightBar_xxxsmall
+            implicitHeight: parent.height * 3 / 4
 
             color: {
                 if (model.isCurrent)


=====================================
modules/gui/qt/widgets/qml/BannerTabButton.qml
=====================================
@@ -42,14 +42,12 @@ T.TabButton {
     width: control.showText ? VLCStyle.bannerTabButton_width_large
                             : VLCStyle.icon_banner
 
-    height: implicitHeight
-
     implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
                             implicitContentWidth + leftPadding + rightPadding)
     implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
                              implicitContentHeight + topPadding + bottomPadding)
 
-    padding: 0
+    padding: VLCStyle.margin_xxsmall
 
     text: model.displayText
 
@@ -84,75 +82,92 @@ T.TabButton {
     }
 
     background: Widgets.AnimatedBackground {
-        height: control.height
-        width: control.width
-
         enabled: theme.initialized
 
         animationDuration: VLCStyle.duration_short
 
         color: theme.bg.primary
         border.color: visualFocus ? theme.visualFocus : "transparent"
+
+        Widgets.CurrentIndicator {
+            anchors {
+                bottom: parent.bottom
+                bottomMargin: VLCStyle.margin_xxxsmall
+                horizontalCenter: parent.horizontalCenter
+            }
+
+            width: control.contentItem ? control.contentItem.implicitWidth : 0
+
+            visible: (width > 0 && control.showCurrentIndicator && control.selected)
+        }
     }
 
-    contentItem: Item {
-        implicitWidth: tabRow.implicitWidth + VLCStyle.margin_xxsmall * 2
-        implicitHeight: tabRow.implicitHeight
+    contentItem: RowLayout {
+        spacing: 0
 
-        RowLayout {
-            id: tabRow
+        Item {
+            Layout.fillWidth: true
+        }
 
-            anchors.centerIn: parent
-            anchors.leftMargin: VLCStyle.margin_xxsmall
-            anchors.rightMargin: VLCStyle.margin_xxsmall
+        Widgets.IconLabel {
+            id: iconLabel
 
-            spacing: VLCStyle.margin_xsmall
+            visible: text.length > 0
 
-            Widgets.IconLabel {
-                text: control.iconTxt
+            text: control.iconTxt
 
-                color: (control.selected || control.activeFocus || control.hovered)
-                        ? theme.accent
-                        : theme.fg.primary
+            horizontalAlignment: Text.AlignHCenter
+            verticalAlignment: Text.AlignVCenter
 
-                font.pixelSize: VLCStyle.icon_banner
-            }
+            color: (control.selected || control.activeFocus || control.hovered)
+                    ? theme.accent
+                    : theme.fg.primary
 
-            T.Label {
-                visible: showText
+            font.pixelSize: VLCStyle.icon_banner
 
-                text: control.text
+            Layout.fillWidth: !label.visible
+            Layout.fillHeight: true
+        }
 
-                color: control.selected ? theme.fg.secondary : theme.fg.primary
+        T.Label {
+            id: label
 
-                Behavior on color {
-                    enabled: theme.initialized
+            visible: showText
 
-                    ColorAnimation {
-                        duration: VLCStyle.duration_long
-                    }
-                }
+            text: control.text
 
-                font.pixelSize: VLCStyle.fontSize_normal
+            verticalAlignment: Text.AlignVCenter
 
-                font.weight: (control.activeFocus ||
-                              control.hovered     ||
-                              control.selected) ? Font.DemiBold
-                                                : Font.Normal
+            color: control.selected ? theme.fg.secondary : theme.fg.primary
 
-                //button text is already exposed
-                Accessible.ignored: true
-            }
-        }
+            elide: Text.ElideRight
 
-        Widgets.CurrentIndicator {
-            length: tabRow.width
+            font.pixelSize: VLCStyle.fontSize_normal
+
+            font.weight: (control.activeFocus ||
+                          control.hovered     ||
+                          control.selected) ? Font.DemiBold
+                                            : Font.Normal
 
-            orientation: Qt.Horizontal
+            //button text is already exposed
+            Accessible.ignored: true
 
-            margin: VLCStyle.margin_xxsmall
+            Layout.fillWidth: true
+            Layout.fillHeight: true
+            Layout.maximumWidth: implicitWidth + 1
+            Layout.leftMargin: iconLabel.visible ? VLCStyle.margin_xsmall : 0
+
+            Behavior on color {
+                enabled: theme.initialized
+
+                ColorAnimation {
+                    duration: VLCStyle.duration_short
+                }
+            }
+        }
 
-            visible: (control.showCurrentIndicator && control.selected)
+        Item {
+            Layout.fillWidth: true
         }
     }
 }


=====================================
modules/gui/qt/widgets/qml/CurrentIndicator.qml
=====================================
@@ -23,42 +23,12 @@ import org.videolan.vlc 0.1
 import "qrc:///style/"
 
 Rectangle {
-    id: root
-
-    property int orientation: Qt.Vertical
-    property int margin: VLCStyle.margin_xxxsmall
-
     readonly property ColorContext colorContext: ColorContext {
         id: theme
     }
 
-    property Item source: parent
-
-    property int length: 0
-
-    property var _position: [
-        {
-            // for orientation == Qt.Vertical
-            "width" : VLCStyle.heightBar_xxxsmall,
-            "height": root.length,
-            "x": margin,
-            "y": !!source ? (source.height - root.length) / 2 : 0
-        },
-        {
-            // for orientation == Qt.Horizontal
-            "width": root.length,
-            "height": VLCStyle.heightBar_xxxsmall,
-            "x": !!source ? (source.width - root.length) / 2 : 0,
-            "y": !!source ? source.height - margin : 0,
-        }
-    ]
-
-    property var _currentPosition: (orientation === Qt.Vertical) ? _position[0] : _position[1]
-
     color: theme.accent
 
-    x: _currentPosition.x
-    y: _currentPosition.y
-    width: _currentPosition.width
-    height: _currentPosition.height
+    implicitWidth: VLCStyle.heightBar_xxxsmall
+    implicitHeight: VLCStyle.heightBar_xxxsmall
 }



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

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