Merge lp:~martin-borho/ubuntu-weather-app/conditional-weather into lp:ubuntu-weather-app/obsolete.trunk

Proposed by David Planella
Status: Merged
Approved by: David Planella
Approved revision: 203
Merged at revision: 202
Proposed branch: lp:~martin-borho/ubuntu-weather-app/conditional-weather
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 896 lines (+482/-247)
9 files modified
components/AddLocationSheet.qml (+0/-1)
components/CurrentWeather.qml (+66/-233)
components/CurrentWeatherDetail.qml (+122/-0)
components/CurrentWeatherFront.qml (+76/-0)
components/LocationTab.qml (+97/-3)
components/ScrollingArea.qml (+112/-0)
components/WeatherApi.js (+8/-8)
key.js (+0/-1)
tests/autopilot/ubuntu_weather_app/tests/test_settings.py (+1/-1)
To merge this branch: bzr merge lp:~martin-borho/ubuntu-weather-app/conditional-weather
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
David Planella Approve
Review via email: mp+207152@code.launchpad.net

Commit message

Initial tablet design of the Weather app.

Description of the change

Initial tablet design of the Weather app.

I'm proposing the branch on behalf of Martin (the original author) to advance work in terms of landing this for the MWC release today.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

FAILED: Continuous integration, rev:203
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~martin-borho/ubuntu-weather-app/conditional-weather/+merge/207152/+edit-commit-message

http://91.189.93.70:8080/job/ubuntu-weather-app-ci/143/
Executed test runs:
    SUCCESS: http://91.189.93.70:8080/job/ubuntu-weather-app-raring-amd64-ci/141
    SUCCESS: http://91.189.93.70:8080/job/ubuntu-weather-app-saucy-amd64-ci/141
    SUCCESS: http://91.189.93.70:8080/job/ubuntu-weather-app-trusty-amd64-ci/55

Click here to trigger a rebuild:
http://91.189.93.70:8080/job/ubuntu-weather-app-ci/143/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
David Planella (dpm) wrote :

