From 39de6fae412ddb327d7ba0c3545a2445e94fbd9e Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Mon, 20 May 2019 16:16:18 +0900 Subject: add als2019 source code --- launcher/launcher.pro | 7 +- launcher/qml/Launcher.qml | 199 +++++-- launcher/qml/TopShortcutArea.qml | 57 ++ launcher/qml/TopShortcutIcon.qml | 69 +++ launcher/qml/UninstallDialog.qml | 158 ++++++ launcher/qml/images/DividingLine.svg | 62 +++ launcher/qml/images/TopShortcut/hvac.svg | 600 ++++++++++++++++++++ launcher/qml/images/TopShortcut/hvac_active.svg | 614 +++++++++++++++++++++ launcher/qml/images/TopShortcut/launcher.svg | 73 +++ .../qml/images/TopShortcut/launcher_active.svg | 82 +++ launcher/qml/images/TopShortcut/mediaplayer.svg | 50 ++ .../qml/images/TopShortcut/mediaplayer_active.svg | 63 +++ launcher/qml/images/TopShortcut/navigation.svg | 77 +++ .../qml/images/TopShortcut/navigation_active.svg | 90 +++ launcher/qml/images/TopShortcut/sdl_usb.svg | 311 +++++++++++ launcher/qml/images/TopShortcut/sdl_usb_active.svg | 278 ++++++++++ launcher/qml/images/TopShortcut/topshortcut.qrc | 16 + launcher/qml/images/TopShortcut/video.svg | 109 ++++ launcher/qml/images/TopShortcut/video_active.svg | 126 +++++ launcher/qml/images/background.png | Bin 0 -> 828668 bytes launcher/qml/images/browser_active.svg | 231 ++++++++ launcher/qml/images/browser_inactive.svg | 165 ++++++ launcher/qml/images/hud.png | Bin 0 -> 6277 bytes launcher/qml/images/images.qrc | 11 + launcher/qml/images/meterdisplay.png | Bin 0 -> 7545 bytes launcher/qml/images/rse.png | Bin 0 -> 10640 bytes launcher/qml/images/sdl_active.svg | 140 +++++ launcher/qml/images/sdl_inactive.svg | 83 +++ .../qml/images/top_three_shortcut_background.png | Bin 0 -> 1452 bytes launcher/qml/images/uninstall.png | Bin 0 -> 1357 bytes launcher/qml/qml.qrc | 3 + launcher/src/applicationmodel.cpp | 3 +- launcher/src/homescreenhandler.cpp | 52 ++ launcher/src/homescreenhandler.h | 4 + launcher/src/main.cpp | 4 + launcher/src/shortcutappmodel.cpp | 187 +++++++ launcher/src/shortcutappmodel.h | 52 ++ 37 files changed, 3918 insertions(+), 58 deletions(-) create mode 100644 launcher/qml/TopShortcutArea.qml create mode 100644 launcher/qml/TopShortcutIcon.qml create mode 100644 launcher/qml/UninstallDialog.qml create mode 100644 launcher/qml/images/DividingLine.svg create mode 100644 launcher/qml/images/TopShortcut/hvac.svg create mode 100644 launcher/qml/images/TopShortcut/hvac_active.svg create mode 100644 launcher/qml/images/TopShortcut/launcher.svg create mode 100644 launcher/qml/images/TopShortcut/launcher_active.svg create mode 100644 launcher/qml/images/TopShortcut/mediaplayer.svg create mode 100644 launcher/qml/images/TopShortcut/mediaplayer_active.svg create mode 100644 launcher/qml/images/TopShortcut/navigation.svg create mode 100644 launcher/qml/images/TopShortcut/navigation_active.svg create mode 100644 launcher/qml/images/TopShortcut/sdl_usb.svg create mode 100644 launcher/qml/images/TopShortcut/sdl_usb_active.svg create mode 100644 launcher/qml/images/TopShortcut/topshortcut.qrc create mode 100644 launcher/qml/images/TopShortcut/video.svg create mode 100644 launcher/qml/images/TopShortcut/video_active.svg create mode 100644 launcher/qml/images/background.png create mode 100644 launcher/qml/images/browser_active.svg create mode 100644 launcher/qml/images/browser_inactive.svg create mode 100644 launcher/qml/images/hud.png create mode 100644 launcher/qml/images/meterdisplay.png create mode 100644 launcher/qml/images/rse.png create mode 100644 launcher/qml/images/sdl_active.svg create mode 100644 launcher/qml/images/sdl_inactive.svg create mode 100644 launcher/qml/images/top_three_shortcut_background.png create mode 100644 launcher/qml/images/uninstall.png create mode 100644 launcher/src/shortcutappmodel.cpp create mode 100644 launcher/src/shortcutappmodel.h diff --git a/launcher/launcher.pro b/launcher/launcher.pro index e16e9ce..03c7d5d 100644 --- a/launcher/launcher.pro +++ b/launcher/launcher.pro @@ -27,17 +27,20 @@ SOURCES += \ src/applicationmodel.cpp \ src/appinfo.cpp \ src/applicationlauncher.cpp \ - src/homescreenhandler.cpp + src/homescreenhandler.cpp \ + src/shortcutappmodel.cpp HEADERS += \ src/applicationlauncher.h \ src/applicationmodel.h \ src/appinfo.h \ - src/homescreenhandler.h + src/homescreenhandler.h \ + src/shortcutappmodel.h OTHER_FILES += \ README.md RESOURCES += \ + qml/images/TopShortcut/topshortcut.qrc \ qml/images/images.qrc \ qml/qml.qrc diff --git a/launcher/qml/Launcher.qml b/launcher/qml/Launcher.qml index 2247f51..c7060fe 100644 --- a/launcher/qml/Launcher.qml +++ b/launcher/qml/Launcher.qml @@ -30,76 +30,167 @@ ApplicationWindow { id: container anchors.centerIn: parent width: 1080 - height: 1488 + height: 1920 scale: screenInfo.scale_factor() Image { - anchors.centerIn: parent - source: './images/AGL_HMI_Blue_Background_Car-01.png' + id: topshortcutArea + x: 197 + y: 0 + width: 588 + height: 215 + source: './images/top_three_shortcut_background.png' + TopShortcutArea { + anchors.fill: parent + } } - GridView { - id: grid - anchors { - topMargin: 60; bottomMargin: 0 - leftMargin: 60; rightMargin: 60 - fill: parent + Image { + id: meterDisplay + x: 0 + y: 1704 + width: 270 + height: 215 + source: './images/meterdisplay.png' + } + Image { + id: hud + anchors.left: meterDisplay.right + anchors.top: meterDisplay.top + width: 270 + height: 215 + source: './images/hud.png' + } + Image { + id: rse + anchors.left: hud.right + anchors.top: hud.top + width: 270 + height: 215 + source: './images/rse.png' + } + Image { + id: uninstall + anchors.left: rse.right + anchors.top: rse.top + width: 270 + height: 215 + source: './images/uninstall.png' } - contentHeight: 320 - flickableDirection: Flickable.AutoFlickDirection - snapMode: GridView.SnapOneRow - visible: true - cellWidth: 320 - cellHeight: 320 - interactive: false - model: ApplicationModel { id: applicationModel } - delegate: IconItem { - width: grid.cellWidth - height: grid.cellHeight + Image { + anchors.fill: parent + source: './images/background.png' } - Connections { - target: homescreenHandler - onAppListUpdate: { - console.warn("applist update in Launcher.qml") - applicationModel.updateApplist(info); + GridView { + id: grid + anchors { + topMargin: 60 + 218; bottomMargin: 0 + leftMargin: 60; rightMargin: 60 + fill: parent } - } - Connections { - target: homescreenHandler - onInitAppList: { - console.warn("applist init in Launcher.qml") - applicationModel.initAppList(data); + contentHeight: 320 + flickableDirection: Flickable.AutoFlickDirection + snapMode: GridView.SnapOneRow + visible: true + cellWidth: 320 + 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) - x: 62 - y: 264 - onPressAndHold: currentId = applicationModel.id(newIndex = index) - onReleased: { - if(loc.index < 0) { - return + Connections { + target: homescreenHandler + onAppListUpdate: { + console.warn("applist update in Launcher.qml") + applicationModel.updateApplist(info); } - if (currentId === '') { - homescreenHandler.tapShortcut(applicationModel.appid(loc.index)) - } else { - currentId = '' + } + Connections { + target: homescreenHandler + onInitAppList: { + console.warn("applist init in Launcher.qml") + applicationModel.initAppList(data); } } - onPositionChanged: { - if (loc.currentId === '') return - if (index < 0) return - if (index === newIndex) return - applicationModel.move(newIndex, newIndex = index) + + MouseArea { + id: loc + anchors.fill: parent + property string currentId: '' + property string currentName: '' + property int oldIndex: -1 + property int newIndex: -1 + property int index: grid.indexAt(loc.mouseX, loc.mouseY) + x: 62 + y: 264 + + onPressAndHold: { + oldIndex = index + currentId = applicationModel.id(newIndex = index) + currentName = applicationModel.name(loc.index) + homescreenHandler.hideWindow("homescreen") + } + onReleased: { + if (currentId === '' && loc.index >= 0 ) { + // Not long press, exec application and tapshortcut + pid = launcher.launch(applicationModel.id(loc.index)) + if (1 < pid) { + homescreenHandler.tapShortcut(applicationModel.appid(loc.index)) + } + else { + console.warn("app cannot be launched!") + } + } else if (loc.mouseY <= 0) { + if (loc.mouseX >= 197 && loc.mouseX < 393) { + shortcutAppModel.changeShortcut(currentId, currentName, "0"); + homescreenHandler.registerShortcut(currentId, currentName, "0"); + } else if (loc.mouseX >= 393 && loc.mouseX < 589) { + shortcutAppModel.changeShortcut(currentId, currentName, "1"); + homescreenHandler.registerShortcut(currentId, currentName, "1"); + } else if (loc.mouseX >= 589 && loc.mouseX < 785) { + shortcutAppModel.changeShortcut(currentId, currentName, "2"); + homescreenHandler.registerShortcut(currentId, currentName, "2"); + } + if (oldIndex != newIndex){ + applicationModel.move(newIndex, newIndex = oldIndex) + } + } else if (loc.mouseY >= 1488) { + if (loc.mouseX < 270 ) { + console.log("sendAppToMeter", currentId) + homescreenHandler.sendAppToMeter(currentId) + } else if (loc.mouseX >= 270 && loc.mouseX < 540 ) { + + } else if (loc.mouseX >= 540 && loc.mouseX < 810 ) { + + } else if (loc.mouseX >= 810) { + uninstallDialog.contents = 'Do you want to uninstall ' + currentName.toUpperCase() + '?' + uninstallDialog.uninstallApp = currentId + uninstallDialog.visible = true + } + } + + currentName = '' + currentId = '' + homescreenHandler.tapShortcut("homescreen") + } + onPositionChanged: { + if (loc.currentId === '') return + if (index < 0) return + if (index === newIndex) return + applicationModel.move(newIndex, newIndex = index) + } } } + UninstallDialog { + id: uninstallDialog + anchors.fill: parent + visible: false + } } } -} diff --git a/launcher/qml/TopShortcutArea.qml b/launcher/qml/TopShortcutArea.qml new file mode 100644 index 0000000..0e45bb6 --- /dev/null +++ b/launcher/qml/TopShortcutArea.qml @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import QtQuick 2.2 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.1 + +Item { + id: root + width: 588 + height: 218 + + property int pid: -1 + + RowLayout { + anchors.fill: parent + spacing: 2 + Repeater { + id: repeater + model: shortcutAppModel + delegate: TopShortcutIcon { + Layout.fillWidth: true + Layout.fillHeight: true + name: shortcutAppModel.getName(model.index) + icon: shortcutAppModel.getIcon(model.index) + isBlank: shortcutAppModel.isBlank(model.index) + } + } + } + + Connections { + target: shortcutAppModel + onUpdateShortcut: { + for(var i = 0; i < 3; i++) { + var item = repeater.itemAt(i) + item.name = shortcutAppModel.getName(i) + item.icon = shortcutAppModel.getIcon(i) + item.isBlank = shortcutAppModel.isBlank(i) + } + } + } +} diff --git a/launcher/qml/TopShortcutIcon.qml b/launcher/qml/TopShortcutIcon.qml new file mode 100644 index 0000000..7ece370 --- /dev/null +++ b/launcher/qml/TopShortcutIcon.qml @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import QtQuick 2.2 +import QtQuick.Controls 2.0 +import QtGraphicalEffects 1.0 + +MouseArea { + id: root + width: 195 + height: 216.8 + property string name: 'Home' + property string icon:'./images/TopShortcut/' + property bool active: false + property bool isBlank: false + + Item { + id: icon + property real desaturation: 0 + anchors.fill: parent + Image { + id: inactiveIcon + anchors.fill: parent + source: isBlank ? './images/TopShortcut/blank.svg' : root.icon + property string initial: root.name.substring(0,1).toUpperCase() + Label { + style: Text.Outline + styleColor: '#00FFFF' + color: 'transparent' + font.pixelSize: 75 + anchors.centerIn: parent + text: inactiveIcon.initial + visible: root.isBlank + } + } + layer.enabled: true + layer.effect: Desaturate { + id: desaturate + desaturation: icon.desaturation + cached: true + } + } + Label { + id: name + y: 160 + width: root.width - 10 + font.pixelSize: 15 + font.letterSpacing: 5 + // wrapMode: Text.WordWrap + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + color: "white" + text: qsTr(root.name).toUpperCase() + } +} diff --git a/launcher/qml/UninstallDialog.qml b/launcher/qml/UninstallDialog.qml new file mode 100644 index 0000000..4229525 --- /dev/null +++ b/launcher/qml/UninstallDialog.qml @@ -0,0 +1,158 @@ +import QtQuick 2.0 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 + +Item { + id: root + width: 1080 + height: 1920 + property string contents: '' + property string uninstallApp: '' + property int pid: -1 + + MouseArea { + anchors.fill: parent + onPressAndHold: {} + onPressed: {} + onReleased: {} + onClicked: {} + } + + Rectangle { + id: mainform + height: 300 + width: 1000 + radius:2 + anchors.centerIn: parent + + gradient: Gradient { + GradientStop { position: 0.0; color: "#12262E" } + GradientStop { position: 1.0; color: "#18899B" } + } + + ColumnLayout { + anchors { + topMargin: 10; bottomMargin:10 + leftMargin: 20; rightMargin: 20 + fill: parent + } + spacing: 2 + + ColumnLayout { + id: title_part + anchors { + top: parent.top + left: parent.left + topMargin: 10 + } + + Label { + id: title + text: 'Uninstall Dialog' + color: "white" + font.pixelSize: 32 + font.bold: true + maximumLineCount: 1 + wrapMode: Text.Wrap + elide: Text.ElideRight + horizontalAlignment: Label.AlignHCenter + verticalAlignment: Label.AlignVCenter + Layout.preferredWidth: 960 + Layout.preferredHeight: 40 + } + + Image { + source: './images/DividingLine.svg' + anchors.left: title.left + anchors.top: title.bottom + } + } + + RowLayout { + id: contents_part + anchors { + left: parent.left; leftMargin: 20 + right: parent.right; rightMargin: 20 + } + Layout.preferredWidth: 920 + Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter + spacing: 10 + Image { + id: dsp_mark + source: './images/uninstall.png' + Layout.maximumHeight: 120 + Layout.maximumWidth: 120 + } + Label { + text: root.contents + color: "white" + font.pixelSize: 24 + wrapMode: Text.Wrap + elide: Text.ElideRight + horizontalAlignment: Label.AlignLeft + verticalAlignment: Label.AlignVCenter + Layout.preferredWidth: 780 + Layout.preferredHeight: 160 + } + } + + RowLayout { + id: btn_area + spacing: 60 + anchors { + horizontalCenter: parent.horizontalCenter + } + Layout.preferredWidth: parent.width*0.75 + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter + + Button { + id: btn1 + text: 'YES' + onReleased: { + btn1.highlighted = false + root.visible = false + pid = homescreenHandler.uninstallApplication(uninstallApp) + if(pid < 1) { + console.warn("app cannot be uninstaled!") + } + } + onPressed: { + btn1.highlighted = true + } + onCanceled: { + btn1.highlighted = false + } + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter + } + + Button { + id: btn2 + text: 'NO' + onReleased: { + btn2.highlighted = false + root.visible = false + } + onPressed: { + btn2.highlighted = true + } + onCanceled: { + btn2.highlighted = false + } + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter + } + } + + Rectangle { + id: footer + opacity: 0 + width: parent.width + height: 5 + anchors { + bottom: parent.bottom + } + } + } + + } + +} diff --git a/launcher/qml/images/DividingLine.svg b/launcher/qml/images/DividingLine.svg new file mode 100644 index 0000000..788256c --- /dev/null +++ b/launcher/qml/images/DividingLine.svg @@ -0,0 +1,62 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/launcher/qml/images/TopShortcut/hvac.svg b/launcher/qml/images/TopShortcut/hvac.svg new file mode 100644 index 0000000..5c76e85 --- /dev/null +++ b/launcher/qml/images/TopShortcut/hvac.svg @@ -0,0 +1,600 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/qml/images/TopShortcut/hvac_active.svg b/launcher/qml/images/TopShortcut/hvac_active.svg new file mode 100644 index 0000000..46be46b --- /dev/null +++ b/launcher/qml/images/TopShortcut/hvac_active.svg @@ -0,0 +1,614 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/qml/images/TopShortcut/launcher.svg b/launcher/qml/images/TopShortcut/launcher.svg new file mode 100644 index 0000000..b6eab24 --- /dev/null +++ b/launcher/qml/images/TopShortcut/launcher.svg @@ -0,0 +1,73 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/qml/images/TopShortcut/launcher_active.svg b/launcher/qml/images/TopShortcut/launcher_active.svg new file mode 100644 index 0000000..e85c7d8 --- /dev/null +++ b/launcher/qml/images/TopShortcut/launcher_active.svg @@ -0,0 +1,82 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/qml/images/TopShortcut/mediaplayer.svg b/launcher/qml/images/TopShortcut/mediaplayer.svg new file mode 100644 index 0000000..de7448d --- /dev/null +++ b/launcher/qml/images/TopShortcut/mediaplayer.svg @@ -0,0 +1,50 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/qml/images/TopShortcut/mediaplayer_active.svg b/launcher/qml/images/TopShortcut/mediaplayer_active.svg new file mode 100644 index 0000000..16e3af5 --- /dev/null +++ b/launcher/qml/images/TopShortcut/mediaplayer_active.svg @@ -0,0 +1,63 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/qml/images/TopShortcut/navigation.svg b/launcher/qml/images/TopShortcut/navigation.svg new file mode 100644 index 0000000..6f6f1e0 --- /dev/null +++ b/launcher/qml/images/TopShortcut/navigation.svg @@ -0,0 +1,77 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/qml/images/TopShortcut/navigation_active.svg b/launcher/qml/images/TopShortcut/navigation_active.svg new file mode 100644 index 0000000..9076934 --- /dev/null +++ b/launcher/qml/images/TopShortcut/navigation_active.svg @@ -0,0 +1,90 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/qml/images/TopShortcut/sdl_usb.svg b/launcher/qml/images/TopShortcut/sdl_usb.svg new file mode 100644 index 0000000..3b6a7e9 --- /dev/null +++ b/launcher/qml/images/TopShortcut/sdl_usb.svg @@ -0,0 +1,311 @@ + + + +image/svg+xml diff --git a/launcher/qml/images/TopShortcut/sdl_usb_active.svg b/launcher/qml/images/TopShortcut/sdl_usb_active.svg new file mode 100644 index 0000000..9584885 --- /dev/null +++ b/launcher/qml/images/TopShortcut/sdl_usb_active.svg @@ -0,0 +1,278 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + diff --git a/launcher/qml/images/TopShortcut/topshortcut.qrc b/launcher/qml/images/TopShortcut/topshortcut.qrc new file mode 100644 index 0000000..d654bf2 --- /dev/null +++ b/launcher/qml/images/TopShortcut/topshortcut.qrc @@ -0,0 +1,16 @@ + + + launcher.svg + launcher_active.svg + hvac.svg + hvac_active.svg + mediaplayer.svg + mediaplayer_active.svg + navigation.svg + navigation_active.svg + video.svg + video_active.svg + sdl_usb.svg + sdl_usb_active.svg + + diff --git a/launcher/qml/images/TopShortcut/video.svg b/launcher/qml/images/TopShortcut/video.svg new file mode 100644 index 0000000..e368922 --- /dev/null +++ b/launcher/qml/images/TopShortcut/video.svg @@ -0,0 +1,109 @@ + + + + + + image/svg+xml + + + + + + + diff --git a/launcher/qml/images/TopShortcut/video_active.svg b/launcher/qml/images/TopShortcut/video_active.svg new file mode 100644 index 0000000..344385f --- /dev/null +++ b/launcher/qml/images/TopShortcut/video_active.svg @@ -0,0 +1,126 @@ + + + + + + image/svg+xml + + + + + + + diff --git a/launcher/qml/images/background.png b/launcher/qml/images/background.png new file mode 100644 index 0000000..1da52a3 Binary files /dev/null and b/launcher/qml/images/background.png differ diff --git a/launcher/qml/images/browser_active.svg b/launcher/qml/images/browser_active.svg new file mode 100644 index 0000000..70b4617 --- /dev/null +++ b/launcher/qml/images/browser_active.svg @@ -0,0 +1,231 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/launcher/qml/images/browser_inactive.svg b/launcher/qml/images/browser_inactive.svg new file mode 100644 index 0000000..09f34c9 --- /dev/null +++ b/launcher/qml/images/browser_inactive.svg @@ -0,0 +1,165 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/launcher/qml/images/hud.png b/launcher/qml/images/hud.png new file mode 100644 index 0000000..3bdc5d1 Binary files /dev/null and b/launcher/qml/images/hud.png differ diff --git a/launcher/qml/images/images.qrc b/launcher/qml/images/images.qrc index cef5f21..a24fd84 100644 --- a/launcher/qml/images/images.qrc +++ b/launcher/qml/images/images.qrc @@ -1,6 +1,13 @@ AGL_HMI_Blue_Background_Car-01.png + top_three_shortcut_background.png + meterdisplay.png + hud.png + background.png + uninstall.png + rse.png + DividingLine.svg connectivity_active.svg connectivity_inactive.svg dashboard_active.svg @@ -27,6 +34,10 @@ video_inactive.svg webbrowser_active.svg webbrowser_inactive.svg + browser_active.svg + browser_inactive.svg + sdl_active.svg + sdl_inactive.svg blank_active.svg blank_inactive.svg plus_active.svg diff --git a/launcher/qml/images/meterdisplay.png b/launcher/qml/images/meterdisplay.png new file mode 100644 index 0000000..a3ad430 Binary files /dev/null and b/launcher/qml/images/meterdisplay.png differ diff --git a/launcher/qml/images/rse.png b/launcher/qml/images/rse.png new file mode 100644 index 0000000..a3122b3 Binary files /dev/null and b/launcher/qml/images/rse.png differ diff --git a/launcher/qml/images/sdl_active.svg b/launcher/qml/images/sdl_active.svg new file mode 100644 index 0000000..efe3fe7 --- /dev/null +++ b/launcher/qml/images/sdl_active.svg @@ -0,0 +1,140 @@ + + + +image/svg+xml diff --git a/launcher/qml/images/sdl_inactive.svg b/launcher/qml/images/sdl_inactive.svg new file mode 100644 index 0000000..dcc077a --- /dev/null +++ b/launcher/qml/images/sdl_inactive.svg @@ -0,0 +1,83 @@ + + + +image/svg+xml diff --git a/launcher/qml/images/top_three_shortcut_background.png b/launcher/qml/images/top_three_shortcut_background.png new file mode 100644 index 0000000..fb5e180 Binary files /dev/null and b/launcher/qml/images/top_three_shortcut_background.png differ diff --git a/launcher/qml/images/uninstall.png b/launcher/qml/images/uninstall.png new file mode 100644 index 0000000..3f50c8f Binary files /dev/null and b/launcher/qml/images/uninstall.png differ diff --git a/launcher/qml/qml.qrc b/launcher/qml/qml.qrc index d132fed..f440a6e 100644 --- a/launcher/qml/qml.qrc +++ b/launcher/qml/qml.qrc @@ -2,5 +2,8 @@ Launcher.qml IconItem.qml + TopShortcutArea.qml + TopShortcutIcon.qml + UninstallDialog.qml diff --git a/launcher/src/applicationmodel.cpp b/launcher/src/applicationmodel.cpp index 261e43e..cf67617 100644 --- a/launcher/src/applicationmodel.cpp +++ b/launcher/src/applicationmodel.cpp @@ -190,8 +190,7 @@ void ApplicationModel::updateApplist(QStringList info) beginResetModel(); if(icon == "") { // uninstall d->removeApp(id); - } - else { + } else { // new app d->addApp(icon, name, id); } diff --git a/launcher/src/homescreenhandler.cpp b/launcher/src/homescreenhandler.cpp index 9f15b6a..99ced2e 100644 --- a/launcher/src/homescreenhandler.cpp +++ b/launcher/src/homescreenhandler.cpp @@ -18,8 +18,15 @@ #include #include "homescreenhandler.h" #include +#include +#include +#include #include "hmi-debug.h" +#include "afm_user_daemon_proxy.h" +extern org::AGL::afm::user *afm_user_daemon_proxy; + +#define BUF_SIZE 1024 void* HomescreenHandler::myThis = 0; HomescreenHandler::HomescreenHandler(QObject *parent) : @@ -145,6 +152,51 @@ void HomescreenHandler::onRep(struct json_object* reply_contents) } } +void HomescreenHandler::hideWindow(QString application_id) +{ + mp_hs->hideWindow(application_id.section('@', 0, 0).toStdString().c_str()); +} + +void HomescreenHandler::registerShortcut(QString shortcut_id, QString shortcut_name, QString position) +{ + struct json_object* j_obj = json_object_new_object(); + struct json_object* val_id = json_object_new_string(shortcut_id.toStdString().c_str()); + struct json_object* val_name = json_object_new_string(shortcut_name.toStdString().c_str()); + struct json_object* val_position = json_object_new_string(position.toStdString().c_str()); + json_object_object_add(j_obj, "shortcut_id", val_id); + json_object_object_add(j_obj, "shortcut_name", val_name); + json_object_object_add(j_obj, "position", val_position); + + mp_hs->registerShortcut(j_obj); +} + +int HomescreenHandler::uninstallApplication(QString application_id) +{ + int result = -1; + HMI_DEBUG("launcher","Application uninstall %s.", application_id.toStdString().c_str()); + + result = afm_user_daemon_proxy->uninstall(application_id).value().toInt(); + HMI_DEBUG("launcher","ApplicationUninstall pid: %d.", result); + +// QProcess *process = new QProcess(); +// QString command = "/usr/bin/pkill " + application_id.section('@', 0, 0); +// HMI_DEBUG("launcher", "command is %s", command.toStdString().c_str()); +// process->start(command); + + return result; +} + +void HomescreenHandler::sendAppToMeter(QString application_id) +{ + HMI_DEBUG("Launcher","sendAppToMeter %s", application_id.toStdString().c_str()); + struct json_object* j_json = json_object_new_object(); + struct json_object* value; + value = json_object_new_string("master.split.sub"); + json_object_object_add(j_json, "area", value); + + mp_hs->showWindow(application_id.section('@', 0, 0).toStdString().c_str(), j_json); +} + void HomescreenHandler::getRunnables(void) { mp_hs->getRunnables(); diff --git a/launcher/src/homescreenhandler.h b/launcher/src/homescreenhandler.h index 09b6848..8e5bbd1 100644 --- a/launcher/src/homescreenhandler.h +++ b/launcher/src/homescreenhandler.h @@ -36,6 +36,10 @@ public: Q_INVOKABLE void tapShortcut(QString application_id); Q_INVOKABLE void getRunnables(void); + Q_INVOKABLE void hideWindow(QString application_id); + Q_INVOKABLE void registerShortcut(QString shortcut_id, QString shortcut_name, QString position); + Q_INVOKABLE int uninstallApplication(QString application_id); + Q_INVOKABLE void sendAppToMeter(QString application_id); void onRep(struct json_object* reply_contents); diff --git a/launcher/src/main.cpp b/launcher/src/main.cpp index e56ff5a..fc28468 100644 --- a/launcher/src/main.cpp +++ b/launcher/src/main.cpp @@ -30,6 +30,7 @@ #include "appinfo.h" #include "afm_user_daemon_proxy.h" #include "homescreenhandler.h" +#include "shortcutappmodel.h" #include "hmi-debug.h" // XXX: We want this DBus connection to be shared across the different @@ -88,6 +89,7 @@ int main(int argc, char *argv[]) // import C++ class to QML qmlRegisterType("AppModel", 1, 0, "ApplicationModel"); + qmlRegisterType("ShortcutAppModel", 1, 0, "ShortcutAppModel"); // DBus qDBusRegisterMetaType(); @@ -95,6 +97,7 @@ int main(int argc, char *argv[]) ApplicationLauncher *launcher = new ApplicationLauncher(); QLibWindowmanager* layoutHandler = new QLibWindowmanager(); + ShortcutAppModel* shortcutAppModel = new ShortcutAppModel(); if(layoutHandler->init(port,token) != 0){ exit(EXIT_FAILURE); } @@ -149,6 +152,7 @@ int main(int argc, char *argv[]) engine.rootContext()->setContextProperty(QStringLiteral("homescreenHandler"), homescreenHandler); engine.rootContext()->setContextProperty(QStringLiteral("launcher"), launcher); engine.rootContext()->setContextProperty(QStringLiteral("screenInfo"), &screenInfo); + engine.rootContext()->setContextProperty(QStringLiteral("shortcutAppModel"), shortcutAppModel); engine.load(QUrl(QStringLiteral("qrc:/Launcher.qml"))); homescreenHandler->getRunnables(); diff --git a/launcher/src/shortcutappmodel.cpp b/launcher/src/shortcutappmodel.cpp new file mode 100644 index 0000000..bbfb74c --- /dev/null +++ b/launcher/src/shortcutappmodel.cpp @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "shortcutappmodel.h" +#include "hmi-debug.h" + +class ShortcutAppModel::Private +{ +public: + Private(); + + QList data; +}; + +ShortcutAppModel::Private::Private() +{ +} + + +ShortcutAppModel::ShortcutAppModel(QObject *parent) + : QAbstractListModel(parent) + , d(new Private()) +{ + getAppQueue(); +} + +ShortcutAppModel::~ShortcutAppModel() +{ + delete this->d; +} + +int ShortcutAppModel::rowCount(const QModelIndex &parent) const +{ + if (parent.isValid()) + return 0; + + return this->d->data.count(); +} + +QVariant ShortcutAppModel::data(const QModelIndex &index, int role) const +{ + QVariant ret; + if (!index.isValid()) + return ret; + + switch (role) { + case Qt::DecorationRole: + ret = this->d->data[index.row()].icon; + break; + case Qt::DisplayRole: + ret = this->d->data[index.row()].name; + break; + case Qt::UserRole: + ret = this->d->data[index.row()].id; + break; + default: + break; + } + + return ret; +} + +QHash ShortcutAppModel::roleNames() const +{ + QHash roles; + roles[Qt::DecorationRole] = "icon"; + roles[Qt::DisplayRole] = "name"; + roles[Qt::UserRole] = "id"; + return roles; +} + +void ShortcutAppModel::changeShortcut(QString id, QString name, QString position) +{ + for(int i = 0; i < d->data.size(); i++) { + if(id == d->data.at(i).id) { + return; + } + } + d->data.removeAt(position.toInt()); + HMI_DEBUG("launcher","parameter.id========%s", id.toStdString().c_str()); + HMI_DEBUG("launcher","parameter.name========%s", name.toStdString().c_str()); + HMI_DEBUG("launcher","parameter.position========%s", position.toStdString().c_str()); + + RegisterApp temp; + temp.id = id; + temp.name = name; + temp.icon = temp.icon = getIconPath(temp.id); + if (temp.icon == "") { + temp.isBlank = true; + } else { + temp.isBlank = false; + } + + d->data.insert(position.toInt(), temp); + emit updateShortcut(); +} + +QString ShortcutAppModel::getId(int index) const +{ + return d->data.at(index).id; +} + +QString ShortcutAppModel::getName(int index) const +{ + return d->data.at(index).name; +} + +QString ShortcutAppModel::getIcon(int index) const +{ + return d->data.at(index).icon; +} + +bool ShortcutAppModel::isBlank(int index) const +{ + return d->data.at(index).isBlank; +} + +QString ShortcutAppModel::getIconPath(QString id) +{ + QString name = id.section('@', 0, 0); + QString version = id.section('@', 1, 1); + QString boardIconPath = "/var/local/lib/afm/applications/" + name + "/" + version + "/icon.svg"; + QString appIconPath = ":/images/TopShortcut/" + name + ".svg"; + if (QFile::exists(boardIconPath)) { + HMI_DEBUG("launcher", "boardIconPath===%s", boardIconPath.toStdString().c_str()); + return "file://" + boardIconPath; + } else if (QFile::exists(appIconPath)) { + HMI_DEBUG("launcher", "appIconPath===%s", appIconPath.toStdString().c_str()); + return appIconPath.section('/', 1, -1); + } + return ""; +} + +void ShortcutAppModel::getAppQueue() +{ + QFile file("/home/0/app-data/homescreen/registeredApp.xml"); + if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QByteArray line = file.readLine(); + QString str(line); + if(str == "") { + file.close(); + + } + QXmlStreamReader reader(&file); + bool is_first = true; + while(!reader.atEnd()) { + if(reader.isStartElement()) + { + if(reader.name() == "id") + { + app.id = reader.readElementText(); + app.icon = getIconPath(app.id); + if (app.icon == "") { + app.isBlank = true; + } else { + app.isBlank = false; + } + } else if(reader.name() == "name") { + app.name = reader.readElementText(); + } + } else if(reader.isEndElement() && reader.name() == "app") { + if(is_first) { + is_first = false; + } else { + d->data.append(app); + } + } + reader.readNext(); + } + } else { + HMI_ERROR("HomeScreen", "registeredApp.xml file open failed"); + } + file.close(); +} diff --git a/launcher/src/shortcutappmodel.h b/launcher/src/shortcutappmodel.h new file mode 100644 index 0000000..3a2c313 --- /dev/null +++ b/launcher/src/shortcutappmodel.h @@ -0,0 +1,52 @@ +#ifndef SHORTCUTAPPMODEL_H +#define SHORTCUTAPPMODEL_H + +#include +#include +#include +#include +#include +#include + +struct RegisterApp { + QString id; + QString name; + QString icon; + bool isBlank; +}; + +class ShortcutAppModel : public QAbstractListModel +{ + Q_OBJECT +public: + explicit ShortcutAppModel(QObject *parent = nullptr); + ~ShortcutAppModel(); + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QHash roleNames() const override; + + Q_INVOKABLE QString getId(int index) const; + Q_INVOKABLE QString getName(int index) const; + Q_INVOKABLE QString getIcon(int index) const; + Q_INVOKABLE bool isBlank(int index) const; + +public slots: + void changeShortcut(QString id, QString name, QString position); + +signals: + void updateShortcut(); + +private: + void getAppQueue(); +// bool confirmIconImage(QString id); + QString getIconPath(QString id); + + class Private; + Private *d; + RegisterApp app; + +}; + +#endif // SHORTCUTAPPMODEL_H -- cgit 1.2.3-korg