on xenial help sign in
Save 0.2 msec on headers without mascot shape
f0632f5Albert Astals
qml/Dash/CardHeader.qml+13−10
@@ -44,7 +44,7 @@ Item {
44
44
45 property real margins: units.gu(1)
45 property real margins: units.gu(1)
46
46
47− spacing: mascotShape.visible || mascotImage.visible || inOverlay ? margins : 0
47+ spacing: mascotShapeLoader.active || mascotImage.visible || inOverlay ? margins : 0
48 anchors {
48 anchors {
49 top: parent.top; left: parent.left; right: parent.right
49 top: parent.top; left: parent.left; right: parent.right
50 margins: margins
50 margins: margins
@@ -52,30 +52,33 @@ Item {
52 rightMargin: spacing
52 rightMargin: spacing
53 }
53 }
54
54
55− UbuntuShape {
55+ Loader {
56− id: mascotShape
56+ id: mascotShapeLoader
57− objectName: "mascotShape"
57+ objectName: "mascotShapeLoader"
58
58
59+ active: useMascotShape && mascotImage && mascotImage.status === Image.Ready
60+ visible: active
61+ anchors.verticalCenter: parent.verticalCenter
59 // TODO karni: Icon aspect-ratio is 8:7.5. Revisit these values to avoid fraction of pixels.
62 // TODO karni: Icon aspect-ratio is 8:7.5. Revisit these values to avoid fraction of pixels.
60 width: units.gu(6)
63 width: units.gu(6)
61 height: units.gu(5.625)
64 height: units.gu(5.625)
62− anchors.verticalCenter: parent.verticalCenter
63− visible: useMascotShape && image && image.status === Image.Ready
64 readonly property int maxSize: Math.max(width, height) * 4
65 readonly property int maxSize: Math.max(width, height) * 4
65
66
67+ sourceComponent: UbuntuShape {
66− image: useMascotShape ? mascotImage : null
68+ image: useMascotShape ? mascotImage : null
69+ }
67 }
70 }
68
71
69 Image {
72 Image {
70 id: mascotImage
73 id: mascotImage
71 objectName: "mascotImage"
74 objectName: "mascotImage"
72
75
73− width: source ? mascotShape.width : 0
76+ width: source ? mascotShapeLoader.width : 0
74− height: mascotShape.height
77+ height: mascotShapeLoader.height
75 anchors.verticalCenter: parent.verticalCenter
78 anchors.verticalCenter: parent.verticalCenter
76 visible: !useMascotShape && status === Image.Ready
79 visible: !useMascotShape && status === Image.Ready
77
80
78− sourceSize { width: mascotShape.maxSize; height: mascotShape.maxSize }
81+ sourceSize { width: mascotShapeLoader.maxSize; height: mascotShapeLoader.maxSize }
79 fillMode: Image.PreserveAspectCrop
82 fillMode: Image.PreserveAspectCrop
80 horizontalAlignment: Image.AlignHCenter
83 horizontalAlignment: Image.AlignHCenter
81 verticalAlignment: Image.AlignVCenter
84 verticalAlignment: Image.AlignVCenter
tests/qmltests/Dash/tst_Card.qml+2−2
@@ -469,13 +469,13 @@ Rectangle {
469 function test_mascotShape(data) {
469 function test_mascotShape(data) {
470 selector.selectedIndex = data.index;
470 selector.selectedIndex = data.index;
471
471
472− var shape = findChild(card, "mascotShape");
472+ var shape = findChild(card, "mascotShapeLoader");
473 var image = findChild(card, "mascotImage");
473 var image = findChild(card, "mascotImage");
474
474
475 verify(shape, "Could not find shape.");
475 verify(shape, "Could not find shape.");
476 verify(image, "Could not find image.");
476 verify(image, "Could not find image.");
477
477
478− tryCompare(shape, "visible", data.shape);
478+ tryCompare(shape, "active", data.shape);
479 tryCompare(image, "visible", !data.shape);
479 tryCompare(image, "visible", !data.shape);
480 }
480 }
481 }
481 }
tests/qmltests/Dash/tst_CardBenchmark.qml+2−1
@@ -36,7 +36,8 @@ Rectangle {
36 "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."
36 "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."
37 }'
37 }'
38
38
39+// property string artCardModel: '{ "components": { "art": "art" } }'
39− property string artCardModel: '{ "components": { "art": "art" } }'
40+ property string artCardModel: '{ "components": { "art": "art", "title": "title" } }'
40
41
41 CardTool {
42 CardTool {
42 id: cardTool
43 id: cardTool