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

Proposed by Martin Borho
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 212
Merged at revision: 210
Proposed branch: lp:~martin-borho/ubuntu-weather-app/anchors-refactoring
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 1146 lines (+212/-409)
17 files modified
components/AddLocationSheet.qml (+30/-14)
components/ChartComponent.js (+0/-197)
components/ChartComponent.qml (+0/-63)
components/CurrentWeather.qml (+3/-7)
components/DateComponent.qml (+14/-34)
components/LastUpdatedComponent.qml (+10/-5)
components/LocationManagerSheet.qml (+30/-10)
components/LocationTab.qml (+46/-29)
components/ScrollingArea.qml (+2/-2)
components/SettingsSheet.qml (+1/-0)
components/SplashComponent.qml (+8/-6)
components/TabFooter.qml (+36/-19)
components/WeatherApi.js (+2/-8)
tests/autopilot/ubuntu_weather_app/tests/__init__.py (+6/-2)
tests/autopilot/ubuntu_weather_app/tests/test_mainview.py (+3/-1)
tests/autopilot/ubuntu_weather_app/tests/test_settings.py (+17/-9)
ubuntu-weather-app.qml (+4/-3)
To merge this branch: bzr merge lp:~martin-borho/ubuntu-weather-app/anchors-refactoring
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+207793@code.launchpad.net

Commit message

Refactored all "width:parent.width" and "height:parent.height" through corresponding anchors and fixed bugs.

Description of the change

* Refactored all "width:parent.width" and "height:parent.height" through corresponding anchors.
* added a contentsWidth to all Sheet components, which should expand the sheets over the full window size.
* removed obsolete code
* fixed resizing bug in phone mode

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
210. By Martin Borho

fix for ap tests

211. By Martin Borho

a second ap fix

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

At the moment due to it assuming a tablet layout on my n4, the tests fail (4 of them)

review: Needs Fixing
212. By Martin Borho

