From: José Bollo Date: Wed, 26 Jul 2017 08:43:59 +0000 (+0200) Subject: Revert "Add icon re-ordering support by hold and move" X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=6b9e7a984825b05049713ba0aa62dcb6560277f0;p=apps%2Fhomescreen.git Revert "Add icon re-ordering support by hold and move" This reverts commit e412b716601f96466ca786784facb558e28e92e4. Change-Id: I46789eaa70e1fcbb1cfc153f3a5113a5f3131e59 --- diff --git a/homescreen/qml/Home.qml b/homescreen/qml/Home.qml index de8b9bb..aa3a129 100644 --- a/homescreen/qml/Home.qml +++ b/homescreen/qml/Home.qml @@ -31,7 +31,6 @@ Item { property int pid: -1 GridView { - id: grid anchors.centerIn: parent width: cellHeight * 3 height: cellHeight * 3 @@ -39,41 +38,27 @@ Item { cellHeight: 320 interactive: false - model: ApplicationModel { id: applicationModel } - delegate: IconItem { - width: grid.cellWidth - height: grid.cellHeight - } - - 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) + 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) - applicationArea.visible = true - appLauncherAreaLauncher.visible = false - layoutHandler.showAppLayer(applicationModel.id(loc.index), pid) - } - else { - console.warn("app cannot be launched!") - } - } else { - currentId = '' + applicationArea.visible = true + appLauncherAreaLauncher.visible = false + layoutHandler.showAppLayer(pid) + } + else { + console.warn("app cannot be launched!") } - } - onPositionChanged: { - if (loc.currentId === '') return - if (index < 0) return - if (index === newIndex) return - applicationModel.move(newIndex, newIndex = index) } } } diff --git a/homescreen/qml/IconItem.qml b/homescreen/qml/IconItem.qml deleted file mode 100644 index 59131c0..0000000 --- a/homescreen/qml/IconItem.qml +++ /dev/null @@ -1,37 +0,0 @@ -import QtQuick 2.0 - -Item { - id: main - Image { - id: item; parent: loc - x: main.x + 5; y: main.y + 5 - width: main.width - 10; height: main.height - 10; - source: './images/HMI_AppLauncher_%1_%2-01.png'.arg(model.icon).arg(loc.pressed && (loc.index === model.index || loc.currentId === model.id) ? 'Active' : 'Inactive') - antialiasing: item.state !== '' - Behavior on x { enabled: item.state !== 'active'; NumberAnimation { duration: 400; easing.type: Easing.OutCubic } } - Behavior on y { enabled: item.state !== 'active'; NumberAnimation { duration: 400; easing.type: Easing.OutCubic } } - SequentialAnimation on rotation { - NumberAnimation { to: 5; duration: 100 } - NumberAnimation { to: -5; duration: 200 } - NumberAnimation { to: 0; duration: 100 } - running: loc.currentId !== '' && item.state !== 'active' - loops: Animation.Infinite; alwaysRunToEnd: true - } - states: [ - State { - name: 'active' - when: loc.currentId == model.id - PropertyChanges { target: item; x: loc.mouseX - width/2; y: loc.mouseY - height/2; scale: 1.15; z: 10 } - }, - State { - when: loc.currentId !== '' - PropertyChanges { - target: item - scale: 0.85 - opacity: 0.75 - } - } - ] - transitions: Transition { NumberAnimation { properties: 'scale, opacity, x, y'; duration: 150; easing.type: Easing.OutCubic} } - } -} diff --git a/homescreen/qml/qml.qrc b/homescreen/qml/qml.qrc index c25e266..3d699e0 100644 --- a/homescreen/qml/qml.qrc +++ b/homescreen/qml/qml.qrc @@ -10,6 +10,5 @@ ShortcutIcon.qml StatusArea.qml TopArea.qml - IconItem.qml diff --git a/homescreen/src/applicationmodel.cpp b/homescreen/src/applicationmodel.cpp index 417bc4c..c43e1bc 100644 --- a/homescreen/src/applicationmodel.cpp +++ b/homescreen/src/applicationmodel.cpp @@ -114,31 +114,3 @@ QHash ApplicationModel::roleNames() const roles[Qt::UserRole] = "id"; return roles; } - -QString ApplicationModel::id(int i) const -{ - return data(index(i), Qt::UserRole).toString(); -} - -void ApplicationModel::move(int from, int to) -{ - QModelIndex parent; - if (to < 0 || to > rowCount()) return; - if (from < to) { - if (!beginMoveRows(parent, from, from, parent, to + 1)) { - qDebug() << from << to << false; - return; - } - d->data.move(from, to); - endMoveRows(); - } else if (from > to) { - if (!beginMoveRows(parent, from, from, parent, to)) { - qDebug() << from << to << false; - return; - } - d->data.move(from, to); - endMoveRows(); - } else { - qDebug() << from << to << false; - } -} diff --git a/homescreen/src/applicationmodel.h b/homescreen/src/applicationmodel.h index 2414b7e..bffc4c9 100644 --- a/homescreen/src/applicationmodel.h +++ b/homescreen/src/applicationmodel.h @@ -30,8 +30,6 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QHash roleNames() const override; - Q_INVOKABLE QString id(int index) const; - Q_INVOKABLE void move(int from, int to); private: class Private;