diff options
author | Jan-Simon Moeller <jsmoeller@linuxfoundation.org> | 2017-05-24 08:50:33 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@automotivelinux.org> | 2017-05-24 08:50:33 +0000 |
commit | fbdd80c3c6fd9b27ce1cbe21941baa8a643050fe (patch) | |
tree | 5e3eafbb1331c52b4606d99fb2ab731b4263dd0f /homescreen/qml/Home.qml | |
parent | 79e0139fb399b5af1342783ed6abb61aff6e28dd (diff) | |
parent | e412b716601f96466ca786784facb558e28e92e4 (diff) |
Merge "Add icon re-ordering support by hold and move"dab_3.99.1dab/3.99.13.99.1
Diffstat (limited to 'homescreen/qml/Home.qml')
-rw-r--r-- | homescreen/qml/Home.qml | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/homescreen/qml/Home.qml b/homescreen/qml/Home.qml index aa3a129..a312670 100644 --- a/homescreen/qml/Home.qml +++ b/homescreen/qml/Home.qml @@ -31,6 +31,7 @@ Item { property int pid: -1 GridView { + id: grid anchors.centerIn: parent width: cellHeight * 3 height: cellHeight * 3 @@ -38,28 +39,42 @@ Item { cellHeight: 320 interactive: false - model: ApplicationModel {} - delegate: MouseArea { - width: 320 - height: 320 - Image { - anchors.fill: parent - source: './images/HMI_AppLauncher_%1_%2-01.png'.arg(model.icon).arg(pressed ? 'Active' : 'Inactive') - } - onClicked: { - console.log("app is ", model.id) - pid = launcher.launch(model.id) - if (1 < pid) { - layoutHandler.makeMeVisible(pid) + model: ApplicationModel { id: applicationModel } + delegate: IconItem { + width: grid.cellWidth + height: grid.cellHeight + } - applicationArea.visible = true - appLauncherAreaLauncher.visible = false - layoutHandler.showAppLayer(pid) - } - else { - console.warn("app cannot be launched!") + MouseArea { + id: loc + anchors.fill: parent + property string currentId: '' + property int newIndex: -1 + property int index: grid.indexAt(loc.mouseX, loc.mouseY) + onPressAndHold: currentId = applicationModel.id(newIndex = index) + onReleased: { + if (currentId === '') { + pid = launcher.launch(applicationModel.id(loc.index)) + if (1 < pid) { + layoutHandler.makeMeVisible(pid) + + applicationArea.visible = true + appLauncherAreaLauncher.visible = false + layoutHandler.showAppLayer(pid) + } + else { + console.warn("app cannot be launched!") + } + } else { + currentId = '' } } + onPositionChanged: { + if (loc.currentId === '') return + if (index < 0) return + if (index === newIndex) return + applicationModel.move(newIndex, newIndex = index) + } } } } |