summaryrefslogtreecommitdiffstats
path: root/homescreen
diff options
context:
space:
mode:
Diffstat (limited to 'homescreen')
-rw-r--r--homescreen/homescreen.pro4
-rw-r--r--homescreen/qml/StatusArea.qml27
-rw-r--r--homescreen/src/main.cpp12
3 files changed, 41 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();