diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-02-08 17:27:17 -0800 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-02-13 23:37:07 -0800 |
commit | 928dd96f5225769d4af7354e75d4d245ae586884 (patch) | |
tree | 9ccb83cda12928a652455d8bf67a6dd1d7cd254e | |
parent | db9f41d75fb4460f668117c69be05c4d4d4c7c7c (diff) |
homescreen: add OpenWeatherMap data to homescreen
Use agl-service-weather weather data via libqtappfw framework on homescreen
interface.
Bug-AGL: SPEC-1273
Change-Id: If591b74c1e6a912384abf6289128ec9a4a1101b4
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r-- | homescreen/homescreen.pro | 4 | ||||
-rw-r--r-- | homescreen/qml/StatusArea.qml | 27 | ||||
-rw-r--r-- | homescreen/src/main.cpp | 12 | ||||
-rw-r--r-- | package/config.xml | 1 |
4 files changed, 42 insertions, 2 deletions
diff --git a/homescreen/homescreen.pro b/homescreen/homescreen.pro index b72931b..70f4ca7 100644 --- a/homescreen/homescreen.pro +++ b/homescreen/homescreen.pro @@ -15,10 +15,10 @@ TEMPLATE = app TARGET = HomeScreen -QT = qml quick dbus +QT = qml quick dbus websockets CONFIG += c++11 link_pkgconfig DESTDIR = $${OUT_PWD}/../package/root/bin -PKGCONFIG += qlibwindowmanager +PKGCONFIG += qlibwindowmanager qtappfw LIBS += -lhomescreen diff --git a/homescreen/qml/StatusArea.qml b/homescreen/qml/StatusArea.qml index 4dbe0ba..e464980 100644 --- a/homescreen/qml/StatusArea.qml +++ b/homescreen/qml/StatusArea.qml @@ -30,6 +30,31 @@ Item { onTriggered: root.now = new Date } + Connections { + target: weather + + onConditionChanged: { + var current_condition = weather.condition + var icon = '' + + if (current_condition.indexOf("clouds") != -1) { + icon = "WeatherIcons_Cloudy-01.png" + } else if (current_condition.indexOf("thunderstorm") != -1) { + icon = "WeatherIcons_Thunderstorm-01.png" + } else if (current_condition.indexOf("snow") != -1) { + icon = "WeatherIcons_Snow-01.png" + } else if (current_condition.indexOf("rain") != -1) { + icon = "WeatherIcons_Rain-01.png" + } + + condition.source = icon ? './images/Weather/' + icon : '' + } + + onTemperatureChanged: { + temperature.text = weather.temperature.split(".")[0] + '°F' + } + } + RowLayout { anchors.fill: parent spacing: 0 @@ -73,9 +98,11 @@ Item { Layout.fillHeight: true Layout.preferredHeight: 20 Image { + id: condition source: './images/Weather/WeatherIcons_Rain-01.png' } Text { + id: temperature text: '64°F' color: 'white' font.family: 'Helvetica' diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp index 522f957..8845253 100644 --- a/homescreen/src/main.cpp +++ b/homescreen/src/main.cpp @@ -24,6 +24,7 @@ #include <QQuickWindow> #include <qlibwindowmanager.h> +#include <weather.h> #include "applicationlauncher.h" #include "statusbarmodel.h" #include "applicationmodel.h" @@ -124,11 +125,22 @@ int main(int argc, char *argv[]) HomescreenHandler* homescreenHandler = new HomescreenHandler(); homescreenHandler->init(port, token.toStdString().c_str()); + QUrl bindingAddress; + bindingAddress.setScheme(QStringLiteral("ws")); + bindingAddress.setHost(QStringLiteral("localhost")); + bindingAddress.setPort(port); + bindingAddress.setPath(QStringLiteral("/api")); + + QUrlQuery query; + query.addQueryItem(QStringLiteral("token"), token); + bindingAddress.setQuery(query); + // mail.qml loading QQmlApplicationEngine engine; engine.rootContext()->setContextProperty("layoutHandler", layoutHandler); engine.rootContext()->setContextProperty("homescreenHandler", homescreenHandler); engine.rootContext()->setContextProperty("launcher", launcher); + engine.rootContext()->setContextProperty("weather", new Weather(bindingAddress)); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); QObject *root = engine.rootObjects().first(); diff --git a/package/config.xml b/package/config.xml index 885473c..036b9ba 100644 --- a/package/config.xml +++ b/package/config.xml @@ -8,6 +8,7 @@ <license>APL 2.0</license> <feature name="urn:AGL:widget:required-api"> <param name="homescreen" value="ws" /> + <param name="weather" value="ws" /> <param name="windowmanager" value="ws" /> </feature> <feature name="urn:AGL:widget:required-permission"> |