[vlc-commits] [Git][videolan/vlc][master] 3 commits: qml: remove root FocusScope from KeyNavigableListView

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Sun Jan 16 10:51:21 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
d9f33618 by Prince Gupta at 2022-01-16T10:37:37+00:00
qml: remove root FocusScope from KeyNavigableListView

underlying ListView is already a FocusScope, no need to wrap it in a FocusScope

- - - - -
cada7c8d by Prince Gupta at 2022-01-16T10:37:37+00:00
qml: remove modelCount property from KeyNavigableListView

directly use ListView.count property instead

- - - - -
59e81976 by Prince Gupta at 2022-01-16T10:37:37+00:00
qml/BannerSources: suppress Binding warning

- - - - -


3 changed files:

- modules/gui/qt/maininterface/qml/BannerSources.qml
- modules/gui/qt/widgets/qml/KeyNavigableListView.qml
- modules/gui/qt/widgets/qml/KeyNavigableTableView.qml


Changes:

=====================================
modules/gui/qt/maininterface/qml/BannerSources.qml
=====================================
@@ -62,10 +62,17 @@ FocusScope {
     }
 
     Binding {
-        target: !!contentModel ? contentModel : null
         property: "searchPattern"
         value: searchBox.searchPattern
         when: !!contentModel
+
+        Component.onCompleted: {
+            // restoreMode is only available in Qt >= 5.14
+            if ("restoreMode" in this)
+                this.restoreMode = Binding.RestoreBindingOrValue
+
+            target = Qt.binding(function() { return !!contentModel ? contentModel : null })
+        }
     }
 
     Widgets.AcrylicBackground {


=====================================
modules/gui/qt/widgets/qml/KeyNavigableListView.qml
=====================================
@@ -24,20 +24,16 @@ import org.videolan.vlc 0.1
 import "qrc:///style/"
 import "qrc:///util/" as Util
 import "qrc:///util/Helpers.js" as Helpers
-import "qrc:///util/" as Util
 
-FocusScope {
-    id: listview_id
+ListView {
+    id: root
 
     // Properties
 
-    property alias modelCount: view.count
-
-    property alias listView: view
-
-    property int fadeSize: view.delegateItem ? (orientation === Qt.Vertical ? view.delegateItem.height
-                                                                            : view.delegateItem.width) / 2
-                                             : (VLCStyle.margin_large * 2)
+    property int fadeSize: root.delegateItem
+                           ? (orientation === Qt.Vertical ? root.delegateItem.height
+                                                          : root.delegateItem.width) / 2
+                           : (VLCStyle.margin_large * 2)
 
     property var fadeColor: undefined // fading will only work when fade color is defined
 
@@ -48,53 +44,57 @@ FocusScope {
 
     property bool keyNavigationWraps : false
 
-    // Private
-
-    property int _currentFocusReason: Qt.OtherFocusReason
-
-    // Aliases
-
-    //forward view properties
-    property alias spacing: view.spacing
-    property alias interactive: view.interactive
-    property alias model: view.model
-    property alias delegate: view.delegate
-
-    property alias leftMargin: view.leftMargin
-    property alias rightMargin: view.rightMargin
-    property alias topMargin: view.topMargin
-    property alias bottomMargin: view.bottomMargin
-
-    property alias originX: view.originX
-    property alias originY: view.originY
-
-    property alias contentX: view.contentX
-    property alias contentY:  view.contentY
-    property alias contentHeight: view.contentHeight
-    property alias contentWidth: view.contentWidth
-
-    property alias footer: view.footer
-    property alias footerItem: view.footerItem
-    property alias header: view.header
-    property alias headerItem: view.headerItem
-    property alias headerPositioning: view.headerPositioning
+    // TODO: Use itemAtIndex(0) Qt >= 5.13
+    // FIXME: Delegate with variable size
+    readonly property Item delegateItem: root.contentItem.children.length > 0
+                                         ? root.contentItem.children[root.contentItem.children.length - 1]
+                                         : null
+
+    readonly property bool transitionsRunning: ((root.add ? root.add.running : false) ||
+                                                (root.addDisplaced ? root.addDisplaced.running : false) ||
+                                                (root.populate ? root.populate.running : false) ||
+                                                (root.remove ? root.remove.running : false) ||
+                                                (root.removeDisplaced ? root.removeDisplaced.running : false))
+
+    readonly property Item firstVisibleItem: {
+        if (transitionsRunning || !delegateItem)
+            null
+
+        var margin = -root.displayMarginBeginning
+        if (orientation === Qt.Vertical) {
+            if (headerItem && headerItem.visible && headerPositioning === ListView.OverlayHeader)
+                margin += headerItem.height
+
+            itemAt(contentX + (delegateItem.x + delegateItem.width / 2), contentY + margin)
+        } else {
+            if (headerItem && headerItem.visible && headerPositioning === ListView.OverlayHeader)
+                margin += headerItem.width
+
+            itemAt(contentX + margin, contentY + (delegateItem.y + delegateItem.height / 2))
+        }
+    }
 
-    property alias currentIndex: view.currentIndex
-    property alias currentItem: view.currentItem
+    readonly property Item lastVisibleItem: {
+        if (transitionsRunning || !delegateItem)
+            null
 
-    property alias highlightMoveVelocity: view.highlightMoveVelocity
+        var margin = -root.displayMarginEnd
+        if (orientation === Qt.Vertical) {
+            if (footerItem && footerItem.visible && footerPositioning === ListView.OverlayFooter)
+                margin += footerItem.height
 
-    property alias section: view.section
-    property alias currentSection: view.currentSection
-    property alias orientation: view.orientation
+            itemAt(contentX + (delegateItem.x + delegateItem.width / 2), contentY + height - margin - 1)
+        } else {
+            if (footerItem && footerItem.visible && footerPositioning === ListView.OverlayFooter)
+                margin += footerItem.width
 
-    property alias add: view.add
-    property alias displaced: view.displaced
+            itemAt(contentX + width - margin - 1, contentY + (delegateItem.y + delegateItem.height / 2))
+        }
+    }
 
-    property alias displayMarginBeginning: view.displayMarginBeginning
-    property alias displayMarginEnd: view.displayMarginEnd
+    // Aliases
 
-    property alias flickableDirection: view.flickableDirection
+    //forward view properties
     property alias listScrollBar: scroll_id
 
     property alias buttonLeft: buttonLeft
@@ -116,6 +116,14 @@ FocusScope {
 
     signal showContextMenu(point globalPos)
 
+    // Private
+
+    property int _currentFocusReason: Qt.OtherFocusReason
+
+    readonly property bool _fadeRectEnoughSize: (root.orientation === Qt.Vertical
+                                                 ? root.height
+                                                 : root.width) > (fadeSize * 2 + VLCStyle.dp(25))
+
     // Settings
 
     Accessible.role: Accessible.List
@@ -127,7 +135,7 @@ FocusScope {
             return;
 
         // NOTE: We make sure the view has active focus before enforcing it on the item.
-        if (view.activeFocus && currentItem)
+        if (root.activeFocus && currentItem)
             Helpers.enforceFocus(currentItem, _currentFocusReason);
 
         _currentFocusReason = Qt.OtherFocusReason;
@@ -138,7 +146,7 @@ FocusScope {
     function setCurrentItemFocus(reason) {
         if (!model || model.count === 0) {
             // NOTE: By default we want the focus on the flickable.
-            view.forceActiveFocus(reason);
+            root.forceActiveFocus(reason);
 
             // NOTE: Saving the focus reason for later.
             _currentFocusReason = reason;
@@ -155,21 +163,104 @@ FocusScope {
     }
 
     function nextPage() {
-        view.contentX += (Math.min(view.width, (view.contentWidth - view.width - view.contentX)))
+        root.contentX += (Math.min(root.width, (root.contentWidth - root.width - root.contentX)))
     }
+
     function prevPage() {
-        view.contentX -= Math.min(view.width,view.contentX - view.originX)
+        root.contentX -= Math.min(root.width,root.contentX - root.originX)
     }
 
-    function positionViewAtIndex(index, mode) {
-        view.positionViewAtIndex(index, mode)
-    }
+    focus: true
+
+    //key navigation is reimplemented for item selection
+    keyNavigationEnabled: false
+
+    ScrollBar.vertical: ScrollBar { id: scroll_id }
+    ScrollBar.horizontal: ScrollBar { visible: root.contentWidth > root.width }
+
+    highlightMoveDuration: 300 //ms
+    highlightMoveVelocity: 1000 //px/s
+
+    section.property: ""
+    section.criteria: ViewSection.FullString
+    section.delegate: sectionHeading
+
+    // NOTE: We always want a valid 'currentIndex' by default.
+    onCountChanged: if (count && currentIndex === -1) currentIndex = 0
+
+    Keys.onPressed: {
+        var newIndex = -1
+
+        if (orientation === ListView.Vertical)
+        {
+            if ( KeyHelper.matchDown(event) ) {
+                if (currentIndex !== count - 1 )
+                    newIndex = currentIndex + 1
+                else if ( root.keyNavigationWraps )
+                    newIndex = 0
+            } else if ( KeyHelper.matchPageDown(event) ) {
+                newIndex = Math.min(count - 1, currentIndex + 10)
+            } else if ( KeyHelper.matchUp(event) ) {
+                if ( currentIndex !== 0 )
+                    newIndex = currentIndex - 1
+                else if ( root.keyNavigationWraps )
+                    newIndex = count - 1
+            } else if ( KeyHelper.matchPageUp(event) ) {
+                newIndex = Math.max(0, currentIndex - 10)
+            }
+        }else{
+            if ( KeyHelper.matchRight(event) ) {
+                if (currentIndex !== count - 1 )
+                    newIndex = currentIndex + 1
+                else if ( root.keyNavigationWraps )
+                    newIndex = 0
+            }
+            else if ( KeyHelper.matchPageDown(event) ) {
+                newIndex = Math.min(count - 1, currentIndex + 10)
+            } else if ( KeyHelper.matchLeft(event) ) {
+                if ( currentIndex !== 0 )
+                    newIndex = currentIndex - 1
+                else if ( root.keyNavigationWraps )
+                    newIndex = count - 1
+            } else if ( KeyHelper.matchPageUp(event) ) {
+                newIndex = Math.max(0, currentIndex - 10)
+            }
+        }
+
+        if (KeyHelper.matchOk(event) || event.matches(StandardKey.SelectAll) ) {
+            //these events are matched on release
+            event.accepted = true
+        }
+
+        var oldIndex = currentIndex
+        if (newIndex >= 0 && newIndex < count && newIndex !== oldIndex) {
+            event.accepted = true;
+
+            currentIndex = newIndex;
+
+            selectionUpdated(event.modifiers, oldIndex, newIndex);
+
+            // NOTE: We make sure we have the proper visual focus on components.
+            if (oldIndex < currentIndex)
+                Helpers.enforceFocus(currentItem, Qt.TabFocusReason);
+            else
+                Helpers.enforceFocus(currentItem, Qt.BacktabFocusReason);
+        }
 
-    function itemAtIndex(index) {
-        return view.itemAtIndex(index)
+        if (!event.accepted) {
+            root.Navigation.defaultKeyAction(event)
+        }
     }
 
-    // Events
+    Keys.onReleased: {
+        if (event.matches(StandardKey.SelectAll)) {
+            event.accepted = true
+            selectAll()
+        } else if ( KeyHelper.matchOk(event) ) { //enter/return/space
+            event.accepted = true
+            actionAtIndex(currentIndex)
+        }
+    }
 
     Component {
         id: sectionHeading
@@ -191,342 +282,192 @@ FocusScope {
         }
     }
 
-    // Connections
-
-    // FIXME: This is probably not useful anymore.
-    Connections {
-        target: view.headerItem
-        onFocusChanged: {
-            if (!headerItem.focus) {
-                currentItem.focus = true
-            }
-        }
-    }
-
-    // Children
-
-    ListView {
-        id: view
-
-        anchors.fill: parent
-
-        focus: true
-
-        //key navigation is reimplemented for item selection
-        keyNavigationEnabled: false
-
-        ScrollBar.vertical: ScrollBar { id: scroll_id }
-        ScrollBar.horizontal: ScrollBar { visible: view.contentWidth > view.width }
-
-        highlightMoveDuration: 300 //ms
-        highlightMoveVelocity: 1000 //px/s
-
-        section.property: ""
-        section.criteria: ViewSection.FullString
-        section.delegate: sectionHeading
 
-        // TODO: Use itemAtIndex(0) Qt >= 5.13
-        // FIXME: Delegate with variable size
-        readonly property Item delegateItem: view.contentItem.children.length > 0 ? view.contentItem.children[view.contentItem.children.length - 1]
-                                                                                  : null
+    MouseEventFilter {
+        target: root
 
-        readonly property bool transitionsRunning: ((view.add ? view.add.running : false) ||
-                                                    (view.addDisplaced ? view.addDisplaced.running : false) ||
-                                                    (view.populate ? view.populate.running : false) ||
-                                                    (view.remove ? view.remove.running : false) ||
-                                                    (view.removeDisplaced ? view.removeDisplaced.running : false))
+        onMouseButtonPress: {
+            if (buttons & (Qt.LeftButton | Qt.RightButton)) {
+                Helpers.enforceFocus(root, Qt.MouseFocusReason)
 
-        readonly property Item firstVisibleItem: {
-            if (transitionsRunning || !delegateItem)
-                null
-
-            var margin = -listview_id.displayMarginBeginning
-            if (orientation === Qt.Vertical) {
-                if (headerItem && headerItem.visible && headerPositioning === ListView.OverlayHeader)
-                    margin += headerItem.height
-
-                itemAt(contentX + (delegateItem.x + delegateItem.width / 2), contentY + margin)
-            } else {
-                if (headerItem && headerItem.visible && headerPositioning === ListView.OverlayHeader)
-                    margin += headerItem.width
-
-                itemAt(contentX + margin, contentY + (delegateItem.y + delegateItem.height / 2))
+                if (!(modifiers & (Qt.ShiftModifier | Qt.ControlModifier))) {
+                    root.deselectAll()
+                }
             }
         }
 
-        readonly property Item lastVisibleItem: {
-            if (transitionsRunning || !delegateItem)
-                null
-
-            var margin = -listview_id.displayMarginEnd
-            if (orientation === Qt.Vertical) {
-                if (footerItem && footerItem.visible && footerPositioning === ListView.OverlayFooter)
-                    margin += footerItem.height
-
-                itemAt(contentX + (delegateItem.x + delegateItem.width / 2), contentY + height - margin - 1)
-            } else {
-                if (footerItem && footerItem.visible && footerPositioning === ListView.OverlayFooter)
-                    margin += footerItem.width
-
-                itemAt(contentX + width - margin - 1, contentY + (delegateItem.y + delegateItem.height / 2))
+        onMouseButtonRelease: {
+            if (button & Qt.RightButton) {
+                root.showContextMenu(globalPos)
             }
         }
+    }
 
-        MouseEventFilter {
-            target: view
+    Util.ViewDragAutoScrollHandler {
+        id: dragAutoScrollHandler
 
-            onMouseButtonPress: {
-                if (buttons & (Qt.LeftButton | Qt.RightButton)) {
-                    Helpers.enforceFocus(view, Qt.MouseFocusReason)
+        view: root
+    }
 
-                    if (!(modifiers & (Qt.ShiftModifier | Qt.ControlModifier))) {
-                        listview_id.deselectAll()
-                    }
-                }
-            }
+    Util.FlickableScrollHandler { }
 
-            onMouseButtonRelease: {
-                if (button & Qt.RightButton) {
-                    listview_id.showContextMenu(globalPos)
-                }
+    // FIXME: This is probably not useful anymore.
+    Connections {
+        target: root.headerItem
+        onFocusChanged: {
+            if (!headerItem.focus) {
+                currentItem.focus = true
             }
         }
+    }
 
-        Util.ViewDragAutoScrollHandler {
-            id: dragAutoScrollHandler
-
-            view: view
+    // TODO: Make fade rectangle inline component when Qt >= 5.15
+    LinearGradient {
+        id: fadeRectStart
+
+        anchors {
+            top: parent.top
+            left: parent.left
+            right: root.orientation === Qt.Vertical ? parent.right : undefined
+            bottom: root.orientation === Qt.Horizontal ? root.bottom : undefined
+            topMargin: root.orientation === Qt.Vertical ? ((root.headerItem &&
+                                                            root.headerItem.visible &&
+                                                            (root.headerPositioning === ListView.OverlayHeader)) ? root.headerItem.height
+                                                                                                                 : 0) - root.displayMarginBeginning
+                                                        : 0
+            leftMargin: root.orientation === Qt.Horizontal ? ((root.headerItem &&
+                                                               root.headerItem.visible &&
+                                                               (root.headerPositioning === ListView.OverlayHeader)) ? root.headerItem.width
+                                                                                                                    : 0) - root.displayMarginBeginning
+                                                           : 0
         }
 
-        // NOTE: We always want a valid 'currentIndex' by default.
-        onCountChanged: if (count && currentIndex === -1) currentIndex = 0
-
-        Util.FlickableScrollHandler { }
-
-        Keys.onPressed: {
-            var newIndex = -1
-
-            if (orientation === ListView.Vertical)
-            {
-                if ( KeyHelper.matchDown(event) ) {
-                    if (currentIndex !== modelCount - 1 )
-                        newIndex = currentIndex + 1
-                    else if ( listview_id.keyNavigationWraps )
-                        newIndex = 0
-                } else if ( KeyHelper.matchPageDown(event) ) {
-                    newIndex = Math.min(modelCount - 1, currentIndex + 10)
-                } else if ( KeyHelper.matchUp(event) ) {
-                    if ( currentIndex !== 0 )
-                        newIndex = currentIndex - 1
-                    else if ( listview_id.keyNavigationWraps )
-                        newIndex = modelCount - 1
-                } else if ( KeyHelper.matchPageUp(event) ) {
-                    newIndex = Math.max(0, currentIndex - 10)
-                }
-            }else{
-                if ( KeyHelper.matchRight(event) ) {
-                    if (currentIndex !== modelCount - 1 )
-                        newIndex = currentIndex + 1
-                    else if ( listview_id.keyNavigationWraps )
-                        newIndex = 0
-                }
-                else if ( KeyHelper.matchPageDown(event) ) {
-                    newIndex = Math.min(modelCount - 1, currentIndex + 10)
-                } else if ( KeyHelper.matchLeft(event) ) {
-                    if ( currentIndex !== 0 )
-                        newIndex = currentIndex - 1
-                    else if ( listview_id.keyNavigationWraps )
-                        newIndex = modelCount - 1
-                } else if ( KeyHelper.matchPageUp(event) ) {
-                    newIndex = Math.max(0, currentIndex - 10)
-                }
-            }
-
-            if (KeyHelper.matchOk(event) || event.matches(StandardKey.SelectAll) ) {
-                //these events are matched on release
-                event.accepted = true
+        implicitHeight: fadeSize
+        implicitWidth: fadeSize
+
+        visible: (opacity !== 0.0)
+        opacity: 0.0
+
+        readonly property bool requestShow: !root.firstVisibleItem ||
+                                            (!root.firstVisibleItem.activeFocus &&
+                                             // TODO: Qt >5.12 use HoverHandler within the fade:
+                                             !Helpers.get(root.firstVisibleItem, "hovered", false)) &&
+                                            (dragAutoScrollHandler.scrollingDirection !== Util.ViewDragAutoScrollHandler.Backward)
+
+        state: (!!root.fadeColor &&
+                root._fadeRectEnoughSize &&
+                requestShow &&
+                (orientation === ListView.Vertical ? !root.atYBeginning
+                                                   : !root.atXBeginning)) ? "shown"
+                                                                          : ""
+
+        states: State {
+            name: "shown"
+            PropertyChanges {
+                target: fadeRectStart
+                opacity: 1.0
             }
+        }
 
-            var oldIndex = currentIndex
-            if (newIndex >= 0 && newIndex < modelCount && newIndex !== oldIndex) {
-                event.accepted = true;
-
-                currentIndex = newIndex;
-
-                selectionUpdated(event.modifiers, oldIndex, newIndex);
+        transitions: Transition {
+            from: ""; to: "shown"
+            reversible: true
 
-                // NOTE: We make sure we have the proper visual focus on components.
-                if (oldIndex < currentIndex)
-                    Helpers.enforceFocus(currentItem, Qt.TabFocusReason);
-                else
-                    Helpers.enforceFocus(currentItem, Qt.BacktabFocusReason);
+            NumberAnimation {
+                property: "opacity"
+                duration: VLCStyle.duration_fast
+                easing.type: Easing.InOutSine
             }
+        }
+
+        start: Qt.point(0, 0)
 
-            if (!event.accepted) {
-                listview_id.Navigation.defaultKeyAction(event)
+        end: {
+            if (root.orientation === ListView.Vertical) {
+                return Qt.point(0, fadeRectStart.height)
+            } else {
+                return Qt.point(fadeRectStart.width, 0)
             }
         }
 
-        Keys.onReleased: {
-            if (event.matches(StandardKey.SelectAll)) {
-                event.accepted = true
-                selectAll()
-            } else if ( KeyHelper.matchOk(event) ) { //enter/return/space
-                event.accepted = true
-                actionAtIndex(currentIndex)
-            }
+        gradient: Gradient {
+            GradientStop { position: 0.0; color: !!fadeColor ? fadeColor : "transparent" }
+            GradientStop { position: 1.0; color: "transparent" }
         }
+    }
 
-        readonly property bool _fadeRectEnoughSize: (view.orientation === Qt.Vertical ? view.height : view.width) > (fadeSize * 2 + VLCStyle.dp(25))
-
-        // TODO: Make fade rectangle inline component when Qt >= 5.15
-        LinearGradient {
-            id: fadeRectStart
-
-            anchors {
-                top: parent.top
-                left: parent.left
-                right: view.orientation === Qt.Vertical ? parent.right : undefined
-                bottom: view.orientation === Qt.Horizontal ? view.bottom : undefined
-                topMargin: view.orientation === Qt.Vertical ? ((view.headerItem &&
-                                                                view.headerItem.visible &&
-                                                                (view.headerPositioning === ListView.OverlayHeader)) ? view.headerItem.height
-                                                                                                                     : 0) - listview_id.displayMarginBeginning
+    LinearGradient {
+        id: fadeRectEnd
+
+        anchors {
+            top: root.orientation === Qt.Horizontal ? parent.top : undefined
+            left: root.orientation === Qt.Vertical ? parent.left : undefined
+            right: parent.right
+            bottom: parent.bottom
+
+            bottomMargin: root.orientation === Qt.Vertical ? ((root.footerItem &&
+                                                               root.footerItem.visible &&
+                                                               (root.footerPositioning === ListView.OverlayFooter)) ? root.footerItem.height
+                                                                                                                    : 0) - root.displayMarginEnd
+                                                           : 0
+            rightMargin: root.orientation === Qt.Horizontal ? ((root.footerItem &&
+                                                                root.footerItem.visible &&
+                                                                (root.headerPositioning === ListView.OverlayFooter)) ? root.footerItem.width
+                                                                                                                     : 0) - root.displayMarginEnd
                                                             : 0
-                leftMargin: view.orientation === Qt.Horizontal ? ((view.headerItem &&
-                                                                   view.headerItem.visible &&
-                                                                   (view.headerPositioning === ListView.OverlayHeader)) ? view.headerItem.width
-                                                                                                                        : 0) - listview_id.displayMarginBeginning
-                                                               : 0
-            }
-
-            implicitHeight: fadeSize
-            implicitWidth: fadeSize
-
-            visible: (opacity !== 0.0)
-            opacity: 0.0
-
-            readonly property bool requestShow: !view.firstVisibleItem ||
-                                                (!view.firstVisibleItem.activeFocus &&
-                                                 // TODO: Qt >5.12 use HoverHandler within the fade:
-                                                 !Helpers.get(view.firstVisibleItem, "hovered", false)) &&
-                                                (dragAutoScrollHandler.scrollingDirection !== Util.ViewDragAutoScrollHandler.Backward)
-
-            state: (!!listview_id.fadeColor &&
-                    view._fadeRectEnoughSize &&
-                    requestShow &&
-                    (orientation === ListView.Vertical ? !view.atYBeginning
-                                                       : !view.atXBeginning)) ? "shown"
-                                                                              : ""
-
-            states: State {
-                name: "shown"
-                PropertyChanges {
-                    target: fadeRectStart
-                    opacity: 1.0
-                }
-            }
-
-            transitions: Transition {
-                from: ""; to: "shown"
-                reversible: true
-
-                NumberAnimation {
-                    property: "opacity"
-                    duration: VLCStyle.duration_fast
-                    easing.type: Easing.InOutSine
-                }
-            }
-
-            start: Qt.point(0, 0)
-
-            end: {
-                if (view.orientation === ListView.Vertical) {
-                    return Qt.point(0, fadeRectStart.height)
-                } else {
-                    return Qt.point(fadeRectStart.width, 0)
-                }
-            }
-
-            gradient: Gradient {
-                GradientStop { position: 0.0; color: !!fadeColor ? fadeColor : "transparent" }
-                GradientStop { position: 1.0; color: "transparent" }
-            }
         }
 
-        LinearGradient {
-            id: fadeRectEnd
-
-            anchors {
-                top: view.orientation === Qt.Horizontal ? parent.top : undefined
-                left: view.orientation === Qt.Vertical ? parent.left : undefined
-                right: parent.right
-                bottom: parent.bottom
-
-                bottomMargin: view.orientation === Qt.Vertical ? ((view.footerItem &&
-                                                                   view.footerItem.visible &&
-                                                                   (view.footerPositioning === ListView.OverlayFooter)) ? view.footerItem.height
-                                                                                                                        : 0) - listview_id.displayMarginEnd
-                                                               : 0
-                rightMargin: view.orientation === Qt.Horizontal ? ((view.footerItem &&
-                                                                    view.footerItem.visible &&
-                                                                    (view.headerPositioning === ListView.OverlayFooter)) ? view.footerItem.width
-                                                                                                                         : 0) - listview_id.displayMarginEnd
-                                                                : 0
-            }
-
-            implicitHeight: fadeSize
-            implicitWidth: fadeSize
-
-            visible: opacity !== 0.0
-            opacity: 0.0
-
-            readonly property bool requestShow: !view.lastVisibleItem ||
-                                                (!view.lastVisibleItem.activeFocus &&
-                                                 // TODO: Qt >5.12 use HoverHandler within the fade:
-                                                 !Helpers.get(view.lastVisibleItem, "hovered", false)) &&
-                                                (dragAutoScrollHandler.scrollingDirection !== Util.ViewDragAutoScrollHandler.Forward)
-
-            state: (!!listview_id.fadeColor &&
-                    view._fadeRectEnoughSize &&
-                    requestShow &&
-                    (orientation === ListView.Vertical ? !view.atYEnd
-                                                       : !view.atXEnd)) ? "shown"
-                                                                        : ""
-
-            states: State {
-                name: "shown"
-                PropertyChanges {
-                    target: fadeRectEnd
-                    opacity: 1.0
-                }
+        implicitHeight: fadeSize
+        implicitWidth: fadeSize
+
+        visible: opacity !== 0.0
+        opacity: 0.0
+
+        readonly property bool requestShow: !root.lastVisibleItem ||
+                                            (!root.lastVisibleItem.activeFocus &&
+                                             // TODO: Qt >5.12 use HoverHandler within the fade:
+                                             !Helpers.get(root.lastVisibleItem, "hovered", false)) &&
+                                            (dragAutoScrollHandler.scrollingDirection !== Util.ViewDragAutoScrollHandler.Forward)
+
+        state: (!!root.fadeColor &&
+                root._fadeRectEnoughSize &&
+                requestShow &&
+                (orientation === ListView.Vertical ? !root.atYEnd
+                                                   : !root.atXEnd)) ? "shown"
+                                                                    : ""
+
+        states: State {
+            name: "shown"
+            PropertyChanges {
+                target: fadeRectEnd
+                opacity: 1.0
             }
+        }
 
-            transitions: Transition {
-                from: ""; to: "shown"
-                reversible: true
+        transitions: Transition {
+            from: ""; to: "shown"
+            reversible: true
 
-                NumberAnimation {
-                    property: "opacity"
-                    duration: VLCStyle.duration_fast
-                    easing.type: Easing.InOutSine
-                }
+            NumberAnimation {
+                property: "opacity"
+                duration: VLCStyle.duration_fast
+                easing.type: Easing.InOutSine
             }
+        }
 
-            start: Qt.point(0, 0)
+        start: Qt.point(0, 0)
 
-            end: {
-                if (view.orientation === ListView.Vertical) {
-                    return Qt.point(0, fadeRectEnd.height)
-                } else {
-                    return Qt.point(fadeRectEnd.width, 0)
-                }
+        end: {
+            if (root.orientation === ListView.Vertical) {
+                return Qt.point(0, fadeRectEnd.height)
+            } else {
+                return Qt.point(fadeRectEnd.width, 0)
             }
+        }
 
-            gradient: Gradient {
-                GradientStop { position: 0.0; color: "transparent" }
-                GradientStop { position: 1.0; color: !!fadeColor ? fadeColor : "transparent" }
-            }
+        gradient: Gradient {
+            GradientStop { position: 0.0; color: "transparent" }
+            GradientStop { position: 1.0; color: !!fadeColor ? fadeColor : "transparent" }
         }
     }
 
@@ -543,9 +484,9 @@ FocusScope {
 
         text: '<'
 
-        visible: (view.orientation === ListView.Horizontal && !(view.atXBeginning))
+        visible: (root.orientation === ListView.Horizontal && !(root.atXBeginning))
 
-        onClicked: listview_id.prevPage()
+        onClicked: root.prevPage()
     }
 
     RoundButton {
@@ -556,8 +497,8 @@ FocusScope {
 
         text: '>'
 
-        visible: (view.orientation === ListView.Horizontal && !(view.atXEnd))
+        visible: (root.orientation === ListView.Horizontal && !(root.atXEnd))
 
-        onClicked: listview_id.nextPage()
+        onClicked: root.nextPage()
     }
 }


=====================================
modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
=====================================
@@ -103,7 +103,7 @@ FocusScope {
     property alias displaced: view.displaced
 
     property alias listScrollBar: view.listScrollBar
-    property alias listView: view.listView
+    property alias listView: view
 
     property alias displayMarginEnd: view.displayMarginEnd
 
@@ -139,7 +139,7 @@ FocusScope {
      * selectedGroup update itself after this event
      */
     onActiveFocusChanged: {
-        if (activeFocus == false || view.modelCount == 0)
+        if (activeFocus == false || view.count == 0)
             return;
 
         if (view.currentIndex == -1)
@@ -163,7 +163,7 @@ FocusScope {
     }
 
     function positionViewAtBeginning() {
-        view.listView.positionViewAtBeginning()
+        view.positionViewAtBeginning()
     }
 
     function _qtAvoidSectionUpdate() {
@@ -255,7 +255,7 @@ FocusScope {
             width: Math.max(view.width, root.usedRowSpace + root.sectionWidth)
             height: col.height
             color: headerColor
-            visible: view.modelCount > 0
+            visible: view.count > 0
             z: 3
 
             // with inline header positioning and for `root.header` which changes it's height after loading,



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2480a5159fd80916084777b78bbab59f6c6e789b...59e819767a85fe01e69de14d3ba1e0b25f4ef159

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2480a5159fd80916084777b78bbab59f6c6e789b...59e819767a85fe01e69de14d3ba1e0b25f4ef159
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list