fixed AP tests to reflect tablet mode, switched initial MainView back to phone mode

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components/AddLocationSheet.qml'
2--- components/AddLocationSheet.qml 2014-02-18 20:48:23 +0000
3+++ components/AddLocationSheet.qml 2014-02-26 17:08:27 +0000
4@@ -31,6 +31,7 @@
5 objectName: "AddLocationSheet"
6 title: i18n.tr("Add city")
7 contentsHeight: parent.height
8+ contentsWidth: parent.width
9 doneButton: false
10
11 Component.onCompleted: {
12@@ -120,18 +121,24 @@
13 }
14
15 container: Item {
16- width: parent.width
17+ anchors {
18+ right: parent.right
19+ left: parent.left
20+ }
21 Rectangle {
22 id: searchInput
23- width:parent.width-units.gu(2)
24 height:units.gu(5)
25- anchors.horizontalCenter: parent.horizontalCenter
26+ anchors {
27+ right: parent.right
28+ rightMargin: units.gu(1)
29+ left: parent.left
30+ leftMargin: units.gu(1)
31+ }
32 color: "transparent"
33 TextField {
34 id: locationString
35- objectName: "SearchField"
36- width: parent.width
37- height:parent.height
38+ objectName: "SearchField"
39+ anchors.fill: parent
40 placeholderText: i18n.tr("Enter a city name")
41 hasClearButton: true
42 onAccepted: {
43@@ -140,8 +147,8 @@
44 locationString.focus = false
45 }
46 primaryItem: Image {
47- height: parent.height*0.5
48- width: parent.height*0.5
49+ height: searchInput.height*0.5
50+ width: searchInput.height*0.5
51 anchors.verticalCenter: parent.verticalCenter
52 anchors.verticalCenterOffset: -units.gu(0.2)
53 source: Qt.resolvedUrl("../resources/images/search.svg")
54@@ -174,19 +181,26 @@
55
56 Rectangle {
57 id: cityList;
58- anchors.top: searchInput.bottom
59- width: parent.width
60+ anchors {
61+ top:searchInput.bottom
62+ left: parent.left
63+ right: parent.right
64+ }
65 height: addLocationSheet.height-searchInput.height-units.gu(9.5)
66 color: "transparent"
67 visible: true
68 Label {
69 id: noCityError
70 objectName: "noCityError"
71- width: parent.width-units.gu(6)
72 visible: false
73- anchors.centerIn: parent
74+ anchors {
75+ fill: parent
76+ leftMargin: units.gu(3)
77+ rightMargin: units.gu(3)
78+ }
79 fontSize: "medium"
80 wrapMode: Text.WordWrap
81+ verticalAlignment: Text.AlignVCenter
82 horizontalAlignment: Text.AlignHCenter
83 }
84 Component {
85@@ -218,25 +232,27 @@
86 id: searchResultName
87 objectName: "searchResult" + index
88 text: name
89- width: parent.width-units.gu(3)
90 elide: Text.ElideRight
91 anchors {
92 top: parent.top
93 topMargin: units.gu(0.5)
94 left: parent.left
95 leftMargin: units.gu(3)
96+ right: parent.right
97+ rightMargin: units.gu(2)
98 }
99 fontSize: "large"
100 }
101 Label {
102 text: areaLabel
103- width: parent.width-units.gu(3)
104 elide: Text.ElideRight
105 anchors {
106 top: searchResultName.bottom
107 bottom: parent.bottom
108 left: parent.left
109 leftMargin: units.gu(3)
110+ right: parent.right
111+ rightMargin: units.gu(2)
112 }
113 fontSize: "small"
114 }
115
116=== removed file 'components/ChartComponent.js'
117--- components/ChartComponent.js 2013-03-14 22:12:02 +0000
118+++ components/ChartComponent.js 1970-01-01 00:00:00 +0000
119@@ -1,197 +0,0 @@
120-.pragma library
121-
122-//canvas object from .pragma
123-var canvas = 0;
124-var chart = 0;
125-
126-//enables debugging
127-var debug_enabled = 0;
128-
129-//measurements setted in QML
130-var canvasHeight = 0;
131-var canvasWidth = 0;
132-var canvasXOffset = 0;
133-var canvasYOffset = 0;
134-
135-//array of header labels(times)
136-var xLabels = new Array();
137-
138-function debug(text)
139-{
140- if (debug_enabled)
141- console.debug(text);
142-}
143-
144-function refresh()
145-{
146- canvas.requestPaint();
147-}
148-
149-//main draw function
150-function draw()
151-{
152- var context = canvas.getContext("2d");
153- context.clearRect(0, 0, canvas.width, canvas.height);
154- context.save();
155- context.globalAlpha = canvas.alpha;
156-
157- drawGrid(context);
158- drawTemperatures(context);
159- drawCurrentTime(context);
160- context.restore();
161-}
162-
163-//draw background grid
164-function drawGrid(context)
165-{
166- //remove all xLabels
167- while (xLabels.length > 0)
168- {
169- var label = xLabels.pop();
170- label.text = "";
171- label.destroy();
172- }
173-
174- var maxHSections = 24;
175- var hSectionSize = canvasWidth/maxHSections;
176-
177- var hours = chart.xAxisHours;
178- var startX = 0, startY = 0, endX = 0, endY = 0;
179-
180- //draw vertical lines
181- for (var i = 1 ; i < hours.length - 1; i++)
182- {
183- startX = hours[i]*hSectionSize + canvasXOffset;
184- startY = canvas.height;
185- endX = hours[i]*hSectionSize + canvasXOffset;
186- endY = canvasYOffset;
187- drawLine(context, startX, startY, endX, endY, chart.gridColor,1);
188- //create and add hourLabel to the array
189- xLabels.push(Qt.createQmlObject("import QtQuick 2.0;Text{text:\"" + hours[i] +":00\"; y:" + canvasYOffset + " - height; x:" + hours[i]*hSectionSize + "- width/2; color:\"" + chart.trendColor + "\"}", canvas, "labels"));
190- }
191-
192- //draw horizontal lines
193- var vSectionSize = canvasHeight/(chart.gridHorizontalLinesCount + 1);
194- for (var i = 1 ; i < chart.gridHorizontalLinesCount +1 ; i++)
195- {
196- startX = canvasXOffset;
197- startY = i * vSectionSize + canvasYOffset;
198- endX = canvasXOffset+canvas.width;
199- endY = i*vSectionSize + canvasYOffset;
200-
201- drawLine(context, startX, startY, endX, endY, chart.gridColor,1);
202- }
203-}
204-
205-//draw current time vertical bar
206-function drawCurrentTime(context)
207-{
208- var currentMinutes = parseFloat(Qt.formatDateTime(new Date(), "m")) + (parseFloat(Qt.formatDateTime(new Date(), "h")) * 60);
209- var currentTimeWidth = 4;
210- var currentTimeColor = "#DD4814";
211- var position = ((currentMinutes * canvas.width)/(24 * 60)) - (currentTimeWidth/2);
212-
213- drawLine(context,position+canvasXOffset, canvas.height,position+canvasXOffset,canvasYOffset+1, currentTimeColor, currentTimeWidth);
214-}
215-
216-//draw temperature points and lines on the chart
217-function drawTemperatures(context)
218-{
219- context.strokeStyle = chart.trendColor;
220- context.lineWidth = chart.trendWidth;
221-
222- var maxTemp = -999;
223- var minTemp = 999;
224- var circleColor = "#DD4814";
225- var circleRadius = 4;
226- var temperatures = chart.temperatures;
227-
228- //determine min and max temp
229- for (var i = 0 ; i < temperatures.length ; i++)
230- {
231- if (parseFloat(temperatures[i].temp) > maxTemp)
232- maxTemp = temperatures[i].temp;
233- if (parseFloat(temperatures[i].temp) < minTemp)
234- minTemp = temperatures[i].temp;
235- }
236-
237- var positions = new Array();
238-
239- //draw temperature points
240- for (var i = 0 ; i < temperatures.length ; i++)
241- {
242- //get time and temp from array
243- var temp = temperatures[i].temp;
244- var times = temperatures[i].time.split(":");
245- var time = (parseFloat(times[0]) * 60) + parseFloat(times[1]);
246-
247- //count X and Y based on canvas dimensions and offsets
248- var posX = canvasXOffset + ((time * canvas.width)/(24 * 60)) - (chart.trendWidth/2);
249- var posY = (canvasHeight) - (canvasHeight - canvasYOffset - circleRadius) * ((parseInt(temp) - Math.abs(minTemp)) / (maxTemp - minTemp));
250- if (posY == canvasHeight)
251- posY -= circleRadius;
252-
253- //draw temperature point
254- //drawCircle(context, posX, posY, circleRadius, circleColor);
255- positions.push({'posY':posY, 'posX':posX})
256- }
257-
258- drawTemperatureLines(context,positions,circleColor);
259-}
260-
261-//draw lines connecting temperature points
262-//WORK IN PROGRESS. should be smooth paths
263-function drawTemperatureLines(context, positions, color)
264-{
265- var posX = 0, posY = 0, prevX, prevY;
266-
267- context.save();
268- context.strokeStyle = chart.trendColor;
269- context.lineWidth = 2;
270- context.lineJoin = "round";
271- context.beginPath();
272-
273- for (var i = 0 ; i < positions.length ; i++)
274- {
275- posY = positions[i].posY;
276- posX = positions[i].posX;
277-
278- if (i == 0)
279- {
280- context.moveTo(posX, posY);
281- }
282- else
283- {
284- prevX = positions[i-1].posX;
285- prevY = positions[i-1].posY;
286- context.lineTo(posX, posY);
287- }
288- }
289- context.stroke();
290- context.restore();
291-}
292-
293-//general function for circle drawing
294-function drawCircle(context, x, y, radius, color)
295-{
296- context.save();
297- context.fillStyle = color;
298- context.beginPath();
299- context.arc(x, y, radius,0,Math.PI*2,true); // Outer circle
300- context.fill();
301- context.restore();
302-}
303-
304-//general function for line drawing
305-function drawLine(context, startX, startY, endX, endY, color, width)
306-{
307- context.save();
308- context.lineWidth = width;
309- context.strokeStyle = color;
310- context.beginPath();
311- context.moveTo(startX,startY);
312- context.lineTo(endX,endY);
313- context.closePath();
314- context.stroke();
315- context.restore();
316-}
317
318=== removed file 'components/ChartComponent.qml'
319--- components/ChartComponent.qml 2013-03-14 21:46:34 +0000
320+++ components/ChartComponent.qml 1970-01-01 00:00:00 +0000
321@@ -1,63 +0,0 @@
322-import QtQuick 2.0
323-import Ubuntu.Components 0.1
324-import "ChartComponent.js" as ChartFunctions
325-
326-Rectangle {
327- id: chart
328- anchors.horizontalCenter: parent.horizontalCenter
329- width: parent.width-units.gu(2)
330- height: units.gu(20)
331-
332- property string backgroundColor: "#D6D6D6"
333- property string gridColor: "#FFFFFF"
334- property int gridWidth: 1
335- property int gridHorizontalLinesCount: 4
336- property int headerSize: units.gu(4)
337- property string trendColor: "#313131"
338- property int trendWidth: 2
339- //property variant xAxisHours: [0,6,12,18,24]
340- property variant xAxisHours: [0,3,6,9,12,15,18,21,24]
341- property variant temperatures: [{"time" : "0:10", "temp" : "3"},
342- {"time" : "2:00", "temp" : "7"},
343- {"time" : "6:00", "temp" : "9"},
344- {"time" : "10:30", "temp" : "12"},
345- {"time" : "12:00", "temp" : "24"},
346- {"time" : "18:10", "temp" : "20"},
347- {"time" : "22:22", "temp" : "10"}]
348- property bool showExtremeHours: false
349-
350- function refresh()
351- {
352- ChartFunctions.refresh();
353- }
354-
355- UbuntuShape{
356- id: contentShape
357- radius: "small"
358- width: parent.width
359- height: parent.height-units.gu(6)
360- anchors.bottom: parent.bottom
361- anchors.bottomMargin: units.gu(1)
362- color: backgroundColor
363- }
364- Canvas{
365- id:canvas
366- width: parent.width
367- height: parent.height-units.gu(2)
368- anchors.bottom: parent.bottom
369- anchors.bottomMargin: units.gu(1)
370- antialiasing: true
371-
372- onPaint: {
373- ChartFunctions.canvas = canvas;
374- ChartFunctions.chart = chart;
375-
376- ChartFunctions.canvasHeight = canvas.height;
377- ChartFunctions.canvasWidth = canvas.width;
378- ChartFunctions.canvasXOffset = 0;
379- ChartFunctions.canvasYOffset = canvas.height - contentShape.height;
380-
381- ChartFunctions.draw();
382- }
383- }
384-}
385
386=== modified file 'components/CurrentWeather.qml'
387--- components/CurrentWeather.qml 2014-02-20 16:17:04 +0000
388+++ components/CurrentWeather.qml 2014-02-26 17:08:27 +0000
389@@ -54,7 +54,6 @@
390
391 property NumberAnimation appearAnimation: frontrect.conditionIcon.appearAnimation
392
393- width: parent.width
394 anchors.fill: parent
395 anchors.horizontalCenter: parent.horizontalCenter
396
397@@ -103,12 +102,12 @@
398 anchors {
399 horizontalCenter: parent.horizontalCenter
400 verticalCenter: parent.verticalCenter
401- verticalCenterOffset: -(parent.height*0.1);
402+ verticalCenterOffset: -(layouts.height*0.1);
403 }
404 }
405 CurrentWeatherDetail {
406 id: backrect
407- height: parent.height/2
408+ height: layouts.height/2
409 shapeSize: units.gu(14)
410 gridColumns: 4
411 anchors {
412@@ -123,10 +122,7 @@
413 ]
414 Flipable {
415 id: flipable
416- height: parent.height
417- width:parent.width
418- anchors.verticalCenter: parent.verticalCenter
419- anchors.verticalCenterOffset: -units.gu(3)
420+ anchors.fill: parent
421 property bool flipped: false
422
423 Components.ScrollingArea {}
424
425=== modified file 'components/DateComponent.qml'
426--- components/DateComponent.qml 2013-10-08 19:26:12 +0000
427+++ components/DateComponent.qml 2014-02-26 17:08:27 +0000
428@@ -19,14 +19,14 @@
429 import Ubuntu.Components 0.1
430
431 Rectangle {
432- width: parent.width
433- height: childrenRect.height
434+ anchors {
435+ left: parent.left
436+ right:parent.right
437+ }
438+ height: units.gu(4)
439 color: "transparent"
440- property bool borderTopVisible: true
441 property string dateRelative: ""
442 property string dateString: ""
443- property string borderColor: "transparent"
444- property int borderHeight: units.gu(0.1)
445
446 Component.onCompleted: {
447 renderText()
448@@ -41,35 +41,15 @@
449 dayText.text = dateText
450 }
451
452- Rectangle {
453- id: topBorder
454- visible: borderTopVisible
455- width:parent.width
456- height: borderHeight
457- color: borderColor
458- }
459-
460- Item {
461- id: dayLabel
462- width:parent.width-units.gu(4.5)
463- height: units.gu(4)
464- anchors.top: topBorder.bottom
465- anchors.horizontalCenter: parent.horizontalCenter
466-
467- Label {
468- id: dayText
469- objectName: "DayDateLabel"
470- height: parent.height
471- verticalAlignment: Text.AlignVCenter
472- color: Theme.palette.normal.baseText
473- style: Text.Raised
474+ Label {
475+ id: dayText
476+ objectName: "DayDateLabel"
477+ anchors {
478+ fill: parent
479+ leftMargin: units.gu(2.2)
480 }
481- }
482-
483- Rectangle {
484- width:parent.width
485- height: borderHeight
486- anchors.top: dayLabel.bottom
487- color: borderColor
488+ verticalAlignment: Text.AlignVCenter
489+ color: Theme.palette.normal.baseText
490+ style: Text.Raised
491 }
492 }
493
494=== modified file 'components/LastUpdatedComponent.qml'
495--- components/LastUpdatedComponent.qml 2013-10-08 19:26:12 +0000
496+++ components/LastUpdatedComponent.qml 2014-02-26 17:08:27 +0000
497@@ -20,11 +20,13 @@
498 import Ubuntu.Components 0.1
499
500 Rectangle {
501- width:parent.width-units.gu(4.5)
502 height: units.gu(4)
503- anchors.bottom: parent.bottom
504- anchors.bottomMargin: units.gu(2)
505- anchors.horizontalCenter: parent.horizontalCenter
506+ anchors {
507+ left: parent.left
508+ right:parent.right
509+ bottom: parent.bottom
510+ bottomMargin: units.gu(2)
511+ }
512 color: "transparent"
513
514 property string updateDate;
515@@ -44,7 +46,10 @@
516 Label {
517 id: lastUpdatedLabel
518 objectName: "LastUpdatedLabel"
519- height: parent.height
520+ anchors {
521+ fill: parent
522+ leftMargin: units.gu(2.2)
523+ }
524 verticalAlignment: Text.AlignVCenter
525 color: Theme.palette.normal.baseText
526 style: Text.Raised
527
528=== modified file 'components/LocationManagerSheet.qml'
529--- components/LocationManagerSheet.qml 2014-02-08 13:25:26 +0000
530+++ components/LocationManagerSheet.qml 2014-02-26 17:08:27 +0000
531@@ -31,6 +31,7 @@
532 objectName: "LocationManagerSheet"
533 title: i18n.tr("Edit locations")
534 contentsHeight: parent.height
535+ contentsWidth: parent.width
536
537 property int initial_sum: 0
538
539@@ -112,7 +113,10 @@
540 container: Column {
541 anchors.fill: parent
542 Rectangle {
543- width: parent.width
544+ anchors {
545+ left:parent.left
546+ right: parent.right
547+ }
548 height: units.gu(5)
549 color: "transparent"
550 Label {
551@@ -127,7 +131,10 @@
552 }
553 Rectangle {
554 color: "#A9A9A9"
555- width:parent.width
556+ anchors {
557+ left:parent.left
558+ right: parent.right
559+ }
560 height: units.gu(0.1)
561 }
562 ListItem.Standard {
563@@ -170,26 +177,28 @@
564 id: currentLocationLabel
565 objectName: "CurrentLocationLabel"
566 text: ""
567- width: parent.width-lookupItemAddButton.width-units.gu(5.5)
568 elide: Text.ElideRight
569- anchors {
570+ anchors {
571 top: parent.top
572 topMargin: units.gu(0.5)
573 left: parent.left
574 leftMargin: units.gu(3)
575+ right:parent.right
576+ rightMargin: lookupItemAddButton.width+units.gu(5.5)
577 }
578 fontSize: "large"
579 }
580 Label {
581 id: currentLocationAreaLabel
582 text: ""
583- width: parent.width-lookupItemAddButton.width-units.gu(5.5)
584 elide: Text.ElideRight
585 anchors {
586 top: currentLocationLabel.bottom
587 bottom: parent.bottom
588 left: parent.left
589 leftMargin: units.gu(3)
590+ right:parent.right
591+ rightMargin: lookupItemAddButton.width+units.gu(5.5)
592 }
593 fontSize: "small"
594 }
595@@ -212,7 +221,10 @@
596 }
597 }
598 Rectangle {
599- width: parent.width
600+ anchors {
601+ left:parent.left
602+ right: parent.right
603+ }
604 height: units.gu(5)
605 color: "transparent"
606 Label {
607@@ -227,11 +239,17 @@
608 }
609 Rectangle {
610 color: "#A9A9A9"
611- width:parent.width
612+ anchors {
613+ left:parent.left
614+ right: parent.right
615+ }
616 height: units.gu(0.1)
617 }
618 Rectangle {
619- width: parent.width
620+ anchors {
621+ left:parent.left
622+ right: parent.right
623+ }
624 clip:true
625 color:"transparent"
626 height: locationManagerSheet.height-locationLookupItem.height-units.gu(19.2)
627@@ -245,25 +263,27 @@
628 id: searchResultName
629 objectName: "existingLocation" + index
630 text: name
631- width: parent.width-units.gu(3)
632 elide: Text.ElideRight
633 anchors {
634 top: parent.top
635 topMargin: units.gu(0.5)
636 left: parent.left
637 leftMargin: units.gu(3)
638+ right:parent.right
639+ rightMargin: units.gu(3)
640 }
641 fontSize: "large"
642 }
643 Label {
644 text: adminName1.replace(/ Region$/,'')+", "+((Countries.codes[country]) ? i18n.tr(Countries.codes[country]): country)
645- width: parent.width-units.gu(3)
646 elide: Text.ElideRight
647 anchors {
648 top: searchResultName.bottom
649 bottom: parent.bottom
650 left: parent.left
651 leftMargin: units.gu(3)
652+ right:parent.right
653+ rightMargin: units.gu(3)
654 }
655 fontSize: "small"
656 }
657
658=== modified file 'components/LocationTab.qml'
659--- components/LocationTab.qml 2014-02-21 10:25:47 +0000
660+++ components/LocationTab.qml 2014-02-26 17:08:27 +0000
661@@ -143,14 +143,19 @@
662 color: "transparent"
663 ItemLayout {
664 item: "ForecastList"
665- width: parent.width*0.625
666- height:parent.height
667+ width: layouts.width*0.625
668+ anchors {
669+ top: parent.top
670+ bottom: parent.bottom
671+ }
672 }
673 Rectangle {
674- width: parent.width*0.375
675- height:parent.height
676- anchors.right: parent.right
677- anchors.top: parent.top
678+ width: layouts.width*0.375
679+ anchors {
680+ top: parent.top
681+ bottom:parent.bottom
682+ right: parent.right
683+ }
684 color: "black"
685 opacity: 0.3
686 }
687@@ -158,34 +163,37 @@
688 item: "TabFooter"
689 // We're making the footer to be full-width
690 // so that it looks good on a Nexus 7
691- //width: parent.width // * 0.625
692 height: units.gu(8)
693- anchors.bottom: parent.bottom
694- anchors.left: parent.left
695- anchors.right: parent.right
696- clip: true
697+ anchors {
698+ bottom: parent.bottom
699+ left: parent.left
700+ right: parent.right
701+ }
702 }
703 Rectangle {
704 id: sideLabel
705+ objectName: "SideLabel"
706 anchors.top: parent.top
707 anchors.right: parent.right
708- width: parent.width*0.375
709+ width: layouts.width*0.375
710 height: units.gu(6)
711 color: "transparent"
712 Label {
713 text: i18n.tr("Forecast")
714 fontSize: "large"
715- anchors.left:parent.left
716- anchors.leftMargin: units.gu(3)
717- verticalAlignment: Text.AlignVCenter
718- anchors.top: parent.top;
719- anchors.bottom: parent.bottom
720+ anchors {
721+ left:parent.left
722+ leftMargin: units.gu(3)
723+ top: parent.top;
724+ bottom: parent.bottom
725+ }
726+ verticalAlignment: Text.AlignVCenter
727 }
728 }
729 ListView {
730 id: locationDailySide
731- width: (parent.width*0.375)-units.gu(1)
732- height: parent.height-sideLabel.height-units.gu(9)
733+ width: (layouts.width*0.375)-units.gu(1)
734+ height: layouts.height-sideLabel.height-units.gu(9)
735 anchors.right: parent.right
736 anchors.top: sideLabel.bottom
737 model:dayForecastModel
738@@ -230,8 +238,7 @@
739 ListView {
740 id: dailyForecastList
741 objectName: "DailyForecastList"
742- width: parent.width
743- height:parent.height
744+ anchors.fill:parent
745 model:dayForecastModel
746 Layouts.item: "ForecastList"
747 onCurrentIndexChanged: {
748@@ -251,7 +258,10 @@
749
750 delegate: Item {
751 id: dailyForecastItem
752- width:parent.width
753+ anchors {
754+ left:parent.left
755+ right: parent.right
756+ }
757 height: locationPage.height
758
759 property NumberAnimation appearAnimation: currentWeatherComponent.appearAnimation
760@@ -261,16 +271,18 @@
761
762 Rectangle {
763 id: listRectangle
764- width: parent.width
765 height: dailyForecastList.height-tabFooter.height
766- anchors.top: parent.top
767+ anchors {
768+ left:parent.left
769+ right: parent.right
770+ top: parent.top
771+ }
772 color: "transparent"
773
774 DateComponent {
775 id: dateComponent
776 dateRelative: dateRel
777 dateString: date
778- borderTopVisible: false
779 }
780 CurrentWeather {
781 id: currentWeatherComponent
782@@ -325,12 +337,17 @@
783 Rectangle {
784 id: noDataAvaible
785 visible: false
786- width:parent.width-units.gu(10)
787- anchors.centerIn:parent
788- anchors.verticalCenterOffset: -units.gu(10)
789+ anchors {
790+ left: parent.left
791+ leftMargin: units.gu(5)
792+ right: parent.right
793+ rightMargin: units.gu(5)
794+ verticalCenter: parent.verticalCenter
795+ verticalCenterOffset: -units.gu(10)
796+ }
797 color: "transparent"
798 Label {
799- width:parent.width
800+ anchors.fill:parent
801 text: i18n.tr("No weather data available at the moment, please try to refresh later again!")
802 fontSize: "large"
803 wrapMode: Text.WordWrap
804
805=== modified file 'components/ScrollingArea.qml'
806--- components/ScrollingArea.qml 2014-02-18 17:55:17 +0000
807+++ components/ScrollingArea.qml 2014-02-26 17:08:27 +0000
808@@ -9,7 +9,7 @@
809 property int lastIndex: -1
810 anchors.fill: parent
811 anchors.top: parent.top
812- anchors.topMargin: units.gu(3.5)
813+ anchors.topMargin: units.gu(1.2)
814 onClicked: {
815 mouse.accepted = true;
816 if(!wasHourlyScrolled) {
817@@ -36,7 +36,7 @@
818 }
819 onPositionChanged: {
820 mouse.accepted = true;
821- var distance = (parent.height - mouse.y),
822+ var distance = (flippedarea.height - mouse.y),
823 now = new Date().getTime(),
824 speed = distance/(now-startTime);
825 if(speed < 2.3 && !flipable.flipped) {
826
827=== modified file 'components/SettingsSheet.qml'
828--- components/SettingsSheet.qml 2014-02-15 14:31:10 +0000
829+++ components/SettingsSheet.qml 2014-02-26 17:08:27 +0000
830@@ -26,6 +26,7 @@
831 objectName: "SettingsSheet"
832 title: i18n.tr("Settings")
833 contentsHeight: parent.height
834+ contentsWidth: parent.width
835
836 container: Column {
837 anchors.left: parent.left
838
839=== modified file 'components/SplashComponent.qml'
840--- components/SplashComponent.qml 2013-10-01 19:51:22 +0000
841+++ components/SplashComponent.qml 2014-02-26 17:08:27 +0000
842@@ -19,23 +19,26 @@
843 import Ubuntu.Components 0.1
844
845 UbuntuShape {
846- id: httpFailedSplash
847- width: parent.width-units.gu(10)
848+ id: httpFailedSplash
849 color: "#F5F5F5"
850 visible: (opacity > 0.0)
851 opacity: 0
852 z:100
853 anchors {
854- horizontalCenter: parent.horizontalCenter
855 top: parent.top
856 topMargin:units.gu(15)
857+ left: parent.left
858+ leftMargin: units.gu(5)
859+ right: parent.right
860+ rightMargin: units.gu(5)
861 }
862 property string message: i18n.tr("Couldn't load weather data, please try later again!")
863
864 Label {
865 text: message
866- anchors.centerIn: parent
867- width: parent.width-units.gu(3)
868+ anchors.fill:parent
869+ verticalAlignment: Text.AlignVCenter
870+ horizontalAlignment: Text.AlignHCenter
871 fontSize: "medium"
872 color: "#838383"
873 wrapMode: Text.WordWrap
874@@ -45,7 +48,6 @@
875 interval: 2000
876 repeat: false
877 onTriggered: {
878-
879 hideSplashBox.start()
880 }
881 }
882
883=== modified file 'components/TabFooter.qml'
884--- components/TabFooter.qml 2014-02-19 13:39:04 +0000
885+++ components/TabFooter.qml 2014-02-26 17:08:27 +0000
886@@ -19,16 +19,13 @@
887 import Ubuntu.Components 0.1
888
889 Rectangle {
890- width: parent.width
891 height: units.gu(8)
892- anchors.bottom: parent.bottom
893+ anchors {
894+ left: parent.left
895+ right: parent.right
896+ bottom: parent.bottom
897+ }
898
899- /**
900- * TODO
901- *
902- * at the moment it's unknown to the developer, in which way a link to
903- * the weatherchannel website can be generated from wunderground-API data
904- */
905 function openTWCLink(type) {
906 var serviceId = locationTab.locationData.location.services["weatherchannel"],
907 loc_name = Qt.locale().name, url = "http://";
908@@ -85,12 +82,19 @@
909
910 Rectangle {
911 id: forecastLink
912- anchors.left:parent.left
913- anchors.leftMargin: units.gu(1)
914+ anchors {
915+ left:parent.left
916+ leftMargin: units.gu(1)
917+ top: parent.top
918+ bottom:parent.bottom
919+ }
920 width:units.gu(14)
921- height:parent.height
922 Label {
923- anchors.verticalCenter: parent.verticalCenter
924+ verticalAlignment: Text.AlignVCenter
925+ anchors {
926+ bottom: parent.bottom
927+ top: parent.top
928+ }
929 text: i18n.tr("10 days forecast")
930 fontSize:"medium"
931 color: mainView.footerColor
932@@ -101,11 +105,18 @@
933 }
934 }
935 Rectangle {
936- anchors.left:forecastLink.right
937+ anchors {
938+ top: parent.top
939+ bottom:parent.bottom
940+ left:forecastLink.right
941+ }
942 width:units.gu(15)
943- height:parent.height
944 Label {
945- anchors.verticalCenter: parent.verticalCenter
946+ verticalAlignment: Text.AlignVCenter
947+ anchors {
948+ bottom: parent.bottom
949+ top: parent.top
950+ }
951 text: ">> "+i18n.tr("Hourly forecast")
952 fontSize:"medium"
953 color: mainView.footerColor
954@@ -116,16 +127,22 @@
955 }
956 }
957 Rectangle {
958- anchors.right: serviceLogo.left
959 width:units.gu(0.25)
960- height: parent.height
961+ anchors {
962+ top: parent.top
963+ bottom:parent.bottom
964+ right: serviceLogo.left
965+ }
966 color: mainView.footerColor
967 }
968 Rectangle {
969 id: serviceLogo
970 width:units.gu(9)
971- height:parent.height
972- anchors.right: parent.right
973+ anchors {
974+ top: parent.top
975+ bottom:parent.bottom
976+ right: parent.right
977+ }
978 Label {
979 anchors.verticalCenter: parent.verticalCenter
980 anchors.centerIn: parent
981
982=== modified file 'components/WeatherApi.js'
983--- components/WeatherApi.js 2014-02-18 17:55:17 +0000
984+++ components/WeatherApi.js 2014-02-26 17:08:27 +0000
985@@ -585,14 +585,8 @@
986 }),
987 onErrorHandler = (function(err) {
988 onError(err);
989- }),
990- retryHandler = (function(err) {
991- print(JSON.stringify(err))
992- console.log("retry of "+err.request.url);
993- //var retryFunc = handlerMap[err.request.type];
994- //apiCaller(retryFunc, addDataToResponse, onErrorHandler);
995- })
996- apiCaller(handlerMap.all, addDataToResponse, retryHandler);
997+ });
998+ apiCaller(handlerMap.all, addDataToResponse, onErrorHandler);
999 }
1000 }
1001 })();
1002
1003=== modified file 'tests/autopilot/ubuntu_weather_app/tests/__init__.py'
1004--- tests/autopilot/ubuntu_weather_app/tests/__init__.py 2014-02-15 14:31:10 +0000
1005+++ tests/autopilot/ubuntu_weather_app/tests/__init__.py 2014-02-26 17:08:27 +0000
1006@@ -20,7 +20,7 @@
1007 from autopilot.input import Mouse, Touch, Pointer
1008 from autopilot.platform import model
1009 from autopilot.testcase import AutopilotTestCase
1010-from testtools.matchers import Equals
1011+from testtools.matchers import Equals, Is, Not
1012 from autopilot.matchers import Eventually
1013
1014 import ubuntu_weather_app
1015@@ -88,11 +88,15 @@
1016 def get_qml_view(self):
1017 return self.app.select_single("QQuickView")
1018
1019+ """Test if tabs with data are present in tablet mode"""
1020+ def _ensure_tablet_tabs_loaded(self):
1021+ self.assertThat(lambda: self.main_window.wait_select_single('QQuickRectangle', visible=True, objectName='SideLabel'),
1022+ Eventually(Not(Is(None)), timeout=60))
1023+
1024 @property
1025 def main_window(self):
1026 return self.app.select_single(MainView)
1027
1028-
1029 class SheetMixin(object):
1030 """A mixin to to give access to common sheet elements"""
1031
1032
1033=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_mainview.py'
1034--- tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2014-02-15 14:31:10 +0000
1035+++ tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2014-02-26 17:08:27 +0000
1036@@ -84,6 +84,8 @@
1037
1038 def _refresh(self, kb=False):
1039 # get the dates from the test data
1040+ if self.main_window.wideAspect:
1041+ self._ensure_tablet_tabs_loaded()
1042 self.assertThat(lambda: self.main_window.select_many('Label', objectName='DayDateLabel'), Eventually(Not(Is(None))))
1043 curr_dates = self.main_window.select_many('Label', objectName='DayDateLabel')
1044 tab1_curr_date = curr_dates[0].text
1045@@ -96,7 +98,7 @@
1046 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
1047
1048 # get the data from the refreshed tabs, have to be new
1049- self.assertThat(lambda: self.main_window.select_many('Label',objectName='DayDateLabel'), Eventually(Not(Is(None))))
1050+ self.assertThat(lambda: self.main_window.select_many('Label',objectName='DayDateLabel'), Eventually(Not(Is(None)), timeout=60))
1051 refreshed_dates = self.main_window.select_many('Label',objectName='DayDateLabel')
1052 self.assertNotEqual(tab1_curr_date, refreshed_dates[0].text)
1053 self.assertNotEqual(tab2_curr_date, refreshed_dates[2].text)
1054
1055=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_settings.py'
1056--- tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2014-02-18 17:55:17 +0000
1057+++ tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2014-02-26 17:08:27 +0000
1058@@ -41,14 +41,16 @@
1059 self.pointing_device.move_to_object(sheet)
1060
1061 def _check_units(self, units):
1062- """Checks selected units by values from the first location tab"""
1063- self.assertThat(lambda: self.main_window.select_many('QQuickText', objectName='CurrentTempText'),
1064+ """Checks selected units by values from the first location tab"""
1065+ if self.main_window.wideAspect:
1066+ self._ensure_tablet_tabs_loaded()
1067+ self.assertThat(lambda: self.main_window.select_many('QQuickText', objectName='CurrentTempText'),
1068 Eventually(Not(Is(None))))
1069- current_location_tab = self.main_window.select_single(
1070+ current_location_tab = self.main_window.wait_select_single(
1071 'LocationTab', visible=True)
1072- today_item = current_location_tab.select_single(
1073+ today_item = current_location_tab.wait_select_single(
1074 'QQuickItem', focus=True)
1075- today_temp = today_item.select_single(
1076+ today_temp = today_item.wait_select_single(
1077 'QQuickText', objectName='CurrentTempText')
1078 today_temp_scale = today_item.select_single(
1079 'QQuickText', objectName='CurrentTempScale')
1080@@ -67,8 +69,10 @@
1081
1082 def _check_wind_units(self, wind_units):
1083 """Checks selected units by values from the first location tab"""
1084- self.assertThat(lambda: self.main_window.select_many('WeatherDetailComponent', objectName='WindSpeedValue')[0],
1085- Eventually(Not(Is(None))))
1086+ if self.main_window.wideAspect:
1087+ self._ensure_tablet_tabs_loaded()
1088+ self.assertThat(lambda: self.main_window.select_many('WeatherDetailComponent', objectName='WindSpeedValue')[0],
1089+ Eventually(Not(Is(None))))
1090 current_location_tab = self.main_window.select_single(
1091 'LocationTab', visible=True)
1092 focused_item = current_location_tab.select_single(
1093@@ -90,7 +94,9 @@
1094
1095 def _check_precipitation_units(self, pre_units):
1096 """Checks selected units by values from the first location tab"""
1097- self.assertThat(lambda: self.main_window.select_many('WeatherDetailComponent', objectName='PrecipitationValue')[0],
1098+ if self.main_window.wideAspect:
1099+ self._ensure_tablet_tabs_loaded()
1100+ self.assertThat(lambda: self.main_window.select_many('WeatherDetailComponent', objectName='PrecipitationValue')[0],
1101 Eventually(Not(Is(None))))
1102 current_location_tab = self.main_window.select_single(
1103 'LocationTab', visible=True)
1104@@ -113,7 +119,9 @@
1105
1106 def _check_service(self, service):
1107 """Checks selected units weather data service from the first location tab"""
1108- self.assertThat(lambda: self.main_window.select_many('TabFooter', objectName='TabFooter')[0],
1109+ if self.main_window.wideAspect:
1110+ self._ensure_tablet_tabs_loaded()
1111+ self.assertThat(lambda: self.main_window.select_many('TabFooter', objectName='TabFooter')[0],
1112 Eventually(Not(Is(None))))
1113 current_location_tab = self.main_window.select_single('LocationTab', visible=True)
1114 self.assertThat(lambda: current_location_tab.select_single('TabFooter', objectName='TabFooter'),
1115
1116=== modified file 'ubuntu-weather-app.qml'
1117--- ubuntu-weather-app.qml 2014-02-21 10:40:01 +0000
1118+++ ubuntu-weather-app.qml 2014-02-26 17:08:27 +0000
1119@@ -31,7 +31,7 @@
1120
1121 id: mainView
1122
1123- width: units.gu(107)
1124+ width: units.gu(50)
1125 height: units.gu(67)
1126
1127 headerColor: "#E04414"
1128@@ -42,6 +42,8 @@
1129 property string newBackgroundColor: "#E04414"
1130 property string newFooterColor: "#E1983E"
1131
1132+ property bool wideAspect: width >= units.gu(80)
1133+
1134 property var locationsList: []
1135 property var tabsObject: null
1136 property int tabIndexAtRefresh: -1
1137@@ -257,8 +259,7 @@
1138
1139 Page {
1140 id:tabPage
1141- width: parent.width
1142- height:parent.height
1143+ anchors.fill: parent
1144 }
1145
1146 }

Subscribers

People subscribed via source and target branches