X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=homescreen%2Fqml%2FHome.qml;h=a312670341b2033307e7e9a95e38d54781d61d7f;hb=e412b716601f96466ca786784facb558e28e92e4;hp=aa3a129beff917639c924fd7bdea092800d5a8e7;hpb=226982d32f334189b4f465a720a297548a42c077;p=apps%2Fhomescreen.git 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) + } } } }