Integrate Home app into HomeScreen
authorBocklage, Jens <Jens_Bocklage@mentor.com>
Fri, 9 Dec 2016 11:14:02 +0000 (12:14 +0100)
committerBocklage, Jens <Jens_Bocklage@mentor.com>
Fri, 9 Dec 2016 11:14:02 +0000 (12:14 +0100)
Home is located in ces2017 repo. But since it has to use
HomeScreen internal components (layermanager and applauncher),
I had to move it to main HomeScreen app.

Signed-off-by: Bocklage, Jens <Jens_Bocklage@mentor.com>
30 files changed:
HomeScreen/HomeScreen.pro
HomeScreen/qml/Home.qml [new file with mode: 0644]
HomeScreen/qml/ShortcutArea.qml
HomeScreen/qml/images/Home/AGL_HMI_Background_Car-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Active-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Inactive-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Active-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Inactive-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Active-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Inactive-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Active-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Inactive-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Active-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Inactive-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Active-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Inactive-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Active-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Inactive-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Active-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Inactive-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Active-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Inactive-01.png [new file with mode: 0644]
HomeScreen/qml/images/Home/home.qrc [new file with mode: 0644]
HomeScreen/qml/main.qml
HomeScreen/qml/qml.qrc
HomeScreen/src/main.cpp
HomeScreen/src2/appinfo.cpp [new file with mode: 0644]
HomeScreen/src2/appinfo.h [new file with mode: 0644]
HomeScreen/src2/applicationmodel.cpp [new file with mode: 0644]
HomeScreen/src2/applicationmodel.h [new file with mode: 0644]

index 1ad42bf..d48b6e5 100644 (file)
@@ -61,9 +61,13 @@ OTHER_FILES += \
 HEADERS += \
     src2/statusbarmodel.h \
     src2/statusbarserver.h \
-    src2/applicationlauncher.h
+    src2/applicationlauncher.h \
+    src2/applicationmodel.h \
+    src2/appinfo.h
 
 SOURCES += \
+    src2/applicationmodel.cpp \
+    src2/appinfo.cpp \
     src2/statusbarmodel.cpp \
     src2/statusbarserver.cpp \
     src2/applicationlauncher.cpp
@@ -72,6 +76,7 @@ RESOURCES += \
     resources/homescreen.qrc
 
 RESOURCES += \
+    qml/images/Home/home.qrc \
     qml/images/MediaPlayer/mediaplayer.qrc \
     qml/images/MediaMusic/mediamusic.qrc \
     qml/images/Weather/weather.qrc \
@@ -79,10 +84,3 @@ RESOURCES += \
     qml/images/Status/status.qrc \
     qml/images/images.qrc \
     qml/qml.qrc
-
-
-copydata.commands = $(COPY_DIR) $$PWD/resources/colorschemes $$OUT_PWD
-HomeScreen.depends = $(HomeScreen) copydata
-export(HomeScreen.depends)
-export(copydata.commands)
-QMAKE_EXTRA_TARGETS += HomeScreen copydata
diff --git a/HomeScreen/qml/Home.qml b/HomeScreen/qml/Home.qml
new file mode 100644 (file)
index 0000000..cfcd1c8
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2016 The Qt Company Ltd.
+ *
+ * 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 1.0
+import Home 1.0
+
+Item {
+    id: root
+
+    Image {
+        anchors.fill: parent
+        anchors.topMargin: -218
+        anchors.bottomMargin: -215
+        source: './images/AGL_HMI_Background_Car-01.png'
+    }
+
+    property int pid: -1
+
+    GridView {
+        anchors.centerIn: parent
+        width: cellHeight * 3
+        height: cellHeight * 3
+        cellWidth: 320
+        cellHeight: 320
+
+        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)
+                layoutHandler.makeMeVisible(pid)
+
+                applicationArea.visible = true
+                appLauncherAreaLauncher.visible = false
+                layoutHandler.showAppLayer()
+            }
+        }
+    }
+}
index 9ef8701..d9931cb 100644 (file)
 
 import QtQuick 2.2
 import QtQuick.Layouts 1.1
