summaryrefslogtreecommitdiff
path: root/metawatch
diff options
context:
space:
mode:
Diffstat (limited to 'metawatch')
-rw-r--r--metawatch/metawatch.cpp6
-rw-r--r--metawatch/metawatch.h1
-rw-r--r--metawatch/metawatchdigital.cpp53
-rw-r--r--metawatch/metawatchdigital.h4
4 files changed, 57 insertions, 7 deletions
diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp
index 9ca4b2d..b79f6fc 100644
--- a/metawatch/metawatch.cpp
+++ b/metawatch/metawatch.cpp
@@ -226,6 +226,12 @@ void MetaWatch::updateNotificationCount(Notification::Type type, int count)
// Default implementation does nothing
}
+void MetaWatch::updateWeather(WeatherNotification *weather)
+{
+ Q_UNUSED(weather);
+ // Default implementation does nothing
+}
+
void MetaWatch::displayIdleScreen()
{
_currentMode = IdleMode;
diff --git a/metawatch/metawatch.h b/metawatch/metawatch.h
index 8f0d52e..685b2a7 100644
--- a/metawatch/metawatch.h
+++ b/metawatch/metawatch.h
@@ -105,6 +105,7 @@ public:
void ungrabButton(int button);
void updateNotificationCount(Notification::Type type, int count);
+ void updateWeather(WeatherNotification *weather);
void displayIdleScreen();
void displayNotification(Notification *notification);
diff --git a/metawatch/metawatchdigital.cpp b/metawatch/metawatchdigital.cpp
index a4bb833..ae13e49 100644
--- a/metawatch/metawatchdigital.cpp
+++ b/metawatch/metawatchdigital.cpp
@@ -73,6 +73,13 @@ void MetaWatchDigital::updateNotificationCount(Notification::Type type, int coun
}
}
+void MetaWatchDigital::updateWeather(WeatherNotification *weather)
+{
+ if (isConnected()) {
+ renderIdleWeather(weather);
+ }
+}
+
void MetaWatchDigital::displayIdleScreen()
{
qDebug() << "displaying idle screen";
@@ -152,20 +159,54 @@ void MetaWatchDigital::renderIdleScreen()
renderIdleCounts();
}
-void MetaWatchDigital::renderIdleWeather()
+void MetaWatchDigital::renderIdleWeather(WeatherNotification* w)
{
_paintMode = IdleMode;
- QFont f("MetaWatch Small caps 8pt", 6);
- QImage rain(QString(":/metawatch/graphics/weather_rain.bmp"));
+ QFont sf("MetaWatch Small caps 8pt", 6);
+ QFont lf("MetaWatch Large 16pt");
QPainter p(this);
- p.setFont(f);
- p.drawText(30, systemAreaHeight + 14, "No data!");
- p.drawImage(screenWidth - 26, systemAreaHeight + 6, rain);
+ sf.setPixelSize(8);
+ lf.setPixelSize(16);
+
+ p.fillRect(0, systemAreaHeight + 6, screenWidth, systemAreaHeight - 12, Qt::white);
+
+ if (w) {
+ QImage icon = iconForWeather(w);
+ bool metric = w->temperatureUnits() == WeatherNotification::Celsius;
+ QString unit = QString::fromUtf8(metric ? "°C" : "°F");
+ QRect bodyRect(4, systemAreaHeight + 6, 36, systemAreaHeight - 10);
+ p.setFont(sf);
+ p.drawText(bodyRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextWordWrap, w->body());
+ p.drawImage(36, systemAreaHeight + 6, icon);
+ p.setFont(lf);
+ p.drawText(64, systemAreaHeight + 22, QString("%1 %2").arg(w->temperature()).arg(unit));
+ } else {
+ p.setFont(sf);
+ p.drawText(32, systemAreaHeight + 18, tr("No data"));
+ }
_paintMode = _currentMode;
}
+QImage MetaWatchDigital::iconForWeather(WeatherNotification *w)
+{
+ switch (w->forecast()) {
+ case WeatherNotification::Sunny:
+ return QImage(QString(":/metawatch/graphics/weather_sunny.bmp"));
+ case WeatherNotification::Cloudy:
+ return QImage(QString(":/metawatch/graphics/weather_cloudy.bmp"));
+ case WeatherNotification::Rain:
+ return QImage(QString(":/metawatch/graphics/weather_rain.bmp"));
+ case WeatherNotification::Snow:
+ return QImage(QString(":/metawatch/graphics/weather_snow.bmp"));
+ case WeatherNotification::Thunderstorm:
+ return QImage(QString(":/metawatch/graphics/weather_thunderstorm.bmp"));
+ default:
+ return QImage();
+ }
+}
+
void MetaWatchDigital::renderIdleCounts()
{
_paintMode = IdleMode;
diff --git a/metawatch/metawatchdigital.h b/metawatch/metawatchdigital.h
index 0754242..a528eb2 100644
--- a/metawatch/metawatchdigital.h
+++ b/metawatch/metawatchdigital.h
@@ -21,6 +21,7 @@ public:
QString model() const;
void updateNotificationCount(Notification::Type type, int count);
+ void updateWeather(WeatherNotification *weather);
void displayIdleScreen();
void displayNotification(Notification *notification);
@@ -36,7 +37,8 @@ protected:
void handleWatchConnected();
void renderIdleScreen();
- void renderIdleWeather();
+ void renderIdleWeather(WeatherNotification *w = 0);
+ QImage iconForWeather(WeatherNotification *w);
void renderIdleCounts();
void renderNotification(Notification *n);