Merge lp:~aacid/unity8/moreAsyncAudioCard into lp:unity8
- moreAsyncAudioCard
- Merge into trunk
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~aacid/unity8/moreAsyncAudioCard | ||||
Merge into: | lp:unity8 | ||||
Prerequisite: | lp:~aacid/unity8/circleForAudioCards | ||||
Diff against target: |
2680 lines (+1665/-163) 34 files modified
debian/control (+4/-4) plugins/Dash/AudioProgressBar.qml (+1/-0) plugins/Dash/CardCreator.js (+69/-34) plugins/Dash/CardCreatorCache.qml (+3/-3) qml/Dash/CardCarousel.qml (+0/-1) qml/Dash/CardGrid.qml (+0/-1) qml/Dash/CardHorizontalList.qml (+0/-1) qml/Dash/CardTool.qml (+2/-26) qml/Dash/CardVerticalJournal.qml (+0/-1) tests/plugins/Dash/cardcreator/1.res (+4/-6) tests/plugins/Dash/cardcreator/1.res.cardcreator (+119/-0) tests/plugins/Dash/cardcreator/10.res (+3/-5) tests/plugins/Dash/cardcreator/10.res.cardcreator (+137/-0) tests/plugins/Dash/cardcreator/11.res (+5/-7) tests/plugins/Dash/cardcreator/11.res.cardcreator (+210/-0) tests/plugins/Dash/cardcreator/2.res (+3/-5) tests/plugins/Dash/cardcreator/2.res.cardcreator (+136/-0) tests/plugins/Dash/cardcreator/3.res (+3/-5) tests/plugins/Dash/cardcreator/3.res.cardcreator (+137/-0) tests/plugins/Dash/cardcreator/4.res (+3/-5) tests/plugins/Dash/cardcreator/4.res.cardcreator (+109/-0) tests/plugins/Dash/cardcreator/5.res (+5/-7) tests/plugins/Dash/cardcreator/5.res.cardcreator (+156/-0) tests/plugins/Dash/cardcreator/6.res (+2/-4) tests/plugins/Dash/cardcreator/6.res.cardcreator (+126/-0) tests/plugins/Dash/cardcreator/7.res (+3/-5) tests/plugins/Dash/cardcreator/7.res.cardcreator (+149/-0) tests/plugins/Dash/cardcreator/8.res (+3/-5) tests/plugins/Dash/cardcreator/8.res.cardcreator (+107/-0) tests/plugins/Dash/cardcreator/9.res (+4/-5) tests/plugins/Dash/cardcreator/9.res.cardcreator (+119/-0) tests/plugins/Dash/cardcreatortest.cpp (+35/-25) tests/plugins/Dash/cardcreatortest.qml (+4/-4) tests/qmltests/Dash/tst_CardTool.qml (+4/-4) |
||||
To merge this branch: | bzr merge lp:~aacid/unity8/moreAsyncAudioCard | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity8 CI Bot | continuous-integration | Needs Fixing | |
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Andrea Cimitan (community) | Approve | ||
Review via email: mp+285687@code.launchpad.net |
This proposal supersedes a proposal from 2016-01-18.
This proposal has been superseded by a proposal from 2016-03-10.
Commit message
Audio Cards: Make some of the image loading async
It improves a bit the smoothness of scrolling the list
Description of the change
* Are there any related MPs required for this MP to build/function as expected?
https:/
* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes
* Did you make sure that your branch does not contain spurious tags?
Yes
* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A
* If you changed the UI, has there been a design review?
N/A
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:2138
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:2138
https:/
Executed test runs:
Click here to trigger a rebuild:
https:/
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal | # |
I need to merge https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2139
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Andrea Cimitan (cimi) wrote : | # |
* Did you perform an exploratory manual test run of the code change and any related functionality?
Y
* Did CI run pass? If not, please explain why.
ap
* Did you make sure that the branch does not contain spurious tags?
clean
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2139
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 2140. By Albert Astals Cid
-
Require newer sdk
Andrea Cimitan (cimi) wrote : | # |
Reapproving, thanks Saviq for spotting to bump the requirement
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2140
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 2141. By Albert Astals Cid
-
Merge
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2141
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 2142. By Albert Astals Cid
-
Merge cardCreatorFixe
dHeaderSizeOpti mization
Unmerged revisions
Preview Diff
1 | === modified file 'debian/control' |
2 | --- debian/control 2016-03-04 21:03:43 +0000 |
3 | +++ debian/control 2016-03-10 16:53:32 +0000 |
4 | @@ -55,7 +55,7 @@ |
5 | qtdeclarative5-qtmultimedia-plugin (>= 5.4.1-1ubuntu19~overlay2), |
6 | qtdeclarative5-ubuntu-content1, |
7 | qtdeclarative5-ubuntu-settings-components (>= 0.7), |
8 | - qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.3.1796) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.3.1796), |
9 | + qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.3.1845) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.3.1845), |
10 | qtdeclarative5-ubuntu-web-plugin, |
11 | ttf-ubuntu-font-family, |
12 | Standards-Version: 3.9.4 |
13 | @@ -70,7 +70,7 @@ |
14 | Package: indicators-client |
15 | Architecture: amd64 armhf i386 |
16 | Depends: qmenumodel-qml (>= 0.2.9), |
17 | - qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.3.1796) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.3.1796), |
18 | + qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.3.1845) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.3.1845), |
19 | unity8 (= ${binary:Version}), |
20 | ${misc:Depends}, |
21 | ${shlibs:Depends}, |
22 | @@ -128,7 +128,7 @@ |
23 | Depends: qml-module-qtquick-layouts, |
24 | qtdeclarative5-ubuntu-settings-components (>= 0.7), |
25 | qtdeclarative5-ubuntu-thumbnailer0.1 | ubuntu-thumbnailer-impl, |
26 | - qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.3.1796) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.3.1796), |
27 | + qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.3.1845) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.3.1845), |
28 | qtdeclarative5-unity-notifications-plugin (>= 0.1.2) | unity-notifications-impl, |
29 | ubuntu-thumbnailer-impl-0, |
30 | unity-application-impl-13, |
31 | @@ -158,7 +158,7 @@ |
32 | python3-fixtures, |
33 | python3-gi, |
34 | qttestability-autopilot (>= 1.4), |
35 | - ubuntu-ui-toolkit-autopilot (>= 1.3.1796), |
36 | + ubuntu-ui-toolkit-autopilot (>= 1.3.1845), |
37 | unity-scope-click, |
38 | unity8 (= ${source:Version}), |
39 | unity8-fake-env (= ${source:Version}), |
40 | |
41 | === modified file 'plugins/Dash/AudioProgressBar.qml' |
42 | --- plugins/Dash/AudioProgressBar.qml 2015-12-03 14:44:08 +0000 |
43 | +++ plugins/Dash/AudioProgressBar.qml 2016-03-10 16:53:32 +0000 |
44 | @@ -31,6 +31,7 @@ |
45 | anchors { left: parent.left; right: parent.right } |
46 | height: units.dp(6) |
47 | source: "graphics/music_progress_bg.png" |
48 | + asynchronous: true |
49 | sourceSize.width: width |
50 | sourceSize.height: height |
51 | } |
52 | |
53 | === modified file 'plugins/Dash/CardCreator.js' |
54 | --- plugins/Dash/CardCreator.js 2016-02-12 00:11:52 +0000 |
55 | +++ plugins/Dash/CardCreator.js 2016-03-10 16:53:32 +0000 |
56 | @@ -18,12 +18,13 @@ |
57 | |
58 | // %1 is the template["card-background"]["elements"][0] |
59 | // %2 is the template["card-background"]["elements"][1] |
60 | -// %3 is the template["card-background"] string |
61 | +// %3 is whether the loader should be asynchronous or not |
62 | +// %4 is the template["card-background"] string |
63 | var kBackgroundLoaderCode = 'Loader {\n\ |
64 | id: backgroundLoader; \n\ |
65 | objectName: "backgroundLoader"; \n\ |
66 | anchors.fill: parent; \n\ |
67 | - asynchronous: root.asynchronous; \n\ |
68 | + asynchronous: %3; \n\ |
69 | visible: status == Loader.Ready; \n\ |
70 | sourceComponent: UbuntuShape { \n\ |
71 | objectName: "background"; \n\ |
72 | @@ -46,7 +47,7 @@ |
73 | objectName: "backgroundImage"; \n\ |
74 | source: { \n\ |
75 | if (cardData && typeof cardData["background"] === "string") return cardData["background"]; \n\ |
76 | - else return %3; \n\ |
77 | + else return %4; \n\ |
78 | } \n\ |
79 | } \n\ |
80 | function getColor(index) { \n\ |
81 | @@ -63,8 +64,9 @@ |
82 | // %3 is used as image height |
83 | // %4 is used for artShapeSource.hideSource and inner Loader visible |
84 | // %5 is used as aspect ratio fallback |
85 | -// %6 is injected as code to artImage |
86 | -// %7 is used as image fallback |
87 | +// %6 is whether the loader should be asynchronous or not |
88 | +// %7 is injected as code to artImage |
89 | +// %8 is used as image fallback |
90 | var kArtShapeHolderCode = 'Item { \n\ |
91 | id: artShapeHolder; \n\ |
92 | height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\ |
93 | @@ -73,9 +75,9 @@ |
94 | Loader { \n\ |
95 | id: artShapeLoader; \n\ |
96 | objectName: "artShapeLoader"; \n\ |
97 | - readonly property string cardArt: cardData && cardData["art"] || %7; \n\ |
98 | + readonly property string cardArt: cardData && cardData["art"] || %8; \n\ |
99 | active: cardArt != ""; \n\ |
100 | - asynchronous: root.asynchronous; \n\ |
101 | + asynchronous: %6; \n\ |
102 | visible: status == Loader.Ready; \n\ |
103 | sourceComponent: Item { \n\ |
104 | id: artShape; \n\ |
105 | @@ -132,10 +134,10 @@ |
106 | id: artImage; \n\ |
107 | objectName: "artImage"; \n\ |
108 | source: artShapeLoader.cardArt; \n\ |
109 | - asynchronous: root.asynchronous; \n\ |
110 | + asynchronous: %6; \n\ |
111 | width: %2; \n\ |
112 | height: %3; \n\ |
113 | - %6 \n\ |
114 | + %7 \n\ |
115 | } \n\ |
116 | } \n\ |
117 | } \n\ |
118 | @@ -144,6 +146,7 @@ |
119 | // %1 is anchors.fill |
120 | // %2 is width |
121 | // %3 is height |
122 | +// %4 is whether the icon should be asynchronous or not |
123 | var kAudioButtonCode = 'AbstractButton { \n\ |
124 | id: audioButton; \n\ |
125 | anchors.fill: %1; \n\ |
126 | @@ -169,6 +172,7 @@ |
127 | opacity: 0.9; \n\ |
128 | name: DashAudioPlayer.playing && AudioUrlComparer.compare(parent.source, DashAudioPlayer.currentSource) ? "media-playback-pause" : "media-playback-start"; \n\ |
129 | color: "white"; \n\ |
130 | + asynchronous: %4; \n\ |
131 | } \n\ |
132 | onClicked: { \n\ |
133 | if (AudioUrlComparer.compare(source, DashAudioPlayer.currentSource)) { \n\ |
134 | @@ -187,12 +191,14 @@ |
135 | } \n\ |
136 | }'; |
137 | |
138 | +// %1 is whether the loader should be asynchronous or not |
139 | +// %2 is the header height code |
140 | var kOverlayLoaderCode = 'Loader { \n\ |
141 | id: overlayLoader; \n\ |
142 | - readonly property real overlayHeight: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\ |
143 | + readonly property real overlayHeight: %2 + units.gu(2); \n\ |
144 | anchors.fill: artShapeHolder; \n\ |
145 | active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false; \n\ |
146 | - asynchronous: root.asynchronous; \n\ |
147 | + asynchronous: %1; \n\ |
148 | visible: showHeader && status == Loader.Ready; \n\ |
149 | sourceComponent: UbuntuShapeOverlay { \n\ |
150 | id: overlay; \n\ |
151 | @@ -211,17 +217,19 @@ |
152 | objectName: "outerRow"; \n\ |
153 | property real margins: units.gu(1); \n\ |
154 | spacing: margins; \n\ |
155 | - height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\ |
156 | + %2\ |
157 | anchors { %1 } \n\ |
158 | anchors.right: parent.right; \n\ |
159 | anchors.margins: margins; \n\ |
160 | anchors.rightMargin: 0; \n\ |
161 | data: [ \n\ |
162 | - %2 \n\ |
163 | + %3 \n\ |
164 | ] \n\ |
165 | }\n'; |
166 | var args = Array.prototype.slice.call(arguments); |
167 | - var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(args.join(',\n')); |
168 | + var isCardTool = args.shift(); |
169 | + var heightCode = isCardTool ? "" : "height: root.fixedHeaderHeight; \n"; |
170 | + var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(heightCode).arg(args.join(',\n')); |
171 | return code; |
172 | } |
173 | |
174 | @@ -242,10 +250,11 @@ |
175 | } |
176 | |
177 | // %1 is used as anchors of mascotShapeLoader |
178 | +// %2 is whether the loader should be asynchronous or not |
179 | var kMascotShapeLoaderCode = 'Loader { \n\ |
180 | id: mascotShapeLoader; \n\ |
181 | objectName: "mascotShapeLoader"; \n\ |
182 | - asynchronous: root.asynchronous; \n\ |
183 | + asynchronous: %2; \n\ |
184 | active: mascotImage.status === Image.Ready; \n\ |
185 | visible: showHeader && active && status == Loader.Ready; \n\ |
186 | width: units.gu(6); \n\ |
187 | @@ -275,6 +284,7 @@ |
188 | // %2 is used as color of titleLabel |
189 | // %3 is used as extra condition for visible of titleLabel |
190 | // %4 is used as title width |
191 | +// %5 is used as horizontal alignment |
192 | var kTitleLabelCode = 'Label { \n\ |
193 | id: titleLabel; \n\ |
194 | objectName: "titleLabel"; \n\ |
195 | @@ -289,7 +299,7 @@ |
196 | width: %4; \n\ |
197 | text: root.title; \n\ |
198 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; \n\ |
199 | - horizontalAlignment: root.titleAlignment; \n\ |
200 | + horizontalAlignment: %5; \n\ |
201 | }\n'; |
202 | |
203 | // %1 is used as extra anchors of emblemIcon |
204 | @@ -398,7 +408,7 @@ |
205 | return colorString; |
206 | } |
207 | |
208 | -function cardString(template, components) { |
209 | +function cardString(template, components, isCardTool) { |
210 | var code; |
211 | |
212 | var templateInteractive = (template == null ? true : (template["non-interactive"] !== undefined ? !template["non-interactive"] : true)) ? "true" : "false"; |
213 | @@ -410,16 +420,16 @@ |
214 | property string backgroundShapeStyle: "inset"; \n\ |
215 | property real fontScale: 1.0; \n\ |
216 | property var scopeStyle: null; \n\ |
217 | - property int titleAlignment: Text.AlignLeft; \n\ |
218 | - property int fixedHeaderHeight: -1; \n\ |
219 | + %2\ |
220 | property size fixedArtShapeSize: Qt.size(-1, -1); \n\ |
221 | readonly property string title: cardData && cardData["title"] || ""; \n\ |
222 | - property bool asynchronous: true; \n\ |
223 | property bool showHeader: true; \n\ |
224 | implicitWidth: childrenRect.width; \n\ |
225 | enabled: %1; \n\ |
226 | \n'.arg(templateInteractive); |
227 | |
228 | + code = code.arg(isCardTool ? "" : "property int fixedHeaderHeight: -1; \n"); |
229 | + |
230 | var hasArt = components["art"] && components["art"]["field"] || false; |
231 | var hasSummary = components["summary"] || false; |
232 | var isConciergeMode = components["art"] && components["art"]["conciergeMode"] || false; |
233 | @@ -435,6 +445,7 @@ |
234 | var hasHeaderRow = hasMascot && hasTitle; |
235 | var hasAttributes = hasTitle && components["attributes"] && components["attributes"]["field"] || false; |
236 | var isAudio = template["quick-preview-type"] === "audio"; |
237 | + var asynchronous = isCardTool ? "false" : "true"; |
238 | |
239 | if (isAudio) { |
240 | // For now we only support audio cards with [optional] art, title, subtitle |
241 | @@ -468,7 +479,7 @@ |
242 | backgroundElements1 = '"%1"'.arg(element1); |
243 | } |
244 | } |
245 | - code += kBackgroundLoaderCode.arg(backgroundElements0).arg(backgroundElements1).arg(templateCardBackground); |
246 | + code += kBackgroundLoaderCode.arg(backgroundElements0).arg(backgroundElements1).arg(asynchronous).arg(templateCardBackground); |
247 | } |
248 | |
249 | if (hasArt) { |
250 | @@ -497,23 +508,31 @@ |
251 | if (isNaN(aspectRatio)) { |
252 | aspectRatio = 1; |
253 | } |
254 | - var fallback = components["art"] && components["art"]["fallback"] || ""; |
255 | + var fallback = !isCardTool && components["art"] && components["art"]["fallback"] || ""; |
256 | fallback = encodeURI(fallback); |
257 | var fallbackStatusCode = ""; |
258 | var fallbackURICode = '""'; |
259 | if (fallback !== "") { |
260 | // fallbackStatusCode has %6 in it because we want to substitute it for fallbackURICode |
261 | - // which in kArtShapeHolderCode is %7 |
262 | - fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %7;'; |
263 | + // which in kArtShapeHolderCode is %8 |
264 | + fallbackStatusCode += 'onStatusChanged: if (status === Image.Error) source = %8;'; |
265 | fallbackURICode = 'decodeURI("%1")'.arg(fallback); |
266 | } |
267 | - code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode).arg(isConciergeMode ? "false" : "true").arg(aspectRatio).arg(fallbackStatusCode).arg(fallbackURICode); |
268 | + code += kArtShapeHolderCode.arg(artAnchors) |
269 | + .arg(widthCode) |
270 | + .arg(heightCode) |
271 | + .arg(isConciergeMode ? "false" : "true") |
272 | + .arg(aspectRatio) |
273 | + .arg(asynchronous) |
274 | + .arg(fallbackStatusCode) |
275 | + .arg(fallbackURICode); |
276 | } else { |
277 | code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n' |
278 | } |
279 | |
280 | if (headerAsOverlay) { |
281 | - code += kOverlayLoaderCode; |
282 | + var headerHeightCode = isCardTool ? "headerHeight" : "root.fixedHeaderHeight"; |
283 | + code += kOverlayLoaderCode.arg(asynchronous).arg(headerHeightCode); |
284 | } |
285 | |
286 | var headerVerticalAnchors; |
287 | @@ -595,11 +614,11 @@ |
288 | } |
289 | |
290 | if (useMascotShape) { |
291 | - mascotShapeCode = kMascotShapeLoaderCode.arg(mascotAnchors); |
292 | + mascotShapeCode = kMascotShapeLoaderCode.arg(mascotAnchors).arg(asynchronous); |
293 | } |
294 | |
295 | var mascotImageVisible = useMascotShape ? 'false' : 'showHeader'; |
296 | - var fallback = components["mascot"] && components["mascot"]["fallback"] || ""; |
297 | + var fallback = !isCardTool && components["mascot"] && components["mascot"]["fallback"] || ""; |
298 | fallback = encodeURI(fallback); |
299 | var fallbackStatusCode = ""; |
300 | var fallbackURICode = '""'; |
301 | @@ -715,9 +734,24 @@ |
302 | } |
303 | } |
304 | |
305 | + var titleAlignment = "Text.AlignHCenter"; |
306 | + if (template["card-layout"] === "horizontal" |
307 | + || typeof components["title"] !== "object" |
308 | + || components["title"]["align"] === "left") titleAlignment = "Text.AlignLeft"; |
309 | + var keys = ["mascot", "emblem", "subtitle", "attributes", "summary"]; |
310 | + for (var key in keys) { |
311 | + key = keys[key]; |
312 | + try { |
313 | + if (typeof components[key] === "string" |
314 | + || typeof components[key]["field"] === "string") titleAlignment = "Text.AlignLeft"; |
315 | + } catch (e) { |
316 | + continue; |
317 | + } |
318 | + } |
319 | + |
320 | // code for different elements |
321 | var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': ''); |
322 | - var titleCode = kTitleLabelCode.arg(titleAnchors).arg(titleColor).arg(titleLabelVisibleExtra).arg(titleWidth); |
323 | + var titleCode = kTitleLabelCode.arg(titleAnchors).arg(titleColor).arg(titleLabelVisibleExtra).arg(titleWidth).arg(titleAlignment); |
324 | var subtitleCode; |
325 | var attributesCode; |
326 | |
327 | @@ -759,7 +793,7 @@ |
328 | if (mascotShapeCode != '') { |
329 | rowCode.unshift(mascotShapeCode); |
330 | } |
331 | - code += kHeaderRowCodeGenerator(headerVerticalAnchors + headerLeftAnchor, rowCode) |
332 | + code += kHeaderRowCodeGenerator(isCardTool, headerVerticalAnchors + headerLeftAnchor, rowCode) |
333 | } else { |
334 | code += mascotShapeCode + mascotCode + titleSubtitleCode; |
335 | } |
336 | @@ -783,9 +817,10 @@ |
337 | } else { |
338 | audioButtonAnchorsFill = 'undefined'; |
339 | audioButtonWidth = 'height'; |
340 | - audioButtonHeight = '(root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1)'; |
341 | + audioButtonHeight = isCardTool ? 'headerHeight + 2 * units.gu(1)' |
342 | + : 'root.fixedHeaderHeight + 2 * units.gu(1)'; |
343 | } |
344 | - code += kAudioButtonCode.arg(audioButtonAnchorsFill).arg(audioButtonWidth).arg(audioButtonHeight); |
345 | + code += kAudioButtonCode.arg(audioButtonAnchorsFill).arg(audioButtonWidth).arg(audioButtonHeight).arg(asynchronous); |
346 | } |
347 | |
348 | if (hasSummary) { |
349 | @@ -854,13 +889,13 @@ |
350 | return code; |
351 | } |
352 | |
353 | -function createCardComponent(parent, template, components, identifier) { |
354 | +function createCardComponent(parent, template, components, isCardTool, identifier) { |
355 | var imports = 'import QtQuick 2.4; \n\ |
356 | import Ubuntu.Components 1.3; \n\ |
357 | import Ubuntu.Settings.Components 0.1; \n\ |
358 | import Dash 0.1;\n\ |
359 | import Utils 0.1;\n'; |
360 | - var card = cardString(template, components); |
361 | + var card = cardString(template, components, isCardTool); |
362 | var code = imports + 'Component {\n' + card + '}\n'; |
363 | |
364 | try { |
365 | |
366 | === modified file 'plugins/Dash/CardCreatorCache.qml' |
367 | --- plugins/Dash/CardCreatorCache.qml 2016-01-21 17:56:08 +0000 |
368 | +++ plugins/Dash/CardCreatorCache.qml 2016-03-10 16:53:32 +0000 |
369 | @@ -23,16 +23,16 @@ |
370 | |
371 | property var cache: new Object(); |
372 | |
373 | - function getCardComponent(template, components) { |
374 | + function getCardComponent(template, components, isCardTool) { |
375 | if (template === undefined || components === undefined) |
376 | return undefined; |
377 | |
378 | var tString = JSON.stringify(template); |
379 | var cString = JSON.stringify(components); |
380 | - var allString = tString + cString; |
381 | + var allString = tString + cString + isCardTool; |
382 | var component = cache[allString]; |
383 | if (component === undefined) { |
384 | - component = CardCreator.createCardComponent(root, template, components, allString); |
385 | + component = CardCreator.createCardComponent(root, template, components, isCardTool, allString); |
386 | cache[allString] = component; |
387 | } |
388 | return component; |
389 | |
390 | === modified file 'qml/Dash/CardCarousel.qml' |
391 | --- qml/Dash/CardCarousel.qml 2016-01-28 14:11:14 +0000 |
392 | +++ qml/Dash/CardCarousel.qml 2016-03-10 16:53:32 +0000 |
393 | @@ -66,7 +66,6 @@ |
394 | item.cardData = Qt.binding(function() { return model; }); |
395 | item.fontScale = Qt.binding(function() { return carousel.fontScale; }); |
396 | item.showHeader = Qt.binding(function() { return loader.explicitlyScaled; }); |
397 | - item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; }); |
398 | item.artShapeStyle = "shadow"; |
399 | item.scopeStyle = cardCarousel.scopeStyle; |
400 | } |
401 | |
402 | === modified file 'qml/Dash/CardGrid.qml' |
403 | --- qml/Dash/CardGrid.qml 2016-02-02 08:47:07 +0000 |
404 | +++ qml/Dash/CardGrid.qml 2016-03-10 16:53:32 +0000 |
405 | @@ -70,7 +70,6 @@ |
406 | item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; }); |
407 | item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; }); |
408 | item.cardData = Qt.binding(function() { return model; }); |
409 | - item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; }); |
410 | item.scopeStyle = root.scopeStyle; |
411 | item.artShapeStyle = root.artShapeStyle; |
412 | item.backgroundShapeStyle = root.backgroundShapeStyle; |
413 | |
414 | === modified file 'qml/Dash/CardHorizontalList.qml' |
415 | --- qml/Dash/CardHorizontalList.qml 2016-01-28 14:11:14 +0000 |
416 | +++ qml/Dash/CardHorizontalList.qml 2016-03-10 16:53:32 +0000 |
417 | @@ -53,7 +53,6 @@ |
418 | item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; }); |
419 | item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; }); |
420 | item.cardData = Qt.binding(function() { return model; }); |
421 | - item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; }); |
422 | item.scopeStyle = root.scopeStyle; |
423 | } |
424 | Connections { |
425 | |
426 | === modified file 'qml/Dash/CardTool.qml' |
427 | --- qml/Dash/CardTool.qml 2016-01-28 14:11:14 +0000 |
428 | +++ qml/Dash/CardTool.qml 2016-03-10 16:53:32 +0000 |
429 | @@ -66,7 +66,7 @@ |
430 | return layout; |
431 | } |
432 | |
433 | - property var cardComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components); |
434 | + property var cardComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, false); |
435 | |
436 | // FIXME: Saviq |
437 | // Only way for the card below to actually be laid out completely. |
438 | @@ -139,29 +139,6 @@ |
439 | readonly property int headerHeight: cardLoader.item ? cardLoader.item.headerHeight : 0 |
440 | property size artShapeSize: cardLoader.item ? cardLoader.item.artShapeSize : 0 |
441 | |
442 | - /*! |
443 | - \brief Desired alignment of title |
444 | - */ |
445 | - readonly property int titleAlignment: { |
446 | - if (template["card-layout"] === "horizontal" |
447 | - || typeof components["title"] !== "object" |
448 | - || components["title"]["align"] === "left") return Text.AlignLeft; |
449 | - |
450 | - var keys = ["mascot", "emblem", "subtitle", "attributes", "summary"]; |
451 | - |
452 | - for (var key in keys) { |
453 | - key = keys[key]; |
454 | - try { |
455 | - if (typeof components[key] === "string" |
456 | - || typeof components[key]["field"] === "string") return Text.AlignLeft; |
457 | - } catch (e) { |
458 | - continue; |
459 | - } |
460 | - } |
461 | - |
462 | - return Text.AlignHCenter; |
463 | - } |
464 | - |
465 | QtObject { |
466 | id: carouselTool |
467 | |
468 | @@ -216,10 +193,9 @@ |
469 | "summary": "—\n—\n—\n—\n—", |
470 | "attributes": attributesModel.model |
471 | } |
472 | - sourceComponent: cardTool.cardComponent |
473 | + sourceComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, true); |
474 | onLoaded: { |
475 | item.objectName = "cardToolCard"; |
476 | - item.asynchronous = false; |
477 | item.width = Qt.binding(function() { return cardTool.cardWidth !== -1 ? cardTool.cardWidth : item.implicitWidth; }); |
478 | item.height = Qt.binding(function() { return cardTool.cardHeight !== -1 ? cardTool.cardHeight : item.implicitHeight; }); |
479 | } |
480 | |
481 | === modified file 'qml/Dash/CardVerticalJournal.qml' |
482 | --- qml/Dash/CardVerticalJournal.qml 2016-01-28 14:11:14 +0000 |
483 | +++ qml/Dash/CardVerticalJournal.qml 2016-03-10 16:53:32 +0000 |
484 | @@ -72,7 +72,6 @@ |
485 | item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; }); |
486 | item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; }); |
487 | item.cardData = Qt.binding(function() { return model; }); |
488 | - item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; }); |
489 | item.scopeStyle = root.scopeStyle; |
490 | } |
491 | Connections { |
492 | |
493 | === modified file 'tests/plugins/Dash/cardcreator/1.res' |
494 | --- tests/plugins/Dash/cardcreator/1.res 2016-02-11 13:13:31 +0000 |
495 | +++ tests/plugins/Dash/cardcreator/1.res 2016-03-10 16:53:32 +0000 |
496 | @@ -5,12 +5,10 @@ |
497 | property string backgroundShapeStyle: "inset"; |
498 | property real fontScale: 1.0; |
499 | property var scopeStyle: null; |
500 | - property int titleAlignment: Text.AlignLeft; |
501 | property int fixedHeaderHeight: -1; |
502 | property size fixedArtShapeSize: Qt.size(-1, -1); |
503 | readonly property string title: cardData && cardData["title"] || ""; |
504 | - property bool asynchronous: true; |
505 | - property bool showHeader: true; |
506 | + property bool showHeader: true; |
507 | implicitWidth: childrenRect.width; |
508 | enabled: true; |
509 | |
510 | @@ -25,7 +23,7 @@ |
511 | objectName: "artShapeLoader"; |
512 | readonly property string cardArt: cardData && cardData["art"] || ""; |
513 | active: cardArt != ""; |
514 | - asynchronous: root.asynchronous; |
515 | + asynchronous: true; |
516 | visible: status == Loader.Ready; |
517 | sourceComponent: Item { |
518 | id: artShape; |
519 | @@ -82,7 +80,7 @@ |
520 | id: artImage; |
521 | objectName: "artImage"; |
522 | source: artShapeLoader.cardArt; |
523 | - asynchronous: root.asynchronous; |
524 | + asynchronous: true; |
525 | width: root.width; |
526 | height: width / artShape.aspect; |
527 | } |
528 | @@ -108,7 +106,7 @@ |
529 | width: undefined; |
530 | text: root.title; |
531 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
532 | - horizontalAlignment: root.titleAlignment; |
533 | + horizontalAlignment: Text.AlignHCenter; |
534 | } |
535 | UbuntuShape { |
536 | id: touchdown; |
537 | |
538 | === added file 'tests/plugins/Dash/cardcreator/1.res.cardcreator' |
539 | --- tests/plugins/Dash/cardcreator/1.res.cardcreator 1970-01-01 00:00:00 +0000 |
540 | +++ tests/plugins/Dash/cardcreator/1.res.cardcreator 2016-03-10 16:53:32 +0000 |
541 | @@ -0,0 +1,119 @@ |
542 | +AbstractButton { |
543 | + id: root; |
544 | + property var cardData; |
545 | + property string artShapeStyle: "inset"; |
546 | + property string backgroundShapeStyle: "inset"; |
547 | + property real fontScale: 1.0; |
548 | + property var scopeStyle: null; |
549 | + property size fixedArtShapeSize: Qt.size(-1, -1); |
550 | + readonly property string title: cardData && cardData["title"] || ""; |
551 | + property bool showHeader: true; |
552 | + implicitWidth: childrenRect.width; |
553 | + enabled: true; |
554 | + |
555 | +readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1); |
556 | +Item { |
557 | + id: artShapeHolder; |
558 | + height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; |
559 | + width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; |
560 | + anchors { horizontalCenter: parent.horizontalCenter; } |
561 | + Loader { |
562 | + id: artShapeLoader; |
563 | + objectName: "artShapeLoader"; |
564 | + readonly property string cardArt: cardData && cardData["art"] || ""; |
565 | + active: cardArt != ""; |
566 | + asynchronous: false; |
567 | + visible: status == Loader.Ready; |
568 | + sourceComponent: Item { |
569 | + id: artShape; |
570 | + objectName: "artShape"; |
571 | + visible: image.status == Image.Ready; |
572 | + readonly property alias image: artImage; |
573 | + ShaderEffectSource { |
574 | + id: artShapeSource; |
575 | + sourceItem: artImage; |
576 | + anchors.centerIn: parent; |
577 | + width: 1; |
578 | + height: 1; |
579 | + hideSource: true; |
580 | + } |
581 | + Loader { |
582 | + anchors.fill: parent; |
583 | + visible: true; |
584 | + sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent; |
585 | + Component { |
586 | + id: artShapeShapeComponent; |
587 | + UbuntuShape { |
588 | + source: artShapeSource; |
589 | + sourceFillMode: UbuntuShape.PreserveAspectCrop; |
590 | + radius: "medium"; |
591 | + aspect: { |
592 | + switch (root.artShapeStyle) { |
593 | + case "inset": return UbuntuShape.Inset; |
594 | + case "shadow": return UbuntuShape.DropShadow; |
595 | + default: |
596 | + case "flat": return UbuntuShape.Flat; |
597 | + } |
598 | + } |
599 | + } |
600 | + } |
601 | + Component { |
602 | + id: artShapeIconComponent; |
603 | + ProportionalShape { source: artShapeSource; aspect: UbuntuShape.DropShadow; } |
604 | + } |
605 | + } |
606 | + readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; |
607 | + readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1.6; |
608 | + Component.onCompleted: { updateWidthHeightBindings(); } |
609 | + Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } |
610 | + function updateWidthHeightBindings() { |
611 | + if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { |
612 | + width = root.fixedArtShapeSize.width; |
613 | + height = root.fixedArtShapeSize.height; |
614 | + } else { |
615 | + width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width }); |
616 | + height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height }); |
617 | + } |
618 | + } |
619 | + CroppedImageMinimumSourceSize { |
620 | + id: artImage; |
621 | + objectName: "artImage"; |
622 | + source: artShapeLoader.cardArt; |
623 | + asynchronous: false; |
624 | + width: root.width; |
625 | + height: width / artShape.aspect; |
626 | + } |
627 | + } |
628 | + } |
629 | + } |
630 | +readonly property int headerHeight: titleLabel.height; |
631 | +Label { |
632 | + id: titleLabel; |
633 | + objectName: "titleLabel"; |
634 | + anchors { right: parent.right; |
635 | + left: parent.left; |
636 | + top: artShapeHolder.bottom; |
637 | + topMargin: units.gu(1); |
638 | + } |
639 | + elide: Text.ElideRight; |
640 | + fontSize: "small"; |
641 | + wrapMode: Text.Wrap; |
642 | + maximumLineCount: 2; |
643 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
644 | + color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText; |
645 | + visible: showHeader ; |
646 | + width: undefined; |
647 | + text: root.title; |
648 | + font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
649 | + horizontalAlignment: Text.AlignHCenter; |
650 | + } |
651 | +UbuntuShape { |
652 | + id: touchdown; |
653 | + objectName: "touchdown"; |
654 | + anchors { fill: artShapeHolder } |
655 | + visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; |
656 | + radius: "medium"; |
657 | + borderSource: "radius_pressed.sci" |
658 | +} |
659 | +implicitHeight: titleLabel.y + titleLabel.height + units.gu(1); |
660 | +} |
661 | |
662 | === modified file 'tests/plugins/Dash/cardcreator/10.res' |
663 | --- tests/plugins/Dash/cardcreator/10.res 2016-02-02 08:47:07 +0000 |
664 | +++ tests/plugins/Dash/cardcreator/10.res 2016-03-10 16:53:32 +0000 |
665 | @@ -5,11 +5,9 @@ |
666 | property string backgroundShapeStyle: "inset"; |
667 | property real fontScale: 1.0; |
668 | property var scopeStyle: null; |
669 | - property int titleAlignment: Text.AlignLeft; |
670 | property int fixedHeaderHeight: -1; |
671 | property size fixedArtShapeSize: Qt.size(-1, -1); |
672 | readonly property string title: cardData && cardData["title"] || ""; |
673 | - property bool asynchronous: true; |
674 | property bool showHeader: true; |
675 | implicitWidth: childrenRect.width; |
676 | enabled: true; |
677 | @@ -18,7 +16,7 @@ |
678 | id: backgroundLoader; |
679 | objectName: "backgroundLoader"; |
680 | anchors.fill: parent; |
681 | - asynchronous: root.asynchronous; |
682 | + asynchronous: true; |
683 | visible: status == Loader.Ready; |
684 | sourceComponent: UbuntuShape { |
685 | objectName: "background"; |
686 | @@ -59,7 +57,7 @@ |
687 | objectName: "outerRow"; |
688 | property real margins: units.gu(1); |
689 | spacing: margins; |
690 | - height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; |
691 | + height: root.fixedHeaderHeight; |
692 | anchors { top: parent.top; |
693 | topMargin: units.gu(1); |
694 | left: parent.left; |
695 | @@ -103,7 +101,7 @@ |
696 | width: undefined; |
697 | text: root.title; |
698 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
699 | - horizontalAlignment: root.titleAlignment; |
700 | + horizontalAlignment: Text.AlignLeft; |
701 | } |
702 | ,Label { |
703 | id: subtitleLabel; |
704 | |
705 | === added file 'tests/plugins/Dash/cardcreator/10.res.cardcreator' |
706 | --- tests/plugins/Dash/cardcreator/10.res.cardcreator 1970-01-01 00:00:00 +0000 |
707 | +++ tests/plugins/Dash/cardcreator/10.res.cardcreator 2016-03-10 16:53:32 +0000 |
708 | @@ -0,0 +1,137 @@ |
709 | +AbstractButton { |
710 | + id: root; |
711 | + property var cardData; |
712 | + property string artShapeStyle: "inset"; |
713 | + property string backgroundShapeStyle: "inset"; |
714 | + property real fontScale: 1.0; |
715 | + property var scopeStyle: null; |
716 | + property size fixedArtShapeSize: Qt.size(-1, -1); |
717 | + readonly property string title: cardData && cardData["title"] || ""; |
718 | + property bool showHeader: true; |
719 | + implicitWidth: childrenRect.width; |
720 | + enabled: true; |
721 | + |
722 | +Loader { |
723 | + id: backgroundLoader; |
724 | + objectName: "backgroundLoader"; |
725 | + anchors.fill: parent; |
726 | + asynchronous: false; |
727 | + visible: status == Loader.Ready; |
728 | + sourceComponent: UbuntuShape { |
729 | + objectName: "background"; |
730 | + radius: "medium"; |
731 | + aspect: { |
732 | + switch (root.backgroundShapeStyle) { |
733 | + case "inset": return UbuntuShape.Inset; |
734 | + case "shadow": return UbuntuShape.DropShadow; |
735 | + default: |
736 | + case "flat": return UbuntuShape.Flat; |
737 | + } |
738 | + } |
739 | + backgroundColor: getColor(0) || "white"; |
740 | + secondaryBackgroundColor: getColor(1) || backgroundColor; |
741 | + backgroundMode: UbuntuShape.VerticalGradient; |
742 | + anchors.fill: parent; |
743 | + source: backgroundImage.source ? backgroundImage : null; |
744 | + property real luminance: Style.luminance(backgroundColor); |
745 | + property Image backgroundImage: Image { |
746 | + objectName: "backgroundImage"; |
747 | + source: { |
748 | + if (cardData && typeof cardData["background"] === "string") return cardData["background"]; |
749 | + else return ""; |
750 | + } |
751 | + } |
752 | + function getColor(index) { |
753 | + if (cardData && typeof cardData["background"] === "object" |
754 | + && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { |
755 | + return cardData["background"]["elements"][index]; |
756 | + } else return index === 0 ? "" : ""; |
757 | + } |
758 | + } |
759 | + } |
760 | +readonly property size artShapeSize: Qt.size(-1, -1); |
761 | +readonly property int headerHeight: row.height; |
762 | +Row { |
763 | + id: row; |
764 | + objectName: "outerRow"; |
765 | + property real margins: units.gu(1); |
766 | + spacing: margins; |
767 | + anchors { top: parent.top; |
768 | + topMargin: units.gu(1); |
769 | +left: parent.left; |
770 | + } |
771 | + anchors.right: parent.right; |
772 | + anchors.margins: margins; |
773 | + anchors.rightMargin: 0; |
774 | + data: [ |
775 | + CroppedImageMinimumSourceSize { |
776 | + id: mascotImage; |
777 | + objectName: "mascotImage"; |
778 | + anchors { verticalCenter: parent.verticalCenter; } |
779 | + source: cardData && cardData["mascot"] || ""; |
780 | + width: units.gu(6); |
781 | + height: units.gu(5.625); |
782 | + horizontalAlignment: Image.AlignHCenter; |
783 | + verticalAlignment: Image.AlignVCenter; |
784 | + visible: showHeader; |
785 | + |
786 | + } |
787 | +,Item { |
788 | + id: headerTitleContainer; |
789 | + anchors { verticalCenter: parent.verticalCenter; } |
790 | + width: parent.width - x; |
791 | + implicitHeight: titleLabel.height + subtitleLabel.height; |
792 | + data: [ |
793 | + Label { |
794 | + id: titleLabel; |
795 | + objectName: "titleLabel"; |
796 | + anchors { right: parent.right; |
797 | +rightMargin: units.gu(1); |
798 | +left: parent.left; |
799 | + top: parent.top; } |
800 | + elide: Text.ElideRight; |
801 | + fontSize: "small"; |
802 | + wrapMode: Text.Wrap; |
803 | + maximumLineCount: 2; |
804 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
805 | + color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
806 | + visible: showHeader ; |
807 | + width: undefined; |
808 | + text: root.title; |
809 | + font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
810 | + horizontalAlignment: Text.AlignLeft; |
811 | + } |
812 | +,Label { |
813 | + id: subtitleLabel; |
814 | + objectName: "subtitleLabel"; |
815 | + anchors { right: parent.right; |
816 | + left: parent.left; |
817 | +rightMargin: units.gu(1); |
818 | +top: titleLabel.bottom; |
819 | + } |
820 | + anchors.topMargin: units.dp(2); |
821 | + elide: Text.ElideRight; |
822 | + maximumLineCount: 1; |
823 | + fontSize: "x-small"; |
824 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
825 | + color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
826 | + visible: titleLabel.visible && titleLabel.text; |
827 | + text: cardData && cardData["subtitle"] || ""; |
828 | + font.weight: Font.Light; |
829 | + } |
830 | + |
831 | + ] |
832 | + } |
833 | + |
834 | + ] |
835 | + } |
836 | +UbuntuShape { |
837 | + id: touchdown; |
838 | + objectName: "touchdown"; |
839 | + anchors { fill: backgroundLoader } |
840 | + visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; |
841 | + radius: "medium"; |
842 | + borderSource: "radius_pressed.sci" |
843 | + } |
844 | +implicitHeight: row.y + row.height + units.gu(1); |
845 | +} |
846 | |
847 | === modified file 'tests/plugins/Dash/cardcreator/11.res' |
848 | --- tests/plugins/Dash/cardcreator/11.res 2016-02-11 13:13:31 +0000 |
849 | +++ tests/plugins/Dash/cardcreator/11.res 2016-03-10 16:53:32 +0000 |
850 | @@ -5,11 +5,9 @@ |
851 | property string backgroundShapeStyle: "inset"; |
852 | property real fontScale: 1.0; |
853 | property var scopeStyle: null; |
854 | - property int titleAlignment: Text.AlignLeft; |
855 | property int fixedHeaderHeight: -1; |
856 | property size fixedArtShapeSize: Qt.size(-1, -1); |
857 | readonly property string title: cardData && cardData["title"] || ""; |
858 | - property bool asynchronous: true; |
859 | property bool showHeader: true; |
860 | implicitWidth: childrenRect.width; |
861 | enabled: true; |
862 | @@ -18,7 +16,7 @@ |
863 | id: backgroundLoader; |
864 | objectName: "backgroundLoader"; |
865 | anchors.fill: parent; |
866 | - asynchronous: root.asynchronous; |
867 | + asynchronous: true; |
868 | visible: status == Loader.Ready; |
869 | sourceComponent: UbuntuShape { |
870 | objectName: "background"; |
871 | @@ -63,7 +61,7 @@ |
872 | objectName: "artShapeLoader"; |
873 | readonly property string cardArt: cardData && cardData["art"] || decodeURI("%5C"); |
874 | active: cardArt != ""; |
875 | - asynchronous: root.asynchronous; |
876 | + asynchronous: true; |
877 | visible: status == Loader.Ready; |
878 | sourceComponent: Item { |
879 | id: artShape; |
880 | @@ -120,7 +118,7 @@ |
881 | id: artImage; |
882 | objectName: "artImage"; |
883 | source: artShapeLoader.cardArt; |
884 | - asynchronous: root.asynchronous; |
885 | + asynchronous: true; |
886 | width: root.width; |
887 | height: width / artShape.aspect; |
888 | onStatusChanged: if (status === Image.Error) source = decodeURI("%5C"); |
889 | @@ -134,7 +132,7 @@ |
890 | objectName: "outerRow"; |
891 | property real margins: units.gu(1); |
892 | spacing: margins; |
893 | - height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; |
894 | + height: root.fixedHeaderHeight; |
895 | anchors { top: artShapeHolder.bottom; |
896 | topMargin: units.gu(1); |
897 | left: parent.left; |
898 | @@ -178,7 +176,7 @@ |
899 | width: undefined; |
900 | text: root.title; |
901 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
902 | - horizontalAlignment: root.titleAlignment; |
903 | + horizontalAlignment: Text.AlignLeft; |
904 | } |
905 | ,Label { |
906 | id: subtitleLabel; |
907 | |
908 | === added file 'tests/plugins/Dash/cardcreator/11.res.cardcreator' |
909 | --- tests/plugins/Dash/cardcreator/11.res.cardcreator 1970-01-01 00:00:00 +0000 |
910 | +++ tests/plugins/Dash/cardcreator/11.res.cardcreator 2016-03-10 16:53:32 +0000 |
911 | @@ -0,0 +1,210 @@ |
912 | +AbstractButton { |
913 | + id: root; |
914 | + property var cardData; |
915 | + property string artShapeStyle: "inset"; |
916 | + property string backgroundShapeStyle: "inset"; |
917 | + property real fontScale: 1.0; |
918 | + property var scopeStyle: null; |
919 | + property size fixedArtShapeSize: Qt.size(-1, -1); |
920 | + readonly property string title: cardData && cardData["title"] || ""; |
921 | + property bool showHeader: true; |
922 | + implicitWidth: childrenRect.width; |
923 | + enabled: true; |
924 | + |
925 | +Loader { |
926 | + id: backgroundLoader; |
927 | + objectName: "backgroundLoader"; |
928 | + anchors.fill: parent; |
929 | + asynchronous: false; |
930 | + visible: status == Loader.Ready; |
931 | + sourceComponent: UbuntuShape { |
932 | + objectName: "background"; |
933 | + radius: "medium"; |
934 | + aspect: { |
935 | + switch (root.backgroundShapeStyle) { |
936 | + case "inset": return UbuntuShape.Inset; |
937 | + case "shadow": return UbuntuShape.DropShadow; |
938 | + default: |
939 | + case "flat": return UbuntuShape.Flat; |
940 | + } |
941 | + } |
942 | + backgroundColor: getColor(0) || "white"; |
943 | + secondaryBackgroundColor: getColor(1) || backgroundColor; |
944 | + backgroundMode: UbuntuShape.VerticalGradient; |
945 | + anchors.fill: parent; |
946 | + source: backgroundImage.source ? backgroundImage : null; |
947 | + property real luminance: Style.luminance(backgroundColor); |
948 | + property Image backgroundImage: Image { |
949 | + objectName: "backgroundImage"; |
950 | + source: { |
951 | + if (cardData && typeof cardData["background"] === "string") return cardData["background"]; |
952 | + else return ""; |
953 | + } |
954 | + } |
955 | + function getColor(index) { |
956 | + if (cardData && typeof cardData["background"] === "object" |
957 | + && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { |
958 | + return cardData["background"]["elements"][index]; |
959 | + } else return index === 0 ? "#E9E9E9" : undefined; |
960 | + } |
961 | + } |
962 | + } |
963 | +readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1); |
964 | +Item { |
965 | + id: artShapeHolder; |
966 | + height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; |
967 | + width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; |
968 | + anchors { horizontalCenter: parent.horizontalCenter; } |
969 | + Loader { |
970 | + id: artShapeLoader; |
971 | + objectName: "artShapeLoader"; |
972 | + readonly property string cardArt: cardData && cardData["art"] || ""; |
973 | + active: cardArt != ""; |
974 | + asynchronous: false; |
975 | + visible: status == Loader.Ready; |
976 | + sourceComponent: Item { |
977 | + id: artShape; |
978 | + objectName: "artShape"; |
979 | + visible: image.status == Image.Ready; |
980 | + readonly property alias image: artImage; |
981 | + ShaderEffectSource { |
982 | + id: artShapeSource; |
983 | + sourceItem: artImage; |
984 | + anchors.centerIn: parent; |
985 | + width: 1; |
986 | + height: 1; |
987 | + hideSource: true; |
988 | + } |
989 | + Loader { |
990 | + anchors.fill: parent; |
991 | + visible: true; |
992 | + sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent; |
993 | + Component { |
994 | + id: artShapeShapeComponent; |
995 | + UbuntuShape { |
996 | + source: artShapeSource; |
997 | + sourceFillMode: UbuntuShape.PreserveAspectCrop; |
998 | + radius: "medium"; |
999 | + aspect: { |
1000 | + switch (root.artShapeStyle) { |
1001 | + case "inset": return UbuntuShape.Inset; |
1002 | + case "shadow": return UbuntuShape.DropShadow; |
1003 | + default: |
1004 | + case "flat": return UbuntuShape.Flat; |
1005 | + } |
1006 | + } |
1007 | + } |
1008 | + } |
1009 | + Component { |
1010 | + id: artShapeIconComponent; |
1011 | + ProportionalShape { source: artShapeSource; aspect: UbuntuShape.DropShadow; } |
1012 | + } |
1013 | + } |
1014 | + readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; |
1015 | + readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1; |
1016 | + Component.onCompleted: { updateWidthHeightBindings(); } |
1017 | + Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } |
1018 | + function updateWidthHeightBindings() { |
1019 | + if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { |
1020 | + width = root.fixedArtShapeSize.width; |
1021 | + height = root.fixedArtShapeSize.height; |
1022 | + } else { |
1023 | + width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width }); |
1024 | + height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height }); |
1025 | + } |
1026 | + } |
1027 | + CroppedImageMinimumSourceSize { |
1028 | + id: artImage; |
1029 | + objectName: "artImage"; |
1030 | + source: artShapeLoader.cardArt; |
1031 | + asynchronous: false; |
1032 | + width: root.width; |
1033 | + height: width / artShape.aspect; |
1034 | + } |
1035 | + } |
1036 | + } |
1037 | + } |
1038 | +readonly property int headerHeight: row.height; |
1039 | +Row { |
1040 | + id: row; |
1041 | + objectName: "outerRow"; |
1042 | + property real margins: units.gu(1); |
1043 | + spacing: margins; |
1044 | + anchors { top: artShapeHolder.bottom; |
1045 | + topMargin: units.gu(1); |
1046 | +left: parent.left; |
1047 | + } |
1048 | + anchors.right: parent.right; |
1049 | + anchors.margins: margins; |
1050 | + anchors.rightMargin: 0; |
1051 | + data: [ |
1052 | + CroppedImageMinimumSourceSize { |
1053 | + id: mascotImage; |
1054 | + objectName: "mascotImage"; |
1055 | + anchors { verticalCenter: parent.verticalCenter; } |
1056 | + source: cardData && cardData["mascot"] || ""; |
1057 | + width: units.gu(6); |
1058 | + height: units.gu(5.625); |
1059 | + horizontalAlignment: Image.AlignHCenter; |
1060 | + verticalAlignment: Image.AlignVCenter; |
1061 | + visible: showHeader; |
1062 | + } |
1063 | +,Item { |
1064 | + id: headerTitleContainer; |
1065 | + anchors { verticalCenter: parent.verticalCenter; } |
1066 | + width: parent.width - x; |
1067 | + implicitHeight: titleLabel.height + subtitleLabel.height; |
1068 | + data: [ |
1069 | + Label { |
1070 | + id: titleLabel; |
1071 | + objectName: "titleLabel"; |
1072 | + anchors { right: parent.right; |
1073 | +rightMargin: units.gu(1); |
1074 | +left: parent.left; |
1075 | + top: parent.top; } |
1076 | + elide: Text.ElideRight; |
1077 | + fontSize: "small"; |
1078 | + wrapMode: Text.Wrap; |
1079 | + maximumLineCount: 2; |
1080 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
1081 | + color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
1082 | + visible: showHeader ; |
1083 | + width: undefined; |
1084 | + text: root.title; |
1085 | + font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
1086 | + horizontalAlignment: Text.AlignLeft; |
1087 | + } |
1088 | +,Label { |
1089 | + id: subtitleLabel; |
1090 | + objectName: "subtitleLabel"; |
1091 | + anchors { right: parent.right; |
1092 | + left: parent.left; |
1093 | +rightMargin: units.gu(1); |
1094 | +top: titleLabel.bottom; |
1095 | + } |
1096 | + anchors.topMargin: units.dp(2); |
1097 | + elide: Text.ElideRight; |
1098 | + maximumLineCount: 1; |
1099 | + fontSize: "x-small"; |
1100 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
1101 | + color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
1102 | + visible: titleLabel.visible && titleLabel.text; |
1103 | + text: cardData && cardData["subtitle"] || ""; |
1104 | + font.weight: Font.Light; |
1105 | + } |
1106 | + |
1107 | + ] |
1108 | + } |
1109 | + |
1110 | + ] |
1111 | + } |
1112 | +UbuntuShape { |
1113 | + id: touchdown; |
1114 | + objectName: "touchdown"; |
1115 | + anchors { fill: backgroundLoader } |
1116 | + visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; |
1117 | + radius: "medium"; |
1118 | + borderSource: "radius_pressed.sci" |
1119 | + } |
1120 | +implicitHeight: row.y + row.height + units.gu(1); |
1121 | +} |
1122 | |
1123 | === modified file 'tests/plugins/Dash/cardcreator/2.res' |
1124 | --- tests/plugins/Dash/cardcreator/2.res 2016-01-28 14:11:14 +0000 |
1125 | +++ tests/plugins/Dash/cardcreator/2.res 2016-03-10 16:53:32 +0000 |
1126 | @@ -5,11 +5,9 @@ |
1127 | property string backgroundShapeStyle: "inset"; |
1128 | property real fontScale: 1.0; |
1129 | property var scopeStyle: null; |
1130 | - property int titleAlignment: Text.AlignLeft; |
1131 | property int fixedHeaderHeight: -1; |
1132 | property size fixedArtShapeSize: Qt.size(-1, -1); |
1133 | readonly property string title: cardData && cardData["title"] || ""; |
1134 | - property bool asynchronous: true; |
1135 | property bool showHeader: true; |
1136 | implicitWidth: childrenRect.width; |
1137 | enabled: true; |
1138 | @@ -18,7 +16,7 @@ |
1139 | id: backgroundLoader; |
1140 | objectName: "backgroundLoader"; |
1141 | anchors.fill: parent; |
1142 | - asynchronous: root.asynchronous; |
1143 | + asynchronous: true; |
1144 | visible: status == Loader.Ready; |
1145 | sourceComponent: UbuntuShape { |
1146 | objectName: "background"; |
1147 | @@ -59,7 +57,7 @@ |
1148 | objectName: "outerRow"; |
1149 | property real margins: units.gu(1); |
1150 | spacing: margins; |
1151 | - height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; |
1152 | + height: root.fixedHeaderHeight; |
1153 | anchors { top: parent.top; |
1154 | topMargin: units.gu(1); |
1155 | left: parent.left; |
1156 | @@ -102,7 +100,7 @@ |
1157 | width: undefined; |
1158 | text: root.title; |
1159 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
1160 | - horizontalAlignment: root.titleAlignment; |
1161 | + horizontalAlignment: Text.AlignLeft; |
1162 | } |
1163 | ,Label { |
1164 | id: subtitleLabel; |
1165 | |
1166 | === added file 'tests/plugins/Dash/cardcreator/2.res.cardcreator' |
1167 | --- tests/plugins/Dash/cardcreator/2.res.cardcreator 1970-01-01 00:00:00 +0000 |
1168 | +++ tests/plugins/Dash/cardcreator/2.res.cardcreator 2016-03-10 16:53:32 +0000 |
1169 | @@ -0,0 +1,136 @@ |
1170 | +AbstractButton { |
1171 | + id: root; |
1172 | + property var cardData; |
1173 | + property string artShapeStyle: "inset"; |
1174 | + property string backgroundShapeStyle: "inset"; |
1175 | + property real fontScale: 1.0; |
1176 | + property var scopeStyle: null; |
1177 | + property size fixedArtShapeSize: Qt.size(-1, -1); |
1178 | + readonly property string title: cardData && cardData["title"] || ""; |
1179 | + property bool showHeader: true; |
1180 | + implicitWidth: childrenRect.width; |
1181 | + enabled: true; |
1182 | + |
1183 | +Loader { |
1184 | + id: backgroundLoader; |
1185 | + objectName: "backgroundLoader"; |
1186 | + anchors.fill: parent; |
1187 | + asynchronous: false; |
1188 | + visible: status == Loader.Ready; |
1189 | + sourceComponent: UbuntuShape { |
1190 | + objectName: "background"; |
1191 | + radius: "medium"; |
1192 | + aspect: { |
1193 | + switch (root.backgroundShapeStyle) { |
1194 | + case "inset": return UbuntuShape.Inset; |
1195 | + case "shadow": return UbuntuShape.DropShadow; |
1196 | + default: |
1197 | + case "flat": return UbuntuShape.Flat; |
1198 | + } |
1199 | + } |
1200 | + backgroundColor: getColor(0) || "white"; |
1201 | + secondaryBackgroundColor: getColor(1) || backgroundColor; |
1202 | + backgroundMode: UbuntuShape.VerticalGradient; |
1203 | + anchors.fill: parent; |
1204 | + source: backgroundImage.source ? backgroundImage : null; |
1205 | + property real luminance: Style.luminance(backgroundColor); |
1206 | + property Image backgroundImage: Image { |
1207 | + objectName: "backgroundImage"; |
1208 | + source: { |
1209 | + if (cardData && typeof cardData["background"] === "string") return cardData["background"]; |
1210 | + else return ""; |
1211 | + } |
1212 | + } |
1213 | + function getColor(index) { |
1214 | + if (cardData && typeof cardData["background"] === "object" |
1215 | + && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { |
1216 | + return cardData["background"]["elements"][index]; |
1217 | + } else return index === 0 ? "#E9E9E9" : undefined; |
1218 | + } |
1219 | + } |
1220 | + } |
1221 | +readonly property size artShapeSize: Qt.size(-1, -1); |
1222 | +readonly property int headerHeight: row.height; |
1223 | +Row { |
1224 | + id: row; |
1225 | + objectName: "outerRow"; |
1226 | + property real margins: units.gu(1); |
1227 | + spacing: margins; |
1228 | + anchors { top: parent.top; |
1229 | + topMargin: units.gu(1); |
1230 | + left: parent.left; |
1231 | + } |
1232 | + anchors.right: parent.right; |
1233 | + anchors.margins: margins; |
1234 | + anchors.rightMargin: 0; |
1235 | + data: [ |
1236 | +CroppedImageMinimumSourceSize { |
1237 | + id: mascotImage; |
1238 | + objectName: "mascotImage"; |
1239 | + anchors { verticalCenter: parent.verticalCenter; } |
1240 | + source: cardData && cardData["mascot"] || ""; |
1241 | + width: units.gu(6); |
1242 | + height: units.gu(5.625); |
1243 | + horizontalAlignment: Image.AlignHCenter; |
1244 | + verticalAlignment: Image.AlignVCenter; |
1245 | + visible: showHeader; |
1246 | + } |
1247 | +,Item { |
1248 | + id: headerTitleContainer; |
1249 | + anchors { verticalCenter: parent.verticalCenter; } |
1250 | + width: parent.width - x; |
1251 | + implicitHeight: titleLabel.height + subtitleLabel.height; |
1252 | + data: [ |
1253 | + Label { |
1254 | + id: titleLabel; |
1255 | + objectName: "titleLabel"; |
1256 | + anchors { right: parent.right; |
1257 | + rightMargin: units.gu(1); |
1258 | + left: parent.left; |
1259 | + top: parent.top; } |
1260 | + elide: Text.ElideRight; |
1261 | + fontSize: "small"; |
1262 | + wrapMode: Text.Wrap; |
1263 | + maximumLineCount: 2; |
1264 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
1265 | + color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
1266 | + visible: showHeader ; |
1267 | + width: undefined; |
1268 | + text: root.title; |
1269 | + font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
1270 | + horizontalAlignment: Text.AlignLeft; |
1271 | + } |
1272 | + ,Label { |
1273 | + id: subtitleLabel; |
1274 | + objectName: "subtitleLabel"; |
1275 | + anchors { right: parent.right; |
1276 | + left: parent.left; |
1277 | + rightMargin: units.gu(1); |
1278 | + top: titleLabel.bottom; |
1279 | + } |
1280 | + anchors.topMargin: units.dp(2); |
1281 | + elide: Text.ElideRight; |
1282 | + maximumLineCount: 1; |
1283 | + fontSize: "x-small"; |
1284 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
1285 | + color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
1286 | + visible: titleLabel.visible && titleLabel.text; |
1287 | + text: cardData && cardData["subtitle"] || ""; |
1288 | + font.weight: Font.Light; |
1289 | + } |
1290 | + |
1291 | + ] |
1292 | + } |
1293 | + |
1294 | + ] |
1295 | + } |
1296 | +UbuntuShape { |
1297 | + id: touchdown; |
1298 | + objectName: "touchdown"; |
1299 | + anchors { fill: backgroundLoader } |
1300 | + visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; |
1301 | + radius: "medium"; |
1302 | + borderSource: "radius_pressed.sci" |
1303 | +} |
1304 | +implicitHeight: row.y + row.height + units.gu(1); |
1305 | +} |
1306 | |
1307 | === modified file 'tests/plugins/Dash/cardcreator/3.res' |
1308 | --- tests/plugins/Dash/cardcreator/3.res 2016-02-11 13:13:31 +0000 |
1309 | +++ tests/plugins/Dash/cardcreator/3.res 2016-03-10 16:53:32 +0000 |
1310 | @@ -5,11 +5,9 @@ |
1311 | property string backgroundShapeStyle: "inset"; |
1312 | property real fontScale: 1.0; |
1313 | property var scopeStyle: null; |
1314 | - property int titleAlignment: Text.AlignLeft; |
1315 | property int fixedHeaderHeight: -1; |
1316 | property size fixedArtShapeSize: Qt.size(-1, -1); |
1317 | readonly property string title: cardData && cardData["title"] || ""; |
1318 | - property bool asynchronous: true; |
1319 | property bool showHeader: true; |
1320 | implicitWidth: childrenRect.width; |
1321 | enabled: true; |
1322 | @@ -25,7 +23,7 @@ |
1323 | objectName: "artShapeLoader"; |
1324 | readonly property string cardArt: cardData && cardData["art"] || decodeURI("IHAVE%5C%22ESCAPED%5C%22QUOTES%5C%22"); |
1325 | active: cardArt != ""; |
1326 | - asynchronous: root.asynchronous; |
1327 | + asynchronous: true; |
1328 | visible: status == Loader.Ready; |
1329 | sourceComponent: Item { |
1330 | id: artShape; |
1331 | @@ -82,7 +80,7 @@ |
1332 | id: artImage; |
1333 | objectName: "artImage"; |
1334 | source: artShapeLoader.cardArt; |
1335 | - asynchronous: root.asynchronous; |
1336 | + asynchronous: true; |
1337 | width: root.width; |
1338 | height: width / artShape.aspect; |
1339 | onStatusChanged: if (status === Image.Error) source = decodeURI("IHAVE%5C%22ESCAPED%5C%22QUOTES%5C%22"); |
1340 | @@ -109,7 +107,7 @@ |
1341 | width: undefined; |
1342 | text: root.title; |
1343 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
1344 | - horizontalAlignment: root.titleAlignment; |
1345 | + horizontalAlignment: Text.AlignLeft; |
1346 | } |
1347 | Label { |
1348 | id: subtitleLabel; |
1349 | |
1350 | === added file 'tests/plugins/Dash/cardcreator/3.res.cardcreator' |
1351 | --- tests/plugins/Dash/cardcreator/3.res.cardcreator 1970-01-01 00:00:00 +0000 |
1352 | +++ tests/plugins/Dash/cardcreator/3.res.cardcreator 2016-03-10 16:53:32 +0000 |
1353 | @@ -0,0 +1,137 @@ |
1354 | +AbstractButton { |
1355 | + id: root; |
1356 | + property var cardData; |
1357 | + property string artShapeStyle: "inset"; |
1358 | + property string backgroundShapeStyle: "inset"; |
1359 | + property real fontScale: 1.0; |
1360 | + property var scopeStyle: null; |
1361 | + property size fixedArtShapeSize: Qt.size(-1, -1); |
1362 | + readonly property string title: cardData && cardData["title"] || ""; |
1363 | + property bool showHeader: true; |
1364 | + implicitWidth: childrenRect.width; |
1365 | + enabled: true; |
1366 | + |
1367 | +readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1); |
1368 | +Item { |
1369 | + id: artShapeHolder; |
1370 | + height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; |
1371 | + width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; |
1372 | + anchors { horizontalCenter: parent.horizontalCenter; } |
1373 | + Loader { |
1374 | + id: artShapeLoader; |
1375 | + objectName: "artShapeLoader"; |
1376 | + readonly property string cardArt: cardData && cardData["art"] || ""; |
1377 | + active: cardArt != ""; |
1378 | + asynchronous: false; |
1379 | + visible: status == Loader.Ready; |
1380 | + sourceComponent: Item { |
1381 | + id: artShape; |
1382 | + objectName: "artShape"; |
1383 | + visible: image.status == Image.Ready; |
1384 | + readonly property alias image: artImage; |
1385 | + ShaderEffectSource { |
1386 | + id: artShapeSource; |
1387 | + sourceItem: artImage; |
1388 | + anchors.centerIn: parent; |
1389 | + width: 1; |
1390 | + height: 1; |
1391 | + hideSource: true; |
1392 | + } |
1393 | + Loader { |
1394 | + anchors.fill: parent; |
1395 | + visible: true; |
1396 | + sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent; |
1397 | + Component { |
1398 | + id: artShapeShapeComponent; |
1399 | + UbuntuShape { |
1400 | + source: artShapeSource; |
1401 | + sourceFillMode: UbuntuShape.PreserveAspectCrop; |
1402 | + radius: "medium"; |
1403 | + aspect: { |
1404 | + switch (root.artShapeStyle) { |
1405 | + case "inset": return UbuntuShape.Inset; |
1406 | + case "shadow": return UbuntuShape.DropShadow; |
1407 | + default: |
1408 | + case "flat": return UbuntuShape.Flat; |
1409 | + } |
1410 | + } |
1411 | + } |
1412 | + } |
1413 | + Component { |
1414 | + id: artShapeIconComponent; |
1415 | + ProportionalShape { source: artShapeSource; aspect: UbuntuShape.DropShadow; } |
1416 | + } |
1417 | + } |
1418 | + readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; |
1419 | + readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 0.75; |
1420 | + Component.onCompleted: { updateWidthHeightBindings(); } |
1421 | + Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } |
1422 | + function updateWidthHeightBindings() { |
1423 | + if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { |
1424 | + width = root.fixedArtShapeSize.width; |
1425 | + height = root.fixedArtShapeSize.height; |
1426 | + } else { |
1427 | + width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width }); |
1428 | + height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height }); |
1429 | + } |
1430 | + } |
1431 | + CroppedImageMinimumSourceSize { |
1432 | + id: artImage; |
1433 | + objectName: "artImage"; |
1434 | + source: artShapeLoader.cardArt; |
1435 | + asynchronous: false; |
1436 | + width: root.width; |
1437 | + height: width / artShape.aspect; |
1438 | + } |
1439 | + } |
1440 | + } |
1441 | + } |
1442 | +readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin; |
1443 | +Label { |
1444 | + id: titleLabel; |
1445 | + objectName: "titleLabel"; |
1446 | + anchors { right: parent.right; |
1447 | + left: parent.left; |
1448 | + top: artShapeHolder.bottom; |
1449 | + topMargin: units.gu(1); |
1450 | + } |
1451 | + elide: Text.ElideRight; |
1452 | + fontSize: "small"; |
1453 | + wrapMode: Text.Wrap; |
1454 | + maximumLineCount: 2; |
1455 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
1456 | + color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText; |
1457 | + visible: showHeader ; |
1458 | + width: undefined; |
1459 | + text: root.title; |
1460 | + font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
1461 | + horizontalAlignment: Text.AlignLeft; |
1462 | + } |
1463 | +Label { |
1464 | + id: subtitleLabel; |
1465 | + objectName: "subtitleLabel"; |
1466 | + anchors { left: titleLabel.left; |
1467 | + leftMargin: titleLabel.leftMargin; |
1468 | + right: titleLabel.right; |
1469 | + top: titleLabel.bottom; |
1470 | + } |
1471 | + anchors.topMargin: units.dp(2); |
1472 | + elide: Text.ElideRight; |
1473 | + maximumLineCount: 1; |
1474 | + fontSize: "x-small"; |
1475 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
1476 | + color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText; |
1477 | + visible: titleLabel.visible && titleLabel.text; |
1478 | + text: cardData && cardData["subtitle"] || ""; |
1479 | + font.weight: Font.Light; |
1480 | + } |
1481 | +UbuntuShape { |
1482 | + id: touchdown; |
1483 | + objectName: "touchdown"; |
1484 | + anchors { fill: artShapeHolder } |
1485 | + visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; |
1486 | + radius: "medium"; |
1487 | + borderSource: "radius_pressed.sci" |
1488 | +} |
1489 | +implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1); |
1490 | +} |
1491 | |
1492 | === modified file 'tests/plugins/Dash/cardcreator/4.res' |
1493 | --- tests/plugins/Dash/cardcreator/4.res 2016-01-28 14:11:14 +0000 |
1494 | +++ tests/plugins/Dash/cardcreator/4.res 2016-03-10 16:53:32 +0000 |
1495 | @@ -5,11 +5,9 @@ |
1496 | property string backgroundShapeStyle: "inset"; |
1497 | property real fontScale: 1.0; |
1498 | property var scopeStyle: null; |
1499 | - property int titleAlignment: Text.AlignLeft; |
1500 | property int fixedHeaderHeight: -1; |
1501 | property size fixedArtShapeSize: Qt.size(-1, -1); |
1502 | readonly property string title: cardData && cardData["title"] || ""; |
1503 | - property bool asynchronous: true; |
1504 | property bool showHeader: true; |
1505 | implicitWidth: childrenRect.width; |
1506 | enabled: true; |
1507 | @@ -21,7 +19,7 @@ |
1508 | objectName: "outerRow"; |
1509 | property real margins: units.gu(1); |
1510 | spacing: margins; |
1511 | - height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; |
1512 | + height: root.fixedHeaderHeight; |
1513 | anchors { top: parent.top; |
1514 | topMargin: units.gu(1); |
1515 | left: parent.left; |
1516 | @@ -33,7 +31,7 @@ |
1517 | Loader { |
1518 | id: mascotShapeLoader; |
1519 | objectName: "mascotShapeLoader"; |
1520 | - asynchronous: root.asynchronous; |
1521 | + asynchronous: true; |
1522 | active: mascotImage.status === Image.Ready; |
1523 | visible: showHeader && active && status == Loader.Ready; |
1524 | width: units.gu(6); |
1525 | @@ -77,7 +75,7 @@ |
1526 | width: undefined; |
1527 | text: root.title; |
1528 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
1529 | - horizontalAlignment: root.titleAlignment; |
1530 | + horizontalAlignment: Text.AlignLeft; |
1531 | } |
1532 | ,Label { |
1533 | id: subtitleLabel; |
1534 | |
1535 | === added file 'tests/plugins/Dash/cardcreator/4.res.cardcreator' |
1536 | --- tests/plugins/Dash/cardcreator/4.res.cardcreator 1970-01-01 00:00:00 +0000 |
1537 | +++ tests/plugins/Dash/cardcreator/4.res.cardcreator 2016-03-10 16:53:32 +0000 |
1538 | @@ -0,0 +1,109 @@ |
1539 | +AbstractButton { |
1540 | + id: root; |
1541 | + property var cardData; |
1542 | + property string artShapeStyle: "inset"; |
1543 | + property string backgroundShapeStyle: "inset"; |
1544 | + property real fontScale: 1.0; |
1545 | + property var scopeStyle: null; |
1546 | + property size fixedArtShapeSize: Qt.size(-1, -1); |
1547 | + readonly property string title: cardData && cardData["title"] || ""; |
1548 | + property bool showHeader: true; |
1549 | + implicitWidth: childrenRect.width; |
1550 | + enabled: true; |
1551 | + |
1552 | +readonly property size artShapeSize: Qt.size(-1, -1); |
1553 | +readonly property int headerHeight: row.height; |
1554 | +Row { |
1555 | + id: row; |
1556 | + objectName: "outerRow"; |
1557 | + property real margins: units.gu(1); |
1558 | + spacing: margins; |
1559 | + anchors { top: parent.top; |
1560 | + topMargin: units.gu(1); |
1561 | + left: parent.left; |
1562 | +} |
1563 | + anchors.right: parent.right; |
1564 | + anchors.margins: margins; |
1565 | + anchors.rightMargin: 0; |
1566 | +data: [ |
1567 | +Loader { |
1568 | + id: mascotShapeLoader; |
1569 | + objectName: "mascotShapeLoader"; |
1570 | + asynchronous: false; |
1571 | + active: mascotImage.status === Image.Ready; |
1572 | + visible: showHeader && active && status == Loader.Ready; |
1573 | + width: units.gu(6); |
1574 | + height: units.gu(5.625); |
1575 | + sourceComponent: UbuntuShape { image: mascotImage } |
1576 | + anchors { verticalCenter: parent.verticalCenter; } |
1577 | + } |
1578 | + |
1579 | +,CroppedImageMinimumSourceSize { |
1580 | + id: mascotImage; |
1581 | + objectName: "mascotImage"; |
1582 | + anchors { verticalCenter: parent.verticalCenter; } |
1583 | + source: cardData && cardData["mascot"] || ""; |
1584 | + width: units.gu(6); |
1585 | + height: units.gu(5.625); |
1586 | + horizontalAlignment: Image.AlignHCenter; |
1587 | + verticalAlignment: Image.AlignVCenter; |
1588 | + visible: false; |
1589 | + } |
1590 | + |
1591 | +,Item { |
1592 | + id: headerTitleContainer; |
1593 | + anchors { verticalCenter: parent.verticalCenter; } |
1594 | + width: parent.width - x; |
1595 | + implicitHeight: titleLabel.height + subtitleLabel.height; |
1596 | + data: [ |
1597 | +Label { |
1598 | + id: titleLabel; |
1599 | + objectName: "titleLabel"; |
1600 | + anchors { right: parent.right; |
1601 | + rightMargin: units.gu(1); |
1602 | + left: parent.left; |
1603 | + top: parent.top; } |
1604 | + elide: Text.ElideRight; |
1605 | + fontSize: "small"; |
1606 | + wrapMode: Text.Wrap; |
1607 | + maximumLineCount: 2; |
1608 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
1609 | + color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText; |
1610 | + visible: showHeader ; |
1611 | + width: undefined; |
1612 | + text: root.title; |
1613 | + font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
1614 | + horizontalAlignment: Text.AlignLeft; |
1615 | + } |
1616 | +,Label { |
1617 | + id: subtitleLabel; |
1618 | + objectName: "subtitleLabel"; |
1619 | + anchors { right: parent.right; |
1620 | + left: parent.left; |
1621 | + rightMargin: units.gu(1); |
1622 | + top: titleLabel.bottom; |
1623 | + } |
1624 | + anchors.topMargin: units.dp(2); |
1625 | + elide: Text.ElideRight; |
1626 | + maximumLineCount: 1; |
1627 | + fontSize: "x-small"; |
1628 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
1629 | + color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText; |
1630 | + visible: titleLabel.visible && titleLabel.text; |
1631 | + text: cardData && cardData["subtitle"] || ""; |
1632 | + font.weight: Font.Light; |
1633 | + } |
1634 | +] |
1635 | +} |
1636 | +] |
1637 | +} |
1638 | +UbuntuShape { |
1639 | + id: touchdown; |
1640 | + objectName: "touchdown"; |
1641 | + anchors { fill: root } |
1642 | + visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; |
1643 | + radius: "medium"; |
1644 | + borderSource: "radius_pressed.sci" |
1645 | +} |
1646 | +implicitHeight: row.y + row.height + units.gu(1); |
1647 | +} |
1648 | |
1649 | === modified file 'tests/plugins/Dash/cardcreator/5.res' |
1650 | --- tests/plugins/Dash/cardcreator/5.res 2016-02-11 13:13:31 +0000 |
1651 | +++ tests/plugins/Dash/cardcreator/5.res 2016-03-10 16:53:32 +0000 |
1652 | @@ -5,11 +5,9 @@ |
1653 | property string backgroundShapeStyle: "inset"; |
1654 | property real fontScale: 1.0; |
1655 | property var scopeStyle: null; |
1656 | - property int titleAlignment: Text.AlignLeft; |
1657 | property int fixedHeaderHeight: -1; |
1658 | property size fixedArtShapeSize: Qt.size(-1, -1); |
1659 | readonly property string title: cardData && cardData["title"] || ""; |
1660 | - property bool asynchronous: true; |
1661 | property bool showHeader: true; |
1662 | implicitWidth: childrenRect.width; |
1663 | enabled: false; |
1664 | @@ -25,7 +23,7 @@ |
1665 | objectName: "artShapeLoader"; |
1666 | readonly property string cardArt: cardData && cardData["art"] || ""; |
1667 | active: cardArt != ""; |
1668 | - asynchronous: root.asynchronous; |
1669 | + asynchronous: true; |
1670 | visible: status == Loader.Ready; |
1671 | sourceComponent: Item { |
1672 | id: artShape; |
1673 | @@ -82,7 +80,7 @@ |
1674 | id: artImage; |
1675 | objectName: "artImage"; |
1676 | source: artShapeLoader.cardArt; |
1677 | - asynchronous: root.asynchronous; |
1678 | + asynchronous: true; |
1679 | width: root.width; |
1680 | height: width / artShape.aspect; |
1681 | } |
1682 | @@ -91,10 +89,10 @@ |
1683 | } |
1684 | Loader { |
1685 | id: overlayLoader; |
1686 | - readonly property real overlayHeight: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); |
1687 | + readonly property real overlayHeight: root.fixedHeaderHeight + units.gu(2); |
1688 | anchors.fill: artShapeHolder; |
1689 | active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false; |
1690 | - asynchronous: root.asynchronous; |
1691 | + asynchronous: true; |
1692 | visible: showHeader && status == Loader.Ready; |
1693 | sourceComponent: UbuntuShapeOverlay { |
1694 | id: overlay; |
1695 | @@ -126,7 +124,7 @@ |
1696 | width: undefined; |
1697 | text: root.title; |
1698 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
1699 | - horizontalAlignment: root.titleAlignment; |
1700 | + horizontalAlignment: Text.AlignLeft; |
1701 | } |
1702 | Label { |
1703 | id: subtitleLabel; |
1704 | |
1705 | === added file 'tests/plugins/Dash/cardcreator/5.res.cardcreator' |
1706 | --- tests/plugins/Dash/cardcreator/5.res.cardcreator 1970-01-01 00:00:00 +0000 |
1707 | +++ tests/plugins/Dash/cardcreator/5.res.cardcreator 2016-03-10 16:53:32 +0000 |
1708 | @@ -0,0 +1,156 @@ |
1709 | +AbstractButton { |
1710 | + id: root; |
1711 | + property var cardData; |
1712 | + property string artShapeStyle: "inset"; |
1713 | + property string backgroundShapeStyle: "inset"; |
1714 | + property real fontScale: 1.0; |
1715 | + property var scopeStyle: null; |
1716 | + property size fixedArtShapeSize: Qt.size(-1, -1); |
1717 | + readonly property string title: cardData && cardData["title"] || ""; |
1718 | + property bool showHeader: true; |
1719 | + implicitWidth: childrenRect.width; |
1720 | + enabled: false; |
1721 | + |
1722 | +readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1); |
1723 | +Item { |
1724 | + id: artShapeHolder; |
1725 | + height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; |
1726 | + width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; |
1727 | + anchors { horizontalCenter: parent.horizontalCenter; } |
1728 | + Loader { |
1729 | + id: artShapeLoader; |
1730 | + objectName: "artShapeLoader"; |
1731 | + readonly property string cardArt: cardData && cardData["art"] || ""; |
1732 | + active: cardArt != ""; |
1733 | + asynchronous: false; |
1734 | + visible: status == Loader.Ready; |
1735 | + sourceComponent: Item { |
1736 | + id: artShape; |
1737 | + objectName: "artShape"; |
1738 | + visible: image.status == Image.Ready; |
1739 | + readonly property alias image: artImage; |
1740 | + ShaderEffectSource { |
1741 | + id: artShapeSource; |
1742 | + sourceItem: artImage; |
1743 | + anchors.centerIn: parent; |
1744 | + width: 1; |
1745 | + height: 1; |
1746 | + hideSource: false; |
1747 | + } |
1748 | + Loader { |
1749 | + anchors.fill: parent; |
1750 | + visible: false; |
1751 | + sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent; |
1752 | + Component { |
1753 | + id: artShapeShapeComponent; |
1754 | + UbuntuShape { |
1755 | + source: artShapeSource; |
1756 | + sourceFillMode: UbuntuShape.PreserveAspectCrop; |
1757 | + radius: "medium"; |
1758 | + aspect: { |
1759 | + switch (root.artShapeStyle) { |
1760 | + case "inset": return UbuntuShape.Inset; |
1761 | + case "shadow": return UbuntuShape.DropShadow; |
1762 | + default: |
1763 | + case "flat": return UbuntuShape.Flat; |
1764 | + } |
1765 | + } |
1766 | + } |
1767 | + } |
1768 | + Component { |
1769 | + id: artShapeIconComponent; |
1770 | + ProportionalShape { source: artShapeSource; aspect: UbuntuShape.DropShadow; } |
1771 | + } |
1772 | + } |
1773 | + readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; |
1774 | + readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1; |
1775 | + Component.onCompleted: { updateWidthHeightBindings(); } |
1776 | + Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } |
1777 | + function updateWidthHeightBindings() { |
1778 | + if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { |
1779 | + width = root.fixedArtShapeSize.width; |
1780 | + height = root.fixedArtShapeSize.height; |
1781 | + } else { |
1782 | + width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width }); |
1783 | + height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height }); |
1784 | + } |
1785 | + } |
1786 | + CroppedImageMinimumSourceSize { |
1787 | + id: artImage; |
1788 | + objectName: "artImage"; |
1789 | + source: artShapeLoader.cardArt; |
1790 | + asynchronous: false; |
1791 | + width: root.width; |
1792 | + height: width / artShape.aspect; |
1793 | + } |
1794 | + } |
1795 | + } |
1796 | + } |
1797 | +Loader { |
1798 | + id: overlayLoader; |
1799 | + readonly property real overlayHeight: headerHeight + units.gu(2); |
1800 | + anchors.fill: artShapeHolder; |
1801 | + active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false; |
1802 | + asynchronous: false; |
1803 | + visible: showHeader && status == Loader.Ready; |
1804 | + sourceComponent: UbuntuShapeOverlay { |
1805 | + id: overlay; |
1806 | + property real luminance: Style.luminance(overlayColor); |
1807 | + aspect: UbuntuShape.Flat; |
1808 | + radius: "medium"; |
1809 | + overlayColor: cardData && cardData["overlayColor"] || "#99000000"; |
1810 | + overlayRect: Qt.rect(0, 1 - overlayLoader.overlayHeight / height, 1, 1); |
1811 | + } |
1812 | + } |
1813 | +readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin; |
1814 | +Label { |
1815 | + id: titleLabel; |
1816 | + objectName: "titleLabel"; |
1817 | + anchors { right: parent.right; |
1818 | + rightMargin: units.gu(1); |
1819 | + left: parent.left; |
1820 | + leftMargin: units.gu(1); |
1821 | + top: overlayLoader.top; |
1822 | + topMargin: units.gu(1) + overlayLoader.height - overlayLoader.overlayHeight; |
1823 | + } |
1824 | + elide: Text.ElideRight; |
1825 | + fontSize: "small"; |
1826 | + wrapMode: Text.Wrap; |
1827 | + maximumLineCount: 2; |
1828 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
1829 | + color: root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
1830 | + visible: showHeader && overlayLoader.active; |
1831 | + width: undefined; |
1832 | + text: root.title; |
1833 | + font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
1834 | + horizontalAlignment: Text.AlignLeft; |
1835 | + } |
1836 | +Label { |
1837 | + id: subtitleLabel; |
1838 | + objectName: "subtitleLabel"; |
1839 | + anchors { left: titleLabel.left; |
1840 | + leftMargin: titleLabel.leftMargin; |
1841 | + rightMargin: units.gu(1); |
1842 | + right: titleLabel.right; |
1843 | + top: titleLabel.bottom; |
1844 | + } |
1845 | + anchors.topMargin: units.dp(2); |
1846 | + elide: Text.ElideRight; |
1847 | + maximumLineCount: 1; |
1848 | + fontSize: "x-small"; |
1849 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
1850 | + color: root.scopeStyle && overlayLoader.item ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item && overlayLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
1851 | + visible: titleLabel.visible && titleLabel.text; |
1852 | + text: cardData && cardData["subtitle"] || ""; |
1853 | + font.weight: Font.Light; |
1854 | + } |
1855 | +UbuntuShape { |
1856 | + id: touchdown; |
1857 | + objectName: "touchdown"; |
1858 | + anchors { fill: artShapeHolder } |
1859 | + visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; |
1860 | + radius: "medium"; |
1861 | + borderSource: "radius_pressed.sci" |
1862 | +} |
1863 | +implicitHeight: artShapeHolder.height; |
1864 | +} |
1865 | |
1866 | === modified file 'tests/plugins/Dash/cardcreator/6.res' |
1867 | --- tests/plugins/Dash/cardcreator/6.res 2016-02-02 08:47:07 +0000 |
1868 | +++ tests/plugins/Dash/cardcreator/6.res 2016-03-10 16:53:32 +0000 |
1869 | @@ -5,11 +5,9 @@ |
1870 | property string backgroundShapeStyle: "inset"; |
1871 | property real fontScale: 1.0; |
1872 | property var scopeStyle: null; |
1873 | - property int titleAlignment: Text.AlignLeft; |
1874 | property int fixedHeaderHeight: -1; |
1875 | property size fixedArtShapeSize: Qt.size(-1, -1); |
1876 | readonly property string title: cardData && cardData["title"] || ""; |
1877 | - property bool asynchronous: true; |
1878 | property bool showHeader: true; |
1879 | implicitWidth: childrenRect.width; |
1880 | enabled: true; |
1881 | @@ -18,7 +16,7 @@ |
1882 | id: backgroundLoader; |
1883 | objectName: "backgroundLoader"; |
1884 | anchors.fill: parent; |
1885 | - asynchronous: root.asynchronous; |
1886 | + asynchronous: true; |
1887 | visible: status == Loader.Ready; |
1888 | sourceComponent: UbuntuShape { |
1889 | objectName: "background"; |
1890 | @@ -81,7 +79,7 @@ |
1891 | width: undefined; |
1892 | text: root.title; |
1893 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
1894 | - horizontalAlignment: root.titleAlignment; |
1895 | + horizontalAlignment: Text.AlignLeft; |
1896 | } |
1897 | ,Label { |
1898 | id: subtitleLabel; |
1899 | |
1900 | === added file 'tests/plugins/Dash/cardcreator/6.res.cardcreator' |
1901 | --- tests/plugins/Dash/cardcreator/6.res.cardcreator 1970-01-01 00:00:00 +0000 |
1902 | +++ tests/plugins/Dash/cardcreator/6.res.cardcreator 2016-03-10 16:53:32 +0000 |
1903 | @@ -0,0 +1,126 @@ |
1904 | +AbstractButton { |
1905 | + id: root; |
1906 | + property var cardData; |
1907 | + property string artShapeStyle: "inset"; |
1908 | + property string backgroundShapeStyle: "inset"; |
1909 | + property real fontScale: 1.0; |
1910 | + property var scopeStyle: null; |
1911 | + property size fixedArtShapeSize: Qt.size(-1, -1); |
1912 | + readonly property string title: cardData && cardData["title"] || ""; |
1913 | + property bool showHeader: true; |
1914 | + implicitWidth: childrenRect.width; |
1915 | + enabled: true; |
1916 | + |
1917 | +Loader { |
1918 | + id: backgroundLoader; |
1919 | + objectName: "backgroundLoader"; |
1920 | + anchors.fill: parent; |
1921 | + asynchronous: false; |
1922 | + visible: status == Loader.Ready; |
1923 | + sourceComponent: UbuntuShape { |
1924 | + objectName: "background"; |
1925 | + radius: "medium"; |
1926 | + aspect: { |
1927 | + switch (root.backgroundShapeStyle) { |
1928 | + case "inset": return UbuntuShape.Inset; |
1929 | + case "shadow": return UbuntuShape.DropShadow; |
1930 | + default: |
1931 | + case "flat": return UbuntuShape.Flat; |
1932 | + } |
1933 | + } |
1934 | + backgroundColor: getColor(0) || "white"; |
1935 | + secondaryBackgroundColor: getColor(1) || backgroundColor; |
1936 | + backgroundMode: UbuntuShape.VerticalGradient; |
1937 | + anchors.fill: parent; |
1938 | + source: backgroundImage.source ? backgroundImage : null; |
1939 | + property real luminance: Style.luminance(backgroundColor); |
1940 | + property Image backgroundImage: Image { |
1941 | + objectName: "backgroundImage"; |
1942 | + source: { |
1943 | + if (cardData && typeof cardData["background"] === "string") return cardData["background"]; |
1944 | + else return decodeURI("http://assets.ubuntu.com/sites/ubuntu/latest/u/img/logos/logo-ubuntu-grey.png"); |
1945 | + } |
1946 | + } |
1947 | + function getColor(index) { |
1948 | + if (cardData && typeof cardData["background"] === "object" |
1949 | + && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { |
1950 | + return cardData["background"]["elements"][index]; |
1951 | + } else return index === 0 ? undefined : undefined; |
1952 | + } |
1953 | + } |
1954 | + } |
1955 | +readonly property size artShapeSize: Qt.size(-1, -1); |
1956 | +readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin; |
1957 | +Item { |
1958 | + id: headerTitleContainer; |
1959 | + anchors { right: parent.right; left: parent.left; |
1960 | + top: parent.top; |
1961 | + topMargin: units.gu(1); |
1962 | + leftMargin: units.gu(1); |
1963 | + } |
1964 | + width: parent.width - x; |
1965 | + implicitHeight: titleLabel.height + subtitleLabel.height; |
1966 | + data: [ |
1967 | + Label { |
1968 | + id: titleLabel; |
1969 | + objectName: "titleLabel"; |
1970 | + anchors { right: emblemIcon.left; |
1971 | + rightMargin: emblemIcon.width > 0 ? units.gu(0.5) : 0; |
1972 | + left: parent.left; |
1973 | + top: parent.top; } |
1974 | + elide: Text.ElideRight; |
1975 | + fontSize: "small"; |
1976 | + wrapMode: Text.Wrap; |
1977 | + maximumLineCount: 2; |
1978 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
1979 | + color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
1980 | + visible: showHeader ; |
1981 | + width: undefined; |
1982 | + text: root.title; |
1983 | + font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
1984 | + horizontalAlignment: Text.AlignLeft; |
1985 | + } |
1986 | +,Label { |
1987 | + id: subtitleLabel; |
1988 | + objectName: "subtitleLabel"; |
1989 | + anchors { right: parent.right; |
1990 | + left: parent.left; |
1991 | + rightMargin: units.gu(1); |
1992 | + top: titleLabel.bottom; |
1993 | + } |
1994 | + anchors.topMargin: units.dp(2); |
1995 | + elide: Text.ElideRight; |
1996 | + maximumLineCount: 1; |
1997 | + fontSize: "x-small"; |
1998 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
1999 | + color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
2000 | + visible: titleLabel.visible && titleLabel.text; |
2001 | + text: cardData && cardData["subtitle"] || ""; |
2002 | + font.weight: Font.Light; |
2003 | + } |
2004 | +,Icon { |
2005 | + id: emblemIcon; |
2006 | + objectName: "emblemIcon"; |
2007 | + anchors { |
2008 | + bottom: titleLabel.baseline; |
2009 | + right: parent.right; |
2010 | + rightMargin: units.gu(1); |
2011 | + } |
2012 | + source: cardData && cardData["emblem"] || ""; |
2013 | + color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
2014 | + height: source != "" ? titleLabel.font.pixelSize : 0; |
2015 | + width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth; |
2016 | + } |
2017 | + |
2018 | + ] |
2019 | + } |
2020 | +UbuntuShape { |
2021 | + id: touchdown; |
2022 | + objectName: "touchdown"; |
2023 | + anchors { fill: backgroundLoader } |
2024 | + visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; |
2025 | + radius: "medium"; |
2026 | + borderSource: "radius_pressed.sci" |
2027 | +} |
2028 | +implicitHeight: headerTitleContainer.y + headerTitleContainer.height + units.gu(1); |
2029 | +} |
2030 | |
2031 | === modified file 'tests/plugins/Dash/cardcreator/7.res' |
2032 | --- tests/plugins/Dash/cardcreator/7.res 2016-01-28 14:11:14 +0000 |
2033 | +++ tests/plugins/Dash/cardcreator/7.res 2016-03-10 16:53:32 +0000 |
2034 | @@ -5,11 +5,9 @@ |
2035 | property string backgroundShapeStyle: "inset"; |
2036 | property real fontScale: 1.0; |
2037 | property var scopeStyle: null; |
2038 | - property int titleAlignment: Text.AlignLeft; |
2039 | property int fixedHeaderHeight: -1; |
2040 | property size fixedArtShapeSize: Qt.size(-1, -1); |
2041 | readonly property string title: cardData && cardData["title"] || ""; |
2042 | - property bool asynchronous: true; |
2043 | property bool showHeader: true; |
2044 | implicitWidth: childrenRect.width; |
2045 | enabled: true; |
2046 | @@ -18,7 +16,7 @@ |
2047 | id: backgroundLoader; |
2048 | objectName: "backgroundLoader"; |
2049 | anchors.fill: parent; |
2050 | - asynchronous: root.asynchronous; |
2051 | + asynchronous: true; |
2052 | visible: status == Loader.Ready; |
2053 | sourceComponent: UbuntuShape { |
2054 | objectName: "background"; |
2055 | @@ -59,7 +57,7 @@ |
2056 | objectName: "outerRow"; |
2057 | property real margins: units.gu(1); |
2058 | spacing: margins; |
2059 | - height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; |
2060 | + height: root.fixedHeaderHeight; |
2061 | anchors { top: parent.top; |
2062 | topMargin: units.gu(1); |
2063 | left: parent.left; |
2064 | @@ -103,7 +101,7 @@ |
2065 | width: undefined; |
2066 | text: root.title; |
2067 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
2068 | - horizontalAlignment: root.titleAlignment; |
2069 | + horizontalAlignment: Text.AlignLeft; |
2070 | } |
2071 | ,Label { |
2072 | id: subtitleLabel; |
2073 | |
2074 | === added file 'tests/plugins/Dash/cardcreator/7.res.cardcreator' |
2075 | --- tests/plugins/Dash/cardcreator/7.res.cardcreator 1970-01-01 00:00:00 +0000 |
2076 | +++ tests/plugins/Dash/cardcreator/7.res.cardcreator 2016-03-10 16:53:32 +0000 |
2077 | @@ -0,0 +1,149 @@ |
2078 | +AbstractButton { |
2079 | + id: root; |
2080 | + property var cardData; |
2081 | + property string artShapeStyle: "inset"; |
2082 | + property string backgroundShapeStyle: "inset"; |
2083 | + property real fontScale: 1.0; |
2084 | + property var scopeStyle: null; |
2085 | + property size fixedArtShapeSize: Qt.size(-1, -1); |
2086 | + readonly property string title: cardData && cardData["title"] || ""; |
2087 | + property bool showHeader: true; |
2088 | + implicitWidth: childrenRect.width; |
2089 | + enabled: true; |
2090 | + |
2091 | +Loader { |
2092 | + id: backgroundLoader; |
2093 | + objectName: "backgroundLoader"; |
2094 | + anchors.fill: parent; |
2095 | + asynchronous: false; |
2096 | + visible: status == Loader.Ready; |
2097 | + sourceComponent: UbuntuShape { |
2098 | + objectName: "background"; |
2099 | + radius: "medium"; |
2100 | + aspect: { |
2101 | + switch (root.backgroundShapeStyle) { |
2102 | + case "inset": return UbuntuShape.Inset; |
2103 | + case "shadow": return UbuntuShape.DropShadow; |
2104 | + default: |
2105 | + case "flat": return UbuntuShape.Flat; |
2106 | + } |
2107 | + } |
2108 | + backgroundColor: getColor(0) || "white"; |
2109 | + secondaryBackgroundColor: getColor(1) || backgroundColor; |
2110 | + backgroundMode: UbuntuShape.VerticalGradient; |
2111 | + anchors.fill: parent; |
2112 | + source: backgroundImage.source ? backgroundImage : null; |
2113 | + property real luminance: Style.luminance(backgroundColor); |
2114 | + property Image backgroundImage: Image { |
2115 | + objectName: "backgroundImage"; |
2116 | + source: { |
2117 | + if (cardData && typeof cardData["background"] === "string") return cardData["background"]; |
2118 | + else return ""; |
2119 | + } |
2120 | + } |
2121 | + function getColor(index) { |
2122 | + if (cardData && typeof cardData["background"] === "object" |
2123 | + && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { |
2124 | + return cardData["background"]["elements"][index]; |
2125 | + } else return index === 0 ? "#E9E9E9" : "#E9AAE9"; |
2126 | + } |
2127 | + } |
2128 | + } |
2129 | +readonly property size artShapeSize: Qt.size(-1, -1); |
2130 | +readonly property int headerHeight: row.height; |
2131 | +Row { |
2132 | + id: row; |
2133 | + objectName: "outerRow"; |
2134 | + property real margins: units.gu(1); |
2135 | + spacing: margins; |
2136 | + anchors { top: parent.top; |
2137 | + topMargin: units.gu(1); |
2138 | + left: parent.left; |
2139 | + } |
2140 | + anchors.right: parent.right; |
2141 | + anchors.margins: margins; |
2142 | + anchors.rightMargin: 0; |
2143 | + data: [ |
2144 | +CroppedImageMinimumSourceSize { |
2145 | + id: mascotImage; |
2146 | + objectName: "mascotImage"; |
2147 | + anchors { verticalCenter: parent.verticalCenter; } |
2148 | + source: cardData && cardData["mascot"] || ""; |
2149 | + width: units.gu(6); |
2150 | + height: units.gu(5.625); |
2151 | + horizontalAlignment: Image.AlignHCenter; |
2152 | + verticalAlignment: Image.AlignVCenter; |
2153 | + visible: showHeader; |
2154 | + } |
2155 | + |
2156 | +,Item { |
2157 | + id: headerTitleContainer; |
2158 | + anchors { verticalCenter: parent.verticalCenter; } |
2159 | + width: parent.width - x; |
2160 | + implicitHeight: titleLabel.height + subtitleLabel.height + attributesRow.height; |
2161 | + data: [ |
2162 | + Label { |
2163 | + id: titleLabel; |
2164 | + objectName: "titleLabel"; |
2165 | + anchors { right: parent.right; |
2166 | + rightMargin: units.gu(1); |
2167 | + left: parent.left; |
2168 | + top: parent.top; } |
2169 | + elide: Text.ElideRight; |
2170 | + fontSize: "small"; |
2171 | + wrapMode: Text.Wrap; |
2172 | + maximumLineCount: 2; |
2173 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
2174 | + color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
2175 | + visible: showHeader ; |
2176 | + width: undefined; |
2177 | + text: root.title; |
2178 | + font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
2179 | + horizontalAlignment: Text.AlignLeft; |
2180 | + } |
2181 | +,Label { |
2182 | + id: subtitleLabel; |
2183 | + objectName: "subtitleLabel"; |
2184 | + anchors { right: parent.right; |
2185 | + left: parent.left; |
2186 | + rightMargin: units.gu(1); |
2187 | + top: titleLabel.bottom; |
2188 | + } |
2189 | + anchors.topMargin: units.dp(2); |
2190 | + elide: Text.ElideRight; |
2191 | + maximumLineCount: 1; |
2192 | + fontSize: "x-small"; |
2193 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
2194 | + color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
2195 | + visible: titleLabel.visible && titleLabel.text; |
2196 | + text: cardData && cardData["subtitle"] || ""; |
2197 | + font.weight: Font.Light; |
2198 | + } |
2199 | +,CardAttributes { |
2200 | + id: attributesRow; |
2201 | + objectName: "attributesRow"; |
2202 | + anchors { right: parent.right; |
2203 | + left: parent.left; |
2204 | + rightMargin: units.gu(1); |
2205 | + top: subtitleLabel.bottom; |
2206 | + } |
2207 | + color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
2208 | + fontScale: root.fontScale; |
2209 | + model: cardData && cardData["attributes"]; |
2210 | + } |
2211 | + |
2212 | + ] |
2213 | + } |
2214 | + |
2215 | + ] |
2216 | + } |
2217 | +UbuntuShape { |
2218 | + id: touchdown; |
2219 | + objectName: "touchdown"; |
2220 | + anchors { fill: backgroundLoader } |
2221 | + visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; |
2222 | + radius: "medium"; |
2223 | + borderSource: "radius_pressed.sci" |
2224 | +} |
2225 | +implicitHeight: row.y + row.height + units.gu(1); |
2226 | +} |
2227 | |
2228 | === modified file 'tests/plugins/Dash/cardcreator/8.res' |
2229 | --- tests/plugins/Dash/cardcreator/8.res 2016-01-28 14:11:14 +0000 |
2230 | +++ tests/plugins/Dash/cardcreator/8.res 2016-03-10 16:53:32 +0000 |
2231 | @@ -5,11 +5,9 @@ |
2232 | property string backgroundShapeStyle: "inset"; |
2233 | property real fontScale: 1.0; |
2234 | property var scopeStyle: null; |
2235 | - property int titleAlignment: Text.AlignLeft; |
2236 | property int fixedHeaderHeight: -1; |
2237 | property size fixedArtShapeSize: Qt.size(-1, -1); |
2238 | readonly property string title: cardData && cardData["title"] || ""; |
2239 | - property bool asynchronous: true; |
2240 | property bool showHeader: true; |
2241 | implicitWidth: childrenRect.width; |
2242 | enabled: true; |
2243 | @@ -18,7 +16,7 @@ |
2244 | id: backgroundLoader; |
2245 | objectName: "backgroundLoader"; |
2246 | anchors.fill: parent; |
2247 | - asynchronous: root.asynchronous; |
2248 | + asynchronous: true; |
2249 | visible: status == Loader.Ready; |
2250 | sourceComponent: UbuntuShape { |
2251 | objectName: "background"; |
2252 | @@ -59,7 +57,7 @@ |
2253 | objectName: "outerRow"; |
2254 | property real margins: units.gu(1); |
2255 | spacing: margins; |
2256 | - height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; |
2257 | + height: root.fixedHeaderHeight; |
2258 | anchors { top: parent.top; |
2259 | topMargin: units.gu(1); |
2260 | left: parent.left; |
2261 | @@ -94,7 +92,7 @@ |
2262 | width: parent.width - x; |
2263 | text: root.title; |
2264 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
2265 | - horizontalAlignment: root.titleAlignment; |
2266 | + horizontalAlignment: Text.AlignLeft; |
2267 | } |
2268 | |
2269 | ] |
2270 | |
2271 | === added file 'tests/plugins/Dash/cardcreator/8.res.cardcreator' |
2272 | --- tests/plugins/Dash/cardcreator/8.res.cardcreator 1970-01-01 00:00:00 +0000 |
2273 | +++ tests/plugins/Dash/cardcreator/8.res.cardcreator 2016-03-10 16:53:32 +0000 |
2274 | @@ -0,0 +1,107 @@ |
2275 | +AbstractButton { |
2276 | + id: root; |
2277 | + property var cardData; |
2278 | + property string artShapeStyle: "inset"; |
2279 | + property string backgroundShapeStyle: "inset"; |
2280 | + property real fontScale: 1.0; |
2281 | + property var scopeStyle: null; |
2282 | + property size fixedArtShapeSize: Qt.size(-1, -1); |
2283 | + readonly property string title: cardData && cardData["title"] || ""; |
2284 | + property bool showHeader: true; |
2285 | + implicitWidth: childrenRect.width; |
2286 | + enabled: true; |
2287 | + |
2288 | +Loader { |
2289 | + id: backgroundLoader; |
2290 | + objectName: "backgroundLoader"; |
2291 | + anchors.fill: parent; |
2292 | + asynchronous: false; |
2293 | + visible: status == Loader.Ready; |
2294 | + sourceComponent: UbuntuShape { |
2295 | + objectName: "background"; |
2296 | + radius: "medium"; |
2297 | + aspect: { |
2298 | + switch (root.backgroundShapeStyle) { |
2299 | + case "inset": return UbuntuShape.Inset; |
2300 | + case "shadow": return UbuntuShape.DropShadow; |
2301 | + default: |
2302 | + case "flat": return UbuntuShape.Flat; |
2303 | + } |
2304 | + } |
2305 | + backgroundColor: getColor(0) || "white"; |
2306 | + secondaryBackgroundColor: getColor(1) || backgroundColor; |
2307 | + backgroundMode: UbuntuShape.VerticalGradient; |
2308 | + anchors.fill: parent; |
2309 | + source: backgroundImage.source ? backgroundImage : null; |
2310 | + property real luminance: Style.luminance(backgroundColor); |
2311 | + property Image backgroundImage: Image { |
2312 | + objectName: "backgroundImage"; |
2313 | + source: { |
2314 | + if (cardData && typeof cardData["background"] === "string") return cardData["background"]; |
2315 | + else return ""; |
2316 | + } |
2317 | + } |
2318 | + function getColor(index) { |
2319 | + if (cardData && typeof cardData["background"] === "object" |
2320 | + && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { |
2321 | + return cardData["background"]["elements"][index]; |
2322 | + } else return index === 0 ? "#E9E9E9" : "#E9AAE9"; |
2323 | + } |
2324 | + } |
2325 | + } |
2326 | +readonly property size artShapeSize: Qt.size(-1, -1); |
2327 | +readonly property int headerHeight: row.height; |
2328 | +Row { |
2329 | + id: row; |
2330 | + objectName: "outerRow"; |
2331 | + property real margins: units.gu(1); |
2332 | + spacing: margins; |
2333 | + anchors { top: parent.top; |
2334 | + topMargin: units.gu(1); |
2335 | +left: parent.left; |
2336 | + } |
2337 | + anchors.right: parent.right; |
2338 | + anchors.margins: margins; |
2339 | + anchors.rightMargin: 0; |
2340 | + data: [ |
2341 | + CroppedImageMinimumSourceSize { |
2342 | + id: mascotImage; |
2343 | + objectName: "mascotImage"; |
2344 | + anchors { verticalCenter: parent.verticalCenter; } |
2345 | + source: cardData && cardData["mascot"] || ""; |
2346 | + width: units.gu(6); |
2347 | + height: units.gu(5.625); |
2348 | + horizontalAlignment: Image.AlignHCenter; |
2349 | + verticalAlignment: Image.AlignVCenter; |
2350 | + visible: showHeader; |
2351 | + } |
2352 | +,Label { |
2353 | + id: titleLabel; |
2354 | + objectName: "titleLabel"; |
2355 | + anchors { verticalCenter: parent.verticalCenter; |
2356 | + } |
2357 | + elide: Text.ElideRight; |
2358 | + fontSize: "small"; |
2359 | + wrapMode: Text.Wrap; |
2360 | + maximumLineCount: 2; |
2361 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
2362 | + color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); |
2363 | + visible: showHeader ; |
2364 | + width: parent.width - x; |
2365 | + text: root.title; |
2366 | + font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
2367 | + horizontalAlignment: Text.AlignLeft; |
2368 | + } |
2369 | + |
2370 | + ] |
2371 | + } |
2372 | +UbuntuShape { |
2373 | + id: touchdown; |
2374 | + objectName: "touchdown"; |
2375 | + anchors { fill: backgroundLoader } |
2376 | + visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; |
2377 | + radius: "medium"; |
2378 | + borderSource: "radius_pressed.sci" |
2379 | +} |
2380 | +implicitHeight: row.y + row.height + units.gu(1); |
2381 | +} |
2382 | |
2383 | === modified file 'tests/plugins/Dash/cardcreator/9.res' |
2384 | --- tests/plugins/Dash/cardcreator/9.res 2016-02-12 00:11:52 +0000 |
2385 | +++ tests/plugins/Dash/cardcreator/9.res 2016-03-10 16:53:32 +0000 |
2386 | @@ -5,11 +5,9 @@ |
2387 | property string backgroundShapeStyle: "inset"; |
2388 | property real fontScale: 1.0; |
2389 | property var scopeStyle: null; |
2390 | - property int titleAlignment: Text.AlignLeft; |
2391 | property int fixedHeaderHeight: -1; |
2392 | property size fixedArtShapeSize: Qt.size(-1, -1); |
2393 | readonly property string title: cardData && cardData["title"] || ""; |
2394 | - property bool asynchronous: true; |
2395 | property bool showHeader: true; |
2396 | implicitWidth: childrenRect.width; |
2397 | enabled: true; |
2398 | @@ -36,7 +34,7 @@ |
2399 | width: undefined; |
2400 | text: root.title; |
2401 | font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
2402 | - horizontalAlignment: root.titleAlignment; |
2403 | + horizontalAlignment: Text.AlignLeft; |
2404 | } |
2405 | Label { |
2406 | id: subtitleLabel; |
2407 | @@ -72,7 +70,7 @@ |
2408 | id: audioButton; |
2409 | anchors.fill: undefined; |
2410 | width: height; |
2411 | - height: (root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1); |
2412 | + height: root.fixedHeaderHeight + 2 * units.gu(1); |
2413 | readonly property url source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || ""; |
2414 | UbuntuShape { |
2415 | anchors.fill: parent; |
2416 | @@ -93,7 +91,8 @@ |
2417 | opacity: 0.9; |
2418 | name: DashAudioPlayer.playing && AudioUrlComparer.compare(parent.source, DashAudioPlayer.currentSource) ? "media-playback-pause" : "media-playback-start"; |
2419 | color: "white"; |
2420 | - } |
2421 | + asynchronous: true; |
2422 | + } |
2423 | onClicked: { |
2424 | if (AudioUrlComparer.compare(source, DashAudioPlayer.currentSource)) { |
2425 | if (DashAudioPlayer.playing) { |
2426 | |
2427 | === added file 'tests/plugins/Dash/cardcreator/9.res.cardcreator' |
2428 | --- tests/plugins/Dash/cardcreator/9.res.cardcreator 1970-01-01 00:00:00 +0000 |
2429 | +++ tests/plugins/Dash/cardcreator/9.res.cardcreator 2016-03-10 16:53:32 +0000 |
2430 | @@ -0,0 +1,119 @@ |
2431 | +AbstractButton { |
2432 | + id: root; |
2433 | + property var cardData; |
2434 | + property string artShapeStyle: "inset"; |
2435 | + property string backgroundShapeStyle: "inset"; |
2436 | + property real fontScale: 1.0; |
2437 | + property var scopeStyle: null; |
2438 | + property size fixedArtShapeSize: Qt.size(-1, -1); |
2439 | + readonly property string title: cardData && cardData["title"] || ""; |
2440 | + property bool showHeader: true; |
2441 | + implicitWidth: childrenRect.width; |
2442 | + enabled: true; |
2443 | + |
2444 | +readonly property size artShapeSize: Qt.size(-1, -1); |
2445 | +readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin + audioProgressBar.height + audioProgressBar.anchors.topMargin; |
2446 | +Label { |
2447 | + id: titleLabel; |
2448 | + objectName: "titleLabel"; |
2449 | + anchors { right: parent.right; |
2450 | +rightMargin: units.gu(1); |
2451 | +left: audioButton.right; |
2452 | + leftMargin: units.gu(1); |
2453 | +top: parent.top; |
2454 | + topMargin: units.gu(1); |
2455 | + } |
2456 | + elide: Text.ElideRight; |
2457 | + fontSize: "small"; |
2458 | + wrapMode: Text.Wrap; |
2459 | + maximumLineCount: 2; |
2460 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
2461 | + color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText; |
2462 | + visible: showHeader ; |
2463 | + width: undefined; |
2464 | + text: root.title; |
2465 | + font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; |
2466 | + horizontalAlignment: Text.AlignLeft; |
2467 | + } |
2468 | +Label { |
2469 | + id: subtitleLabel; |
2470 | + objectName: "subtitleLabel"; |
2471 | + anchors { left: titleLabel.left; |
2472 | + leftMargin: titleLabel.leftMargin; |
2473 | +rightMargin: units.gu(1); |
2474 | +right: titleLabel.right; |
2475 | +top: titleLabel.bottom; |
2476 | + } |
2477 | + anchors.topMargin: units.dp(2); |
2478 | + elide: Text.ElideRight; |
2479 | + maximumLineCount: 1; |
2480 | + fontSize: "x-small"; |
2481 | + font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); |
2482 | + color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText; |
2483 | + visible: titleLabel.visible && titleLabel.text; |
2484 | + text: cardData && cardData["subtitle"] || ""; |
2485 | + font.weight: Font.Light; |
2486 | + } |
2487 | +CardAudioProgress { |
2488 | + id: audioProgressBar; |
2489 | + duration: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["duration"]) || 0; |
2490 | + source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || ""; |
2491 | + anchors { |
2492 | + bottom: audioButton.bottom; |
2493 | + left: audioButton.right; |
2494 | + right: parent.right; |
2495 | + margins: units.gu(1); |
2496 | + } |
2497 | + color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText; |
2498 | + }AbstractButton { |
2499 | + id: audioButton; |
2500 | + anchors.fill: undefined; |
2501 | + width: height; |
2502 | + height: headerHeight + 2 * units.gu(1); |
2503 | + readonly property url source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || ""; |
2504 | + UbuntuShape { |
2505 | + anchors.fill: parent; |
2506 | + visible: parent.pressed; |
2507 | + radius: "medium"; |
2508 | + } |
2509 | + Rectangle { |
2510 | + color: Qt.rgba(0, 0, 0, 0.5); |
2511 | + anchors.centerIn: parent; |
2512 | + width: parent.width * 0.5; |
2513 | + height: width; |
2514 | + radius: width / 2; |
2515 | + } |
2516 | + Icon { |
2517 | + anchors.centerIn: parent; |
2518 | + width: parent.width * 0.3; |
2519 | + height: width; |
2520 | + opacity: 0.9; |
2521 | + name: DashAudioPlayer.playing && AudioUrlComparer.compare(parent.source, DashAudioPlayer.currentSource) ? "media-playback-pause" : "media-playback-start"; |
2522 | + color: "white"; |
2523 | + asynchronous: false; |
2524 | + } |
2525 | + onClicked: { |
2526 | + if (AudioUrlComparer.compare(source, DashAudioPlayer.currentSource)) { |
2527 | + if (DashAudioPlayer.playing) { |
2528 | + DashAudioPlayer.pause(); |
2529 | + } else { |
2530 | + DashAudioPlayer.play(); |
2531 | + } |
2532 | + } else { |
2533 | + var playlist = (cardData["quickPreviewData"] && cardData["quickPreviewData"]["playlist"]) || null; |
2534 | + DashAudioPlayer.playSource(source, playlist); |
2535 | + } |
2536 | + } |
2537 | + onPressAndHold: { |
2538 | + root.pressAndHold(); |
2539 | + } |
2540 | + }UbuntuShape { |
2541 | + id: touchdown; |
2542 | + objectName: "touchdown"; |
2543 | + anchors { fill: root } |
2544 | + visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; |
2545 | + radius: "medium"; |
2546 | + borderSource: "radius_pressed.sci" |
2547 | + } |
2548 | +implicitHeight: audioButton.height; |
2549 | +} |
2550 | |
2551 | === modified file 'tests/plugins/Dash/cardcreatortest.cpp' |
2552 | --- tests/plugins/Dash/cardcreatortest.cpp 2016-01-25 16:49:26 +0000 |
2553 | +++ tests/plugins/Dash/cardcreatortest.cpp 2016-03-10 16:53:32 +0000 |
2554 | @@ -45,6 +45,30 @@ |
2555 | delete view; |
2556 | } |
2557 | |
2558 | + void compareFileContents(const QString &filePath, const QString cardStringResult) |
2559 | + { |
2560 | + QFile testResultFile(filePath); |
2561 | + QVERIFY(testResultFile.open(QIODevice::ReadOnly)); |
2562 | + QTextStream ts2(&testResultFile); |
2563 | + |
2564 | + // Record failed results to /tmp |
2565 | + const QString executedResult = cardStringResult; |
2566 | + QTemporaryFile tmpFile(QDir::tempPath() + QDir::separator() + "testCardCreatorFailedResultXXXXXX"); |
2567 | + tmpFile.open(); |
2568 | + tmpFile.setAutoRemove(false); |
2569 | + tmpFile.write(executedResult.toUtf8().constData()); |
2570 | + |
2571 | + // Line by line comparison |
2572 | + const QStringList expectedLines = ts2.readAll().trimmed().replace(QRegExp("\n\\s*\n"),"\n").split("\n"); |
2573 | + const QStringList cardStringResultLines = cardStringResult.trimmed().replace(QRegExp("\n\\s*\n"),"\n").split("\n"); |
2574 | + for (int i = 0; i < expectedLines.size(); ++i) { |
2575 | + QCOMPARE(cardStringResultLines[i].simplified(), expectedLines[i].simplified()); |
2576 | + } |
2577 | + |
2578 | + // Remove the result if it passed |
2579 | + tmpFile.setAutoRemove(true); |
2580 | + } |
2581 | + |
2582 | void testKnownCases() |
2583 | { |
2584 | const QString templateString("template: "); |
2585 | @@ -68,33 +92,19 @@ |
2586 | const QString templateJSON = lines[0].mid(templateString.length()); |
2587 | const QString componentsJSON = lines[1].mid(componentsString.length()); |
2588 | const QString resultFileName = lines[2].mid(resultString.length()); |
2589 | - |
2590 | QVariant cardStringResult; |
2591 | - QMetaObject::invokeMethod(view->rootObject(), "cardString", Q_RETURN_ARG(QVariant, cardStringResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON)); |
2592 | - |
2593 | - QFile testResultFile(testDirPath + resultFileName); |
2594 | - QVERIFY(testResultFile.open(QIODevice::ReadOnly)); |
2595 | - QTextStream ts2(&testResultFile); |
2596 | - |
2597 | - // Record failed results to /tmp |
2598 | - const QString executedResult = cardStringResult.toString(); |
2599 | - QTemporaryFile tmpFile(QDir::tempPath() + QDir::separator() + "testCardCreatorFailedResultXXXXXX"); |
2600 | - tmpFile.open(); |
2601 | - tmpFile.setAutoRemove(false); |
2602 | - tmpFile.write(executedResult.toUtf8().constData()); |
2603 | - |
2604 | - // Line by line comparison |
2605 | - const QStringList expectedLines = ts2.readAll().trimmed().replace(QRegExp("\n\\s*\n"),"\n").split("\n"); |
2606 | - const QStringList cardStringResultLines = cardStringResult.toString().trimmed().replace(QRegExp("\n\\s*\n"),"\n").split("\n"); |
2607 | - for (int i = 0; i < expectedLines.size(); ++i) { |
2608 | - QCOMPARE(cardStringResultLines[i].simplified(), expectedLines[i].simplified()); |
2609 | - } |
2610 | - |
2611 | - // Remove the result if it passed |
2612 | - tmpFile.setAutoRemove(true); |
2613 | - |
2614 | QVariant createCardComponentResult; |
2615 | - QMetaObject::invokeMethod(view->rootObject(), "createCardComponent", Q_RETURN_ARG(QVariant, createCardComponentResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON)); |
2616 | + |
2617 | + QMetaObject::invokeMethod(view->rootObject(), "cardString", Q_RETURN_ARG(QVariant, cardStringResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON), Q_ARG(QVariant, false)); |
2618 | + compareFileContents(testDirPath + resultFileName, cardStringResult.toString()); |
2619 | + |
2620 | + QMetaObject::invokeMethod(view->rootObject(), "cardString", Q_RETURN_ARG(QVariant, cardStringResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON), Q_ARG(QVariant, true)); |
2621 | + compareFileContents(testDirPath + resultFileName + ".cardcreator", cardStringResult.toString()); |
2622 | + |
2623 | + QMetaObject::invokeMethod(view->rootObject(), "createCardComponent", Q_RETURN_ARG(QVariant, createCardComponentResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON), Q_ARG(QVariant, false)); |
2624 | + QVERIFY(createCardComponentResult.toBool()); |
2625 | + |
2626 | + QMetaObject::invokeMethod(view->rootObject(), "createCardComponent", Q_RETURN_ARG(QVariant, createCardComponentResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON), Q_ARG(QVariant, true)); |
2627 | QVERIFY(createCardComponentResult.toBool()); |
2628 | } |
2629 | } |
2630 | |
2631 | === modified file 'tests/plugins/Dash/cardcreatortest.qml' |
2632 | --- tests/plugins/Dash/cardcreatortest.qml 2015-07-15 15:07:19 +0000 |
2633 | +++ tests/plugins/Dash/cardcreatortest.qml 2016-03-10 16:53:32 +0000 |
2634 | @@ -19,11 +19,11 @@ |
2635 | |
2636 | Item { |
2637 | id: root |
2638 | - function cardString(template, components) { |
2639 | - return CardCreator.cardString(JSON.parse(template), JSON.parse(components)); |
2640 | + function cardString(template, components, isCardCreator) { |
2641 | + return CardCreator.cardString(JSON.parse(template), JSON.parse(components), isCardCreator); |
2642 | } |
2643 | |
2644 | - function createCardComponent(template, components) { |
2645 | - return CardCreator.createCardComponent(root, JSON.parse(template), JSON.parse(components)) !== null; |
2646 | + function createCardComponent(template, components, isCardCreator) { |
2647 | + return CardCreator.createCardComponent(root, JSON.parse(template), JSON.parse(components), isCardCreator) !== null; |
2648 | } |
2649 | } |
2650 | |
2651 | === modified file 'tests/qmltests/Dash/tst_CardTool.qml' |
2652 | --- tests/qmltests/Dash/tst_CardTool.qml 2015-11-06 10:20:36 +0000 |
2653 | +++ tests/qmltests/Dash/tst_CardTool.qml 2016-03-10 16:53:32 +0000 |
2654 | @@ -339,22 +339,22 @@ |
2655 | function test_card_title_alignment(data) { |
2656 | selector.selectedIndex = data.index; |
2657 | |
2658 | - tryCompare(cardTool, "titleAlignment", Text.AlignLeft); |
2659 | + tryCompareFunction(function() { return findChild(internalCard, "titleLabel").horizontalAlignment == Text.AlignLeft; }, true); |
2660 | |
2661 | cardTool.components['title'] = { "field": "title", "align": "center" }; |
2662 | cardTool.componentsChanged(); |
2663 | |
2664 | - tryCompare(cardTool, "titleAlignment", data.value); |
2665 | + tryCompareFunction(function() { return findChild(internalCard, "titleLabel").horizontalAlignment == data.value; }, true); |
2666 | |
2667 | cardTool.components['title'] = { "field": "title" }; |
2668 | cardTool.componentsChanged(); |
2669 | |
2670 | - tryCompare(cardTool, "titleAlignment", data.value); |
2671 | + tryCompareFunction(function() { return findChild(internalCard, "titleLabel").horizontalAlignment == data.value; }, true); |
2672 | |
2673 | cardTool.components['title'] = { "field": "title", "align": "left" }; |
2674 | cardTool.componentsChanged(); |
2675 | |
2676 | - tryCompare(cardTool, "titleAlignment", Text.AlignLeft); |
2677 | + tryCompareFunction(function() { return findChild(internalCard, "titleLabel").horizontalAlignment == Text.AlignLeft; }, true); |
2678 | } |
2679 | |
2680 | function test_categoryLayout_data() { |
FAILED: Continuous integration, rev:2137 /unity8- jenkins. ubuntu. com/job/ lp-unity8- 1-ci/130/
https:/
Executed test runs:
Click here to trigger a rebuild: /unity8- jenkins. ubuntu. com/job/ lp-unity8- 1-ci/130/ rebuild
https:/