on xenial help sign in
Merged cleanup and 5.2
26758dcAndrea Cimitan
plugins/DashViews/listviewwithpageheader.cpp+27−9
@@ -91,6 +91,7 @@
91
91
92#include "listviewwithpageheader.h"
92#include "listviewwithpageheader.h"
93
93
94+#include <QCoreApplication>
94#include <QDebug>
95#include <QDebug>
95#include <qqmlinfo.h>
96#include <qqmlinfo.h>
96#include <qqmlengine.h>
97#include <qqmlengine.h>
@@ -484,6 +485,11 @@ void ListViewWithPageHeader::componentComplete()
484 polish();
485 polish();
485}
486}
486
487
488+static inline bool uFuzzyCompare(qreal r1, qreal r2)
489+{
490+ return qFuzzyCompare(r1, r2) || (qFuzzyIsNull(r1) && qFuzzyIsNull(r2));
491+}
492+
487void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
493void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
488{
494{
489 // Check we are not being taken down and don't paint anything
495 // Check we are not being taken down and don't paint anything
@@ -498,11 +504,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
498 const bool showHeaderAnimationRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationShowHeader;
504 const bool showHeaderAnimationRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationShowHeader;
499 if (m_headerItem) {
505 if (m_headerItem) {
500 const auto oldHeaderItemShownHeight = m_headerItemShownHeight;
506 const auto oldHeaderItemShownHeight = m_headerItemShownHeight;
501− if (contentY() < -m_minYExtent) {
507+ if (uFuzzyCompare(contentY(), -m_minYExtent) || contentY() > -m_minYExtent) {
502− // Stick the header item to the top when dragging down
503− m_headerItem->setY(contentY());
504− m_headerItem->setHeight(m_headerItem->implicitHeight() + (-m_minYExtent - contentY()));
505− } else {
506 m_headerItem->setHeight(m_headerItem->implicitHeight());
508 m_headerItem->setHeight(m_headerItem->implicitHeight());
507 // We are going down (but it's not because of the rebound at the end)
509 // We are going down (but it's not because of the rebound at the end)
508 // (but the header was not shown by it's own position)
510 // (but the header was not shown by it's own position)
@@ -516,21 +518,32 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
516 m_headerItemShownHeight = 0;
518 m_headerItemShownHeight = 0;
517 m_headerItem->setY(-m_minYExtent);
519 m_headerItem->setY(-m_minYExtent);
518 } else if ((scrolledUp && notRebounding && notShownByItsOwn && !maximizeVisibleAreaRunning) || (m_headerItemShownHeight > 0) || m_inContentHeightKeepHeaderShown) {
520 } else if ((scrolledUp && notRebounding && notShownByItsOwn && !maximizeVisibleAreaRunning) || (m_headerItemShownHeight > 0) || m_inContentHeightKeepHeaderShown) {
521+ if (maximizeVisibleAreaRunning && diff > 0) {
519− if (maximizeVisibleAreaRunning && diff > 0) // If we are maximizing and the header was shown, make sure we hide it
522+ // If we are maximizing and the header was shown, make sure we hide it
520 m_headerItemShownHeight -= diff;
523 m_headerItemShownHeight -= diff;
521− else
524+ } else {
522 m_headerItemShownHeight += diff;
525 m_headerItemShownHeight += diff;
526+ }
523− if (contentY() == -m_minYExtent) {
527+ if (uFuzzyCompare(contentY(), -m_minYExtent)) {
524 m_headerItemShownHeight = 0;
528 m_headerItemShownHeight = 0;
525 } else {
529 } else {
526 m_headerItemShownHeight = qBound(static_cast<qreal>(0.), m_headerItemShownHeight, m_headerItem->height());
530 m_headerItemShownHeight = qBound(static_cast<qreal>(0.), m_headerItemShownHeight, m_headerItem->height());
527 }
531 }
528 if (m_headerItemShownHeight > 0) {
532 if (m_headerItemShownHeight > 0) {
533+ if (uFuzzyCompare(m_headerItem->height(), m_headerItemShownHeight)) {
534+ m_headerItem->setY(contentY());
535+ m_headerItemShownHeight = m_headerItem->height();
536+ } else {
529− m_headerItem->setY(contentY() - m_headerItem->height() + m_headerItemShownHeight);
537+ m_headerItem->setY(contentY() - m_headerItem->height() + m_headerItemShownHeight);
538+ }
530 } else {
539 } else {
531 m_headerItem->setY(-m_minYExtent);
540 m_headerItem->setY(-m_minYExtent);
532 }
541 }
533 }
542 }
543+ } else {
544+ // Stick the header item to the top when dragging down
545+ m_headerItem->setY(contentY());
546+ m_headerItem->setHeight(m_headerItem->implicitHeight() + (-m_minYExtent - contentY()));
534 }
547 }
535 // We will be changing the clip item, need to accomadate for it
548 // We will be changing the clip item, need to accomadate for it
536 // otherwise we move the firstItem down/up twice (unless the
549 // otherwise we move the firstItem down/up twice (unless the
@@ -1271,6 +1284,11 @@ void ListViewWithPageHeader::updatePolish()
1271 refill();
1284 refill();
1272
1285
1273 if (m_contentHeightDirty) {
1286 if (m_contentHeightDirty) {
1287+ // We need to make sure all bindings have updated otherwise
1288+ // we may end up with bindings updating when we call setContentHeight
1289+ // and then everything gets out of sync, i.e. testHeaderPositionBug1240118
1290+ QCoreApplication::instance()->processEvents();
1291+
1274 qreal contentHeight;
1292 qreal contentHeight;
1275 if (m_visibleItems.isEmpty()) {
1293 if (m_visibleItems.isEmpty()) {
1276 contentHeight = m_headerItem ? m_headerItem->height() : 0;
1294 contentHeight = m_headerItem ? m_headerItem->height() : 0;
qml/Components/Stage.qml+4−6
@@ -339,13 +339,11 @@ Showable {
339
339
340 ScriptAction {
340 ScriptAction {
341 script: {
341 script: {
342− if (!stage.focusedApplicationWhenUsingScreenshots) {
343− // FIXME: only here to support case where application does
342+ // FIXME: only here to support case where application does
344− // not exist yet but is about to
343+ // not exist yet but is about to
345− return;
344+ if (stage.focusedApplicationWhenUsingScreenshots) {
345+ stage.__focusApplication(stage.focusedApplicationWhenUsingScreenshots);
346 }
346 }
347−
348− stage.__focusApplication(stage.focusedApplicationWhenUsingScreenshots);
349 }
347 }
350 }
348 }
351 }
349 }
tests/plugins/DashViews/listviewwithpageheadertest.cpp−6
@@ -1281,9 +1281,6 @@ private Q_SLOTS:
1281
1281
1282 void testShowHeaderHalfShown()
1282 void testShowHeaderHalfShown()
1283 {
1283 {
1284−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
1285− QSKIP("This test is extremely unstable in 5.0.x");
1286−#endif
1287 changeContentY(20);
1284 changeContentY(20);
1288
1285
1289 QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1286 QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
@@ -1860,9 +1857,6 @@ private Q_SLOTS:
1860 model->setProperty(4, "size", 10);
1857 model->setProperty(4, "size", 10);
1861 model->setProperty(5, "size", 10);
1858 model->setProperty(5, "size", 10);
1862 model->setProperty(6, "size", 10);
1859 model->setProperty(6, "size", 10);
1863−#if (QT_VERSION > QT_VERSION_CHECK(5, 0, 3))
1864− QTRY_COMPARE(lvwph->m_minYExtent, 210.);
1865−#endif
1866 QTRY_COMPARE(lvwph->m_headerItem->y(), -lvwph->m_minYExtent);
1860 QTRY_COMPARE(lvwph->m_headerItem->y(), -lvwph->m_minYExtent);
1867 }
1861 }
1868
1862
tests/plugins/DashViews/listviewwithpageheadertestsection.cpp−3
@@ -1486,9 +1486,6 @@ private Q_SLOTS:
1486
1486
1487 void testShowHeaderHalfShown()
1487 void testShowHeaderHalfShown()
1488 {
1488 {
1489−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
1490− QSKIP("This test is extremely unstable in 5.0.x");
1491−#endif
1492 changeContentY(20);
1489 changeContentY(20);
1493
1490
1494 QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
1491 QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
tests/qmltests/Components/tst_LazyImage.qml+1−1
@@ -155,7 +155,7 @@ Rectangle {
155
155
156 if (data.transition) {
156 if (data.transition) {
157 // wait for the transition to complete
157 // wait for the transition to complete
158− var transition = findInvisibleChild(data.image, data.transition);
158+ var transition = findChildIn(data.image, "transitions", data.transition);
159 tryCompare(transition, "running", true);
159 tryCompare(transition, "running", true);
160 tryCompare(transition, "running", false);
160 tryCompare(transition, "running", false);
161 }
161 }
tests/qmltests/Dash/Previews/tst_PreviewVideoPlayback.qml−6
@@ -53,12 +53,6 @@ Rectangle {
53 function test_loadScreenshot() {
53 function test_loadScreenshot() {
54 var screenshot = findChild(videoPlayback, "screenshot");
54 var screenshot = findChild(videoPlayback, "screenshot");
55
55
56− videoPlayback.widgetData = widgetData0;
57− tryCompare(screenshot.visible, false);
58−
59− videoPlayback.widgetData = widgetData1;
60− tryCompare(screenshot.visible, true);
61−
62 videoPlayback.widgetData = widgetData2;
56 videoPlayback.widgetData = widgetData2;
63 var screenshotSource = screenshot.source
57 var screenshotSource = screenshot.source
64 verify(screenshotSource.toString().indexOf("image://thumbnailer/") === 0)
58 verify(screenshotSource.toString().indexOf("image://thumbnailer/") === 0)
tests/qmltests/Dash/Previews/tst_PreviewZoomableImage.qml+3−4
@@ -30,14 +30,13 @@ Rectangle {
30 }
30 }
31
31
32 property var widgetData1: {
32 property var widgetData1: {
33− "source": "../../graphics/phone_background.jpg",
33+ "source": Qt.resolvedUrl("../artwork/checkers.png"),
34 "zoomable": false
34 "zoomable": false
35 }
35 }
36
36
37 PreviewZoomableImage {
37 PreviewZoomableImage {
38 id: zoomableImage
38 id: zoomableImage
39 width: parent.width
39 width: parent.width
40− widgetData: widgetData1
41 }
40 }
42
41
43 UT.UnityTestCase {
42 UT.UnityTestCase {
@@ -48,10 +47,10 @@ Rectangle {
48 var image = findChild(zoomableImage, "image");
47 var image = findChild(zoomableImage, "image");
49
48
50 zoomableImage.widgetData = widgetData0;
49 zoomableImage.widgetData = widgetData0;
51− tryCompare(image.state, "default");
50+ tryCompare(image, "state", "default");
52
51
53 zoomableImage.widgetData = widgetData1;
52 zoomableImage.widgetData = widgetData1;
54− tryCompare(image.state, "ready");
53+ tryCompare(image, "state", "ready");
55 }
54 }
56 }
55 }
57}
56}
tests/qmltests/Dash/tst_CardHeader.qml+1−1
@@ -122,7 +122,7 @@ Rectangle {
122 return [
122 return [
123 { tag: "Column width", object: column, width: cardHeader.width },
123 { tag: "Column width", object: column, width: cardHeader.width },
124 { tag: "Column width with mascot", object: column, width: cardHeader.width - mascot.width - outerRow.margins * 3, mascot: "artwork/avatar.png" },
124 { tag: "Column width with mascot", object: column, width: cardHeader.width - mascot.width - outerRow.margins * 3, mascot: "artwork/avatar.png" },
125− { tag: "Header height", object: cardHeader, height: function() { return subtitleLabel.y + subtitleLabel.height + outerRow.margins * 2 } },
125+ { tag: "Header height", object: cardHeader, height: function() { return outerRow.height + outerRow.margins * 2 } },
126 ]
126 ]
127 }
127 }
128
128
tests/qmltests/Dash/tst_GenericScopeView.qml+1−1
@@ -69,7 +69,7 @@ Item {
69 function init() {
69 function init() {
70 shell.width = units.gu(120)
70 shell.width = units.gu(120)
71 genericScopeView.categoryView.positionAtBeginning();
71 genericScopeView.categoryView.positionAtBeginning();
72− tryCompare(genericScopeView.categoryView.contentY, 0)
72+ tryCompare(genericScopeView.categoryView, "contentY", 0)
73 }
73 }
74
74
75 function test_isCurrent() {
75 function test_isCurrent() {
tests/qmltests/tst_Shell.qml+2−2
@@ -232,8 +232,8 @@ Item {
232
232
233 var dash = findChild(shell, "dash");
233 var dash = findChild(shell, "dash");
234 // check that dash has normal scale and opacity
234 // check that dash has normal scale and opacity
235− tryCompare(dash.contentScale, 1.0);
235+ tryCompare(dash, "contentScale", 1.0);
236− tryCompare(dash.opacity, 1.0);
236+ tryCompare(dash, "opacity", 1.0);
237
237
238 touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
238 touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
239 true /* beginTouch */, false /* endTouch */);
239 true /* beginTouch */, false /* endTouch */);
tests/utils/modules/Unity/Test/UnityTestCase.qml+10−16
@@ -71,19 +71,8 @@ TestCase {
71
71
72
72
73 // Find an object with the given name in the children tree of "obj"
73 // Find an object with the given name in the children tree of "obj"
74− function findChild(obj,objectName) {
74+ function findChild(obj, objectName) {
75− var childs = new Array(0);
75+ return findChildIn(obj, "children", objectName);
76− childs.push(obj)
77− while (childs.length > 0) {
78− if (childs[0].objectName == objectName) {
79− return childs[0]
80− }
81− for (var i in childs[0].children) {
82− childs.push(childs[0].children[i])
83− }
84− childs.splice(0, 1);
85− }
86− return null;
87 }
76 }
88
77
89 // Find an object with the given name in the children tree of "obj"
78 // Find an object with the given name in the children tree of "obj"
@@ -91,15 +80,20 @@ TestCase {
91 // Note: you should use findChild if you're not sure you need this
80 // Note: you should use findChild if you're not sure you need this
92 // as this tree is much bigger and might contain stuff that goes
81 // as this tree is much bigger and might contain stuff that goes
93 // away randomly.
82 // away randomly.
94− function findInvisibleChild(obj,objectName) {
83+ function findInvisibleChild(obj, objectName) {
84+ return findChildIn(obj, "data", objectName);
85+ }
86+
87+ // Find a child in the named property
88+ function findChildIn(obj, prop, objectName) {
95 var childs = new Array(0);
89 var childs = new Array(0);
96 childs.push(obj)
90 childs.push(obj)
97 while (childs.length > 0) {
91 while (childs.length > 0) {
98 if (childs[0].objectName == objectName) {
92 if (childs[0].objectName == objectName) {
99 return childs[0]
93 return childs[0]
100 }
94 }
101− for (var i in childs[0].data) {
95+ for (var i in childs[0][prop]) {
102− childs.push(childs[0].data[i])
96+ childs.push(childs[0][prop][i])
103 }
97 }
104 childs.splice(0, 1);
98 childs.splice(0, 1);
105 }
99 }