From e42e7dca8df8d1e4966545894e2dde228f19b6f0 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Mon, 17 Oct 2011 15:33:23 +0200 Subject: Some weather related fixes --- metawatch/metawatch.pro | 6 +----- metawatch/metawatch.qrc | 23 +++++++++++++++++++++++ metawatch/metawatchdigital.cpp | 34 ++++++++++++++++++++-------------- metawatch/metawatchdigital.h | 13 +++++++++---- metawatch/uires.qrc | 23 ----------------------- 5 files changed, 53 insertions(+), 46 deletions(-) create mode 100644 metawatch/metawatch.qrc delete mode 100644 metawatch/uires.qrc (limited to 'metawatch') diff --git a/metawatch/metawatch.pro b/metawatch/metawatch.pro index 96518da..3435bb5 100644 --- a/metawatch/metawatch.pro +++ b/metawatch/metawatch.pro @@ -31,7 +31,7 @@ FORMS += \ metawatchsimulatorform.ui RESOURCES += \ - uires.qrc + metawatch.qrc OTHER_FILES += \ idle_sms.bmp \ @@ -73,7 +73,3 @@ unix:!symbian { } INSTALLS += target } - - - - diff --git a/metawatch/metawatch.qrc b/metawatch/metawatch.qrc new file mode 100644 index 0000000..821a3dc --- /dev/null +++ b/metawatch/metawatch.qrc @@ -0,0 +1,23 @@ + + + idle_call.bmp + idle_gmail.bmp + idle_sms.bmp + weather_cloudy.bmp + weather_rain.bmp + weather_snow.bmp + weather_sunny.bmp + weather_thunderstorm.bmp + weather_wind.bmp + email.bmp + message.bmp + phone.bmp + play.bmp + timer.bmp + + + metawatch_8pt_5pxl_CAPS.ttf + metawatch_8pt_7pxl_CAPS.ttf + metawatch_16pt_11pxl.ttf + + diff --git a/metawatch/metawatchdigital.cpp b/metawatch/metawatchdigital.cpp index 8a81f97..f35eab0 100644 --- a/metawatch/metawatchdigital.cpp +++ b/metawatch/metawatchdigital.cpp @@ -4,7 +4,8 @@ using namespace sowatch; MetaWatchDigital::MetaWatchDigital(const QBluetoothAddress& address, QSettings* settings, QObject *parent) : MetaWatch(address, settings, parent), - _nMails(0), _nCalls(0), _nIms(0), _nSms(0), _nMms(0) + _nMails(0), _nCalls(0), _nIms(0), _nSms(0), _nMms(0), + _wForecast(WeatherNotification::UnknownWeather) { QImage baseImage(screenWidth, screenHeight, QImage::Format_MonoLSB); baseImage.setColor(0, QColor(Qt::white).rgb()); @@ -75,8 +76,16 @@ void MetaWatchDigital::updateNotificationCount(Notification::Type type, int coun void MetaWatchDigital::updateWeather(WeatherNotification *weather) { + if (weather) { + _wForecast = weather->forecast(); + _wBody = weather->body(); + _wTemperature = weather->temperature(); + _wMetric = weather->temperatureUnits() == WeatherNotification::Celsius; + } else { + _wForecast = WeatherNotification::UnknownWeather; + } if (isConnected()) { - renderIdleWeather(weather); + renderIdleWeather(); } } @@ -159,7 +168,7 @@ void MetaWatchDigital::renderIdleScreen() renderIdleCounts(); } -void MetaWatchDigital::renderIdleWeather(WeatherNotification* w) +void MetaWatchDigital::renderIdleWeather() { _paintMode = IdleMode; QFont sf("MetaWatch Small caps 8pt", 6); @@ -171,35 +180,32 @@ void MetaWatchDigital::renderIdleWeather(WeatherNotification* w) p.fillRect(0, systemAreaHeight + 6, screenWidth, systemAreaHeight - 6, Qt::white); - if (w) { - QImage icon = iconForWeather(w); - bool metric = w->temperatureUnits() == WeatherNotification::Celsius; - QString unit = QString::fromUtf8(metric ? "°C" : "°F"); + if (_wForecast != WeatherNotification::UnknownWeather) { + QImage icon = iconForWeather(_wForecast); + QString unit = QString::fromUtf8(_wMetric ? "°C" : "°F"); QRect bodyRect(3, systemAreaHeight + 6, 36, systemAreaHeight - 6); QTextOption option; option.setAlignment(Qt::AlignLeft | Qt::AlignVCenter); option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); p.setFont(sf); - p.drawText(bodyRect, w->body(), option); + p.drawText(bodyRect, _wBody, option); p.drawImage(36, systemAreaHeight + 6, icon); p.setFont(lf); - p.drawText(63, systemAreaHeight + 23, QString("%1 %2").arg(w->temperature()).arg(unit)); - } else { - p.setFont(sf); - p.drawText(32, systemAreaHeight + 18, tr("No data")); + p.drawText(63, systemAreaHeight + 23, QString("%1 %2").arg(_wTemperature).arg(unit)); } _paintMode = _currentMode; } -QImage MetaWatchDigital::iconForWeather(WeatherNotification *w) +QImage MetaWatchDigital::iconForWeather(WeatherNotification::WeatherType w) { - switch (w->forecast()) { + switch (w) { case WeatherNotification::Sunny: return QImage(QString(":/metawatch/graphics/weather_sunny.bmp")); + case WeatherNotification::PartlyCloudy: case WeatherNotification::Cloudy: case WeatherNotification::Fog: return QImage(QString(":/metawatch/graphics/weather_cloudy.bmp")); diff --git a/metawatch/metawatchdigital.h b/metawatch/metawatchdigital.h index a528eb2..7ce195b 100644 --- a/metawatch/metawatchdigital.h +++ b/metawatch/metawatchdigital.h @@ -31,14 +31,19 @@ public: void update(Mode mode, const QList& rects = QList()); protected: - // Notifications: Unread count - uint _nMails, _nCalls, _nIms, _nSms, _nMms; + // Idle screen: notifications unread count + ushort _nMails, _nCalls, _nIms, _nSms, _nMms; + // Idle screen: weather information + WeatherNotification::WeatherType _wForecast; + QString _wBody; + short _wTemperature; + bool _wMetric; void handleWatchConnected(); void renderIdleScreen(); - void renderIdleWeather(WeatherNotification *w = 0); - QImage iconForWeather(WeatherNotification *w); + void renderIdleWeather(); + QImage iconForWeather(WeatherNotification::WeatherType w); void renderIdleCounts(); void renderNotification(Notification *n); diff --git a/metawatch/uires.qrc b/metawatch/uires.qrc deleted file mode 100644 index 821a3dc..0000000 --- a/metawatch/uires.qrc +++ /dev/null @@ -1,23 +0,0 @@ - - - idle_call.bmp - idle_gmail.bmp - idle_sms.bmp - weather_cloudy.bmp - weather_rain.bmp - weather_snow.bmp - weather_sunny.bmp - weather_thunderstorm.bmp - weather_wind.bmp - email.bmp - message.bmp - phone.bmp - play.bmp - timer.bmp - - - metawatch_8pt_5pxl_CAPS.ttf - metawatch_8pt_7pxl_CAPS.ttf - metawatch_16pt_11pxl.ttf - - -- cgit v1.2.3