Looks awesome to me!

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'components/AddLocationSheet.qml'
--- components/AddLocationSheet.qml 2014-02-08 13:25:26 +0000
+++ components/AddLocationSheet.qml 2014-02-19 12:16:52 +0000
@@ -37,7 +37,6 @@
37 Cities.preList.forEach(function(loc) {37 Cities.preList.forEach(function(loc) {
38 citiesModel.append(loc)38 citiesModel.append(loc)
39 })39 })
40 Theme.palette.normal.backgroundText = "#656565" //color: Theme.palette.normal.baseText
41 }40 }
4241
43 Connections {42 Connections {
4443
=== modified file 'components/CurrentWeather.qml'
--- components/CurrentWeather.qml 2014-02-15 14:31:10 +0000
+++ components/CurrentWeather.qml 2014-02-19 12:16:52 +0000
@@ -18,6 +18,7 @@
18 */18 */
19import QtQuick 2.019import QtQuick 2.0
20import Ubuntu.Components 0.120import Ubuntu.Components 0.1
21import Ubuntu.Layouts 0.1
21import "./" as Components22import "./" as Components
2223
23Rectangle {24Rectangle {
@@ -43,7 +44,7 @@
43 property string speedScale: (mainView.settings["wind_units"] === "mph") ? "mph" : "km/h"44 property string speedScale: (mainView.settings["wind_units"] === "mph") ? "mph" : "km/h"
44 property string precipScale: (mainView.settings["precip_units"] === "in") ? "in" : "mm"45 property string precipScale: (mainView.settings["precip_units"] === "in") ? "in" : "mm"
4546
46 property NumberAnimation appearAnimation: currentConditionIcon.appearAnimation47 property NumberAnimation appearAnimation: frontrect.conditionIcon.appearAnimation
4748
48 width: parent.width49 width: parent.width
49 anchors.fill: parent50 anchors.fill: parent
@@ -77,7 +78,42 @@
77 onToggle: {flipable.flipped = !flipable.flipped}78 onToggle: {flipable.flipped = !flipable.flipped}
78 }79 }
7980
80 Flipable {81 Layouts {
82 objectName: "WeatherLayout"
83 id: layoutsCurrent
84 anchors.fill: parent
85 layouts: [
86 ConditionalLayout {
87 name: "WeatherItem"
88 when: layouts.width > units.gu(80)
89 Rectangle {
90 color: "transparent"
91 anchors.fill: parent
92 CurrentWeatherFront {
93 id: frontrect
94 shapeSize: units.gu(18)
95 anchors {
96 horizontalCenter: parent.horizontalCenter
97 verticalCenter: parent.verticalCenter
98 verticalCenterOffset: -(parent.height*0.1);
99 }
100 }
101 CurrentWeatherDetail {
102 id: backrect
103 height: parent.height/2
104 shapeSize: units.gu(14)
105 gridColumns: 4
106 anchors {
107 horizontalCenter: parent.horizontalCenter
108 verticalCenter: parent.verticalCenter
109 verticalCenterOffset: (parent.height*0.2);
110 }
111 }
112 Components.ScrollingArea {}
113 }
114 }
115 ]
116 Flipable {
81 id: flipable117 id: flipable
82 height: parent.height118 height: parent.height
83 width:parent.width119 width:parent.width
@@ -85,231 +121,28 @@
85 anchors.verticalCenterOffset: -units.gu(3)121 anchors.verticalCenterOffset: -units.gu(3)
86 property bool flipped: false122 property bool flipped: false
87123
88 MouseArea {124 Components.ScrollingArea {}
89 id: flippedarea125
90 property bool wasHourlyScrolled: false126 back: CurrentWeatherDetail {
91 property int startY: 0127 id: backrect
92 property double startTime: 0128 Layouts.item: "back"
93 property int sectionHeight: flippedarea.height/hourly.count129 anchors.fill: parent
94 property int lastIndex: -1130 }
95 anchors.fill: parent131
96 anchors.top: parent.top132 front: CurrentWeatherFront {
97 anchors.topMargin: units.gu(3.5)133 id: frontrect
98 onClicked: {134 anchors.fill: parent
99 mouse.accepted = true;135 Layouts.item: "front"
100 if(!wasHourlyScrolled) {136 }
101 var movement = Math.round(startY-mouse.y);
102 if(movement < 10 && movement > -10) {
103 // flip to detail data
104 flipable.flipped = !flipable.flipped;
105 } else {
106 // switch to next/prevoius day
107 if(movement >= 10) {
108 dailyForecastList.incrementCurrentIndex();
109 } else if(movement <= -10) {
110 dailyForecastList.decrementCurrentIndex();
111 }
112 dailyForecastList.positionViewAtIndex(dailyForecastList.currentIndex,ListView.SnapPosition);
113 flipable.flipped = false;
114 }
115 }
116 }
117 onPressed: {
118 wasHourlyScrolled = false;
119 startY = mouse.y;
120 startTime = new Date().getTime()
121 }
122 onPositionChanged: {
123 mouse.accepted = true;
124 var distance = (parent.height - mouse.y),
125 now = new Date().getTime(),
126 speed = distance/(now-startTime);
127 if(speed < 2.3 && !flipable.flipped) {
128 // slow scrolling detected
129 var movement = Math.round(distance/sectionHeight);
130 if(movement > 0) {
131 var hourIndex = movement-1,
132 currentHour = currentWeather.hourly.get(hourIndex);
133 if( currentHour !== undefined && (lastIndex < 0 || lastIndex !== hourIndex)) {
134 wasHourlyScrolled = true;
135 currentConditionIcon.condition = currentWeather.hourly.get(hourIndex).icon;
136 var temp = currentWeather.hourly.get(hourIndex)[mainView.settings["units"]].temp;
137 currentConditionTempContent.currentTemp = temp;
138 adjustBackground(Math.round(temp));
139 var dateData = currentWeather.hourly.get(hourIndex).date;
140 var dateTime = new Date(dateData.year, dateData.month, dateData.date, dateData.hours, dateData.minutes)
141 // TRANSLATORS: this is a date to which a time of the day will be appended
142 var dateTimeString = Qt.formatDateTime(dateTime, i18n.tr('dddd, dd MMMM')) + ' - ' + Qt.formatTime(dateTime);
143 dateComponent.dateString = dateTimeString;
144 dateComponent.renderText();
145 hourlyScrollEffect.start();
146 lastIndex = hourIndex;
147 }
148 }
149 }
150 }
151 onReleased: {
152 if(wasHourlyScrolled) {
153 // reset temp and date to current day
154 var currentDayData = dayForecastModel.get(dailyForecastList.currentIndex);
155 currentConditionIcon.condition = currentDayData.condIcon;
156 currentConditionIcon.appearAnimation.start();
157 currentConditionTempContent.currentTemp = currentDayData.temp;
158 adjustBackground(Math.round(currentDayData.temp));
159 dateComponent.dateString = currentDayData.date;
160 dateComponent.renderText();
161 lastIndex = -1;
162 }
163 }
164 }
165
166 back:
167 Rectangle {
168 id: backrect
169 anchors.fill: parent
170 color: "transparent"
171
172 Column {
173 id: leftColumn
174 anchors {
175 horizontalCenter: parent.horizontalCenter
176 horizontalCenterOffset: units.gu(-8)
177 verticalCenter: parent.verticalCenter
178 }
179 spacing: units.gu(1)
180
181 UbuntuShape {
182 color: "#10000000"
183 radius: "medium"
184
185 width: units.gu(15)
186 height: units.gu(15)
187
188 Components.WeatherDetailComponent {
189 value: currentWeather.humidity
190 measure: i18n.tr("Humidity")
191 unit: i18n.tr('%')
192 anchors.fill: parent
193 }
194 }
195
196 UbuntuShape {
197 color: "#10000000"
198 radius: "medium"
199
200 width: units.gu(15)
201 height: units.gu(15)
202
203 Components.WeatherDetailComponent {
204 objectName: "WindSpeedValue"
205 value: currentWeather.windSpeed
206 measure: i18n.tr("Wind speed")
207 unit: currentWeather.speedScale + " " + currentWeather.windDir
208 anchors.fill: parent
209 }
210 }
211 }
212
213 Column {
214 id: rightColumn
215 anchors {
216 horizontalCenter: parent.horizontalCenter
217 horizontalCenterOffset: units.gu(8)
218 verticalCenter: parent.verticalCenter
219 }
220 spacing: units.gu(1)
221
222 UbuntuShape {
223 color: "#10000000"
224 radius: "medium"
225
226 width: units.gu(15)
227 height: units.gu(15)
228
229 Components.WeatherDetailComponent {
230 value: (currentWeather.propPrecip !== "") ? currentWeather.propPrecip: currentWeather.pressure
231 measure: (currentWeather.propPrecip !== "") ? getProcipLabel(): i18n.tr("Pressure")
232 unit: (currentWeather.propPrecip !== "") ? i18n.tr("Percent") : i18n.tr("mbar")
233 anchors.fill: parent
234 }
235 }
236
237 UbuntuShape {
238 color: "#10000000"
239 radius: "medium"
240
241 width: units.gu(15)
242 height: units.gu(15)
243
244 Components.WeatherDetailComponent {
245 objectName: "PrecipitationValue"
246 value: (currentWeather.uvIndex !== "") ? currentWeather.uvIndex : currentWeather.precipitation
247 measure: (currentWeather.uvIndex !== "") ? i18n.tr("UV index"): i18n.tr("Precipitation")
248 unit: (currentWeather.uvIndex !== "") ? getUvLabel() : i18n.tr("Percent");
249 anchors.fill: parent
250 }
251 }
252 }
253 }
254
255 front:
256 Rectangle {
257 id: frontrect
258 color: "transparent"
259 anchors.fill: parent
260
261 UbuntuShape {
262 id: currentCondition
263 color: "#10000000"
264 radius: "medium"
265
266 width: units.gu(15)
267 height: units.gu(15)
268 anchors {
269 horizontalCenter: parent.horizontalCenter
270 horizontalCenterOffset: units.gu(-8)
271 verticalCenter: parent.verticalCenter
272 }
273
274 Components.WeatherConditionIconComponent {
275 id: currentConditionIcon
276 anchors.centerIn: parent
277 anchors.margins: units.gu(1)
278 condition: currentWeather.icon
279 }
280 }
281
282 UbuntuShape {
283 id: currentConditionTemp
284 color: "#10000000"
285 radius: "medium"
286 width: units.gu(15)
287 height: units.gu(15)
288 anchors {
289 horizontalCenter: parent.horizontalCenter
290 horizontalCenterOffset: units.gu(8)
291 verticalCenter: parent.verticalCenter
292 }
293
294 Components.WeatherTemperatureComponent {
295 id: currentConditionTempContent
296 currentTemp: currentWeather.currentTemp
297 tempScale: currentWeather.tempScale
298 minTemp: currentWeather.minTemp
299 maxTemp: currentWeather.maxTemp
300 anchors.fill: parent
301 }
302 }
303 }
304137
305 states:[138 states:[
306 State {139 State {
307 name: "back"140 name: "back"
308 when: flipable.flipped141 when: flipable.flipped && layouts.width < units.gu(80)
309 },142 },
310 State {143 State {
311 name: "front"144 name: "front"
312 when: !flipable.flipped145 when: !flipable.flipped && layouts.width < units.gu(80)
313 }146 }
314 ]147 ]
315148
@@ -318,10 +151,10 @@
318 to:"back"151 to:"back"
319 SequentialAnimation{152 SequentialAnimation{
320 ParallelAnimation {153 ParallelAnimation {
321 NumberAnimation { target: currentCondition; property: "anchors.verticalCenterOffset"; duration: UbuntuAnimation.SlowDuration; to: units.gu(8); easing: UbuntuAnimation.StandardEasing }154 NumberAnimation { target: frontrect.condition; property: "anchors.verticalCenterOffset"; duration: UbuntuAnimation.SlowDuration; to: units.gu(8); easing: UbuntuAnimation.StandardEasing }
322 NumberAnimation { target: currentConditionTemp; property: "anchors.verticalCenterOffset"; duration: UbuntuAnimation.SlowDuration; to: units.gu(-8); easing: UbuntuAnimation.StandardEasing }155 NumberAnimation { target: frontrect.conditionTemp; property: "anchors.verticalCenterOffset"; duration: UbuntuAnimation.SlowDuration; to: units.gu(-8); easing: UbuntuAnimation.StandardEasing }
323 NumberAnimation {target: currentConditionIcon; property: "opacity"; to:0; duration: UbuntuAnimation.SlowDuration}156 NumberAnimation {target: frontrect.conditionIcon; property: "opacity"; to:0; duration: UbuntuAnimation.SlowDuration}
324 NumberAnimation {target: currentConditionTempContent; property: "opacity"; to:0; duration: UbuntuAnimation.SlowDuration}157 NumberAnimation {target: frontrect.conditionTempContent; property: "opacity"; to:0; duration: UbuntuAnimation.SlowDuration}
325 }158 }
326 ParallelAnimation {159 ParallelAnimation {
327 NumberAnimation {target: backrect; property: "opacity"; to:1; duration: UbuntuAnimation.SlowDuration}160 NumberAnimation {target: backrect; property: "opacity"; to:1; duration: UbuntuAnimation.SlowDuration}
@@ -339,10 +172,10 @@
339 }else{172 }else{
340 backrect.opacity = 0;173 backrect.opacity = 0;
341 frontrect.opacity = 1;174 frontrect.opacity = 1;
342 currentConditionIcon.opacity = 1;175 frontrect.conditionIcon.opacity = 1;
343 currentConditionTempContent.opacity = 1;176 frontrect.conditionTempContent.opacity = 1;
344 currentCondition.anchors.verticalCenterOffset = 0;177 frontrect.condition.anchors.verticalCenterOffset = 0;
345 currentConditionTemp.anchors.verticalCenterOffset = 0;178 frontrect.conditionTemp.anchors.verticalCenterOffset = 0;
346 }179 }
347 }180 }
348 }181 }
@@ -357,12 +190,12 @@
357 NumberAnimation {target: backrect; property: "opacity"; to:0; duration: UbuntuAnimation.SlowDuration}190 NumberAnimation {target: backrect; property: "opacity"; to:0; duration: UbuntuAnimation.SlowDuration}
358 }191 }
359 ParallelAnimation{192 ParallelAnimation{
360 NumberAnimation {target: currentConditionIcon; property: "opacity"; to:1; duration: UbuntuAnimation.SlowDuration}193 NumberAnimation {target: frontrect.conditionIcon; property: "opacity"; to:1; duration: UbuntuAnimation.SlowDuration}
361 NumberAnimation {target: currentConditionTempContent; property: "opacity"; to:1; duration: UbuntuAnimation.SlowDuration}194 NumberAnimation {target: frontrect.conditionTempContent; property: "opacity"; to:1; duration: UbuntuAnimation.SlowDuration}
362 NumberAnimation { target: currentCondition; property: "anchors.verticalCenterOffset"; duration: UbuntuAnimation.SlowDuration; to: 0; easing: UbuntuAnimation.StandardEasingReverse }195 NumberAnimation { target: frontrect.condition; property: "anchors.verticalCenterOffset"; duration: UbuntuAnimation.SlowDuration; to: 0; easing: UbuntuAnimation.StandardEasingReverse }
363 NumberAnimation { target: currentConditionTemp; property: "anchors.verticalCenterOffset"; duration: UbuntuAnimation.SlowDuration; to: 0; easing: UbuntuAnimation.StandardEasingReverse }196 NumberAnimation { target: frontrect.conditionTemp; property: "anchors.verticalCenterOffset"; duration: UbuntuAnimation.SlowDuration; to: 0; easing: UbuntuAnimation.StandardEasingReverse }
364 }197 }
365 }198 }
366 }199 }
367 }200 }
368201}
369202
=== added file 'components/CurrentWeatherDetail.qml'
--- components/CurrentWeatherDetail.qml 1970-01-01 00:00:00 +0000
+++ components/CurrentWeatherDetail.qml 2014-02-19 12:16:52 +0000
@@ -0,0 +1,122 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Raúl Yeguas <neokore@gmail.com>
17 * Martin Borho <martin@borho.net>
18 */
19import QtQuick 2.0
20import Ubuntu.Components 0.1
21import Ubuntu.Layouts 0.1
22import "./" as Components
23
24Rectangle {
25 id: backrect
26 color: "transparent"
27 property int shapeSize: units.gu(15)
28 property int gridColumns: 2
29
30 function getProcipLabel() {
31 // show the right Label, depending on precipitation type
32 return (currentWeather.precipType === "snow") ? i18n.tr("Chance of Snow") : i18n.tr("Chance of Rain")
33 }
34
35 function getUvLabel() {
36 var label = "",
37 uvInt = parseInt(currentWeather.uvIndex);
38 if(uvInt <= 2) {
39 label = i18n.tr("Low");
40 } else if(uvInt <= 5) {
41 label = i18n.tr("Moderate");
42 } else if(uvInt <= 8) {
43 label = i18n.tr("High");
44 } else if(uvInt <= 10) {
45 label = i18n.tr("Very high");
46 } else {
47 label = i18n.tr("Extreme");
48 }
49 return label;
50 }
51
52 Grid {
53 columns: gridColumns
54 spacing: units.gu(1)
55 anchors {
56 horizontalCenter: parent.horizontalCenter
57 verticalCenter: parent.verticalCenter
58 }
59
60 UbuntuShape {
61 color: "#10000000"
62 radius: "medium"
63
64 width: shapeSize
65 height: shapeSize
66
67 Components.WeatherDetailComponent {
68 value: currentWeather.humidity
69 measure: i18n.tr("Humidity")
70 unit: i18n.tr('%')
71 anchors.fill: parent
72 }
73 }
74
75 UbuntuShape {
76 color: "#10000000"
77 radius: "medium"
78
79 width: shapeSize
80 height: shapeSize
81
82 Components.WeatherDetailComponent {
83 objectName: "WindSpeedValue"
84 value: currentWeather.windSpeed
85 measure: i18n.tr("Wind speed")
86 unit: currentWeather.speedScale + " " + currentWeather.windDir
87 anchors.fill: parent
88 }
89 }
90
91 UbuntuShape {
92 color: "#10000000"
93 radius: "medium"
94
95 width: shapeSize
96 height: shapeSize
97
98 Components.WeatherDetailComponent {
99 value: (currentWeather.propPrecip !== "") ? currentWeather.propPrecip: currentWeather.pressure
100 measure: (currentWeather.propPrecip !== "") ? getProcipLabel(): i18n.tr("Pressure")
101 unit: (currentWeather.propPrecip !== "") ? i18n.tr("Percent") : i18n.tr("mbar")
102 anchors.fill: parent
103 }
104 }
105
106 UbuntuShape {
107 color: "#10000000"
108 radius: "medium"
109
110 width: shapeSize
111 height: shapeSize
112
113 Components.WeatherDetailComponent {
114 objectName: "PrecipitationValue"
115 value: (currentWeather.uvIndex !== "") ? currentWeather.uvIndex : currentWeather.precipitation
116 measure: (currentWeather.uvIndex !== "") ? i18n.tr("UV index"): i18n.tr("Precipitation")
117 unit: (currentWeather.uvIndex !== "") ? getUvLabel() : currentWeather.precipScale;
118 anchors.fill: parent
119 }
120 }
121 }
122}
0123
=== added file 'components/CurrentWeatherFront.qml'
--- components/CurrentWeatherFront.qml 1970-01-01 00:00:00 +0000
+++ components/CurrentWeatherFront.qml 2014-02-19 12:16:52 +0000
@@ -0,0 +1,76 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Raúl Yeguas <neokore@gmail.com>
17 * Martin Borho <martin@borho.net>
18 */
19import QtQuick 2.0
20import Ubuntu.Components 0.1
21import Ubuntu.Layouts 0.1
22import "./" as Components
23
24Rectangle {
25 id: frontrect
26 color: "transparent"
27
28 property alias condition: currentCondition
29 property alias conditionIcon: currentConditionIcon
30 property alias conditionTempContent: currentConditionTempContent
31 property alias conditionTemp: currentConditionTemp
32 property int shapeSize: units.gu(15)
33
34 UbuntuShape {
35 id: currentCondition
36 color: "#10000000"
37 radius: "medium"
38
39 width: shapeSize
40 height: shapeSize
41 anchors {
42 horizontalCenter: parent.horizontalCenter
43 horizontalCenterOffset: -(shapeSize*0.53)//units.gu(-8)
44 verticalCenter: parent.verticalCenter
45 }
46
47 Components.WeatherConditionIconComponent {
48 id: currentConditionIcon
49 anchors.centerIn: parent
50 anchors.margins: units.gu(1)
51 condition: currentWeather.icon
52 }
53 }
54
55 UbuntuShape {
56 id: currentConditionTemp
57 color: "#10000000"
58 radius: "medium"
59 width: shapeSize
60 height: shapeSize
61 anchors {
62 horizontalCenter: parent.horizontalCenter
63 horizontalCenterOffset: shapeSize*0.53//units.gu(8)
64 verticalCenter: parent.verticalCenter
65 }
66
67 Components.WeatherTemperatureComponent {
68 id: currentConditionTempContent
69 currentTemp: Math.round(currentWeather.currentTemp)
70 tempScale: currentWeather.tempScale
71 minTemp: Math.round(currentWeather.minTemp)
72 maxTemp: Math.round(currentWeather.maxTemp)
73 anchors.fill: parent
74 }
75 }
76}
077
=== modified file 'components/LocationTab.qml'
--- components/LocationTab.qml 2014-02-15 14:31:10 +0000
+++ components/LocationTab.qml 2014-02-19 12:16:52 +0000
@@ -19,6 +19,8 @@
19import QtQuick 2.019import QtQuick 2.0
20import Ubuntu.Components.Popups 0.120import Ubuntu.Components.Popups 0.1
21import Ubuntu.Components 0.121import Ubuntu.Components 0.1
22import Ubuntu.Components.ListItems 0.1 as ListItem
23import Ubuntu.Layouts 0.1
22import QtFeedback 5.024import QtFeedback 5.0
2325
24Tab {26Tab {
@@ -128,13 +130,103 @@
128 id: dayForecastModel130 id: dayForecastModel
129 }131 }
130132
133 Layouts {
134 objectName: "WeatherLayout"
135 id: layouts
136 anchors.fill: parent
137 layouts: [
138 ConditionalLayout {
139 name: "WeatherData"
140 when: layouts.width > units.gu(80)
141 Rectangle {
142 anchors.fill: parent
143 color: "transparent"
144 ItemLayout {
145 item: "ForecastList"
146 width: parent.width*0.625
147 height:parent.height
148 }
149 ItemLayout {
150 item: "TabFooter"
151 width: mainView.width*0.625
152 height: units.gu(8)
153 anchors.bottom: parent.bottom
154 clip: true
155 }
156 Rectangle {
157 width: parent.width*0.375
158 height:parent.height
159 anchors.right: parent.right
160 anchors.top: parent.top
161 color: "black"
162 opacity: 0.3
163 }
164 Rectangle {
165 id: sideLabel
166 anchors.top: parent.top
167 anchors.right: parent.right
168 width: parent.width*0.375
169 height: units.gu(6)
170 color: "transparent"
171 Label {
172 text: i18n.tr("Forecast")
173 fontSize: "large"
174 anchors.left:parent.left
175 anchors.leftMargin: units.gu(3)
176 anchors.verticalCenter: parent.verticalCenter
177 }
178 }
179 ListView {
180 id: locationDailySide
181 width: (parent.width*0.375)-units.gu(1)
182 height: parent.height-sideLabel.height-units.gu(9)
183 anchors.right: parent.right
184 anchors.top: sideLabel.bottom
185 model:dayForecastModel
186 clip: true
187 // TODO doubled code, to refactor
188 property var conditionIcon: {
189 "clear_day": "02",
190 "clear_night": "12",
191 "few_clouds_day": "05",
192 "few_clouds_night": "04",
193 "scattered_clouds_day": "05",
194 "scattered_clouds_night": "04",
195 "broken_clouds_day": "03",
196 "broken_clouds_night": "03",
197 "mostly_cloudy": "03",
198 "shower_rain_day": "09",
199 "shower_rain_night": "09",
200 "rain_day": "09",
201 "rain_night": "09",
202 "thunderstorm_day": "13",
203 "thunderstorm_night": "13",
204 "snow_day": "14",
205 "snow_night": "14",
206 "chance_snow_day": "11",
207 "chances_now_night": "11",
208 "snow_shower": "11",
209 "mist_day": "06",
210 "mist_night": "06"
211 }
212 delegate: ListItem.Subtitled {
213 subText: "H:"+Math.round(temp)+" L:"+Math.round(tempMin)
214 text: date
215 //selected: (dailyForecastList.currentIndex == index)
216 iconSource: "../resources/images/"+locationDailySide.conditionIcon[dayForecastModel.get(index).condIcon]+".png"
217 onClicked: { dailyForecastList.currentIndex = index }
218 }
219 }
220 }
221 }
222 ]
131 ListView {223 ListView {
132 id: dailyForecastList224 id: dailyForecastList
133 objectName: "DailyForecastList"225 objectName: "DailyForecastList"
134 width: parent.width226 width: parent.width
135 height:parent.height227 height:parent.height
136 model:dayForecastModel228 model:dayForecastModel
137229 Layouts.item: "ForecastList"
138 onCurrentIndexChanged: {230 onCurrentIndexChanged: {
139 if(visible) {231 if(visible) {
140 var data = dayForecastModel.get(currentIndex)232 var data = dayForecastModel.get(currentIndex)
@@ -195,11 +287,13 @@
195 }287 }
196 LastUpdatedComponent{288 LastUpdatedComponent{
197 id: lastUpdatedComponent289 id: lastUpdatedComponent
198 anchors.bottom: (tabFooter.visible) ? tabFooter.top : parent.bottom290 anchors.bottom: parent.bottom
291 anchors.bottomMargin: (tabFooter.visible) ? units.gu(8) : 0
199 }292 }
200 TabFooter {293 TabFooter {
201 id:tabFooter294 id:tabFooter
202 objectName: "TabFooter"295 objectName: "TabFooter"
296 Layouts.item: "TabFooter"
203 visible: !dataProviderLogo.visible297 visible: !dataProviderLogo.visible
204 }298 }
205 Image {299 Image {
@@ -236,7 +330,7 @@
236 }330 }
237 } 331 }
238 }332 }
239333 }
240334
241 tools: ToolbarItems {335 tools: ToolbarItems {
242 id: pageTools336 id: pageTools
243337
=== added file 'components/ScrollingArea.qml'
--- components/ScrollingArea.qml 1970-01-01 00:00:00 +0000
+++ components/ScrollingArea.qml 2014-02-19 12:16:52 +0000
@@ -0,0 +1,112 @@
1import QtQuick 2.0
2
3MouseArea {
4 id: flippedarea
5 property bool wasHourlyScrolled: false
6 property int startY: 0
7 property double startTime: 0
8 property int sectionHeight: flippedarea.height/hourly.count
9 property int lastIndex: -1
10 anchors.fill: parent
11 anchors.top: parent.top
12 anchors.topMargin: units.gu(3.5)
13 onClicked: {
14 mouse.accepted = true;
15 if(!wasHourlyScrolled) {
16 var movement = Math.round(startY-mouse.y);
17 if(movement < 10 && movement > -10) {
18 // flip to detail data
19 flipable.flipped = !flipable.flipped;
20 } else {
21 // switch to next/prevoius day
22 if(movement >= 10) {
23 dailyForecastList.incrementCurrentIndex();
24 } else if(movement <= -10) {
25 dailyForecastList.decrementCurrentIndex();
26 }
27 dailyForecastList.positionViewAtIndex(dailyForecastList.currentIndex,ListView.SnapPosition);
28 flipable.flipped = false;
29 }
30 }
31 }
32 onPressed: {
33 wasHourlyScrolled = false;
34 startY = mouse.y;
35 startTime = new Date().getTime()
36 }
37 onPositionChanged: {
38 mouse.accepted = true;
39 var distance = (parent.height - mouse.y),
40 now = new Date().getTime(),
41 speed = distance/(now-startTime);
42 if(speed < 2.3 && !flipable.flipped) {
43 // slow scrolling detected
44 var movement = Math.round(distance/sectionHeight);
45 if(movement > 0) {
46 var hourIndex = movement-1,
47 currentHour = currentWeather.hourly.get(hourIndex);
48 if( currentHour !== undefined && (lastIndex < 0 || lastIndex !== hourIndex)) {
49 wasHourlyScrolled = true;
50 frontrect.conditionIcon.condition = currentHour.icon;
51 var temp = currentHour[mainView.settings["units"]].temp;
52 frontrect.conditionTempContent.currentTemp = temp;
53 adjustBackground(Math.round(temp));
54 // adjust detail data
55 currentWeather.humidity = currentHour.humidity
56 currentWeather.windSpeed = currentHour[mainView.settings["units"]].windSpeed
57 currentWeather.windDir = currentHour.windDir
58 if(currentHour.propPrecip !== undefined && currentHour.propPrecip !== "") {
59 currentWeather.propPrecip = currentHour.propPrecip;
60 } else {
61 currentWeather.pressure = currentHour.pressure
62 }
63 if(currentHour.uvIndex !== undefined && currentHour.uvIndex !== "") {
64 currentWeather.uvIndex = currentHour.uvIndex;
65 } else {
66 var precip_units = (mainView.settings.precip_units === 'in') ? 'imperial' : 'metric';
67 currentWeather.precipitation = +(currentHour[precip_units].rain || currentHour[precip_units].snow || 0).toFixed(2)
68 }
69 // adjust date data
70 var dateData = currentHour.date;
71 var dateTime = new Date(dateData.year, dateData.month, dateData.date, dateData.hours, dateData.minutes)
72 // TRANSLATORS: this is a date to which a time of the day will be appended
73 var dateTimeString = Qt.formatDateTime(dateTime, i18n.tr('dddd, dd MMMM')) + ' - ' + Qt.formatTime(dateTime);
74 dateComponent.dateString = dateTimeString;
75 dateComponent.renderText();
76 //
77 hourlyScrollEffect.start();
78 lastIndex = hourIndex;
79 }
80 }
81 }
82 }
83 onReleased: {
84 if(wasHourlyScrolled) {
85 // reset temp and date to current day
86 var currentDayData = dayForecastModel.get(dailyForecastList.currentIndex);
87 frontrect.conditionIcon.condition = currentDayData.condIcon;
88 frontrect.conditionIcon.appearAnimation.start();
89 frontrect.conditionTempContent.currentTemp = currentDayData.temp;
90 // set back detail data
91 currentWeather.humidity = currentDayData.humid
92 currentWeather.windSpeed = currentDayData.wind_speed
93 currentWeather.windDir = currentDayData.wind_dir
94 if(currentDayData.prop_precip !== undefined && currentDayData.prop_precip !== "") {
95 currentWeather.propPrecip = currentDayData.prop_precip;
96 } else {
97 currentWeather.pressure = currentDayData.press
98 }
99 if(currentDayData.uv !== undefined && currentDayData.uv !== "") {
100 currentWeather.uvIndex = currentDayData.uv;
101 } else {
102 var precip_units = (mainView.settings.precip_units === 'in') ? 'imperial' : 'metric';
103 currentWeather.precipitation = currentDayData.precip
104 }
105 // set back date data
106 adjustBackground(Math.round(currentDayData.temp));
107 dateComponent.dateString = currentDayData.date;
108 dateComponent.renderText();
109 lastIndex = -1;
110 }
111 }
112}
0113
=== modified file 'components/WeatherApi.js'
--- components/WeatherApi.js 2014-02-11 18:00:07 +0000
+++ components/WeatherApi.js 2014-02-19 12:16:52 +0000
@@ -214,20 +214,20 @@
214 date: date,214 date: date,
215 metric: {215 metric: {
216 temp:data.main.temp,216 temp:data.main.temp,
217 windSpeed: calcKmh(data.main.speed),217 windSpeed: calcKmh(data.wind.speed),
218 rain: data.main.rain || 0,218 rain: data.main.rain || ((data.rain) ? data.rain["3h"] : false ) || 0,
219 snow: data.main.snow || 0219 snow: data.main.snow || ((data.snow) ? data.snow["3h"] : false ) || 0
220 },220 },
221 imperial: {221 imperial: {
222 temp: calcFahrenheit(data.main.temp),222 temp: calcFahrenheit(data.main.temp),
223 windSpeed: calcMph(data.main.speed),223 windSpeed: calcMph(data.wind.speed),
224 rain: calcInch(data.main.rain || 0),224 rain: calcInch(data.main.rain || ((data.rain) ? data.rain["3h"] : false ) || 0),
225 snow: calcInch(data.main.snow || 0)225 snow: calcInch(data.main.snow || ((data.snow) ? data.snow["3h"] : false ) ||0)
226 },226 },
227 humidity: data.main.humidity,227 humidity: data.main.humidity,
228 pressure: data.main.pressure,228 pressure: data.main.pressure,
229 windDeg: data.main.deg,229 windDeg: data.wind.deg,
230 windDir: calcWindDir(data.main.deg),230 windDir: calcWindDir(data.wind.deg),
231 icon: _icon_map[data.weather[0].icon],231 icon: _icon_map[data.weather[0].icon],
232 condition: data.weather[0]232 condition: data.weather[0]
233 };233 };
234234
=== added file 'key.js'
--- key.js 1970-01-01 00:00:00 +0000
+++ key.js 2014-02-19 12:16:52 +0000
@@ -0,0 +1,1 @@
1var twcKey = "";
02
=== removed file 'key.js'
--- key.js 2014-02-15 14:51:47 +0000
+++ key.js 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1var twcKey = "";
20
=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_settings.py'
--- tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2014-01-24 13:58:48 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2014-02-19 12:16:52 +0000
@@ -58,7 +58,7 @@
58 'QQuickText', objectName='CurrentTempText')58 'QQuickText', objectName='CurrentTempText')
59 if units == "imperial":59 if units == "imperial":
60 self.assertThat(today_temp_scale.text, Eventually(Equals(u'°F')))60 self.assertThat(today_temp_scale.text, Eventually(Equals(u'°F')))
61 self.assertThat(today_temp.text, Eventually(Equals(u'26')))61 self.assertThat(today_temp.text, Eventually(Equals(u'27')))
62 self.assertThat(tomorrow_temp.text, Eventually(Equals(u'23')))62 self.assertThat(tomorrow_temp.text, Eventually(Equals(u'23')))
63 else:63 else:
64 self.assertThat(today_temp_scale.text, Eventually(Equals(u'°C')))64 self.assertThat(today_temp_scale.text, Eventually(Equals(u'°C')))

Subscribers

People subscribed via source and target branches