on xenial help sign in
Removed file
commit32dde39ef3addf47339c0055a8a07cb07e5c8541 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateTue 13 May 2014, 09:34 (12 years ago) parentb8c4039
1 file changed−243
qml/Dash/Card.qml.THIS−243
qml/Dash/Card.qml.THISdeleted−243
@@ -1,243 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−// For image://albumart and image://thumbnailer image providers
20−import Ubuntu.Thumbnailer 0.1
21−
22−AbstractButton {
23− id: root
24− property var template
25− property var components
26− property var cardData
27−
28− property real fontScale: 1.0
29− property int headerAlignment: Text.AlignLeft
30− readonly property int headerHeight: headerLoader.item ? headerLoader.item.height : 0
31− property int fixedHeaderHeight: -1
32− readonly property string title: cardData && cardData["title"] || ""
33−
34− property bool showHeader: true
35−
36− implicitWidth: childrenRect.width
37− implicitHeight: summary.y + summary.height + (summary.text && backgroundLoader.active ? units.gu(1) : 0)
38−
39− BorderImage {
40− source: "graphics/carousel_dropshadow.sci"
41− anchors.fill: artShape
42− anchors.margins: -units.gu(1)
43− }
44−
45− Loader {
46− id: backgroundLoader
47− objectName: "backgroundLoader"
48−
49− readonly property bool artAndSummary: components["art"]["field"] && components["summary"] || false
50− active: template["card-layout"] !== "horizontal" && (template["card-background"] || components["background"] || artAndSummary)
51− anchors.fill: parent
52−
53− sourceComponent: UbuntuShape {
54− objectName: "background"
55− radius: "medium"
56− color: getColor(0) || "white"
57− gradientColor: getColor(1) || color
58− anchors.fill: parent
59− image: backgroundImage.source ? backgroundImage : null
60−
61− property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b
62−
63− property Image backgroundImage: Image {
64− objectName: "backgroundImage"
65− source: {
66− if (cardData && typeof cardData["background"] === "string") return cardData["background"]
67− else if (template && typeof template["card-background"] === "string") return template["card-background"]
68− else return ""
69− }
70− }
71−
72− function getColor(index) {
73− if (cardData && typeof cardData["background"] === "object"
74− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
75− return cardData["background"]["elements"][index];
76− } else if (template && typeof template["card-background"] === "object"
77− && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
78− return template["card-background"]["elements"][index];
79− } else return undefined;
80− }
81− }
82− }
83−
84− UbuntuShape {
85− id: artShape
86− radius: "medium"
87− objectName: "artShape"
88− anchors.horizontalCenter: template && template["card-layout"] === "horizontal" ? undefined : parent.horizontalCenter
89− anchors.left: template && template["card-layout"] === "horizontal" ? parent.left : undefined
90− visible: cardData && cardData["art"] || false
91− borderSource: "none"
92−
93− readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1
94− readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect
95−
96− Component.onCompleted: updateWidthHeightBindings();
97− onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
98−
99− function updateWidthHeightBindings() {
100− if (aspectSmallerThanImageAspect) {
101− width = Qt.binding(function() { return !visible ? 0 : image.width });
102− height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
103− } else {
104− width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
105− height = Qt.binding(function() { return !visible ? 0 : image.height });
106− }
107− }
108−
109− image: Image {
110− objectName: "artImage"
111− source: cardData && cardData["art"] || ""
112− cache: true
113− // FIXME uncomment when having investigated / fixed the crash
114− //sourceSize.width: width > height ? width : 0
115− //sourceSize.height: height > width ? height : 0
116− fillMode: components && components["art"]["fill-mode"] === "fit" ? Image.PreserveAspectFit: Image.PreserveAspectCrop
117−
118− readonly property real aspect: implicitWidth / implicitHeight
119− readonly property bool isHorizontal: template && template["card-layout"] === "horizontal"
120−
121− Component.onCompleted: updateWidthHeightBindings();
122− onIsHorizontalChanged: updateWidthHeightBindings();
123−
124− function updateWidthHeightBindings() {
125− if (isHorizontal) {
126− width = Qt.binding(function() { return height * artShape.aspect });
127− height = Qt.binding(function() { return root.headerHeight });
128− } else {
129− width = Qt.binding(function() { return root.width });
130− height = Qt.binding(function() { return width / artShape.aspect });
131− }
132− }
133− }
134− }
135−
136− Loader {
137− id: overlayLoader
138− anchors {
139− left: artShape.left
140− right: artShape.right
141− bottom: artShape.bottom
142− }
143− active: template && template["overlay"] && artShape.visible && artShape.image.status === Image.Ready || false
144−
145− sourceComponent: ShaderEffect {
146− id: overlay
147−
148− height: headerLoader.item ? headerLoader.item.height : 0
149− opacity: headerLoader.item ? headerLoader.item.opacity * 0.6 : 0
150−
151− property var source: ShaderEffectSource {
152− id: shaderSource
153− sourceItem: artShape
154− onVisibleChanged: if (visible) scheduleUpdate()
155− live: false
156− sourceRect: Qt.rect(0, artShape.height - overlay.height, artShape.width, overlay.height)
157− }
158−
159− vertexShader: "
160− uniform highp mat4 qt_Matrix;
161− attribute highp vec4 qt_Vertex;
162− attribute highp vec2 qt_MultiTexCoord0;
163− varying highp vec2 coord;
164− void main() {
165− coord = qt_MultiTexCoord0;
166− gl_Position = qt_Matrix * qt_Vertex;
167− }"
168−
169− fragmentShader: "
170− varying highp vec2 coord;
171− uniform sampler2D source;
172− uniform lowp float qt_Opacity;
173− void main() {
174− lowp vec4 tex = texture2D(source, coord);
175− gl_FragColor = vec4(0, 0, 0, tex.a) * qt_Opacity;
176− }"
177− }
178− }
179−
180− Loader {
181− id: headerLoader
182− objectName: "cardHeaderLoader"
183−
184− anchors {
185− top: {
186− if (template) {
187− if (template["overlay"]) return overlayLoader.top;
188− if (template["card-layout"] === "horizontal") return artShape.top;
189− }
190− return artShape.bottom;
191− }
192− left: {
193− if (template) {
194− if (!template["overlay"] && template["card-layout"] === "horizontal") return artShape.right;
195− }
196− return parent.left;
197− }
198− right: parent.right
199− }
200− active: cardData && cardData["title"] || cardData && cardData["mascot"] || false
201−
202− sourceComponent: CardHeader {
203− id: header
204− objectName: "cardHeader"
205−
206− mascot: cardData && cardData["mascot"] || ""
207− title: root.title
208− subtitle: cardData && cardData["subtitle"] || ""
209−
210− titleWeight: components && components["subtitle"] ? Font.DemiBold : Font.Normal
211−
212− opacity: showHeader ? 1 : 0
213− inOverlay: root.template && root.template["overlay"] === true
214− fontColor: inOverlay ? "white" : summary.color
215− useMascotShape: !backgroundLoader.active && !inOverlay
216− headerAlignment: root.headerAlignment
217− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight
218− fontScale: root.fontScale
219−
220− Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
221− }
222− }
223−
224− Label {
225− id: summary
226− objectName: "summaryLabel"
227− anchors {
228− top: headerLoader.active ? headerLoader.bottom : artShape.bottom
229− left: parent.left
230− right: parent.right
231− margins: backgroundLoader.active ? units.gu(1) : 0
232− topMargin: 0
233− }
234− wrapMode: Text.Wrap
235− maximumLineCount: 5
236− elide: Text.ElideRight
237− text: cardData && cardData["summary"] || ""
238− height: text ? implicitHeight : 0
239− fontSize: "small"
240− // TODO karni: Change "grey" to Ubuntu.Components.Palette color once updated.
241− color: backgroundLoader.active && backgroundLoader.item.luminance < 0.7 ? "white" : "grey"
242− }
243−}