on xenial help sign in
Don't create the whole current scope delegates, just height * 3

Fixes: #1384374, #1384393 Approved by: Andrea Cimitan

commit422592feebe8af52bdb4a20543ac09c9ff9c07c4 authorAlbert Astals <albert.astals@canonical.com> dateTue 2 Dec 2014, 09:24 (12 years ago) parent3b43143bf8cb83
24 files changed+47−80
debian/control−1 plugins/Dash/CardCreator.js+2−5 plugins/Dash/CroppedImageMinimumSourceSize.qml+1−1 plugins/Dash/croppedimagesizer.cpp+3 plugins/Dash/croppedimagesizer.h+3−3 qml/Dash/CardCarousel.qml+1 qml/Dash/CardGrid.qml+1−1 qml/Dash/CardHorizontalList.qml+1 qml/Dash/CardVerticalJournal.qml−1 qml/Dash/DashRenderer.qml−4 qml/Dash/GenericScopeView.qml+22−25 qml/Dash/Previews/PreviewZoomableImage.qml+1 qml/Dash/ScopesOverviewAll.qml−2 qml/graphics/applicationIcons/dash@18.png → qml/graphics/applicationIcons/dash.png tests/autopilot/unity8/shell/emulators/dash.py+1−1 tests/plugins/Dash/cardcreator/1.res+1−2 tests/plugins/Dash/cardcreator/2.res+1−2 tests/plugins/Dash/cardcreator/3.res+1−2 tests/plugins/Dash/cardcreator/4.res+1−2 tests/plugins/Dash/cardcreator/5.res+1−2 tests/plugins/Dash/cardcreator/7.res+1−2 tests/qmltests/Dash/tst_Card.qml−22 tests/qmltests/Dash/tst_Dash.qml+4−2 tests/qmltests/Dash/tst_GenericScopeView.qml+1
debian/control−1
@@ -173,7 +173,6 @@ Depends: accountsservice-ubuntu-schemas (>= 0.0.3),
173173 libhardware2,
174174 unity-schemas (>= 7.3.1+14.10.20140915),
175175 pay-service,
176− qml-module-ubuntu-connectivity,
177176 ${misc:Depends},
178177 ${shlibs:Depends},
179178Provides: unity-launcher-impl,
plugins/Dash/CardCreator.js+2−5
@@ -85,8 +85,7 @@ var kArtShapeHolderCode = 'Item { \n\
8585 CroppedImageMinimumSourceSize { \n\
8686 id: artImage; \n\
8787 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\
9089 asynchronous: root.asynchronous; \n\
9190 visible: false; \n\
9291 width: %2; \n\
@@ -196,8 +195,7 @@ var kMascotImageCode = 'CroppedImageMinimumSourceSize { \n\
196195 id: mascotImage; \n\
197196 objectName: "mascotImage"; \n\
198197 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\
201199 width: units.gu(6); \n\
202200 height: units.gu(5.625); \n\
203201 horizontalAlignment: Image.AlignHCenter; \n\
@@ -656,7 +654,6 @@ function createCardComponent(parent, template, components) {
656654 var imports = 'import QtQuick 2.2; \n\
657655 import Ubuntu.Components 1.1; \n\
658656 import Ubuntu.Settings.Components 0.1; \n\
659− import Ubuntu.Connectivity 1.0; \n\
660657 import Dash 0.1;\n\
661658 import Utils 0.1;\n';
662659 var card = cardString(template, components);
plugins/Dash/CroppedImageMinimumSourceSize.qml+1−1
@@ -39,6 +39,6 @@ Item {
3939 anchors.fill: parent
4040 fillMode: Image.PreserveAspectCrop
4141 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
4343 }
4444}
plugins/Dash/croppedimagesizer.cpp+3
@@ -24,6 +24,9 @@
2424#include <QQuickView>
2525
2626CroppedImageSizer::CroppedImageSizer()
27+ : m_width(0),
28+ m_height(0),
29+ m_sourceSize(QSize(-1, -1))
2730{
2831 connect(this, &CroppedImageSizer::inputParamsChanged, this, &CroppedImageSizer::calculateSourceSize);
2932 connect(this, &CroppedImageSizer::sourceChanged, this, &CroppedImageSizer::requestImage);
plugins/Dash/croppedimagesizer.h+3−3
@@ -61,9 +61,9 @@ private Q_SLOT:
6161
6262private:
6363 QUrl m_source;
64− qreal m_width = 0;
65− qreal m_height = 0;
66− QSize m_sourceSize = QSize(-1, -1);
64+ qreal m_width;
65+ qreal m_height;
66+ QSize m_sourceSize;
6767 QSize m_imageSize;
6868 QNetworkReply *m_reply = nullptr;
6969};
qml/Dash/CardCarousel.qml+1
@@ -52,6 +52,7 @@ DashRenderer {
5252 function pressAndHold() { cardCarousel.pressAndHold(index, model.result, model) }
5353
5454 sourceComponent: cardTool.cardComponent
55+ asynchronous: true
5556 onLoaded: {
5657 item.fixedHeaderHeight = Qt.binding(function() { return carousel.headerHeight; });
5758 item.height = Qt.binding(function() { return cardTool.cardHeight; });
qml/Dash/CardGrid.qml+1−1
@@ -55,11 +55,11 @@ DashRenderer {
5555 delegate: Item {
5656 width: grid.cellWidth
5757 height: grid.cellHeight
58− visible: y + height >= root.visibleRangeBegin && y <= root.visibleRangeEnd
5958 Loader {
6059 id: loader
6160 sourceComponent: cardTool.cardComponent
6261 anchors.horizontalCenter: parent.horizontalCenter
62+ asynchronous: true
6363 onLoaded: {
6464 item.objectName = "delegate" + index;
6565 item.width = Qt.binding(function() { return cardTool.cardWidth; });
qml/Dash/CardHorizontalList.qml+1
@@ -42,6 +42,7 @@ DashRenderer {
4242 sourceComponent: cardTool.cardComponent
4343 anchors { top: parent.top; bottom: parent.bottom }
4444 width: cardTool.cardWidth
45+ asynchronous: true
4546 onLoaded: {
4647 item.objectName = "delegate" + index;
4748 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
qml/Dash/CardVerticalJournal.qml−1
@@ -66,7 +66,6 @@ DashRenderer {
6666 id: loader
6767 sourceComponent: cardTool.cardComponent
6868 width: cardTool.cardWidth
69− visible: y + height >= root.visibleRangeBegin && y <= root.visibleRangeEnd
7069 onLoaded: {
7170 item.objectName = "delegate" + index;
7271 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
qml/Dash/DashRenderer.qml−4
@@ -27,10 +27,6 @@ Item {
2727
2828 property int displayMarginEnd: 0
2929
30− property int visibleRangeBegin: 0
31−
32− property int visibleRangeEnd: 0
33−
3430 property real originY: 0
3531
3632 // The model to renderer
qml/Dash/GenericScopeView.qml+22−25
@@ -379,32 +379,29 @@ FocusScope {
379379 }
380380 }
381381
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−
387382 if (item && item.hasOwnProperty("displayMarginBeginning")) {
388− // TODO do we need item.originY here, test 1300302 once we have a silo
389− // and we can run it on the phone
390− if (scopeView.isCurrent) {
391− // 1073741823 is s^30 -1. A quite big number so that you have "infinite" display margin, but not so
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));
405− item.displayMarginEnd = -Math.round(Math.max(baseItem.height - seeAll.height -
406− categoryView.height + baseItem.y, 0));
407− }
383+ // A item view is considered visible from
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
400+ var extraMargins = scopeView.isCurrent ? categoryView.height * 1.5 : 0;
401+
402+ item.displayMarginBeginning = Math.round(-Math.max(-baseItem.y - extraMargins, 0));
403+ item.displayMarginEnd = -Math.round(Math.max(baseItem.height - extraMargins - seeAll.height -
404+ categoryView.height + baseItem.y, 0));
408405 }
409406 }
410407 }
qml/Dash/Previews/PreviewZoomableImage.qml+1
@@ -40,6 +40,7 @@ PreviewWidget {
4040 }
4141 scaleTo: "height"
4242 source: widgetData["source"]
43+ asynchronous: true
4344
4445 borderSource: mouseArea.pressed ? "radius_pressed.sci" : "radius_idle.sci"
4546
qml/Dash/ScopesOverviewAll.qml−2
@@ -43,8 +43,6 @@ Flickable {
4343 id: cardGrid
4444 width: root.width
4545 height: parent.height
46− visibleRangeBegin: root.contentY
47− visibleRangeEnd: root.contentY + root.height
4846
4947 onClicked: {
5048 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):
204204
205205 """
206206 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)
208208 self.pointing_device.click_object(icon)
209209
210210 def _get_category_element(self, category):
tests/plugins/Dash/cardcreator/1.res+1−2
@@ -49,8 +49,7 @@ Item {
4949 CroppedImageMinimumSourceSize {
5050 id: artImage;
5151 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"] || "";
5453 asynchronous: root.asynchronous;
5554 visible: false;
5655 width: root.width;
tests/plugins/Dash/cardcreator/2.res+1−2
@@ -68,8 +68,7 @@ CroppedImageMinimumSourceSize {
6868 id: mascotImage;
6969 objectName: "mascotImage";
7070 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"] || "";
7372 width: units.gu(6);
7473 height: units.gu(5.625);
7574 horizontalAlignment: Image.AlignHCenter;
tests/plugins/Dash/cardcreator/3.res+1−2
@@ -49,8 +49,7 @@ Item {
4949 CroppedImageMinimumSourceSize {
5050 id: artImage;
5151 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"] || "";
5453 asynchronous: root.asynchronous;
5554 visible: false;
5655 width: root.width;
tests/plugins/Dash/cardcreator/4.res+1−2
@@ -47,8 +47,7 @@ Loader {
4747 id: mascotImage;
4848 objectName: "mascotImage";
4949 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"] || "";
5251 width: units.gu(6);
5352 height: units.gu(5.625);
5453 horizontalAlignment: Image.AlignHCenter;
tests/plugins/Dash/cardcreator/5.res+1−2
@@ -49,8 +49,7 @@ Item {
4949 CroppedImageMinimumSourceSize {
5050 id: artImage;
5151 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"] || "";
5453 asynchronous: root.asynchronous;
5554 visible: false;
5655 width: root.width;
tests/plugins/Dash/cardcreator/7.res+1−2
@@ -68,8 +68,7 @@ CroppedImageMinimumSourceSize {
6868 id: mascotImage;
6969 objectName: "mascotImage";
7070 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"] || "";
7372 width: units.gu(6);
7473 height: units.gu(5.625);
7574 horizontalAlignment: Image.AlignHCenter;
tests/qmltests/Dash/tst_Card.qml−22
@@ -17,7 +17,6 @@
1717import QtQuick 2.0
1818import QtTest 1.0
1919import Ubuntu.Components 0.1
20−import Ubuntu.Connectivity 1.0
2120import Unity.Test 0.1 as UT
2221import "../../../qml/Dash"
2322import "CardHelpers.js" as Helpers
@@ -221,7 +220,6 @@ Rectangle {
221220
222221 function init() {
223222 loader.visible = true;
224− NetworkingStatus.limitedBandwith = false;
225223 }
226224
227225 function cleanup() {
@@ -585,25 +583,5 @@ Rectangle {
585583 verify((card.width - titleToCard.x - titleToCard.width) === units.gu(1));
586584 }
587585 }
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− }
608586 }
609587}
tests/qmltests/Dash/tst_Dash.qml+4−2
@@ -243,8 +243,10 @@ Item {
243243 tryCompare(scopesOverviewRepeater, "count", 0);
244244
245245 // Click on a temp scope in the search
246− var dashCategorysearchA = findChild(searchResultsViewer, "dashCategorysearchA");
247− var cardTempScope = findChild(dashCategorysearchA, "delegate2");
246+ tryCompareFunction( function() {
247+ return findChild(findChild(searchResultsViewer, "dashCategorysearchA"), "delegate2") != null;
248+ }, true);
249+ var cardTempScope = findChild(findChild(searchResultsViewer, "dashCategorysearchA"), "delegate2");
248250 verify(cardTempScope, "Could not find delegate2");
249251
250252 waitForRendering(cardTempScope);
tests/qmltests/Dash/tst_GenericScopeView.qml+1
@@ -293,6 +293,7 @@ Item {
293293 },
294294 true);
295295 var tile = findChild(findChild(genericScopeView, "dashCategory"+category), "delegate"+delegate);
296+ waitForRendering(tile);
296297 mouseClick(tile, tile.width / 2, tile.height / 2);
297298 tryCompare(testCase.subPageLoader, "open", true);
298299 tryCompare(testCase.subPageLoader, "x", 0);