From 3ca9235ddb93b52730099164a0dc387f7a301280 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Sun, 12 May 2013 03:49:38 +0200 Subject: weather rendering in metawatchwatchlets --- metawatchwatchlets/ChatBubble.qml | 37 +++++++ metawatchwatchlets/idle-border.png | Bin 0 -> 198 bytes metawatchwatchlets/idle-call.png | Bin 0 -> 197 bytes metawatchwatchlets/idle-mail.png | Bin 0 -> 196 bytes metawatchwatchlets/idle-msg.png | Bin 0 -> 191 bytes metawatchwatchlets/idle_border.png | Bin 198 -> 0 bytes metawatchwatchlets/idle_call.png | Bin 197 -> 0 bytes metawatchwatchlets/idle_mail.png | Bin 196 -> 0 bytes metawatchwatchlets/idle_msg.png | Bin 191 -> 0 bytes .../metawatch-digital-notification.qml | 106 ++++++++++++++------- metawatchwatchlets/metawatch-digital-watchface.qml | 66 +++++++++++-- metawatchwatchlets/metawatchwatchlets.pro | 3 + metawatchwatchlets/notification-email.png | Bin 0 -> 224 bytes metawatchwatchlets/notification-message.png | Bin 0 -> 217 bytes metawatchwatchlets/notification-phone.png | Bin 0 -> 233 bytes metawatchwatchlets/notification-timer.png | Bin 0 -> 231 bytes metawatchwatchlets/weather-cloudy.png | Bin 0 -> 337 bytes metawatchwatchlets/weather-rain.png | Bin 0 -> 372 bytes metawatchwatchlets/weather-snow.png | Bin 0 -> 363 bytes metawatchwatchlets/weather-sunny.png | Bin 0 -> 333 bytes metawatchwatchlets/weather-thunderstorm.png | Bin 0 -> 370 bytes metawatchwatchlets/weather-wind.png | Bin 0 -> 289 bytes 22 files changed, 169 insertions(+), 43 deletions(-) create mode 100644 metawatchwatchlets/ChatBubble.qml create mode 100644 metawatchwatchlets/idle-border.png create mode 100644 metawatchwatchlets/idle-call.png create mode 100644 metawatchwatchlets/idle-mail.png create mode 100644 metawatchwatchlets/idle-msg.png delete mode 100644 metawatchwatchlets/idle_border.png delete mode 100644 metawatchwatchlets/idle_call.png delete mode 100644 metawatchwatchlets/idle_mail.png delete mode 100644 metawatchwatchlets/idle_msg.png create mode 100644 metawatchwatchlets/notification-email.png create mode 100644 metawatchwatchlets/notification-message.png create mode 100644 metawatchwatchlets/notification-phone.png create mode 100644 metawatchwatchlets/notification-timer.png create mode 100644 metawatchwatchlets/weather-cloudy.png create mode 100644 metawatchwatchlets/weather-rain.png create mode 100644 metawatchwatchlets/weather-snow.png create mode 100644 metawatchwatchlets/weather-sunny.png create mode 100644 metawatchwatchlets/weather-thunderstorm.png create mode 100644 metawatchwatchlets/weather-wind.png (limited to 'metawatchwatchlets') diff --git a/metawatchwatchlets/ChatBubble.qml b/metawatchwatchlets/ChatBubble.qml new file mode 100644 index 0000000..ba69e64 --- /dev/null +++ b/metawatchwatchlets/ChatBubble.qml @@ -0,0 +1,37 @@ +import QtQuick 1.0 + +Item { + id: container + height: bubble.height + 4 + + default property alias children: childContainer.children + + Image { + anchors { + top: parent.top; left: parent.left; + leftMargin: 18; + } + source: "bubble_tip.png" + z: 1 + } + + BorderImage { + id: bubble + anchors { + top: parent.top; left: parent.left; right: parent.right; + topMargin: 8; + } + border { left: 16; top: 16; right: 16; bottom: 16; } + height: childContainer.height + 16 + source: "bubble.png" + Item { + id: childContainer + height: childrenRect.height + anchors { + top: parent.top; left: parent.left; right: parent.right; + margins: 16 / 2 + } + } + } +} + diff --git a/metawatchwatchlets/idle-border.png b/metawatchwatchlets/idle-border.png new file mode 100644 index 0000000..7879647 Binary files /dev/null and b/metawatchwatchlets/idle-border.png differ diff --git a/metawatchwatchlets/idle-call.png b/metawatchwatchlets/idle-call.png new file mode 100644 index 0000000..872f681 Binary files /dev/null and b/metawatchwatchlets/idle-call.png differ diff --git a/metawatchwatchlets/idle-mail.png b/metawatchwatchlets/idle-mail.png new file mode 100644 index 0000000..6afaaaa Binary files /dev/null and b/metawatchwatchlets/idle-mail.png differ diff --git a/metawatchwatchlets/idle-msg.png b/metawatchwatchlets/idle-msg.png new file mode 100644 index 0000000..b3bbd6b Binary files /dev/null and b/metawatchwatchlets/idle-msg.png differ diff --git a/metawatchwatchlets/idle_border.png b/metawatchwatchlets/idle_border.png deleted file mode 100644 index 7879647..0000000 Binary files a/metawatchwatchlets/idle_border.png and /dev/null differ diff --git a/metawatchwatchlets/idle_call.png b/metawatchwatchlets/idle_call.png deleted file mode 100644 index 872f681..0000000 Binary files a/metawatchwatchlets/idle_call.png and /dev/null differ diff --git a/metawatchwatchlets/idle_mail.png b/metawatchwatchlets/idle_mail.png deleted file mode 100644 index 6afaaaa..0000000 Binary files a/metawatchwatchlets/idle_mail.png and /dev/null differ diff --git a/metawatchwatchlets/idle_msg.png b/metawatchwatchlets/idle_msg.png deleted file mode 100644 index b3bbd6b..0000000 Binary files a/metawatchwatchlets/idle_msg.png and /dev/null differ diff --git a/metawatchwatchlets/metawatch-digital-notification.qml b/metawatchwatchlets/metawatch-digital-notification.qml index 72f7bc9..dad8cca 100644 --- a/metawatchwatchlets/metawatch-digital-notification.qml +++ b/metawatchwatchlets/metawatch-digital-notification.qml @@ -11,64 +11,87 @@ MWPage { id: title } - Item { - id: container + MWScrollable { + id: scrollable anchors.top: title.bottom anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right - Item { + Column { + id: defaultContainer + visible: false + width: page.width + + MWLabel { + text: curNotification ? curNotification.title : "" + font.pixelSize: 16 + wrapMode: Text.WordWrap + } + MWLabel { + text: curNotification ? curNotification.body : "" + wrapMode: Text.WordWrap + } + } + + Column { id: emailContainer - visible: curNotification.type === Notification.EmailNotification - anchors.fill: parent + visible: false + width: page.width + Image { + source: "notification-email.png" + } + MWLabel { + text: curNotification ? curNotification.title : "" + font.pixelSize: 16 + wrapMode: Text.WordWrap + } MWLabel { - anchors.centerIn: parent - text: "Email" + text: curNotification ? curNotification.body : "" + wrapMode: Text.WordWrap } } - Item { + Column { id: chatContainer - visible: curNotification.type === Notification.ImNotification - anchors.fill: parent + visible: false + width: page.width MWLabel { id: chatTitle - text: curNotification.title + font.pixelSize: 16 + text: curNotification ? curNotification.title : "" } - Image { - x: 20 - y: chatBubble.y - 8 - source: "bubble_tip.png" - z: 1 - } - - BorderImage { - id: chatBubble - anchors { - top: chatTitle.bottom; left: parent.left; right: parent.right; - leftMargin: 2; topMargin: 8; rightMargin: 2; bottomMargin: 2; - } - border { left: 16; top: 16; right: 16; bottom: 16; } - height: childrenRect.height + 16 - source: "bubble.png" - + ChatBubble { + width: parent.width MWLabel { - anchors { - top: parent.top; left: parent.left; right: parent.right; - margins: 16 / 2 - } - text: curNotification.body width: parent.width + text: curNotification ? curNotification.body : "" wrapMode: Text.Wrap } } } } + states: [ + State { + when: curNotification && curNotification.type === Notification.EmailNotification + PropertyChanges { target: emailContainer; visible: true; } + }, + State { + when: curNotification && ( + curNotification.type === Notification.ImNotification || + curNotification.type === Notification.SmsNotification || + curNotification.type === Notification.MmsNotification) + PropertyChanges { target: chatContainer; visible: true; } + }, + State { + when: curNotification // Any other notification type + PropertyChanges { target: defaultContainer; visible: true; } + } + ] function handlesNotification(notification) { @@ -78,4 +101,21 @@ MWPage { function openNotification(notification) { curNotification = notification; } + + Connections { + target: watch + onButtonPressed: { + switch (button) { + case 1: + scrollable.scrollUp(); + break; + case 2: + scrollable.scrollDown(); + break; + } + } + onActiveChanged: { + scrollable.scrollTop(); + } + } } diff --git a/metawatchwatchlets/metawatch-digital-watchface.qml b/metawatchwatchlets/metawatch-digital-watchface.qml index a030bdb..535cbab 100644 --- a/metawatchwatchlets/metawatch-digital-watchface.qml +++ b/metawatchwatchlets/metawatch-digital-watchface.qml @@ -17,19 +17,42 @@ MWPage { Image { width: page.width height: 2 - source: "idle_border.png" + source: "idle-border.png" } - Item { + Row { width: page.width height: 30 - // TODO Weather stuff. + + Text { + id: labelForecast + width: 36 + anchors.verticalCenter: parent.verticalCenter + font.family: "MetaWatch Small caps 8pt" + font.pixelSize: 8 + wrapMode: Text.Wrap + } + + Image { + id: iconForecast + anchors.verticalCenter: parent.verticalCenter + width: 24 + } + + Text { + id: labelTemperature + width: 36 + anchors.verticalCenter: parent.verticalCenter + font.family: "MetaWatch Large 16pt" + font.pixelSize: 16 + wrapMode: Text.Wrap + } } Image { width: page.width height: 2 - source: "idle_border.png" + source: "idle-border.png" } Item { @@ -46,7 +69,7 @@ MWPage { Image { width: 24 height: 18 - source: "idle_call.png" + source: "idle-call.png" } Text { id: labelCalls @@ -61,7 +84,7 @@ MWPage { Image { width: 24 height: 18 - source: "idle_msg.png" + source: "idle-msg.png" } Text { id: labelMsgs @@ -76,7 +99,7 @@ MWPage { Image { width: 24 height: 18 - source: "idle_mail.png" + source: "idle-mail.png" } Text { id: labelMails @@ -89,19 +112,42 @@ MWPage { } } + function _getImageForWeather(type) { + switch (type) { + case WeatherNotification.Sunny: + return "weather-sunny.png"; + case WeatherNotification.PartlyCloudy: + case WeatherNotification.Cloudy: + case WeatherNotification.Fog: + return "weather-cloudy.png"; + case WeatherNotification.Rain: + return "weather-rain.png"; + case WeatherNotification.Thunderstorm: + return "weather-thunderstorm.png"; + case WeatherNotification.Snow: + return "weather-snow.png"; + } + } + function updateUnreadCounts() { labelCalls.text = notifications.fullCountByType(Notification.MissedCallNotification); labelMsgs.text = notifications.fullCountByType(Notification.SmsNotification) + notifications.fullCountByType(Notification.MmsNotification) + notifications.fullCountByType(Notification.ImNotification); labelMails.text = notifications.fullCountByType(Notification.EmailNotification); - console.log("unread mails = " + labelMails.text); } function updateWeather() { var weather = notifications.getMostRecentByType(Notification.WeatherNotification); - if (typeof weather !== "undefined") { - // TODO Weather stuff + if (weather) { + var unit = weather.temperatureUnits == WeatherNotification.Celsius ? "°C" : "°F"; + labelForecast.text = weather.body + labelTemperature.text = weather.temperature + unit + iconForecast.source = _getImageForWeather(weather.forecast) + } else { + labelForecast.text = "" + labelTemperature.text = "" + iconForecast.source = "" } } diff --git a/metawatchwatchlets/metawatchwatchlets.pro b/metawatchwatchlets/metawatchwatchlets.pro index af6dcdb..d7ec44e 100644 --- a/metawatchwatchlets/metawatchwatchlets.pro +++ b/metawatchwatchlets/metawatchwatchlets.pro @@ -26,3 +26,6 @@ unix:!symbian { } INSTALLS += target qml_files } + +OTHER_FILES += \ + ChatBubble.qml diff --git a/metawatchwatchlets/notification-email.png b/metawatchwatchlets/notification-email.png new file mode 100644 index 0000000..da7baaf Binary files /dev/null and b/metawatchwatchlets/notification-email.png differ diff --git a/metawatchwatchlets/notification-message.png b/metawatchwatchlets/notification-message.png new file mode 100644 index 0000000..babb117 Binary files /dev/null and b/metawatchwatchlets/notification-message.png differ diff --git a/metawatchwatchlets/notification-phone.png b/metawatchwatchlets/notification-phone.png new file mode 100644 index 0000000..ba2aa40 Binary files /dev/null and b/metawatchwatchlets/notification-phone.png differ diff --git a/metawatchwatchlets/notification-timer.png b/metawatchwatchlets/notification-timer.png new file mode 100644 index 0000000..56fd1de Binary files /dev/null and b/metawatchwatchlets/notification-timer.png differ diff --git a/metawatchwatchlets/weather-cloudy.png b/metawatchwatchlets/weather-cloudy.png new file mode 100644 index 0000000..027d79d Binary files /dev/null and b/metawatchwatchlets/weather-cloudy.png differ diff --git a/metawatchwatchlets/weather-rain.png b/metawatchwatchlets/weather-rain.png new file mode 100644 index 0000000..a0e6671 Binary files /dev/null and b/metawatchwatchlets/weather-rain.png differ diff --git a/metawatchwatchlets/weather-snow.png b/metawatchwatchlets/weather-snow.png new file mode 100644 index 0000000..9c26f88 Binary files /dev/null and b/metawatchwatchlets/weather-snow.png differ diff --git a/metawatchwatchlets/weather-sunny.png b/metawatchwatchlets/weather-sunny.png new file mode 100644 index 0000000..ede115c Binary files /dev/null and b/metawatchwatchlets/weather-sunny.png differ diff --git a/metawatchwatchlets/weather-thunderstorm.png b/metawatchwatchlets/weather-thunderstorm.png new file mode 100644 index 0000000..7f24ce6 Binary files /dev/null and b/metawatchwatchlets/weather-thunderstorm.png differ diff --git a/metawatchwatchlets/weather-wind.png b/metawatchwatchlets/weather-wind.png new file mode 100644 index 0000000..f303123 Binary files /dev/null and b/metawatchwatchlets/weather-wind.png differ -- cgit v1.2.3