on xenial help sign in
Don't create the whole current scope delegates, just height * 3
422592fAlbert Astals
debian/control−1
@@ -173,7 +173,6 @@ Depends: accountsservice-ubuntu-schemas (>= 0.0.3),
173 libhardware2,
173 libhardware2,
174 unity-schemas (>= 7.3.1+14.10.20140915),
174 unity-schemas (>= 7.3.1+14.10.20140915),
175 pay-service,
175 pay-service,
176− qml-module-ubuntu-connectivity,
177 ${misc:Depends},
176 ${misc:Depends},
178 ${shlibs:Depends},
177 ${shlibs:Depends},
179Provides: unity-launcher-impl,
178Provides: unity-launcher-impl,
plugins/Dash/CardCreator.js+2−5
@@ -85,8 +85,7 @@ var kArtShapeHolderCode = 'Item { \n\
85 CroppedImageMinimumSourceSize { \n\
85 CroppedImageMinimumSourceSize { \n\
86 id: artImage; \n\
86 id: artImage; \n\
87 objectName: "artImage"; \n\
87 objectName: "artImage"; \n\
88− property bool doLoadSource: !NetworkingStatus.limitedBandwith; \n\
89− source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["art"] || ""; } \n\
88+ source: cardData && cardData["art"] || ""; \n\
90 asynchronous: root.asynchronous; \n\
89 asynchronous: root.asynchronous; \n\
91 visible: false; \n\
90 visible: false; \n\
92 width: %2; \n\
91 width: %2; \n\
@@ -196,8 +195,7 @@ var kMascotImageCode = 'CroppedImageMinimumSourceSize { \n\
196 id: mascotImage; \n\
195 id: mascotImage; \n\
197 objectName: "mascotImage"; \n\
196 objectName: "mascotImage"; \n\
198 anchors { %1 } \n\
197 anchors { %1 } \n\
199− property bool doLoadSource: !NetworkingStatus.limitedBandwith; \n\
200− source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["mascot"] || ""; } \n\
198+ source: cardData && cardData["mascot"] || ""; \n\
201 width: units.gu(6); \n\
199 width: units.gu(6); \n\
202 height: units.gu(5.625); \n\
200 height: units.gu(5.625); \n\
203 horizontalAlignment: Image.AlignHCenter; \n\
201 horizontalAlignment: Image.AlignHCenter; \n\
@@ -656,7 +654,6 @@ function createCardComponent(parent, template, components) {
656 var imports = 'import QtQuick 2.2; \n\
654 var imports = 'import QtQuick 2.2; \n\
657 import Ubuntu.Components 1.1; \n\
655 import Ubuntu.Components 1.1; \n\
658 import Ubuntu.Settings.Components 0.1; \n\
656 import Ubuntu.Settings.Components 0.1; \n\
659− import Ubuntu.Connectivity 1.0; \n\
660 import Dash 0.1;\n\
657 import Dash 0.1;\n\
661 import Utils 0.1;\n';
658 import Utils 0.1;\n';
662 var card = cardString(template, components);
659 var card = cardString(template, components);
plugins/Dash/CroppedImageMinimumSourceSize.qml+1−1
@@ -39,6 +39,6 @@ Item {
39 anchors.fill: parent
39 anchors.fill: parent
40 fillMode: Image.PreserveAspectCrop
40 fillMode: Image.PreserveAspectCrop
41 sourceSize: sizer.sourceSize.width == 0 && sizer.sourceSize.height == 0 ? undefined : sizer.sourceSize
41 sourceSize: sizer.sourceSize.width == 0 && sizer.sourceSize.height == 0 ? undefined : sizer.sourceSize
42− source: sourceSize.width == -1 && sourceSize.height == -1 ? "" : root.source
42+ source: sizer.sourceSize.width == -1 && sizer.sourceSize.height == -1 ? "" : root.source
43 }
43 }
44}
44}
plugins/Dash/croppedimagesizer.cpp+3
@@ -24,6 +24,9 @@
24#include <QQuickView>
24#include <QQuickView>
25
25
26CroppedImageSizer::CroppedImageSizer()
26CroppedImageSizer::CroppedImageSizer()
27+ : m_width(0),
28+ m_height(0),
29+ m_sourceSize(QSize(-1, -1))
27{
30{
28 connect(this, &CroppedImageSizer::inputParamsChanged, this, &CroppedImageSizer::calculateSourceSize);
31 connect(this, &CroppedImageSizer::inputParamsChanged, this, &CroppedImageSizer::calculateSourceSize);
29 connect(this, &CroppedImageSizer::sourceChanged, this, &CroppedImageSizer::requestImage);
32 connect(this, &CroppedImageSizer::sourceChanged, this, &CroppedImageSizer::requestImage);
plugins/Dash/croppedimagesizer.h+3−3
@@ -61,9 +61,9 @@ private Q_SLOT:
61
61
62private:
62private:
63 QUrl m_source;
63 QUrl m_source;
64− qreal m_width = 0;
64+ qreal m_width;
65− qreal m_height = 0;
65+ qreal m_height;
66− QSize m_sourceSize = QSize(-1, -1);
66+ QSize m_sourceSize;
67 QSize m_imageSize;
67 QSize m_imageSize;
68 QNetworkReply *m_reply = nullptr;
68 QNetworkReply *m_reply = nullptr;
69};
69};
qml/Dash/CardCarousel.qml+1
@@ -52,6 +52,7 @@ DashRenderer {
52 function pressAndHold() { cardCarousel.pressAndHold(index, model.result, model) }
52 function pressAndHold() { cardCarousel.pressAndHold(index, model.result, model) }
53
53
54 sourceComponent: cardTool.cardComponent
54 sourceComponent: cardTool.cardComponent
55+ asynchronous: true
55 onLoaded: {
56 onLoaded: {
56 item.fixedHeaderHeight = Qt.binding(function() { return carousel.headerHeight; });
57 item.fixedHeaderHeight = Qt.binding(function() { return carousel.headerHeight; });
57 item.height = Qt.binding(function() { return cardTool.cardHeight; });
58 item.height = Qt.binding(function() { return cardTool.cardHeight; });
qml/Dash/CardGrid.qml+1−1
@@ -55,11 +55,11 @@ DashRenderer {
55 delegate: Item {
55 delegate: Item {
56 width: grid.cellWidth
56 width: grid.cellWidth
57 height: grid.cellHeight
57 height: grid.cellHeight
58− visible: y + height >= root.visibleRangeBegin && y <= root.visibleRangeEnd
59 Loader {
58 Loader {
60 id: loader
59 id: loader
61 sourceComponent: cardTool.cardComponent
60 sourceComponent: cardTool.cardComponent
62 anchors.horizontalCenter: parent.horizontalCenter
61 anchors.horizontalCenter: parent.horizontalCenter
62+ asynchronous: true
63 onLoaded: {
63 onLoaded: {
64 item.objectName = "delegate" + index;
64 item.objectName = "delegate" + index;
65 item.width = Qt.binding(function() { return cardTool.cardWidth; });
65 item.width = Qt.binding(function() { return cardTool.cardWidth; });
qml/Dash/CardHorizontalList.qml+1
@@ -42,6 +42,7 @@ DashRenderer {
42 sourceComponent: cardTool.cardComponent
42 sourceComponent: cardTool.cardComponent
43 anchors { top: parent.top; bottom: parent.bottom }
43 anchors { top: parent.top; bottom: parent.bottom }
44 width: cardTool.cardWidth
44 width: cardTool.cardWidth
45+ asynchronous: true
45 onLoaded: {
46 onLoaded: {
46 item.objectName = "delegate" + index;
47 item.objectName = "delegate" + index;
47 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
48 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
qml/Dash/CardVerticalJournal.qml−1
@@ -66,7 +66,6 @@ DashRenderer {
66 id: loader
66 id: loader
67 sourceComponent: cardTool.cardComponent
67 sourceComponent: cardTool.cardComponent
68 width: cardTool.cardWidth
68 width: cardTool.cardWidth
69− visible: y + height >= root.visibleRangeBegin && y <= root.visibleRangeEnd
70 onLoaded: {
69 onLoaded: {
71 item.objectName = "delegate" + index;
70 item.objectName = "delegate" + index;
72 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
71 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
qml/Dash/DashRenderer.qml−4
@@ -27,10 +27,6 @@ Item {
27
27
28 property int displayMarginEnd: 0
28 property int displayMarginEnd: 0
29
29
30− property int visibleRangeBegin: 0
31−
32− property int visibleRangeEnd: 0
33−
34 property real originY: 0
30 property real originY: 0
35
31
36 // The model to renderer
32 // The model to renderer
qml/Dash/GenericScopeView.qml+22−25
@@ -379,32 +379,29 @@ FocusScope {
379 }
379 }
380 }
380 }
381
381
382− if (item && item.hasOwnProperty("visibleRangeBegin")) {
383− item.visibleRangeBegin = Math.max(-baseItem.y, 0)
384− item.visibleRangeEnd = item.visibleRangeBegin + Math.min(categoryView.height, rendererLoader.height)
385− }
386−
387 if (item && item.hasOwnProperty("displayMarginBeginning")) {
382 if (item && item.hasOwnProperty("displayMarginBeginning")) {
388− // TODO do we need item.originY here, test 1300302 once we have a silo
383+ // A item view is considered visible from
389− // and we can run it on the phone
384+ // -displayMarginBeginning
385+ // to
386+ // height + item.displayMarginEnd
387+ // We adjust displayMarginBeginning and displayMarginEnd so
388+ // * In non visible scopes only the viewport is considered visible
389+ // that way when you switch to it the visible items are there
390+ // * For visible scopes we increase the visible range by categoryView.height * 1.5
391+ // in both directions to make scrolling nicer by mantaining a higher number of
392+ // cached items
393+ // TODO Improvements
394+ // - For non visible scopes we should always have a visible range of 0 and
395+ // make sure the items in the viewport are created with the cache buffer feature
396+ // - For visible scopes we should always the have a visible range be exactly the
397+ // viewport and make sure the rest of items are created with the cache buffer feature
398+ // To be able to implement that feature VerticalJournal/AbstractDashView needs to
399+ // make the cache buffer value setable externally
390− if (scopeView.isCurrent) {
400+ var extraMargins = scopeView.isCurrent ? categoryView.height * 1.5 : 0;
391− // 1073741823 is s^30 -1. A quite big number so that you have "infinite" display margin, but not so
401+
392− // big so that if you add if with itself you're outside the 2^31 int range
393− item.displayMarginBeginning = 1073741823;
394− item.displayMarginEnd = 1073741823;
395− } else if (baseItem.y + baseItem.height <= 0) {
396− // Not visible (item at top of the list viewport)
397− item.displayMarginBeginning = -baseItem.height;
398− item.displayMarginEnd = 0;
399− } else if (baseItem.y >= categoryView.height) {
400− // Not visible (item at bottom of the list viewport)
401− item.displayMarginBeginning = 0;
402− item.displayMarginEnd = -baseItem.height;
403− } else {
404− item.displayMarginBeginning = Math.round(-Math.max(-baseItem.y, 0));
402+ item.displayMarginBeginning = Math.round(-Math.max(-baseItem.y - extraMargins, 0));
405− item.displayMarginEnd = -Math.round(Math.max(baseItem.height - seeAll.height -
403+ item.displayMarginEnd = -Math.round(Math.max(baseItem.height - extraMargins - seeAll.height -
406− categoryView.height + baseItem.y, 0));
404+ categoryView.height + baseItem.y, 0));
407− }
408 }
405 }
409 }
406 }
410 }
407 }
qml/Dash/Previews/PreviewZoomableImage.qml+1
@@ -40,6 +40,7 @@ PreviewWidget {
40 }
40 }
41 scaleTo: "height"
41 scaleTo: "height"
42 source: widgetData["source"]
42 source: widgetData["source"]
43+ asynchronous: true
43
44
44 borderSource: mouseArea.pressed ? "radius_pressed.sci" : "radius_idle.sci"
45 borderSource: mouseArea.pressed ? "radius_pressed.sci" : "radius_idle.sci"
45
46
qml/Dash/ScopesOverviewAll.qml−2
@@ -43,8 +43,6 @@ Flickable {
43 id: cardGrid
43 id: cardGrid
44 width: root.width
44 width: root.width
45 height: parent.height
45 height: parent.height
46− visibleRangeBegin: root.contentY
47− visibleRangeEnd: root.contentY + root.height
48
46
49 onClicked: {
47 onClicked: {
50 root.clicked(index, result, item, itemModel);
48 root.clicked(index, result, item, itemModel);
qml/graphics/applicationIcons/dash@18.png → qml/graphics/applicationIcons/dash.pngrenamed

Binary file not shown.

tests/autopilot/unity8/shell/emulators/dash.py+1−1
@@ -204,7 +204,7 @@ class GenericScopeView(emulators.UnityEmulatorBase):
204
204
205 """
205 """
206 category_element = self._get_category_element(category)
206 category_element = self._get_category_element(category)
207− icon = category_element.select_single('AbstractButton', title=title)
207+ icon = category_element.wait_select_single('AbstractButton', title=title)
208 self.pointing_device.click_object(icon)
208 self.pointing_device.click_object(icon)
209
209
210 def _get_category_element(self, category):
210 def _get_category_element(self, category):
tests/plugins/Dash/cardcreator/1.res+1−2
@@ -49,8 +49,7 @@ Item {
49 CroppedImageMinimumSourceSize {
49 CroppedImageMinimumSourceSize {
50 id: artImage;
50 id: artImage;
51 objectName: "artImage";
51 objectName: "artImage";
52− property bool doLoadSource: !NetworkingStatus.limitedBandwith;
53− source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["art"] || ""; }
52+ source: cardData && cardData["art"] || "";
54 asynchronous: root.asynchronous;
53 asynchronous: root.asynchronous;
55 visible: false;
54 visible: false;
56 width: root.width;
55 width: root.width;
tests/plugins/Dash/cardcreator/2.res+1−2
@@ -68,8 +68,7 @@ CroppedImageMinimumSourceSize {
68 id: mascotImage;
68 id: mascotImage;
69 objectName: "mascotImage";
69 objectName: "mascotImage";
70 anchors { verticalCenter: parent.verticalCenter; }
70 anchors { verticalCenter: parent.verticalCenter; }
71− property bool doLoadSource: !NetworkingStatus.limitedBandwith;
72− source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["mascot"] || ""; }
71+ source: cardData && cardData["mascot"] || "";
73 width: units.gu(6);
72 width: units.gu(6);
74 height: units.gu(5.625);
73 height: units.gu(5.625);
75 horizontalAlignment: Image.AlignHCenter;
74 horizontalAlignment: Image.AlignHCenter;
tests/plugins/Dash/cardcreator/3.res+1−2
@@ -49,8 +49,7 @@ Item {
49 CroppedImageMinimumSourceSize {
49 CroppedImageMinimumSourceSize {
50 id: artImage;
50 id: artImage;
51 objectName: "artImage";
51 objectName: "artImage";
52− property bool doLoadSource: !NetworkingStatus.limitedBandwith;
53− source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["art"] || ""; }
52+ source: cardData && cardData["art"] || "";
54 asynchronous: root.asynchronous;
53 asynchronous: root.asynchronous;
55 visible: false;
54 visible: false;
56 width: root.width;
55 width: root.width;
tests/plugins/Dash/cardcreator/4.res+1−2
@@ -47,8 +47,7 @@ Loader {
47 id: mascotImage;
47 id: mascotImage;
48 objectName: "mascotImage";
48 objectName: "mascotImage";
49 anchors { verticalCenter: parent.verticalCenter; }
49 anchors { verticalCenter: parent.verticalCenter; }
50− property bool doLoadSource: !NetworkingStatus.limitedBandwith;
51− source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["mascot"] || ""; }
50+ source: cardData && cardData["mascot"] || "";
52 width: units.gu(6);
51 width: units.gu(6);
53 height: units.gu(5.625);
52 height: units.gu(5.625);
54 horizontalAlignment: Image.AlignHCenter;
53 horizontalAlignment: Image.AlignHCenter;
tests/plugins/Dash/cardcreator/5.res+1−2
@@ -49,8 +49,7 @@ Item {
49 CroppedImageMinimumSourceSize {
49 CroppedImageMinimumSourceSize {
50 id: artImage;
50 id: artImage;
51 objectName: "artImage";
51 objectName: "artImage";
52− property bool doLoadSource: !NetworkingStatus.limitedBandwith;
53− source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["art"] || ""; }
52+ source: cardData && cardData["art"] || "";
54 asynchronous: root.asynchronous;
53 asynchronous: root.asynchronous;
55 visible: false;
54 visible: false;
56 width: root.width;
55 width: root.width;
tests/plugins/Dash/cardcreator/7.res+1−2
@@ -68,8 +68,7 @@ CroppedImageMinimumSourceSize {
68 id: mascotImage;
68 id: mascotImage;
69 objectName: "mascotImage";
69 objectName: "mascotImage";
70 anchors { verticalCenter: parent.verticalCenter; }
70 anchors { verticalCenter: parent.verticalCenter; }
71− property bool doLoadSource: !NetworkingStatus.limitedBandwith;
72− source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["mascot"] || ""; }
71+ source: cardData && cardData["mascot"] || "";
73 width: units.gu(6);
72 width: units.gu(6);
74 height: units.gu(5.625);
73 height: units.gu(5.625);
75 horizontalAlignment: Image.AlignHCenter;
74 horizontalAlignment: Image.AlignHCenter;
tests/qmltests/Dash/tst_Card.qml−22
@@ -17,7 +17,6 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import QtTest 1.0
18import QtTest 1.0
19import Ubuntu.Components 0.1
19import Ubuntu.Components 0.1
20−import Ubuntu.Connectivity 1.0
21import Unity.Test 0.1 as UT
20import Unity.Test 0.1 as UT
22import "../../../qml/Dash"
21import "../../../qml/Dash"
23import "CardHelpers.js" as Helpers
22import "CardHelpers.js" as Helpers
@@ -221,7 +220,6 @@ Rectangle {
221
220
222 function init() {
221 function init() {
223 loader.visible = true;
222 loader.visible = true;
224− NetworkingStatus.limitedBandwith = false;
225 }
223 }
226
224
227 function cleanup() {
225 function cleanup() {
@@ -585,25 +583,5 @@ Rectangle {
585 verify((card.width - titleToCard.x - titleToCard.width) === units.gu(1));
583 verify((card.width - titleToCard.x - titleToCard.width) === units.gu(1));
586 }
584 }
587 }
585 }
588−
589− function test_load_images_visibility_network_data() {
590− return [
591− { tag: "Visible, network", visible: true, limitedBandwith: false },
592− { tag: "Visible, no network", visible: true, limitedBandwith: true },
593− { tag: "Not Visible, network", visible: false, limitedBandwith: false },
594− { tag: "Not Visible, no network", visible: false, limitedBandwith: true }
595− ];
596− }
597−
598− function test_load_images_visibility_network(data) {
599− loader.visible = data.visible;
600− NetworkingStatus.limitedBandwith = data.limitedBandwith;
601−
602− selector.selectedIndex = 0;
603− waitForRendering(selector);
604− waitForRendering(card);
605−
606− verify(data.visible || !data.limitedBandwith || artImage.source == "");
607− }
608 }
586 }
609}
587}
tests/qmltests/Dash/tst_Dash.qml+4−2
@@ -243,8 +243,10 @@ Item {
243 tryCompare(scopesOverviewRepeater, "count", 0);
243 tryCompare(scopesOverviewRepeater, "count", 0);
244
244
245 // Click on a temp scope in the search
245 // Click on a temp scope in the search
246+ tryCompareFunction( function() {
246− var dashCategorysearchA = findChild(searchResultsViewer, "dashCategorysearchA");
247+ return findChild(findChild(searchResultsViewer, "dashCategorysearchA"), "delegate2") != null;
248+ }, true);
247− var cardTempScope = findChild(dashCategorysearchA, "delegate2");
249+ var cardTempScope = findChild(findChild(searchResultsViewer, "dashCategorysearchA"), "delegate2");
248 verify(cardTempScope, "Could not find delegate2");
250 verify(cardTempScope, "Could not find delegate2");
249
251
250 waitForRendering(cardTempScope);
252 waitForRendering(cardTempScope);
tests/qmltests/Dash/tst_GenericScopeView.qml+1
@@ -293,6 +293,7 @@ Item {
293 },
293 },
294 true);
294 true);
295 var tile = findChild(findChild(genericScopeView, "dashCategory"+category), "delegate"+delegate);
295 var tile = findChild(findChild(genericScopeView, "dashCategory"+category), "delegate"+delegate);
296+ waitForRendering(tile);
296 mouseClick(tile, tile.width / 2, tile.height / 2);
297 mouseClick(tile, tile.width / 2, tile.height / 2);
297 tryCompare(testCase.subPageLoader, "open", true);
298 tryCompare(testCase.subPageLoader, "open", true);
298 tryCompare(testCase.subPageLoader, "x", 0);
299 tryCompare(testCase.subPageLoader, "x", 0);