[vlc-commits] [Git][videolan/vlc][master] 32 commits: qml: fix wheel scroll in toolbar editor

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Oct 2 09:00:44 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
2e91603f by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: fix wheel scroll in toolbar editor

fixes #25644.

- - - - -
2ed01863 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: adjust geometry of toolbar editor dialog

- - - - -
73751bb7 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: better forbidden cursor handling in toolbar editor

- - - - -
458488aa by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: enable inter-view dragging in toolbar editor

- - - - -
959e3737 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: use function for drop event in toolbar editor

- - - - -
bf104671 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: use binding to set containsDrag in toolbar editor

- - - - -
b2dfcfa1 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: use binding to determine active dragging in toolbar editor

- - - - -
2e1a4cb4 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: remove unneeded property in toolbar editor

- - - - -
f70f308f by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: disable indexing in toolbar editor grid view

completely fixes #25576

- - - - -
725fbafd by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: remove function call in toolbar editor

- - - - -
5a143915 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: use alias in toolbar editor view footer item

- - - - -
947f718a by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: small reformat ToolbarEditor

- - - - -
f5d1676f by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: small refactor in EditorDNDView

- - - - -
f76423a1 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: small refactor in EditorDNDDelegate

- - - - -
a47d8adc by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: reject drag instead of manually checking in EditorDNDDelegate

- - - - -
1f0ab1ee by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: disable indexing in toolbar editor dndview

- - - - -
7aaae066 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: remove unnecessary property in toolbar editor

- - - - -
c561afde by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: small refactor in ToolbarEditorButtonList

- - - - -
1cb2e01e by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: set property properly in toolbar editor

- - - - -
4e8133f4 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: disable overshoot in toolbar editor grid view

- - - - -
ddb5082e by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: toolbar view to stop at bounds

- - - - -
062a8386 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: set maximum width for toolbar editor combobox

- - - - -
a2fbb48b by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: add left right margins to toolbar editor dndview

- - - - -
dafcfc42 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: show controls in minimum width mode in toolbar editor center view

toolbar widgets can not be expanded if placed in player toolbar center
alignment. However, this behavior was not being reflected in the toolbar
editor.

- - - - -
265c5eae by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: adjust hover indication in toolbar editor

- - - - -
625c2f00 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: correct sizing calculation in toolbar editor

- - - - -
0b42a717 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: hide center view when control is not compatible in toolbar editor

Extending spacer widget is not compatible with the central alignment,
so it makes sense to hide while this widget is being dragged

- - - - -
8f270005 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: add missing check in ButtonsLayout

- - - - -
2fe57f53 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: make EditorDNDDelegate Control

- - - - -
9c8c3c20 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: toolbar editor view drag auto scroll rework

- - - - -
7b8e1022 by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: disable incompatible transitions in EditorDNDView

- - - - -
176241cf by Fatih Uzunoglu at 2021-10-02T08:23:22+00:00
qml: fix type error in toolbar editor

- - - - -


8 changed files:

- modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml
- modules/gui/qt/dialogs/toolbar/qml/EditorDNDView.qml
- modules/gui/qt/dialogs/toolbar/qml/EditorTabButton.qml
- modules/gui/qt/dialogs/toolbar/qml/ToolbarEditor.qml
- modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorButtonList.qml
- modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorDialog.qml
- modules/gui/qt/player/qml/ButtonsLayout.qml
- modules/gui/qt/player/qml/controlbarcontrols/ArtworkInfoWidget.qml


Changes:

=====================================
modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml
=====================================
@@ -17,6 +17,7 @@
  *****************************************************************************/
 
 import QtQuick 2.11
+import QtQuick.Controls 2.4
 import QtQml.Models 2.11
 
 import org.videolan.vlc 0.1
@@ -25,177 +26,150 @@ import "qrc:///player/"
 import "qrc:///widgets/" as Widgets
 import "qrc:///style/"
 
