on xenial help sign in
Save 0.2 msec on headers without mascot shape
commitf0632f592758d7f0032871c5dbbc19ab29b3adb0 authorAlbert Astals <albert.astals@canonical.com> dateTue 1 Apr 2014, 10:03 (13 years ago) parent11c5188
3 files changed+17−13
qml/Dash/CardHeader.qml+13−10 tests/qmltests/Dash/tst_Card.qml+2−2 tests/qmltests/Dash/tst_CardBenchmark.qml+2−1
qml/Dash/CardHeader.qml+13−10
@@ -44,7 +44,7 @@ Item {
4444
4545 property real margins: units.gu(1)
4646
47− spacing: mascotShape.visible || mascotImage.visible || inOverlay ? margins : 0
47+ spacing: mascotShapeLoader.active || mascotImage.visible || inOverlay ? margins : 0
4848 anchors {
4949 top: parent.top; left: parent.left; right: parent.right
5050 margins: margins
@@ -52,30 +52,33 @@ Item {
5252 rightMargin: spacing
5353 }
5454
55− UbuntuShape {
56− id: mascotShape
57− objectName: "mascotShape"
55+ Loader {
56+ id: mascotShapeLoader
57+ objectName: "mascotShapeLoader"
5858
59+ active: useMascotShape && mascotImage && mascotImage.status === Image.Ready
60+ visible: active
61+ anchors.verticalCenter: parent.verticalCenter
5962 // TODO karni: Icon aspect-ratio is 8:7.5. Revisit these values to avoid fraction of pixels.
6063 width: units.gu(6)
6164 height: units.gu(5.625)
62− anchors.verticalCenter: parent.verticalCenter
63− visible: useMascotShape && image && image.status === Image.Ready
6465 readonly property int maxSize: Math.max(width, height) * 4
6566
66− image: useMascotShape ? mascotImage : null
67+ sourceComponent: UbuntuShape {
68+ image: useMascotShape ? mascotImage : null
69+ }
6770 }
6871
6972 Image {
7073 id: mascotImage
7174 objectName: "mascotImage"
7275
73− width: source ? mascotShape.width : 0
74− height: mascotShape.height
76+ width: source ? mascotShapeLoader.width : 0
77+ height: mascotShapeLoader.height
7578 anchors.verticalCenter: parent.verticalCenter
7679 visible: !useMascotShape && status === Image.Ready
7780
78− sourceSize { width: mascotShape.maxSize; height: mascotShape.maxSize }
81+ sourceSize { width: mascotShapeLoader.maxSize; height: mascotShapeLoader.maxSize }
7982 fillMode: Image.PreserveAspectCrop
8083 horizontalAlignment: Image.AlignHCenter
8184 verticalAlignment: Image.AlignVCenter
tests/qmltests/Dash/tst_Card.qml+2−2
@@ -469,13 +469,13 @@ Rectangle {
469469 function test_mascotShape(data) {
470470 selector.selectedIndex = data.index;
471471
472− var shape = findChild(card, "mascotShape");
472+ var shape = findChild(card, "mascotShapeLoader");
473473 var image = findChild(card, "mascotImage");
474474
475475 verify(shape, "Could not find shape.");
476476 verify(image, "Could not find image.");
477477
478− tryCompare(shape, "visible", data.shape);
478+ tryCompare(shape, "active", data.shape);
479479 tryCompare(image, "visible", !data.shape);
480480 }
481481 }
tests/qmltests/Dash/tst_CardBenchmark.qml+2−1
@@ -36,7 +36,8 @@ Rectangle {
3636 "summary": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
3737 }'
3838
39− property string artCardModel: '{ "components": { "art": "art" } }'
39+// property string artCardModel: '{ "components": { "art": "art" } }'
40+ property string artCardModel: '{ "components": { "art": "art", "title": "title" } }'
4041
4142 CardTool {
4243 id: cardTool