-import HomeScreen 1.0
 
 Item {
     id: root
     width: 785
     height: 218
 
-    ApplicationLauncher {
-        id: launcher
-    }
-
-    LayoutHandler {
-        id: layoutHandler
-    }
 
     ListModel {
         id: applicationModel
@@ -40,7 +32,7 @@ Item {
         }
         ListElement {
             name: 'Multimedia'
-            application: 'radio@0.1'
+            application: 'mediaplayer@0.1'
         }
         ListElement {
             name: 'HVAC'
@@ -67,8 +59,18 @@ Item {
                 active: model.index === root.currentIndex
                 onClicked: {
                     root.currentIndex = active ? -1 : model.index
-                    pid = launcher.launch(model.application)
-                    layoutHandler.makeMeVisible(pid)
+                    if (0 === model.index) {
+                        appLauncherAreaLauncher.visible = true
+                        applicationArea.visible = false
+                        layoutHandler.hideAppLayer()
+                    }
+                    else {
+                        applicationArea.visible = true
+                        appLauncherAreaLauncher.visible = false
+                        pid = launcher.launch(model.application)
+                        layoutHandler.makeMeVisible(pid)
+                        layoutHandler.showAppLayer()
+                    }
                 }
             }
         }
diff --git a/HomeScreen/qml/images/Home/AGL_HMI_Background_Car-01.png b/HomeScreen/qml/images/Home/AGL_HMI_Background_Car-01.png
new file mode 100644 (file)
index 0000000..b0072d8
Binary files /dev/null and b/HomeScreen/qml/images/Home/AGL_HMI_Background_Car-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Active-01.png
new file mode 100644 (file)
index 0000000..888d0bd
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Active-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Inactive-01.png
new file mode 100644 (file)
index 0000000..ab83b0e
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Inactive-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Active-01.png
new file mode 100644 (file)
index 0000000..11d39e5
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Active-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Inactive-01.png
new file mode 100644 (file)
index 0000000..6c0b914
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Inactive-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Active-01.png
new file mode 100644 (file)
index 0000000..efc11e9
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Active-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Inactive-01.png
new file mode 100644 (file)
index 0000000..b528376
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Inactive-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Active-01.png
new file mode 100644 (file)
index 0000000..1c99ac4
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Active-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Inactive-01.png
new file mode 100644 (file)
index 0000000..0bed61d
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Inactive-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Active-01.png
new file mode 100644 (file)
index 0000000..e7ad085
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Active-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Inactive-01.png
new file mode 100644 (file)
index 0000000..dd40750
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Inactive-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Active-01.png
new file mode 100644 (file)
index 0000000..2df01d3
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Active-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Inactive-01.png
new file mode 100644 (file)
index 0000000..ec62b87
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Inactive-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Active-01.png
new file mode 100644 (file)
index 0000000..2150581
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Active-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Inactive-01.png
new file mode 100644 (file)
index 0000000..61dcedc
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Inactive-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Active-01.png
new file mode 100644 (file)
index 0000000..1aa5a01
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Active-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Inactive-01.png
new file mode 100644 (file)
index 0000000..616983e
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Inactive-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Active-01.png
new file mode 100644 (file)
index 0000000..1d13fd6
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Active-01.png differ
diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Inactive-01.png
new file mode 100644 (file)
index 0000000..027f1fe
Binary files /dev/null and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Inactive-01.png differ
diff --git a/HomeScreen/qml/images/Home/home.qrc b/HomeScreen/qml/images/Home/home.qrc
new file mode 100644 (file)
index 0000000..7dde212
--- /dev/null
@@ -0,0 +1,23 @@
+<RCC>
+    <qresource prefix="/images">
+        <file>AGL_HMI_Background_Car-01.png</file>
+        <file>HMI_AppLauncher_Connectivity_Active-01.png</file>
+        <file>HMI_AppLauncher_Connectivity_Inactive-01.png</file>
+        <file>HMI_AppLauncher_Dashboard_Active-01.png</file>
+        <file>HMI_AppLauncher_Dashboard_Inactive-01.png</file>
+        <file>HMI_AppLauncher_HVAC_Active-01.png</file>
+        <file>HMI_AppLauncher_HVAC_Inactive-01.png</file>
+        <file>HMI_AppLauncher_Multimedia_Active-01.png</file>
+        <file>HMI_AppLauncher_Multimedia_Inactive-01.png</file>
+        <file>HMI_AppLauncher_Navigation_Active-01.png</file>
+        <file>HMI_AppLauncher_Navigation_Inactive-01.png</file>
+        <file>HMI_AppLauncher_Phone_Active-01.png</file>
+        <file>HMI_AppLauncher_Phone_Inactive-01.png</file>
+        <file>HMI_AppLauncher_POI_Active-01.png</file>
+        <file>HMI_AppLauncher_POI_Inactive-01.png</file>
+        <file>HMI_AppLauncher_Radio_Active-01.png</file>
+        <file>HMI_AppLauncher_Radio_Inactive-01.png</file>
+        <file>HMI_AppLauncher_Settings_Active-01.png</file>
+        <file>HMI_AppLauncher_Settings_Inactive-01.png</file>
+    </qresource>
+</RCC>
index 542f395..143d649 100644 (file)
@@ -18,6 +18,7 @@
 import QtQuick 2.2
 import QtQuick.Window 2.1
 import QtQuick.Layouts 1.1
+import HomeScreen 1.0
 
 Window {
     visible: true
@@ -26,6 +27,14 @@ Window {
     height: container.height * container.scale
     title: 'HomeScreen'
 
+    ApplicationLauncher {
+        id: launcher
+    }
+
+    LayoutHandler {
+        id: layoutHandler
+    }
+
     Image {
         id: container
         anchors.centerIn: parent
@@ -48,6 +57,16 @@ Window {
                 Layout.fillWidth: true
                 Layout.fillHeight: true
                 Layout.preferredHeight: 1920 - 218 - 215
+
+                visible: true
+            }
+
+            Home {
+                id: appLauncherAreaLauncher
+                Layout.fillWidth: true
+                Layout.fillHeight: true
+                Layout.preferredHeight: 1920 - 218 - 215
+                visible: false
             }
 
             MediaArea {
index a916b03..3d699e0 100644 (file)
@@ -1,5 +1,6 @@
 <RCC>
     <qresource prefix="/">
+        <file>Home.qml</file>
         <file>main.qml</file>
         <file>MediaArea.qml</file>
         <file>MediaAreaBlank.qml</file>
index 99f98c9..ac798a9 100644 (file)
@@ -23,7 +23,7 @@
 #include "../src2/applicationlauncher.h"
 #include "../src2/statusbarmodel.h"
 #include "layouthandler.h"
-
+#include "../src2/applicationmodel.h"
 
 int main(int argc, char *argv[])
 {
@@ -41,6 +41,7 @@ int main(int argc, char *argv[])
     qDBusRegisterMetaType<QList<AppInfo> >();
 
     qmlRegisterType<ApplicationLauncher>("HomeScreen", 1, 0, "ApplicationLauncher");
+    qmlRegisterType<ApplicationModel>("Home", 1, 0, "ApplicationModel");
     qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel");
     qmlRegisterType<LayoutHandler>("HomeScreen", 1, 0, "LayoutHandler");
 
diff --git a/HomeScreen/src2/appinfo.cpp b/HomeScreen/src2/appinfo.cpp
new file mode 100644 (file)
index 0000000..6b61632
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH
+ * Copyright (C) 2016 The Qt Company Ltd.
+ *
+ * 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 "appinfo.h"
+
+#include <QtCore/QJsonObject>
+
+class AppInfo::Private : public QSharedData
+{
+public:
+    Private();
+    Private(const Private &other);
+
+    QString id;
+    QString version;
+    int width;
+    int height;
+    QString name;
+    QString description;
+    QString shortname;
+    QString author;
+    QString iconPath;
+};
+
+AppInfo::Private::Private()
+    : width(-1)
+    , height(-1)
+{
+}
+
+AppInfo::Private::Private(const Private &other)
+    : QSharedData(other)
+    , id(other.id)
+    , version(other.version)
+    , width(other.width)
+    , height(other.height)
+    , name(other.name)
+    , description(other.description)
+    , shortname(other.shortname)
+    , author(other.author)
+    , iconPath(other.iconPath)
+{
+}
+
+AppInfo::AppInfo()
+    : d(new Private)
+{
+}
+
+AppInfo::AppInfo(const QString &icon, const QString &name, const QString &id)
+    : d(new Private)
+{
+    d->iconPath = icon;
+    d->name = name;
+    d->id = id;
+}
+
+AppInfo::AppInfo(const AppInfo &other)
+    : d(other.d)
+{
+}
+
+AppInfo::~AppInfo()
+{
+}
+
+AppInfo &AppInfo::operator =(const AppInfo &other)
+{
+    d = other.d;
+    return *this;
+}
+
+QString AppInfo::id() const
+{
+    return d->id;
+}
+
+QString AppInfo::version() const
+{
+    return d->version;
+}
+
+int AppInfo::width() const
+{
+    return d->width;
+}
+
+int AppInfo::height() const
+{
+    return d->height;
+}
+
+QString AppInfo::name() const
+{
+    return d->name;
+}
+
+QString AppInfo::description() const
+{
+    return d->description;
+}
+
+QString AppInfo::shortname() const
+{
+    return d->shortname;
+}
+
+QString AppInfo::author() const
+{
+    return d->author;
+}
+
+QString AppInfo::iconPath() const
+{
+    return d->iconPath;
+}
+
+void AppInfo::read(const QJsonObject &json)
+{
+    d->id = json["id"].toString();
+    d->version = json["version"].toString();
+    d->width = json["width"].toInt();
+    d->height = json["height"].toInt();
+    d->name = json["name"].toString();
+    d->description = json["description"].toString();
+    d->shortname = json["shortname"].toString();
+    d->author = json["author"].toString();
+    d->iconPath = json["iconPath"].toString();
+}
+
+QDBusArgument &operator <<(QDBusArgument &argument, const AppInfo &appInfo)
+{
+    argument.beginStructure();
+    argument << appInfo.d->id;
+    argument << appInfo.d->version;
+    argument << appInfo.d->width;
+    argument << appInfo.d->height;
+    argument << appInfo.d->name;
+    argument << appInfo.d->description;
+    argument << appInfo.d->shortname;
+    argument << appInfo.d->author;
+    argument << appInfo.d->iconPath;
+    argument.endStructure();
+
+    return argument;
+}
+
+const QDBusArgument &operator >>(const QDBusArgument &argument, AppInfo &appInfo)
+{
+    argument.beginStructure();
+    argument >> appInfo.d->id;
+    argument >> appInfo.d->version;
+    argument >> appInfo.d->width;
+    argument >> appInfo.d->height;
+    argument >> appInfo.d->name;
+    argument >> appInfo.d->description;
+    argument >> appInfo.d->shortname;
+    argument >> appInfo.d->author;
+    argument >> appInfo.d->iconPath;
+    argument.endStructure();
+    return argument;
+}
diff --git a/HomeScreen/src2/appinfo.h b/HomeScreen/src2/appinfo.h
new file mode 100644 (file)
index 0000000..a800a80
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH
+ * Copyright (C) 2016 The Qt Company Ltd.
+ *
+ * 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.
+ */
+
+#ifndef APPINFO_H
+#define APPINFO_H
+
+#include <QtCore/QSharedDataPointer>
+#include <QtDBus/QDBusArgument>
+
+class AppInfo
+{
+    Q_GADGET
+    Q_PROPERTY(QString id READ id)
+    Q_PROPERTY(QString version READ version)
+    Q_PROPERTY(int width READ width)
+    Q_PROPERTY(int height READ height)
+    Q_PROPERTY(QString name READ name)
+    Q_PROPERTY(QString description READ description)
+    Q_PROPERTY(QString shortname READ shortname)
+    Q_PROPERTY(QString author READ author)
+    Q_PROPERTY(QString iconPath READ iconPath)
+public:
+    AppInfo();
+    AppInfo(const QString &icon, const QString &name, const QString &id);
+    AppInfo(const AppInfo &other);
+    virtual ~AppInfo();
+    AppInfo &operator =(const AppInfo &other);
+    void swap(AppInfo &other) { qSwap(d, other.d); }
+
+    QString id() const;
+    QString version() const;
+    int width() const;
+    int height() const;
+    QString name() const;
+    QString description() const;
+    QString shortname() const;
+    QString author() const;
+    QString iconPath() const;
+
+    void read(const QJsonObject &json);
+
+    friend QDBusArgument &operator <<(QDBusArgument &argument, const AppInfo &appInfo);
+    friend const QDBusArgument &operator >>(const QDBusArgument &argument, AppInfo &appInfo);
+
+private:
+    class Private;
+    QSharedDataPointer<Private> d;
+};
+
+Q_DECLARE_SHARED(AppInfo)
+Q_DECLARE_METATYPE(AppInfo)
+Q_DECLARE_METATYPE(QList<AppInfo>)
+
+#endif // APPINFO_H
diff --git a/HomeScreen/src2/applicationmodel.cpp b/HomeScreen/src2/applicationmodel.cpp
new file mode 100644 (file)
index 0000000..b8bbb38
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2016 The Qt Company Ltd.
+ * Copyright (C) 2016 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.
+ */
+
+#include "applicationmodel.h"
+#include "appinfo.h"
+
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusReply>
+
+class ApplicationModel::Private
+{
+public:
+    Private(ApplicationModel *parent);
+
+private:
+    ApplicationModel *q;
+public:
+    QDBusInterface proxy;
+    QList<AppInfo> data;
+};
+
+ApplicationModel::Private::Private(ApplicationModel *parent)
+    : q(parent)
+    , proxy(QStringLiteral("org.agl.homescreenappframeworkbinder"), QStringLiteral("/AppFramework"), QStringLiteral("org.agl.appframework"), QDBusConnection::sessionBus())
+{
+    QDBusReply<QList<AppInfo>> reply = proxy.call("getAvailableApps");
+    if (false)/*reply.isValid()) TODO: test for CES!  */ {
+        data = reply.value();
+    } else {
+        data.append(AppInfo(QStringLiteral("HVAC"), QStringLiteral("HVAC"), QStringLiteral("hvac@0.1")));
+        data.append(AppInfo(QStringLiteral("Navigation"), QStringLiteral("NAVIGATION"), QStringLiteral("navigation@0.1")));
+        data.append(AppInfo(QStringLiteral("Phone"), QStringLiteral("PHONE"), QStringLiteral("phone@0.1")));
+        data.append(AppInfo(QStringLiteral("Radio"), QStringLiteral("RADIO"), QStringLiteral("radio@0.1")));
+        data.append(AppInfo(QStringLiteral("Multimedia"), QStringLiteral("MULTIMEDIA"), QStringLiteral("multimedia@0.1")));
+        data.append(AppInfo(QStringLiteral("Connectivity"), QStringLiteral("CONNECTIVITY"), QStringLiteral("connectivity@0.1")));
+        data.append(AppInfo(QStringLiteral("Dashboard"), QStringLiteral("DASHBOARD"), QStringLiteral("dashboard@0.1")));
+        data.append(AppInfo(QStringLiteral("Settings"), QStringLiteral("SETTINGS"), QStringLiteral("settings@0.1")));
+        data.append(AppInfo(QStringLiteral("POI"), QStringLiteral("POINT OF\nINTEREST"), QStringLiteral("poi@0.1")));
+    }
+}
+
+ApplicationModel::ApplicationModel(QObject *parent)
+    : QAbstractListModel(parent)
+    , d(new Private(this))
+{
+}
+
+ApplicationModel::~ApplicationModel()
+{
+    delete d;
+}
+
+int ApplicationModel::rowCount(const QModelIndex &parent) const
+{
+    if (parent.isValid())
+        return 0;
+
+    return d->data.count();
+}
+
+QVariant ApplicationModel::data(const QModelIndex &index, int role) const
+{
+    QVariant ret;
+    if (!index.isValid())
+        return ret;
+
+    switch (role) {
+    case Qt::DecorationRole:
+        ret = d->data[index.row()].iconPath();
+        break;
+    case Qt::DisplayRole:
+        ret = d->data[index.row()].name();
+        break;
+    case Qt::UserRole:
+        ret = d->data[index.row()].id();
+        break;
+    default:
+        break;
+    }
+
+    return ret;
+}
+
+QHash<int, QByteArray> ApplicationModel::roleNames() const
+{
+    QHash<int, QByteArray> roles;
+    roles[Qt::DecorationRole] = "icon";
+    roles[Qt::DisplayRole] = "name";
+    roles[Qt::UserRole] = "id";
+    return roles;
+}
diff --git a/HomeScreen/src2/applicationmodel.h b/HomeScreen/src2/applicationmodel.h
new file mode 100644 (file)
index 0000000..bffc4c9
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2016 The Qt Company Ltd.
+ *
+ * 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.
+ */
+
+#ifndef APPLICATIONMODEL_H
+#define APPLICATIONMODEL_H
+
+#include <QtCore/QAbstractListModel>
+
+class ApplicationModel : public QAbstractListModel
+{
+    Q_OBJECT
+public:
+    explicit ApplicationModel(QObject *parent = nullptr);
+    ~ApplicationModel();
+
+    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+
+    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+    QHash<int, QByteArray> roleNames() const override;
+
+private:
+    class Private;
+    Private *d;
+};
+
+#endif // APPLICATIONMODEL_H