on xenial help sign in
Add unit tests.

Fix CardCreator results.

commit22f804f589260fc10196ed84be4f940d55629e1f authorYing-Chun Liu <paul.liu@canonical.com> dateThu 11 Sep 2014, 22:33 (12 years ago) parenta07f9c7
9 files changed+324−260
qml/Dash/GenericScopeView.qml+5−4 tests/plugins/Dash/cardcreator/1.res+23−18 tests/plugins/Dash/cardcreator/2.res+34−29 tests/plugins/Dash/cardcreator/3.res+29−24 tests/plugins/Dash/cardcreator/4.res+87−82 tests/plugins/Dash/cardcreator/5.res+36−31 tests/plugins/Dash/cardcreator/6.res+46−40 tests/plugins/Dash/cardcreator/7.res+36−32 tests/qmltests/Dash/tst_GenericScopeView.qml+28
qml/Dash/GenericScopeView.qml+5−4
@@ -59,7 +59,7 @@ FocusScope {
5959 subPageLoader.closeSubPage()
6060 }
6161
62− function itemClicked(index, result, item, itemModel, resultsModel, limitedCategoryItemCount) {
62+ function itemClicked(index, result, item, itemModel, resultsModel, limitedCategoryItemCount, cardTool) {
6363 if (cardTool.template && cardTool.template["non-interactive"]) {
6464 return;
6565 }
@@ -73,7 +73,7 @@ FocusScope {
7373 }
7474 }
7575
76− function itemPressedAndHeld(index, itemModel, resultsModel, limitedCategoryItemCount) {
76+ function itemPressedAndHeld(index, itemModel, resultsModel, limitedCategoryItemCount, cardTool) {
7777 if (cardTool.template && cardTool.template["non-interactive"]) {
7878 return;
7979 }
@@ -211,6 +211,7 @@ FocusScope {
211211
212212 Loader {
213213 id: rendererLoader
214+ objectName: "rendererLoader"
214215 anchors {
215216 top: parent.top
216217 left: parent.left
@@ -272,11 +273,11 @@ FocusScope {
272273 Connections {
273274 target: rendererLoader.item
274275 onClicked: {
275− scopeView.itemClicked(index, result, item, itemModel, target.model, categoryItemCount());
276+ scopeView.itemClicked(index, result, item, itemModel, target.model, categoryItemCount(), rendererLoader.item.cardTool);
276277 }
277278
278279 onPressAndHold: {
279− scopeView.itemPressedAndHeld(index, itemModel, target.model, categoryItemCount());
280+ scopeView.itemPressedAndHeld(index, itemModel, target.model, categoryItemCount(), rendererLoader.item.cardTool);
280281 }
281282
282283 function categoryItemCount() {
tests/plugins/Dash/cardcreator/1.res+23−18
@@ -33,15 +33,15 @@ Item {
3333 visible: image.status == Image.Ready;
3434 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
3535 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1;
36− Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
36+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
3737 Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
3838 function updateWidthHeightBindings() {
3939 if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
4040 width = root.fixedArtShapeSize.width;
4141 height = root.fixedArtShapeSize.height;
4242 } else {
43− width = Qt.binding(function() { return !visible ? 0 : image.width });
44− height = Qt.binding(function() { return !visible ? 0 : image.height });
43+ width = Qt.binding(function() { return !visible ? 0 : image.width });
44+ height = Qt.binding(function() { return !visible ? 0 : image.height });
4545 }
4646 }
4747 image: Image {
@@ -49,7 +49,7 @@ Item {
4949 source: cardData && cardData["art"] || "";
5050 cache: true;
5151 asynchronous: root.asynchronous;
52− fillMode: Image.PreserveAspectCrop;
52+ fillMode: Image.PreserveAspectCrop;
5353 width: root.width;
5454 height: width / artShape.aspect;
5555 }
@@ -60,29 +60,34 @@ readonly property int headerHeight: titleLabel.height;
6060Label {
6161 id: titleLabel;
6262 objectName: "titleLabel";
63− anchors { right: parent.right;
64− left: parent.left;
65− top: artShapeHolder.bottom;
66− topMargin: units.gu(1);
67− }
63+ anchors { right: parent.right;
64+left: parent.left;
65+top: artShapeHolder.bottom;
66+ topMargin: units.gu(1);
67+ }
6868 elide: Text.ElideRight;
6969 fontSize: "small";
7070 wrapMode: Text.Wrap;
7171 maximumLineCount: 2;
7272 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
73− color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
73+ color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
7474 visible: showHeader ;
7575 text: root.title;
7676 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
7777 horizontalAlignment: root.headerAlignment;
7878 }
79−UbuntuShape {
80− id: touchdown;
81− objectName: "touchdown";
82− anchors { fill: artShapeHolder }
83− visible: root.pressed;
84− radius: "medium";
85− borderSource: "radius_pressed.sci"
86−}
79+UbuntuShape {
80+ id: touchdown;
81+ objectName: "touchdown";
82+ anchors { fill: artShapeHolder }
83+ visible: {
84+ if (root.template && root.template["non-interactive"]) {
85+ return false;
86+ }
87+ return root.pressed;
88+ }
89+ radius: "medium";
90+ borderSource: "radius_pressed.sci"
91+ }
8792implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);
8893}
tests/plugins/Dash/cardcreator/2.res+34−29
@@ -55,19 +55,19 @@ Row {
5555 spacing: margins;
5656 height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
5757 anchors { top: parent.top;
58− topMargin: units.gu(1);
59− left: parent.left;
60− }
58+ topMargin: units.gu(1);
59+left: parent.left;
60+ }
6161 anchors.right: parent.right;
62− anchors.margins: margins;
63− anchors.rightMargin: 0;
64− data: [
65−Image {
62+ anchors.margins: margins;
63+ anchors.rightMargin: 0;
64+ data: [
65+ Image {
6666 id: mascotImage;
6767 objectName: "mascotImage";
6868 anchors { verticalCenter: parent.verticalCenter; }
6969 readonly property int maxSize: Math.max(width, height) * 4;
70− source: cardData && cardData["mascot"] || "";
70+ source: cardData && cardData["mascot"] || "";
7171 width: units.gu(6);
7272 height: units.gu(5.625);
7373 sourceSize { width: maxSize; height: maxSize }
@@ -85,52 +85,57 @@ Image {
8585 Label {
8686 id: titleLabel;
8787 objectName: "titleLabel";
88− anchors { right: parent.right;
89− rightMargin: units.gu(1);
90− left: parent.left;
91− top: parent.top; }
88+ anchors { right: parent.right;
89+rightMargin: units.gu(1);
90+left: parent.left;
91+ top: parent.top; }
9292 elide: Text.ElideRight;
9393 fontSize: "small";
9494 wrapMode: Text.Wrap;
9595 maximumLineCount: 2;
9696 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
97− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
97+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
9898 visible: showHeader ;
9999 text: root.title;
100100 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
101101 horizontalAlignment: root.headerAlignment;
102102 }
103− ,Label {
103+,Label {
104104 id: subtitleLabel;
105105 objectName: "subtitleLabel";
106− anchors { right: parent.right;
107− left: parent.left;
108− rightMargin: units.gu(1);
109− top: titleLabel.bottom;
110− }
106+ anchors { right: parent.right;
107+ left: parent.left;
108+rightMargin: units.gu(1);
109+top: titleLabel.bottom;
110+ }
111111 anchors.topMargin: units.dp(2);
112112 elide: Text.ElideRight;
113113 fontSize: "small";
114114 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
115− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
115+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
116116 visible: titleLabel.visible && titleLabel.text;
117117 text: cardData && cardData["subtitle"] || "";
118118 font.weight: Font.Light;
119119 horizontalAlignment: root.headerAlignment;
120120 }
121121
122− ]
122+ ]
123123 }
124124
125125 ]
126126 }
127−UbuntuShape {
128− id: touchdown;
129− objectName: "touchdown";
130− anchors { fill: backgroundLoader }
131− visible: root.pressed;
132− radius: "medium";
133− borderSource: "radius_pressed.sci"
134−}
127+UbuntuShape {
128+ id: touchdown;
129+ objectName: "touchdown";
130+ anchors { fill: backgroundLoader }
131+ visible: {
132+ if (root.template && root.template["non-interactive"]) {
133+ return false;
134+ }
135+ return root.pressed;
136+ }
137+ radius: "medium";
138+ borderSource: "radius_pressed.sci"
139+ }
135140implicitHeight: row.y + row.height + units.gu(1);
136141}
tests/plugins/Dash/cardcreator/3.res+29−24
@@ -25,7 +25,7 @@ Item {
2525 objectName: "artShapeLoader";
2626 active: cardData && cardData["art"] || false;
2727 asynchronous: root.asynchronous;
28− visible: status == Loader.Ready;
28+ visible: status == Loader.Ready;
2929 sourceComponent: UbuntuShape {
3030 id: artShape;
3131 objectName: "artShape";
@@ -40,8 +40,8 @@ Item {
4040 width = root.fixedArtShapeSize.width;
4141 height = root.fixedArtShapeSize.height;
4242 } else {
43− width = Qt.binding(function() { return !visible ? 0 : image.width });
44− height = Qt.binding(function() { return !visible ? 0 : image.height });
43+ width = Qt.binding(function() { return !visible ? 0 : image.width });
44+ height = Qt.binding(function() { return !visible ? 0 : image.height });
4545 }
4646 }
4747 image: Image {
@@ -49,7 +49,7 @@ Item {
4949 source: cardData && cardData["art"] || "";
5050 cache: true;
5151 asynchronous: root.asynchronous;
52− fillMode: Image.PreserveAspectCrop;
52+ fillMode: Image.PreserveAspectCrop;
5353 width: root.width;
5454 height: width / artShape.aspect;
5555 }
@@ -60,17 +60,17 @@ readonly property int headerHeight: titleLabel.height + subtitleLabel.height + s
6060Label {
6161 id: titleLabel;
6262 objectName: "titleLabel";
63− anchors { right: parent.right;
64− left: parent.left;
65− top: artShapeHolder.bottom;
66− topMargin: units.gu(1);
67− }
63+ anchors { right: parent.right;
64+left: parent.left;
65+top: artShapeHolder.bottom;
66+ topMargin: units.gu(1);
67+ }
6868 elide: Text.ElideRight;
6969 fontSize: "small";
7070 wrapMode: Text.Wrap;
7171 maximumLineCount: 2;
7272 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
73− color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
73+ color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
7474 visible: showHeader ;
7575 text: root.title;
7676 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
@@ -80,27 +80,32 @@ Label {
8080 id: subtitleLabel;
8181 objectName: "subtitleLabel";
8282 anchors { left: titleLabel.left;
83− leftMargin: titleLabel.leftMargin;
84− right: titleLabel.right;
85− top: titleLabel.bottom;
86− }
87− anchors.topMargin: units.dp(2);
83+ leftMargin: titleLabel.leftMargin;
84+right: titleLabel.right;
85+top: titleLabel.bottom;
86+ }
87+ anchors.topMargin: units.dp(2);
8888 elide: Text.ElideRight;
8989 fontSize: "small";
9090 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
91− color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
91+ color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
9292 visible: titleLabel.visible && titleLabel.text;
9393 text: cardData && cardData["subtitle"] || "";
9494 font.weight: Font.Light;
9595 horizontalAlignment: root.headerAlignment;
9696 }
97−UbuntuShape {
98− id: touchdown;
99− objectName: "touchdown";
100− anchors { fill: artShapeHolder }
101− visible: root.pressed;
102− radius: "medium";
103− borderSource: "radius_pressed.sci"
104−}
97+UbuntuShape {
98+ id: touchdown;
99+ objectName: "touchdown";
100+ anchors { fill: artShapeHolder }
101+ visible: {
102+ if (root.template && root.template["non-interactive"]) {
103+ return false;
104+ }
105+ return root.pressed;
106+ }
107+ radius: "medium";
108+ borderSource: "radius_pressed.sci"
109+ }
105110implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
106111}
tests/plugins/Dash/cardcreator/4.res+87−82
@@ -5,8 +5,8 @@ AbstractButton {
55 property var cardData;
66 property var artShapeBorderSource: undefined;
77 property real fontScale: 1.0;
8− property var scopeStyle: null;
9− property int headerAlignment: Text.AlignLeft;
8+ property var scopeStyle: null;
9+ property int headerAlignment: Text.AlignLeft;
1010 property int fixedHeaderHeight: -1;
1111 property size fixedArtShapeSize: Qt.size(-1, -1);
1212 readonly property string title: cardData && cardData["title"] || "";
@@ -16,99 +16,104 @@ AbstractButton {
1616readonly property size artShapeSize: Qt.size(-1, -1);
1717readonly property int headerHeight: row.height;
1818Row {
19− id: row;
20− objectName: "outerRow";
21− property real margins: units.gu(1);
22− spacing: margins;
23− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
24− anchors { top: parent.top;
19+ id: row;
20+ objectName: "outerRow";
21+ property real margins: units.gu(1);
22+ spacing: margins;
23+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
24+ anchors { top: parent.top;
2525 topMargin: units.gu(1);
26− left: parent.left;
27−}
28− anchors.right: parent.right;
29− anchors.margins: margins;
30− anchors.rightMargin: 0;
31−data: [
32−Loader {
33− id: mascotShapeLoader;
34− objectName: "mascotShapeLoader";
35− asynchronous: root.asynchronous;
36− active: mascotImage.status === Image.Ready;
37− visible: showHeader && active && status == Loader.Ready;
38− width: units.gu(6);
39− height: units.gu(5.625);
40− sourceComponent: UbuntuShape { image: mascotImage }
41− anchors { verticalCenter: parent.verticalCenter; }
42− }
43−
26+left: parent.left;
27+ }
28+ anchors.right: parent.right;
29+ anchors.margins: margins;
30+ anchors.rightMargin: 0;
31+ data: [
32+ Loader {
33+ id: mascotShapeLoader;
34+ objectName: "mascotShapeLoader";
35+ asynchronous: root.asynchronous;
36+ active: mascotImage.status === Image.Ready;
37+ visible: showHeader && active && status == Loader.Ready;
38+ width: units.gu(6);
39+ height: units.gu(5.625);
40+ sourceComponent: UbuntuShape { image: mascotImage }
41+ anchors { verticalCenter: parent.verticalCenter; }
42+ }
4443,Image {
45− id: mascotImage;
46− objectName: "mascotImage";
47− anchors { verticalCenter: parent.verticalCenter; }
48− readonly property int maxSize: Math.max(width, height) * 4;
49− source: cardData && cardData["mascot"] || "";
50− width: units.gu(6);
51− height: units.gu(5.625);
52− sourceSize { width: maxSize; height: maxSize }
53− fillMode: Image.PreserveAspectCrop;
54− horizontalAlignment: Image.AlignHCenter;
55− verticalAlignment: Image.AlignVCenter;
56− visible: false;
57− }
58−
44+ id: mascotImage;
45+ objectName: "mascotImage";
46+ anchors { verticalCenter: parent.verticalCenter; }
47+ readonly property int maxSize: Math.max(width, height) * 4;
48+ source: cardData && cardData["mascot"] || "";
49+ width: units.gu(6);
50+ height: units.gu(5.625);
51+ sourceSize { width: maxSize; height: maxSize }
52+ fillMode: Image.PreserveAspectCrop;
53+ horizontalAlignment: Image.AlignHCenter;
54+ verticalAlignment: Image.AlignVCenter;
55+ visible: false;
56+ }
5957,Item {
6058 id: headerTitleContainer;
6159 anchors { verticalCenter: parent.verticalCenter; }
6260 width: parent.width - x;
6361 implicitHeight: titleLabel.height + subtitleLabel.height;
6462 data: [
65−Label {
66− id: titleLabel;
67− objectName: "titleLabel";
68− anchors { right: parent.right;
69− rightMargin: units.gu(1);
70− left: parent.left;
71− top: parent.top; }
72− elide: Text.ElideRight;
73− fontSize: "small";
74− wrapMode: Text.Wrap;
75− maximumLineCount: 2;
76− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
77− color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
78− visible: showHeader ;
79− text: root.title;
80− font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
81− horizontalAlignment: root.headerAlignment;
82− }
83−,Label {
84− id: subtitleLabel;
85− objectName: "subtitleLabel";
63+ Label {
64+ id: titleLabel;
65+ objectName: "titleLabel";
8666 anchors { right: parent.right;
87− left: parent.left;
88− rightMargin: units.gu(1);
89− top: titleLabel.bottom;
90− }
91− anchors.topMargin: units.dp(2);
67+rightMargin: units.gu(1);
68+left: parent.left;
69+ top: parent.top; }
9270 elide: Text.ElideRight;
9371 fontSize: "small";
72+ wrapMode: Text.Wrap;
73+ maximumLineCount: 2;
9474 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
95− color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
96− visible: titleLabel.visible && titleLabel.text;
97− text: cardData && cardData["subtitle"] || "";
98− font.weight: Font.Light;
75+ color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
76+ visible: showHeader ;
77+ text: root.title;
78+ font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
9979 horizontalAlignment: root.headerAlignment;
10080 }
101−]
102−}
103−]
104−}
105−UbuntuShape {
106− id: touchdown;
107− objectName: "touchdown";
108− anchors { fill: root }
109− visible: root.pressed;
110− radius: "medium";
111− borderSource: "radius_pressed.sci"
112−}
81+,Label {
82+ id: subtitleLabel;
83+ objectName: "subtitleLabel";
84+ anchors { right: parent.right;
85+ left: parent.left;
86+rightMargin: units.gu(1);
87+top: titleLabel.bottom;
88+ }
89+ anchors.topMargin: units.dp(2);
90+ elide: Text.ElideRight;
91+ fontSize: "small";
92+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
93+ color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
94+ visible: titleLabel.visible && titleLabel.text;
95+ text: cardData && cardData["subtitle"] || "";
96+ font.weight: Font.Light;
97+ horizontalAlignment: root.headerAlignment;
98+ }
99+
100+ ]
101+ }
102+
103+ ]
104+ }
105+UbuntuShape {
106+ id: touchdown;
107+ objectName: "touchdown";
108+ anchors { fill: root }
109+ visible: {
110+ if (root.template && root.template["non-interactive"]) {
111+ return false;
112+ }
113+ return root.pressed;
114+ }
115+ radius: "medium";
116+ borderSource: "radius_pressed.sci"
117+ }
113118implicitHeight: row.y + row.height + units.gu(1);
114119}
tests/plugins/Dash/cardcreator/5.res+36−31
@@ -25,7 +25,7 @@ Item {
2525 objectName: "artShapeLoader";
2626 active: cardData && cardData["art"] || false;
2727 asynchronous: root.asynchronous;
28− visible: status == Loader.Ready;
28+ visible: status == Loader.Ready;
2929 sourceComponent: UbuntuShape {
3030 id: artShape;
3131 objectName: "artShape";
@@ -40,8 +40,8 @@ Item {
4040 width = root.fixedArtShapeSize.width;
4141 height = root.fixedArtShapeSize.height;
4242 } else {
43− width = Qt.binding(function() { return !visible ? 0 : image.width });
44− height = Qt.binding(function() { return !visible ? 0 : image.height });
43+ width = Qt.binding(function() { return !visible ? 0 : image.width });
44+ height = Qt.binding(function() { return !visible ? 0 : image.height });
4545 }
4646 }
4747 image: Image {
@@ -49,12 +49,12 @@ Item {
4949 source: cardData && cardData["art"] || "";
5050 cache: true;
5151 asynchronous: root.asynchronous;
52− fillMode: Image.PreserveAspectCrop;
52+ fillMode: Image.PreserveAspectCrop;
5353 width: root.width;
5454 height: width / artShape.aspect;
5555 }
5656 }
57− }
57+ }
5858 }
5959Loader {
6060 id: overlayLoader;
@@ -63,14 +63,14 @@ Loader {
6363 right: artShapeHolder.right;
6464 bottom: artShapeHolder.bottom;
6565 }
66− active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false;
66+ active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false;
6767 asynchronous: root.asynchronous;
6868 visible: showHeader && status == Loader.Ready;
6969 sourceComponent: ShaderEffect {
7070 id: overlay;
71− height: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2);
72− property real luminance: Style.luminance(overlayColor);
73− property color overlayColor: cardData && cardData["overlayColor"] || "#99000000";
71+ height: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2);
72+ property real luminance: Style.luminance(overlayColor);
73+ property color overlayColor: cardData && cardData["overlayColor"] || "#99000000";
7474 property var source: ShaderEffectSource {
7575 id: shaderSource;
7676 sourceItem: artShapeLoader.item;
@@ -91,7 +91,7 @@ Loader {
9191 varying highp vec2 coord;
9292 uniform sampler2D source;
9393 uniform lowp float qt_Opacity;
94− uniform highp vec4 overlayColor;
94+ uniform highp vec4 overlayColor;
9595 void main() {
9696 lowp vec4 tex = texture2D(source, coord);
9797 gl_FragColor = vec4(overlayColor.r, overlayColor.g, overlayColor.b, 1) * qt_Opacity * overlayColor.a * tex.a;
@@ -100,21 +100,21 @@ Loader {
100100 }
101101readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
102102Label {
103− id: titleLabel;
103+ id: titleLabel;
104104 objectName: "titleLabel";
105105 anchors { right: parent.right;
106− rightMargin: units.gu(1);
107− left: parent.left;
108− leftMargin: units.gu(1);
109− top: overlayLoader.top;
110− topMargin: units.gu(1);
111− }
106+rightMargin: units.gu(1);
107+left: parent.left;
108+ leftMargin: units.gu(1);
109+ top: overlayLoader.top;
110+ topMargin: units.gu(1);
111+ }
112112 elide: Text.ElideRight;
113113 fontSize: "small";
114114 wrapMode: Text.Wrap;
115115 maximumLineCount: 2;
116116 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
117− color: root.scopeStyle ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
117+ color: root.scopeStyle ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
118118 visible: showHeader && overlayLoader.active;
119119 text: root.title;
120120 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
@@ -124,28 +124,33 @@ Label {
124124 id: subtitleLabel;
125125 objectName: "subtitleLabel";
126126 anchors { left: titleLabel.left;
127− leftMargin: titleLabel.leftMargin;
128− rightMargin: units.gu(1);
129− right: titleLabel.right;
130− top: titleLabel.bottom;
131− }
127+ leftMargin: titleLabel.leftMargin;
128+rightMargin: units.gu(1);
129+right: titleLabel.right;
130+top: titleLabel.bottom;
131+ }
132132 anchors.topMargin: units.dp(2);
133133 elide: Text.ElideRight;
134134 fontSize: "small";
135135 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
136− color: root.scopeStyle ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
136+ color: root.scopeStyle ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
137137 visible: titleLabel.visible && titleLabel.text;
138138 text: cardData && cardData["subtitle"] || "";
139139 font.weight: Font.Light;
140140 horizontalAlignment: root.headerAlignment;
141141 }
142142UbuntuShape {
143− id: touchdown;
144− objectName: "touchdown";
145− anchors { fill: artShapeHolder }
146− visible: root.pressed;
147− radius: "medium";
148− borderSource: "radius_pressed.sci"
149−}
143+ id: touchdown;
144+ objectName: "touchdown";
145+ anchors { fill: artShapeHolder }
146+ visible: {
147+ if (root.template && root.template["non-interactive"]) {
148+ return false;
149+ }
150+ return root.pressed;
151+ }
152+ radius: "medium";
153+ borderSource: "radius_pressed.sci"
154+ }
150155implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
151156}
tests/plugins/Dash/cardcreator/6.res+46−40
@@ -1,18 +1,18 @@
1−AbstractButton {
2− id: root;
3− property var template;
4− property var components;
5− property var cardData;
6− property var artShapeBorderSource: undefined;
7− property real fontScale: 1.0;
8− property var scopeStyle: null;
9− property int headerAlignment: Text.AlignLeft;
10− property int fixedHeaderHeight: -1;
11− property size fixedArtShapeSize: Qt.size(-1, -1);
12− readonly property string title: cardData && cardData["title"] || "";
13− property bool asynchronous: true;
14− property bool showHeader: true;
15− implicitWidth: childrenRect.width;
1+AbstractButton {
2+ id: root;
3+ property var template;
4+ property var components;
5+ property var cardData;
6+ property var artShapeBorderSource: undefined;
7+ property real fontScale: 1.0;
8+ property var scopeStyle: null;
9+ property int headerAlignment: Text.AlignLeft;
10+ property int fixedHeaderHeight: -1;
11+ property size fixedArtShapeSize: Qt.size(-1, -1);
12+ readonly property string title: cardData && cardData["title"] || "";
13+ property bool asynchronous: true;
14+ property bool showHeader: true;
15+ implicitWidth: childrenRect.width;
1616Loader {
1717 id: backgroundLoader;
1818 objectName: "backgroundLoader";
@@ -51,10 +51,10 @@ readonly property int headerHeight: titleLabel.height + subtitleLabel.height + s
5151Item {
5252 id: headerTitleContainer;
5353 anchors { right: parent.right; left: parent.left;
54− top: parent.top;
55− topMargin: units.gu(1);
56− leftMargin: units.gu(1);
57− }
54+top: parent.top;
55+ topMargin: units.gu(1);
56+leftMargin: units.gu(1);
57+ }
5858 width: parent.width - x;
5959 implicitHeight: titleLabel.height + subtitleLabel.height;
6060 data: [
@@ -62,15 +62,15 @@ Item {
6262 id: titleLabel;
6363 objectName: "titleLabel";
6464 anchors { right: emblemIcon.left;
65− rightMargin: emblemIcon.width > 0 ? units.gu(0.5) : 0;
66− left: parent.left;
67− top: parent.top; }
65+ rightMargin: emblemIcon.width > 0 ? units.gu(0.5) : 0;
66+left: parent.left;
67+ top: parent.top; }
6868 elide: Text.ElideRight;
6969 fontSize: "small";
7070 wrapMode: Text.Wrap;
7171 maximumLineCount: 2;
7272 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
73− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
73+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
7474 visible: showHeader ;
7575 text: root.title;
7676 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
@@ -80,15 +80,15 @@ Item {
8080 id: subtitleLabel;
8181 objectName: "subtitleLabel";
8282 anchors { right: parent.right;
83− left: parent.left;
84− rightMargin: units.gu(1);
85− top: titleLabel.bottom;
86− }
83+ left: parent.left;
84+rightMargin: units.gu(1);
85+top: titleLabel.bottom;
86+ }
8787 anchors.topMargin: units.dp(2);
8888 elide: Text.ElideRight;
8989 fontSize: "small";
9090 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
91− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
91+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
9292 visible: titleLabel.visible && titleLabel.text;
9393 text: cardData && cardData["subtitle"] || "";
9494 font.weight: Font.Light;
@@ -98,25 +98,31 @@ Item {
9898 id: emblemIcon;
9999 objectName: "emblemIcon";
100100 anchors {
101− bottom: titleLabel.baseline;
102− right: parent.right;
103− rightMargin: units.gu(1);
101+ bottom: titleLabel.baseline;
102+ right: parent.right;
103+ rightMargin: units.gu(1);
104+
104105 }
105106 source: cardData && cardData["emblem"] || "";
106− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
107+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
107108 width: height;
108109 height: source != "" ? titleLabel.font.pixelSize : 0;
109110 }
110111
111112 ]
112113 }
113−UbuntuShape {
114− id: touchdown;
115− objectName: "touchdown";
116− anchors { fill: backgroundLoader }
117− visible: root.pressed;
118− radius: "medium";
119− borderSource: "radius_pressed.sci"
120−}
114+UbuntuShape {
115+ id: touchdown;
116+ objectName: "touchdown";
117+ anchors { fill: backgroundLoader }
118+ visible: {
119+ if (root.template && root.template["non-interactive"]) {
120+ return false;
121+ }
122+ return root.pressed;
123+ }
124+ radius: "medium";
125+ borderSource: "radius_pressed.sci"
126+ }
121127implicitHeight: headerTitleContainer.y + headerTitleContainer.height + units.gu(1);
122128}
tests/plugins/Dash/cardcreator/7.res+36−32
@@ -55,14 +55,14 @@ Row {
5555 spacing: margins;
5656 height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
5757 anchors { top: parent.top;
58− topMargin: units.gu(1);
59− left: parent.left;
60− }
58+ topMargin: units.gu(1);
59+left: parent.left;
60+ }
6161 anchors.right: parent.right;
62− anchors.margins: margins;
63− anchors.rightMargin: 0;
62+ anchors.margins: margins;
63+ anchors.rightMargin: 0;
6464 data: [
65−Image {
65+ Image {
6666 id: mascotImage;
6767 objectName: "mascotImage";
6868 anchors { verticalCenter: parent.verticalCenter; }
@@ -76,7 +76,6 @@ Image {
7676 verticalAlignment: Image.AlignVCenter;
7777 visible: showHeader;
7878 }
79−
8079,Item {
8180 id: headerTitleContainer;
8281 anchors { verticalCenter: parent.verticalCenter; }
@@ -87,15 +86,15 @@ Image {
8786 id: titleLabel;
8887 objectName: "titleLabel";
8988 anchors { right: parent.right;
90− rightMargin: units.gu(1);
91− left: parent.left;
92− top: parent.top; }
89+rightMargin: units.gu(1);
90+left: parent.left;
91+ top: parent.top; }
9392 elide: Text.ElideRight;
9493 fontSize: "small";
9594 wrapMode: Text.Wrap;
9695 maximumLineCount: 2;
9796 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
98− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
97+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
9998 visible: showHeader ;
10099 text: root.title;
101100 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
@@ -105,15 +104,15 @@ Image {
105104 id: subtitleLabel;
106105 objectName: "subtitleLabel";
107106 anchors { right: parent.right;
108− left: parent.left;
109− rightMargin: units.gu(1);
110− top: titleLabel.bottom;
111− }
107+ left: parent.left;
108+rightMargin: units.gu(1);
109+top: titleLabel.bottom;
110+ }
112111 anchors.topMargin: units.dp(2);
113112 elide: Text.ElideRight;
114113 fontSize: "small";
115114 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
116− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
115+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
117116 visible: titleLabel.visible && titleLabel.text;
118117 text: cardData && cardData["subtitle"] || "";
119118 font.weight: Font.Light;
@@ -122,28 +121,33 @@ Image {
122121,CardAttributes {
123122 id: attributesRow;
124123 objectName: "attributesRow";
125− anchors { right: parent.right;
126− left: parent.left;
127− rightMargin: units.gu(1);
128− top: subtitleLabel.bottom;
129− }
130− color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
124+ anchors { right: parent.right;
125+ left: parent.left;
126+rightMargin: units.gu(1);
127+top: subtitleLabel.bottom;
128+ }
129+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
131130 fontScale: root.fontScale;
132131 model: cardData && cardData["attributes"];
133132 }
134133
135− ]
136− }
134+ ]
135+ }
137136
138137 ]
139138 }
140−UbuntuShape {
141− id: touchdown;
142− objectName: "touchdown";
143− anchors { fill: backgroundLoader }
144− visible: root.pressed;
145− radius: "medium";
146− borderSource: "radius_pressed.sci"
147−}
139+UbuntuShape {
140+ id: touchdown;
141+ objectName: "touchdown";
142+ anchors { fill: backgroundLoader }
143+ visible: {
144+ if (root.template && root.template["non-interactive"]) {
145+ return false;
146+ }
147+ return root.pressed;
148+ }
149+ radius: "medium";
150+ borderSource: "radius_pressed.sci"
151+ }
148152implicitHeight: row.y + row.height + units.gu(1);
149153}
tests/qmltests/Dash/tst_GenericScopeView.qml+28
@@ -453,6 +453,34 @@ Item {
453453
454454 genericScopeView.scope = !genericScopeView.scope;
455455 }
456+
457+ function test_item_noninteractive() {
458+ waitForRendering(genericScopeView);
459+
460+ var categoryListView = findChild(genericScopeView, "categoryListView");
461+ waitForRendering(categoryListView);
462+
463+ var category0 = findChild(categoryListView, "dashCategory0");
464+ waitForRendering(category0);
465+
466+ var cardTool = findChild(category0, "cardTool");
467+ var rendererLoader = findChild(category0, "rendererLoader");
468+ var cardGrid = rendererLoader.item;
469+
470+ cardTool.template["non-interactive"] = true;
471+ compare(cardGrid.cardTool.template["non-interactive"], true);
472+
473+ var item0 = findChild(cardGrid, "delegate0");
474+ waitForRendering(item0);
475+ var touchdown = findChild(item0, "touchdown");
476+
477+ compare(touchdown.visible, false);
478+ mouseClick(item0, item0.width / 2, item0.height / 2);
479+ compare(touchdown.visible, false);
480+
481+ cardTool.template["non-interactive"] = false;
482+ compare(cardGrid.cardTool.template["non-interactive"], false);
483+ }
456484 }
457485 }
458486}