From b614d03be54e51b1dea80cc27ed34f09e8960146 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Thu, 10 Dec 2015 09:42:07 +0200 Subject: Change ListView to PathView Needed for infinite loop when Scrolling the demos Task-Id: QTRD-3788 Change-Id: I798f27bc01b167794c83781b788ba4595f032132 Reviewed-by: Kalle Viironen --- qml/ApplicationIcon.qml | 11 ++++----- qml/LaunchScreen.qml | 61 ++++++++++++------------------------------------- 2 files changed, 20 insertions(+), 52 deletions(-) diff --git a/qml/ApplicationIcon.qml b/qml/ApplicationIcon.qml index 1b9431e..189268f 100644 --- a/qml/ApplicationIcon.qml +++ b/qml/ApplicationIcon.qml @@ -23,8 +23,8 @@ Item { property real offset; - property real x1: (x - offset) / ListView.view.width * Math.PI; - property real x2: (x + width - offset) / ListView.view.width * Math.PI; + property real x1: (x - offset) / PathView.view.width * Math.PI; + property real x2: (x + width - offset) / PathView.view.width * Math.PI; property real shift: Math.min(height, width) * 0.05 signal clicked; @@ -49,9 +49,9 @@ Item { property real x2: appIcon.x2 - appIcon.x1; property real shift: appIcon.shift; - property real selection: appIcon.ListView.isCurrentItem ? 1.1 + 0.3 * Math.sin(_t) : 1; + property real selection: appIcon.PathView.isCurrentItem ? 1.1 + 0.3 * Math.sin(_t) : 1; property real _t; - NumberAnimation on _t { from: 0; to: 2 * Math.PI; duration: 3000; loops: Animation.Infinite; running: appIcon.ListView.isCurrentItem && shader.visible } + NumberAnimation on _t { from: 0; to: 2 * Math.PI; duration: 3000; loops: Animation.Infinite; running: appIcon.PathView.isCurrentItem && shader.visible } mesh: "5x2" blending: false @@ -87,12 +87,11 @@ Item { } " } - MouseArea { id: mouse anchors.fill: parent onClicked: { - if (appIcon.ListView.isCurrentItem) { + if (appIcon.PathView.isCurrentItem) { engine.launchApplication(location, mainFile, name) } else { appIcon.clicked(); diff --git a/qml/LaunchScreen.qml b/qml/LaunchScreen.qml index 66b50bf..096914b 100644 --- a/qml/LaunchScreen.qml +++ b/qml/LaunchScreen.qml @@ -24,58 +24,42 @@ Item { property real size: Math.min(root.width, root.height); property int itemsPerScreen: 2 - ListView { + PathView { id: list y: 10 width: parent.width height: parent.height - property real cellWidth: (list.width - (root.itemsPerScreen - 1) * list.spacing) / root.itemsPerScreen + property real cellWidth: (list.width - (root.itemsPerScreen - 1) /** list.spacing*/) / root.itemsPerScreen property real cellHeight: (list.height / root.itemsPerScreen) - cacheBuffer: count * (cellWidth + spacing) - orientation: ListView.Horizontal - maximumFlickVelocity: 5000 + pathItemCount: list.count model: applicationsModel; + preferredHighlightBegin: 1/(list.count/2) + preferredHighlightEnd: 1 + currentIndex: -1 - spacing: 10 + path: Path { + startX:-list.cellWidth; startY: list.y + list.cellHeight/2 + PathLine{x: list.cellWidth*list.count - list.cellWidth; y: list.y + list.cellHeight/2} + } - leftMargin: width / 2 - cellWidth / 2 - rightMargin: width / 2 - cellWidth / 2 + highlightMoveDuration: 700 - highlight: Rectangle { color: "red" } - highlightFollowsCurrentItem: false - highlightMoveDuration: 10 delegate: ApplicationIcon { id: iconRoot; width: list.cellWidth height: list.cellHeight - - offset: list.contentX; - function select() { - list.targetContentX = iconRoot.x - (list.width / 2 - list.cellWidth / 2); - list.targetIndex = index; - if (Math.abs(list.targetContentX - list.contentX) < 50) { - moveAnimation.duration = 50 - } else { - moveAnimation.duration = 500 - } - animateToCenter.running = true; + list.currentIndex = index; } - onClicked: select() - } - - property int targetIndex; - property real targetContentX: 0 - SequentialAnimation { - id: animateToCenter; - NumberAnimation { id: moveAnimation; target: list; property: "contentX"; to: list.targetContentX; duration: 300; easing.type: Easing.InOutCubic } - PropertyAction { target: list; property: "currentIndex"; value: list.targetIndex } + onClicked: { + select() + } } onCurrentIndexChanged: { @@ -88,22 +72,7 @@ Item { } } - onMovementEnded: { - var hCenter = mapToItem(contentItem, width / 2, engine.centimeter()) - var demo = itemAt(hCenter.x, hCenter.y) - if (demo) - demo.select() - } - onCountChanged: if (count > 0 && currentIndex < 0) currentIndex = 0 - - MouseArea { - anchors.fill: parent - onPressed: { - animateToCenter.stop() - mouse.accepted = false - } - } } Text { -- cgit v1.2.3