aboutsummaryrefslogtreecommitdiffstats
path: root/homescreen/src/statusbarmodel.cpp
diff options
context:
space:
mode:
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>2018-08-08 14:38:03 +0900
committerzheng_wenlong <wenlong_zheng@nexty-ele.com>2018-08-08 14:41:13 +0900
commit58ecf2c3229ab677ca39095b52ab88b1a41861bd (patch)
treedd9ec6ec0bb49826746d942ee59322262e54c835 /homescreen/src/statusbarmodel.cpp
parent4d66f9362b74500b1ceb1850c156cd7aeaf60fc6 (diff)
Merge lastest commit from homescreen-2017
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>
Diffstat (limited to 'homescreen/src/statusbarmodel.cpp')
-rw-r--r--homescreen/src/statusbarmodel.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/homescreen/src/statusbarmodel.cpp b/homescreen/src/statusbarmodel.cpp
index bb44171..5e63b7d 100644
--- a/homescreen/src/statusbarmodel.cpp
+++ b/homescreen/src/statusbarmodel.cpp
@@ -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())