Merge lastest commit from homescreen-2017 57/16057/1
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>
Wed, 8 Aug 2018 05:38:03 +0000 (14:38 +0900)
committerzheng_wenlong <wenlong_zheng@nexty-ele.com>
Wed, 8 Aug 2018 05:41:13 +0000 (14:41 +0900)
    Merge two lastest commit from homescreen-2017.

1)  StatusBarModel: fix QQmlContext reference
    Fix missing include
    Bug-AGL: SPEC-1628

2)  Improve output of multiple screen resolution
    To improve output on various monitor with various resolution,
    use scale_factor from WM to fit various screen resolution.
    Bug-AGL: SPEC-1568, SPEC-1569, SPEC-1611

Change-Id: I71a6c87187c2b0b81bb0ed10cc8779032aa19300
Signed-off-by: Matt Porter <mporter@konsulko.com>Y
Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
Signed-off-by: zheng_wenlong <wenlong_zheng@nexty-ele.com>
homescreen/qml/StatusArea.qml
homescreen/qml/main.qml
homescreen/src/main.cpp
homescreen/src/statusbarmodel.cpp
homescreen/src/statusbarmodel.h
package/config.xml

index 24d2b18..3f2b280 100644 (file)
@@ -157,7 +157,7 @@ Item {
                 }
             }
             Repeater {
-                model: StatusBarModel {}
+                model: StatusBarModel { objectName: "statusBar" }
                 delegate: Image {
                     Layout.preferredWidth: 77
                     Layout.preferredHeight: 73
index 1312e87..96a1950 100644 (file)
@@ -32,7 +32,7 @@ Window {
         anchors.centerIn: parent
         width: 1080
         height: 1920
-        scale: 1.0
+        scale: screenInfo.scale_factor()
         source: './images/AGL_HMI_Blue_Background_NoCar-01.png'
 
         ColumnLayout {
index 704bb9a..620c869 100644 (file)
@@ -75,7 +75,7 @@ int main(int argc, char *argv[])
     parser.addVersionOption();
     parser.process(a);
     QStringList positionalArguments = parser.positionalArguments();
-    
+
     int port = 1700;
     QString token = "wm";
 
@@ -97,6 +97,8 @@ int main(int argc, char *argv[])
         exit(EXIT_FAILURE);
     }
 
+    AGLScreenInfo screenInfo(layoutHandler->get_scale_factor());
+
     if (layoutHandler->requestSurface(QString("HomeScreen")) != 0) {
         exit(EXIT_FAILURE);
     }
@@ -136,11 +138,16 @@ int main(int argc, char *argv[])
     engine.rootContext()->setContextProperty("launcher", launcher);
     engine.rootContext()->setContextProperty("weather", new Weather(bindingAddress));
     engine.rootContext()->setContextProperty("bluetooth", new Bluetooth(bindingAddress));
+    engine.rootContext()->setContextProperty("screenInfo", &screenInfo);
     engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
 
     QObject *root = engine.rootObjects().first();
     QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
     QObject::connect(window, SIGNAL(frameSwapped()), layoutHandler, SLOT(slotActivateSurface()));
 
+    QList<QObject *> sobjs = engine.rootObjects();
+    StatusBarModel *statusBar = sobjs.first()->findChild<StatusBarModel *>("statusBar");
+    statusBar->init(bindingAddress, engine.rootContext());
+
     return a.exec();
 }
index bb44171..5e63b7d 100644 (file)
@@ -20,6 +20,8 @@
 
 #include <QtDBus/QDBusConnection>
 
+#include "network.h"
+
 class StatusBarModel::Private
 {
 public:
@@ -30,6 +32,7 @@ private:
 public:
     StatusBarServer server;
     QString iconList[StatusBarServer::SupportedCount];
+    Network *network;
 };
 
 StatusBarModel::Private::Private(StatusBarModel *parent)
@@ -60,6 +63,49 @@ StatusBarModel::~StatusBarModel()
     delete d;
 }
 
+void StatusBarModel::init(QUrl &url, QQmlContext *context)
+{
+    d->network = new Network(url, context);
+    context->setContextProperty("network", d->network);
+
+    QObject::connect(d->network, &Network::wifiConnectedChanged, this, &StatusBarModel::onWifiConnectedChanged);
+    QObject::connect(d->network, &Network::wifiEnabledChanged, this, &StatusBarModel::onWifiEnabledChanged);
+    QObject::connect(d->network, &Network::wifiStrengthChanged, this, &StatusBarModel::onWifiStrengthChanged);
+
+    setWifiStatus(d->network->wifiConnected(), d->network->wifiEnabled(), d->network->wifiStrength());
+}
+
+void StatusBarModel::setWifiStatus(bool connected, bool enabled, int strength)
+{
+    if (enabled && connected)
+        if (strength < 30)
+            d->server.setStatusIcon(0, QStringLiteral("qrc:/images/Status/HMI_Status_Wifi_1Bar-01.png"));
+        else if (strength < 50)
+            d->server.setStatusIcon(0, QStringLiteral("qrc:/images/Status/HMI_Status_Wifi_2Bars-01.png"));
+        else if (strength < 70)
+            d->server.setStatusIcon(0, QStringLiteral("qrc:/images/Status/HMI_Status_Wifi_3Bars-01.png"));
+        else
+            d->server.setStatusIcon(0, QStringLiteral("qrc:/images/Status/HMI_Status_Wifi_Full-01.png"));
+    else
+        d->server.setStatusIcon(0, QStringLiteral("qrc:/images/Status/HMI_Status_Wifi_NoBars-01.png"));
+}
+
+void StatusBarModel::onWifiConnectedChanged(bool connected)
+{
+    setWifiStatus(connected, d->network->wifiEnabled(), d->network->wifiStrength());
+}
+
+void StatusBarModel::onWifiEnabledChanged(bool enabled)
+{
+    setWifiStatus(d->network->wifiConnected(), enabled, d->network->wifiStrength());
+}
+
+void StatusBarModel::onWifiStrengthChanged(int strength)
+{
+    qInfo() << "Strength changed: " << strength;
+    setWifiStatus(d->network->wifiConnected(), d->network->wifiEnabled(), strength);
+}
+
 int StatusBarModel::rowCount(const QModelIndex &parent) const
 {
     if (parent.isValid())
index 8d6a70b..4e31f19 100644 (file)
@@ -18,6 +18,7 @@
 #define STATUSBARMODEL_H
 
 #include <QtCore/QAbstractListModel>
+#include <QtQml/QQmlContext>
 
 class StatusBarModel : public QAbstractListModel
 {
@@ -26,14 +27,21 @@ public:
     explicit StatusBarModel(QObject *parent = NULL);
     ~StatusBarModel();
 
+    void init(QUrl &url, QQmlContext *context);
     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;
 
+    // slots
+    void onWifiConnectedChanged(bool connected);
+    void onWifiEnabledChanged(bool enabled);
+    void onWifiStrengthChanged(int strength);
+
 private:
     class Private;
     Private *d;
+    void setWifiStatus(bool connected, bool enabled, int strength);
 };
 
 #endif // STATUSBARMODEL_H
index 4b2a218..32d19fd 100644 (file)
@@ -8,6 +8,7 @@
   <license>APL 2.0</license>
   <feature name="urn:AGL:widget:required-api">
     <param name="homescreen" value="ws" />
+    <param name="network-manager" value="ws" />
     <param name="weather" value="ws" />
     <param name="Bluetooth-Manager" value="ws" />
     <param name="windowmanager" value="ws" />