-MouseArea {
-    id: dragArea
+Control {
+    id: control
 
-    property int controlId: model.id
-    property bool held: false
-    property bool dropVisible: false
+    padding: background.border.width
+
+    readonly property int controlId: model.id
     property var dndView: null
-    anchors.verticalCenter: (!!parent) ? parent.verticalCenter : undefined
-    cursorShape: Qt.OpenHandCursor
-    drag.target: held ? content : undefined
-    width: buttonloader.width
-    height: VLCStyle.icon_medium
-    hoverEnabled: true
-
-    property alias containsDrag: dropArea.containsDrag
-
-    onHeldChanged: {
-        if (held) {
-            removeInfoRectVisible = true
-        }
-        else {
-            removeInfoRectVisible = false
-        }
-    }
 
-    Rectangle {
-        z: -1
+    readonly property bool dragActive: loader.Drag.active
+    property alias dropArea: dropArea
+
+    property alias containsMouse: mouseArea.containsMouse
+    property alias pressed: mouseArea.pressed
+
+    ListView.delayRemove: dragActive
+    
+    MouseArea {
+        id: mouseArea
+
         anchors.fill: parent
 
-        visible: dragArea.containsMouse && !held
-        color: VLCStyle.colors.bgHover
-    }
+        cursorShape: (pressed || root.dragActive) ? Qt.DragMoveCursor
+                                                  : Qt.OpenHandCursor
 
-    Rectangle {
-        z: 1
-        width: VLCStyle.dp(2, VLCStyle.scale)
-        height: parent.height
-        anchors {
-            left: parent.left
-            verticalCenter: parent.verticalCenter
-            leftMargin: index === 0 ? 0 : -width
+        drag.target: loader
+
+        hoverEnabled: true
+
+        drag.onActiveChanged: {
+            if (drag.active) {
+                root.dragStarted(controlId)
+                removeInfoRectVisible = true
+                drag.target.Drag.start()
+
+            } else {
+                drag.target.Drag.drop()
+                removeInfoRectVisible = false
+                root.dragStopped(controlId)
+            }
         }
-        antialiasing: true
-        visible: dropVisible
-        color: VLCStyle.colors.accent
-    }
 
-    onPressed: {
-        held = true
-        root._held = true
+        onPositionChanged: {
+            if (drag.active) {
+                // FIXME: There must be a better way of this
+                var pos = mapToItem(loader.parent, mouseX, mouseY)
+                // y should be set first, because the automatic scroll is
+                // triggered by change on X
+                loader.y = pos.y
+                loader.x = pos.x
+            }
+        }
     }
 
-    onEntered: playerBtnDND.currentIndex = index
+    DropArea {
+        id: dropArea
+        anchors.fill: parent
+
+        onEntered: {
+            if ((drag.source === null ||
+                 (drag.source.dndView === dndView &&
+                  (parent.DelegateModel.itemsIndex === drag.source.DelegateModel.itemsIndex + 1))) ||
+                    pressed)
+                drag.accepted = false
+        }
 
-    onWheel: {
-        playerBtnDND.wheelScroll(wheel.angleDelta.y)
-    }
+        onDropped: {
+            var destIndex = parent.DelegateModel.itemsIndex
 
-    onReleased: {
-        drag.target.Drag.drop()
-        held = false
-        root._held = false
-    }
+            if((drag.source.dndView === dndView)
+                    && (drag.source.DelegateModel.itemsIndex < destIndex))
+                --destIndex
 
-    onPositionChanged: {
-        var pos = this.mapToGlobal(mouseX, mouseY)
-        updatePos(pos.x, pos.y)
+            dropEvent(drag, destIndex)
+        }
     }
 
-    function updatePos(x, y) {
-        var pos = root.mapFromGlobal(x, y)
-        content.x = pos.x
-        content.y = pos.y
+    Binding {
+        when: dragActive
+        value: true
+
+        target: root
+        property: "dragActive"
     }
 
     Rectangle {
-        id: content
-        Drag.active: dragArea.held
-        Drag.source: dragArea
         anchors {
-            horizontalCenter: parent.horizontalCenter
+            left: parent.left
             verticalCenter: parent.verticalCenter
+            leftMargin: index === 0 ? 0 : -width
         }
 
-        opacity: held ? 0.75 : 1.0
-
-        Loader{
-            id: buttonloader
-            anchors {
-                horizontalCenter: parent.horizontalCenter
-                verticalCenter: parent.verticalCenter
-            }
-            source: PlayerControlbarControls.control(model.id).source
-            onLoaded: {
-                buttonloader.item.paintOnly = true
-                buttonloader.item.enabled = false
-            }
+        z: 1
 
-        }
+        implicitWidth: VLCStyle.dp(2, VLCStyle.scale)
+        implicitHeight: VLCStyle.icon_medium
 
-        states: State {
-            when: dragArea.held
+        visible: dropArea.containsDrag
+        color: VLCStyle.colors.accent
+    }
 
-            ParentChange { target: content; parent: root }
-            AnchorChanges {
-                target: content
-                anchors { horizontalCenter: undefined; verticalCenter: undefined }
-            }
+    background: Rectangle {
+        opacity: Drag.active ? 0.75 : 1.0
 
-            PropertyChanges {
-                target: dragArea
-                ListView.delayRemove: true
-            }
-        }
+        color: "transparent"
 
-        onXChanged: {
-            if (content.Drag.active)
-                root.handleScroll(this)
-        }
+        border.width: VLCStyle.dp(1, VLCStyle.scale)
+        border.color: containsMouse && !pressed ? VLCStyle.colors.buttonBorder
+                                                : "transparent"
     }
 
-    DropArea {
-        id: dropArea
-        anchors.fill: parent
-
-        onEntered: {
-            if ((drag.source === null ||
-                 (drag.source.dndView === playerBtnDND &&
-                  (parent.DelegateModel.itemsIndex === drag.source.DelegateModel.itemsIndex + 1))))
-                return
-
-            if (held)
-                return
+    contentItem: Item {
+        id: wrapper
 
-            dropVisible = true
-        }
+        implicitHeight: loader.implicitHeight
+        implicitWidth: loader.implicitWidth
 
-        onExited: {
-            if (held)
-                return
+        Loader {
+            id: loader
 
-            dropVisible = false
-        }
+            parent: Drag.active ? root : wrapper
 
-        onDropped: {
-            if (!dropVisible)
-                return
+            anchors.horizontalCenter: Drag.active ? undefined : parent.horizontalCenter
+            anchors.verticalCenter:  Drag.active ? undefined : parent.verticalCenter
 
-            if (held)
-                return
+            source: PlayerControlbarControls.control(model.id).source
 
-            if (drag.source.dndView === playerBtnDND) {
-                // moving from same section
-                var srcIndex = drag.source.DelegateModel.itemsIndex
-                var destIndex = parent.DelegateModel.itemsIndex
+            Drag.source: control
 
-                if(srcIndex < destIndex)
-                    destIndex -= 1
-                playerBtnDND.model.move(srcIndex,destIndex)
-            }
-            else if (drag.source.objectName == "buttonsList"){
-                // moving from buttonsList
-                dndView.model.insert(parent.DelegateModel.itemsIndex, {"id" : drag.source.mIndex})
-            }
-            else {
-                // moving between sections
-                dndView.model.insert(parent.DelegateModel.itemsIndex, {"id" : drag.source.controlId})
-                drag.source.dndView.model.remove(drag.source.DelegateModel.itemsIndex)
+            onXChanged: {
+                if (Drag.active)
+                    root.handleScroll(this)
             }
 
-            dropVisible = false
+            onLoaded: {
+                item.paintOnly = true
+                item.enabled = false
+
+                if (item.extraWidth !== undefined) {
+                    if (extraWidthAvailable)
+                        item.extraWidth = Number.MAX_VALUE
+                    else
+                        item.extraWidth = 0
+                }
+            }
         }
     }
 }


=====================================
modules/gui/qt/dialogs/toolbar/qml/EditorDNDView.qml
=====================================
@@ -25,28 +25,28 @@ import "qrc:///style/"
 
 ListView {
     id: playerBtnDND
+
     spacing: VLCStyle.margin_xsmall
     orientation: Qt.Horizontal
     clip: true
 
+    currentIndex: -1
     highlightFollowsCurrentItem: false
 
+    boundsBehavior: Flickable.StopAtBounds
+    boundsMovement: Flickable.StopAtBounds
+
     property bool containsDrag: footerItem.dropVisible
 
     property alias scrollBar: scrollBar
 
+    property bool extraWidthAvailable: true
+
     ScrollBar.horizontal: ScrollBar {
         id: scrollBar
         policy: playerBtnDND.contentWidth > playerBtnDND.width ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded
     }
 
-    function wheelScroll(delta) {
-        if (delta > 0)
-            scrollBar.decrease()
-        else
-            scrollBar.increase()
-    }
-
     remove: Transition {
         NumberAnimation {
             property: "opacity"; from: 1.0; to: 0
@@ -55,6 +55,10 @@ ListView {
         }
     }
 
+    // FIXME: Animations are disabled because they are incompatible
+    // with the delegate loader which sets extra width after the
+    // control gets loaded.
+    /*
     add: Transition {
         NumberAnimation {
             property: "opacity"; from: 0; to: 1.0
@@ -73,85 +77,102 @@ ListView {
 
         NumberAnimation { property: "opacity"; to: 1.0 }
     }
+    */
+
+    function dropEvent(drag, destIndex) {
+        if (drag.source.dndView === playerBtnDND) {
+            // moving from same section
+            playerBtnDND.model.move(drag.source.DelegateModel.itemsIndex,
+                                    destIndex)
+        } else if (drag.source.objectName === "buttonsList") {
+            // moving from buttonsList
+            playerBtnDND.model.insert(destIndex, {"id" : drag.source.mIndex})
+        } else {
+            // moving between sections or views
+            playerBtnDND.model.insert(destIndex, {"id" : drag.source.controlId})
+            drag.source.dndView.model.remove(drag.source.DelegateModel.itemsIndex)
+        }
+    }
     
     MouseArea {
         anchors.fill: parent
-        z: 1
 
-        visible: root._held
+        acceptedButtons: Qt.NoButton
+        z: -1
+
+        cursorShape: root.dragActive ? Qt.DragMoveCursor : Qt.ArrowCursor
 
-        cursorShape: visible ? Qt.DragMoveCursor : Qt.ArrowCursor
+        onWheel: {
+            // scrolling based on angleDelta.x is handled by the listview itself
+            var y = wheel.angleDelta.y
+
+            if (y > 0) {
+                scrollBar.decrease()
+                wheel.accepted = true
+            } else if (y < 0) {
+                scrollBar.increase()
+                wheel.accepted = true
+            } else {
+                wheel.accepted = false
+            }
+        }
     }
 
-    footer: MouseArea {
-        height: VLCStyle.icon_medium
-        width: Math.max(height, playerBtnDND.width - x)
+    footer: Item {
         anchors.verticalCenter: parent.verticalCenter
-        property bool dropVisible: false
 
-        onWheel: {
-            wheelScroll(wheel.angleDelta.y)
-        }
+        implicitHeight: VLCStyle.icon_medium
+        implicitWidth: Math.max(implicitHeight, playerBtnDND.width - x)
+
+        property alias dropVisible: footerDropArea.containsDrag
 
         Rectangle {
+            anchors.left: parent.left
+            anchors.top: parent.top
+            anchors.bottom: parent.bottom
+
             z: 2
-            width: VLCStyle.dp(2, VLCStyle.scale)
-            height: parent.height
-            anchors {
-                left: parent.left
-            }
-            antialiasing: true
+
+            implicitWidth: VLCStyle.dp(2, VLCStyle.scale)
+
             visible: dropVisible
             color: VLCStyle.colors.accent
         }
+
         DropArea {
+            id: footerDropArea
+
             anchors.fill: parent
 
             onEntered: {
-                if (drag.source.dndView === playerBtnDND && drag.source.DelegateModel.itemsIndex === playerBtnDND.count - 1)
-                    return
-
-                dropVisible = true
-            }
-
-            onExited: {
-                dropVisible = false
+                if (drag.source.dndView === playerBtnDND &&
+                        drag.source.DelegateModel.itemsIndex === playerBtnDND.count - 1) {
+                    drag.accepted = false
+                }
             }
 
             onDropped: {
-                if (!dropVisible)
-                    return
+                var destIndex = playerBtnDND.count
 
-                if (drag.source.dndView === playerBtnDND) {
-                    // moving from same section
-                    playerBtnDND.model.move(drag.source.DelegateModel.itemsIndex, playerBtnDND.count - 1)
-                }
-                else if (drag.source.objectName == "buttonsList"){
-                    // moving from buttonsList
-                    playerBtnDND.model.insert(playerBtnDND.count, {"id" : drag.source.mIndex})
-                }
-                else {
-                    // moving between sections
-                    playerBtnDND.model.insert(playerBtnDND.count, {"id" : drag.source.controlId})
-                    drag.source.dndView.model.remove(drag.source.DelegateModel.itemsIndex)
-                }
+                if (drag.source.dndView === playerBtnDND)
+                    --destIndex
 
-                dropVisible = false
+                dropEvent(drag, destIndex)
             }
         }
     }
 
     delegate: EditorDNDDelegate {
+        anchors.verticalCenter: (!!parent) ? parent.verticalCenter : undefined
+
         dndView: playerBtnDND
 
-        onContainsDragChanged: {
-            for(var child in playerBtnDND.contentItem.children) {
-                if (playerBtnDND.contentItem.children[child].containsDrag === true) {
-                    playerBtnDND.containsDrag = true
-                    return
-                }
-            }
-            playerBtnDND.containsDrag = Qt.binding(function() { return footerItem.dropVisible; } )
+        Binding {
+            when: dropArea.containsDrag
+            value: true
+
+            target: playerBtnDND
+            property: "containsDrag"
         }
     }
 }


=====================================
modules/gui/qt/dialogs/toolbar/qml/EditorTabButton.qml
=====================================
@@ -24,7 +24,7 @@ import "qrc:///widgets/" as Widgets
 TabButton {
     id: mainPlayerControl
 
-    property bool active: index == bar.currentIndex
+    readonly property bool active: index === bar.currentIndex
 
     implicitWidth: VLCStyle.button_width_large
 
@@ -62,4 +62,12 @@ TabButton {
             height: parent.border.width * 2
         }
     }
+
+    DropArea {
+        anchors.fill: parent
+
+        onEntered: {
+            bar.currentIndex = index
+        }
+    }
 }


=====================================
modules/gui/qt/dialogs/toolbar/qml/ToolbarEditor.qml
=====================================
@@ -29,20 +29,14 @@ Rectangle{
     id: root
     color: VLCStyle.colors.bg
 
-    property bool _held: false
+    property bool dragActive: !!_viewThatContainsDrag || buttonDragItem.Drag.active
 
     property alias removeInfoRectVisible: buttonList.removeInfoRectVisible
 
     property var _viewThatContainsDrag: undefined
 
-    MouseArea {
-        anchors.fill: parent
-        z: -1
-
-        visible: _held
-
-        cursorShape: visible ? Qt.ForbiddenCursor : Qt.ArrowCursor
-    }
+    signal dragStarted(int controlId)
+    signal dragStopped(int controlId)
 
     ColumnLayout{
         anchors.fill: parent
@@ -54,6 +48,8 @@ Rectangle{
 
             background: Item { }
 
+            readonly property int currentIdentifier: currentItem.identifier
+
             Repeater {
                 model: PlayerListModel.model
 
@@ -96,109 +92,141 @@ Rectangle{
                 font.pixelSize: VLCStyle.fontSize_xxlarge
             }
 
-            StackLayout{
-                anchors.fill: parent
-                currentIndex: bar.currentIndex
-
-                Repeater {
-                    model: PlayerListModel.model
+            Repeater {
+                model: PlayerListModel.model
 
-                    delegate: RowLayout {
-                        id: layout
+                delegate: RowLayout {
+                    id: layout
 
-                        readonly property int identifier: modelData.identifier
-                        readonly property var model: {
-                            if (!!mainInterface.controlbarProfileModel.currentModel)
-                                return mainInterface.controlbarProfileModel.currentModel.getModel(identifier)
-                            else
-                                return undefined
-                        }
+                    // can't use StackLayout or change visibility
+                    // because there is a bug with the dragging
+                    // that it doesn't work when the visibility
+                    // is set to false, so instead use stacking
+                    // and width/height to show the current view
+                    clip: true
+                    z: bar.currentIdentifier === identifier ? 0 : -1
+                    width: bar.currentIdentifier === identifier ? parent.width : 0
+                    height: bar.currentIdentifier === identifier ? parent.height : 0
+                    visible: root.dragActive || (bar.currentIdentifier === identifier)
 
-                        spacing: VLCStyle.margin_small
+                    readonly property int identifier: modelData.identifier
+                    readonly property var model: {
+                        if (!!mainInterface.controlbarProfileModel.currentModel)
+                            return mainInterface.controlbarProfileModel.currentModel.getModel(identifier)
+                        else
+                            return undefined
+                    }
 
-                        Repeater {
-                            id: repeater
+                    spacing: VLCStyle.margin_small
 
-                            model: 3 // left, center, and right
+                    Repeater {
+                        id: repeater
 
-                            function getModel(index) {
-                                if (!!layout.model) {
-                                    switch (index) {
-                                    case 0:
-                                        return layout.model.left
-                                    case 1:
-                                        return layout.model.center
-                                    case 2:
-                                        return layout.model.right
-                                    default:
-                                        return undefined
-                                    }
-                                } else {
-                                    return undefined
-                                }
-                            }
+                        model: 3 // left, center, and right
 
-                            function getMetric(index) {
+                        function getModel(index) {
+                            if (!!layout.model) {
                                 switch (index) {
                                 case 0:
-                                    return leftMetric
+                                    return layout.model.left
                                 case 1:
-                                    return centerMetric
+                                    return layout.model.center
                                 case 2:
-                                    return rightMetric
+                                    return layout.model.right
+                                default:
+                                    return undefined
                                 }
+                            } else {
+                                return undefined
                             }
+                        }
 
-                            Loader {
-                                id : playerBtnDND
-                                active: !!repeater.getModel(index)
-
-                                Layout.fillHeight: true
-                                Layout.fillWidth: count > 0 ||
-                                                  (repeater.itemAt(0).count === 0 &&
-                                                   repeater.itemAt(1).count === 0 &&
-                                                   repeater.itemAt(2).count === 0)
-
-                                Layout.minimumWidth: Math.max(leftMetric.width,
-                                                              centerMetric.width,
-                                                              rightMetric.width) * 1.25
-                                Layout.margins: parentRectangle.border.width
-
-                                readonly property int count: {
-                                    if (status === Loader.Ready)
-                                        return item.count
-                                    else
-                                        return 0
+                        function getMetric(index) {
+                            switch (index) {
+                            case 0:
+                                return leftMetric
+                            case 1:
+                                return centerMetric
+                            case 2:
+                                return rightMetric
+                            }
+                        }
+
+                        Loader {
+                            id : playerBtnDND
+                            active: !!repeater.getModel(index)
+
+                            Layout.fillHeight: true
+                            Layout.fillWidth: {
+                                if (count === 0) {
+                                    for (var i = 0; i < repeater.count; ++i) {
+                                        var item = repeater.itemAt(i)
+                                        if (!!item && item.count > 0)
+                                            return false
+                                    }
                                 }
 
-                                sourceComponent: Rectangle {
-                                    color: VLCStyle.colors.bgAlt
+                                return true
+                            }
+
+                            Layout.minimumWidth: !!item && item.visible ? Math.max(leftMetric.width,
+                                                                                   centerMetric.width,
+                                                                                   rightMetric.width) * 1.25
+                                                                        : 0
+                            Layout.margins: parentRectangle.border.width
 
-                                    property alias count: dndView.count
+                            readonly property int count: !!item ? item.count : 0
 
-                                    EditorDNDView {
-                                        id: dndView
+                            sourceComponent: Rectangle {
+                                color: VLCStyle.colors.bgAlt
+
+                                property alias count: dndView.count
+
+                                Connections {
+                                    target: root
+                                    enabled: dndView.model === layout.model.center
+
+                                    onDragStarted: {
+                                        // extending spacer widget should not be placed in the
+                                        // central alignment view
+                                        if (controlId === ControlListModel.WIDGET_SPACER_EXTEND)
+                                            visible = false
+                                    }
+
+                                    onDragStopped: {
+                                        if (controlId === ControlListModel.WIDGET_SPACER_EXTEND)
+                                            visible = true
+                                    }
+                                }
+
+                                EditorDNDView {
+                                    id: dndView
+                                    anchors.fill: parent
+                                    anchors.leftMargin: spacing
+                                    anchors.rightMargin: spacing
+
+                                    model: repeater.getModel(index)
+
+                                    // controls in the center view can not have
+                                    // extra width
+                                    extraWidthAvailable: model !== layout.model.center
+
+                                    onContainsDragChanged: {
+                                        if (containsDrag)
+                                            _viewThatContainsDrag = this
+                                        else if (_viewThatContainsDrag === this)
+                                            _viewThatContainsDrag = null
+                                    }
+
+                                    Text {
                                         anchors.fill: parent
 
-                                        model: repeater.getModel(index)
-
-                                        onContainsDragChanged: {
-                                            if (containsDrag)
-                                                _viewThatContainsDrag = this
-                                            else if (_viewThatContainsDrag === this)
-                                                _viewThatContainsDrag = null
-                                        }
-
-                                        Text {
-                                            anchors.fill: parent
-
-                                            text: repeater.getMetric(index).text
-                                            verticalAlignment: Text.AlignVCenter
-                                            font.pixelSize: VLCStyle.fontSize_xxlarge
-                                            color: VLCStyle.colors.menuCaption
-                                            horizontalAlignment: Text.AlignHCenter
-                                            visible: (playerBtnDND.count === 0)
-                                        }
+                                        text: repeater.getMetric(index).text
+                                        verticalAlignment: Text.AlignVCenter
+                                        font.pixelSize: VLCStyle.fontSize_xxlarge
+                                        color: VLCStyle.colors.menuCaption
+                                        horizontalAlignment: Text.AlignHCenter
+                                        visible: (count === 0)
                                     }
                                 }
                             }
@@ -208,14 +236,14 @@ Rectangle{
             }
         }
 
-        Rectangle{
-            id : allBtnsGrid
+        Rectangle {
             Layout.fillHeight: true
             Layout.fillWidth: true
             Layout.margins: VLCStyle.margin_xxsmall
+
             color: VLCStyle.colors.bgAlt
 
-            ColumnLayout{
+            ColumnLayout {
                 anchors.fill: parent
 
                 Widgets.MenuCaption {
@@ -234,22 +262,15 @@ Rectangle{
         }
     }
 
-    EditorDummyButton{
+    EditorDummyButton {
         id: buttonDragItem
-        visible: false
-        Drag.active: visible
-        color: VLCStyle.colors.buttonText
 
+        visible: Drag.active
+        color: VLCStyle.colors.buttonText
         opacity: 0.75
 
-        function updatePos(x, y) {
-            var pos = root.mapFromGlobal(x, y)
-            this.x = pos.x
-            this.y = pos.y
-        }
-
         onXChanged: {
-            if (buttonDragItem.Drag.active)
+            if (Drag.active)
                 handleScroll(this)
         }
     }
@@ -265,20 +286,26 @@ Rectangle{
         }
 
         var dragItemX = dragItem.x
-        var viewX     = view.mapToItem(root, view.x, view.y).x
+        var viewPos   = view.mapToItem(root, view.x, view.y)
 
-        var leftMark  = (viewX + VLCStyle.dp(20, VLCStyle.scale))
-        var rightMark = (viewX + view.width - VLCStyle.dp(20, VLCStyle.scale))
+        var margin = VLCStyle.dp(25, VLCStyle.scale)
+
+        var leftMark  = (viewPos.x + margin)
+        var rightMark = (viewPos.x + view.width - margin)
 
         scrollAnimation.target = view
         scrollAnimation.dragItem = dragItem
 
-        if (!view.atXBeginning && dragItemX <= leftMark) {
-            scrollAnimation.direction = -1
-        } else if (!view.atXEnd && dragItemX >= rightMark) {
-            scrollAnimation.direction = 1
-        } else {
+        if (!view.contains(view.mapFromItem(root, dragItemX, dragItem.y))) {
             scrollAnimation.direction = 0
+        } else {
+            if (!view.atXBeginning && dragItemX <= leftMark) {
+                scrollAnimation.direction = -1
+            } else if (!view.atXEnd && dragItemX >= rightMark) {
+                scrollAnimation.direction = 1
+            } else {
+                scrollAnimation.direction = 0
+            }
         }
     }
 
@@ -288,6 +315,11 @@ Rectangle{
         property var dragItem
         property int direction: 0 // -1: left, 0: stop, 1: right
 
+        onDirectionChanged: {
+            if (direction === 0)
+                stop()
+        }
+
         to: {
             if (direction === -1)
                 0


=====================================
modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorButtonList.qml
=====================================
@@ -26,18 +26,21 @@ import "qrc:///player/"
 import "qrc:///style/"
 import "qrc:///widgets/" as Widgets
 
-GridView{
-    id: allButtonsView
+GridView {
     clip: true
 
     ScrollBar.vertical: ScrollBar { policy: ScrollBar.AlwaysOn }
     model: PlayerControlbarControls.controlList.length
 
+    currentIndex: -1
     highlightFollowsCurrentItem: false
 
     cellWidth: VLCStyle.cover_small
     cellHeight: cellWidth
 
+    boundsBehavior: Flickable.StopAtBounds
+    boundsMovement: Flickable.StopAtBounds
+
     property alias removeInfoRectVisible: removeInfoRect.visible
 
     DropArea {
@@ -98,82 +101,88 @@ GridView{
         anchors.fill: parent
         z: 1
 
-        visible: root._held
+        visible: buttonDragItem.Drag.active
 
         cursorShape: visible ? Qt.DragMoveCursor : Qt.ArrowCursor
     }
 
     delegate: MouseArea {
-        id:dragArea
-        objectName: "buttonsList"
-        hoverEnabled: true
         width: cellWidth
         height: cellHeight
 
-        property bool held: false
-        property int mIndex: PlayerControlbarControls.controlList[model.index].id
-        drag.target: held ? buttonDragItem : undefined
+        hoverEnabled: true
         cursorShape: Qt.OpenHandCursor
 
-        onPressed: {
-            buttonDragItem.visible = true
-            buttonDragItem.text = PlayerControlbarControls.controlList[model.index].label
-            buttonDragItem.Drag.source = dragArea
-            held = true
-            root._held = true
+        objectName: "buttonsList"
 
-            dragArea.ListView.delayRemove = true
-        }
+        drag.target: buttonDragItem
 
-        onReleased: {
-            drag.target.Drag.drop()
-            buttonDragItem.visible = false
-            held = false
-            root._held = false
+        readonly property int mIndex: PlayerControlbarControls.controlList[model.index].id
 
-            dragArea.ListView.delayRemove = false
-        }
+        drag.onActiveChanged: {
+            if (drag.active) {
+                root.dragStarted(mIndex)
 
-        onPositionChanged: {
-            var pos = this.mapToGlobal(mouseX, mouseY)
-            buttonDragItem.updatePos(pos.x, pos.y)
-        }
+                buttonDragItem.text = PlayerControlbarControls.controlList[model.index].label
+                buttonDragItem.Drag.source = this
+                buttonDragItem.Drag.start()
 
-        onEntered: allButtonsView.currentIndex = index
+                GridView.delayRemove = true
+            } else {
+                buttonDragItem.Drag.drop()
 
-        Loader {
-            active: allButtonsView.currentIndex === index
-            anchors.fill: parent
+                root.dragStopped(mIndex)
+
+                GridView.delayRemove = false
+            }
+        }
 
-            sourceComponent: Rectangle {
-                color: VLCStyle.colors.bgHover
+        onPositionChanged: {
+            if (drag.active) {
+                // FIXME: There must be a better way of this
+
+                var pos = mapToItem(buttonDragItem.parent, mouseX, mouseY)
+                // y should be set first, because the automatic scroll is
+                // triggered by change on X
+                buttonDragItem.y = pos.y
+                buttonDragItem.x = pos.x
             }
         }
 
-        ColumnLayout{
-            id: listelemlayout
+        Rectangle {
             anchors.fill: parent
-            anchors.margins: 10
 
-            EditorDummyButton {
-                Layout.preferredWidth: VLCStyle.icon_medium
-                Layout.preferredHeight: VLCStyle.icon_medium
-                Layout.alignment: Qt.AlignHCenter
-                text: PlayerControlbarControls.controlList[model.index].label
-            }
+            implicitWidth: childrenRect.width
+            implicitHeight: childrenRect.height
+
+            color: "transparent"
+
+            border.width: VLCStyle.dp(1, VLCStyle.scale)
+            border.color: containsMouse && !buttonDragItem.Drag.active ? VLCStyle.colors.buttonBorder
+                                                                       : "transparent"
 
-            Widgets.ListSubtitleLabel {
-                id: buttonName
-                Layout.fillWidth: true
-                Layout.fillHeight: true
+            ColumnLayout {
+                anchors.fill: parent
+                anchors.margins: 10
 
-                elide: Text.ElideNone
-                text: PlayerControlbarControls.controlList[model.index].text
-                wrapMode: Text.WordWrap
-                horizontalAlignment: Text.AlignHCenter
+                EditorDummyButton {
+                    Layout.preferredWidth: VLCStyle.icon_medium
+                    Layout.preferredHeight: VLCStyle.icon_medium
+                    Layout.alignment: Qt.AlignHCenter
+
+                    text: PlayerControlbarControls.controlList[model.index].label
+                }
+
+                Widgets.ListSubtitleLabel {
+                    Layout.fillWidth: true
+                    Layout.fillHeight: true
+
+                    elide: Text.ElideNone
+                    text: PlayerControlbarControls.controlList[model.index].text
+                    wrapMode: Text.WordWrap
+                    horizontalAlignment: Text.AlignHCenter
+                }
             }
         }
     }
 }
-
-


=====================================
modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorDialog.qml
=====================================
@@ -27,9 +27,12 @@ import org.videolan.vlc 0.1
 WindowDialog {
     id: root
 
-    width: 800
+    width: minimumWidth
     height: 600
 
+    minimumWidth: 825
+    minimumHeight: 400
+
     modal: true
     title: i18n.qtr("Toolbar Editor")
 
@@ -56,6 +59,12 @@ WindowDialog {
     }
 
     contentComponent: Item {
+        MouseArea {
+            anchors.fill: parent
+
+            cursorShape: toolbarEditor.dragActive ? Qt.ForbiddenCursor : Qt.ArrowCursor
+        }
+
         ColumnLayout {
             anchors.fill: parent
 
@@ -68,6 +77,9 @@ WindowDialog {
 
                 Widgets.ComboBoxExt {
                     id: comboBox
+
+                    Layout.maximumWidth: (root.width / 2)
+
                     font.pixelSize: VLCStyle.fontSize_normal
 
                     width: VLCStyle.combobox_width_large


=====================================
modules/gui/qt/player/qml/ButtonsLayout.qml
=====================================
@@ -120,7 +120,7 @@ FocusScope {
                 }
 
                 onActiveFocusChanged: {
-                    if (activeFocus && !item.focus) {
+                    if (activeFocus && (!!item && !item.focus)) {
                         recoverFocus()
                     }
                 }


=====================================
modules/gui/qt/player/qml/controlbarcontrols/ArtworkInfoWidget.qml
=====================================
@@ -134,8 +134,8 @@ Control {
             anchors.verticalCenter: parent.verticalCenter
 
             readonly property real preferredWidth: Math.max(titleLabel.implicitWidth, artistLabel.implicitWidth, progressIndicator.implicitWidth)
-            width: ((extraWidth > preferredWidth) || (paintOnly)) ? preferredWidth
-                                                                  : extraWidth
+            width: ((extraWidth > preferredWidth)) ? preferredWidth
+                                                   : extraWidth
 
             visible: width > VLCStyle.dp(15, VLCStyle.scale)
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f261d474bc978875c68464b78b73cd41bd15a3c1...176241cf2cadc32f9fd74dff3015e6b2f84367a7

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f261d474bc978875c68464b78b73cd41bd15a3c1...176241cf2cadc32f9fd74dff3015e6b2f84367a7
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list