~cimi/unity8/infographics-august-merge

« back to all changes in this revision

Viewing changes to plugins/Dash/CardCreator.js

  • Committer: Andrea Cimitan
  • Date: 2014-07-03 15:28:14 UTC
  • mfrom: (819.72.37 resync-distro)
  • Revision ID: andrea.cimitan@gmail.com-20140703152814-byps56gzhix02tom
* debian/control: 
  list qtdeclarative5-ubuntu-ui-toolkit-plugin-gles as an alternative 
  choice, since provides are not versionned, should restore installability
  on amd64 and i386
[ Michał Sawicz ]
* Adapt to suru theme.
[ Michael Terry ]
* Fix path in launcher mock after moving our mock icons, to avoid a
  lot of "icon not found" warnings during qmluitests.
* Fix the testMultiGreeter qmluitest. Incoming method variables are
  apparently read-only in Qt5.3. (LP: #1332488)
[ CI bot ]
* Resync trunk
[ Michał Sawicz ]
* Adapt scope mock to new api and quiet unused variable warnings.
* Fix dynamic overlay height. (LP: #1334879)
* Don't center items in CardVerticalJournal, kind of beats the
  purpose... Also don't bind unnecessarily.
[ Ying-Chun Liu ]
* Fix LP:1330957 Fix some failed test cases. (LP: #1330957)
[ Albert Astals ]
* Don't seem to need this waitForRendering And makes test fail in 5.3
[ Alberto Aguirre ]
* Update Powerd plugin and Shell.qml to accommodate changes in the
  display power state notification.
[ Ying-Chun Liu ]
* Add logout support. Reviewed by: Daniel d'Andrada (LP: #1302213)
[ Michał Sawicz ]
* Make so that fixedArtShapeSize actually fixes artShapeSize.
[ Albert Astals ]
* Add VerticalJournal integration to Dash/scopes/QML (LP: #1326467)
* Make so that fixedArtShapeSize actually fixes artShapeSize.
[ Mirco Müller ]
* Added the frontend-part of sound-hint support for notifications with
  updated QML-tests.
* New rebuild forced
[ Albert Astals ]
* Departments support (LP: #1320847)
[ Pawel Stolowski ]
* Extend the hack for click scope categories with the upcoming 'store'
  category: single-tap on results from the 'store' category should
  activate them, instead of requesting a preview. (LP: #1326292)
[ Albert Astals ]
* Drop the " Preview" suffix from Preview title As requested in
  https://bugs.launchpad.net/unity8/+bug/1316671 (LP: #1316671)

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
// %3 is used as image height
56
56
var kArtShapeHolderCode = 'Item  { \n\
57
57
                            id: artShapeHolder; \n\
58
 
                            height: root.fixedArtShapeSize.height != -1 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
59
 
                            width: root.fixedArtShapeSize.width != -1 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
 
58
                            height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
 
59
                            width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
60
60
                            anchors { %1 } \n\
61
61
                            Loader { \n\
62
62
                                id: artShapeLoader; \n\
68
68
                                    id: artShape; \n\
69
69
                                    objectName: "artShape"; \n\
70
70
                                    radius: "medium"; \n\
71
 
                                    readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
 
71
                                    visible: image.status == Image.Ready; \n\
 
72
                                    readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
 
73
                                    readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
72
74
                                    readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect; \n\
73
75
                                    Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; } \n\
74
76
                                    onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings(); \n\
75
 
                                    visible: image.status == Image.Ready; \n\
 
77
                                    Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } \n\
76
78
                                    function updateWidthHeightBindings() { \n\
77
 
                                        if (aspectSmallerThanImageAspect) { \n\
 
79
                                        if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { \n\
 
80
                                            width = root.fixedArtShapeSize.width; \n\
 
81
                                            height = root.fixedArtShapeSize.height; \n\
 
82
                                        } else if (aspectSmallerThanImageAspect) { \n\
78
83
                                            width = Qt.binding(function() { return !visible ? 0 : image.width }); \n\
79
84
                                            height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect }); \n\
80
85
                                        } else { \n\
108
113
                            visible: showHeader && status == Loader.Ready; \n\
109
114
                            sourceComponent: ShaderEffect { \n\
110
115
                                id: overlay; \n\
111
 
                                height: fixedHeaderHeight != -1 ? fixedHeaderHeight : headerHeight; \n\
 
116
                                height: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
112
117
                                opacity: 0.6; \n\
113
118
                                property var source: ShaderEffectSource { \n\
114
119
                                    id: shaderSource; \n\
145
150
                        objectName: "outerRow"; \n\
146
151
                        property real margins: units.gu(1); \n\
147
152
                        spacing: margins; \n\
 
153
                        height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
148
154
                        anchors { %1 } \n\
149
155
                        anchors.right: parent.right; \n\
150
156
                        anchors.margins: margins;\n\
163
169
                        objectName: "outerRow"; \n\
164
170
                        property real margins: units.gu(1); \n\
165
171
                        spacing: margins; \n\
 
172
                        height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
166
173
                        anchors { %1 } \n\
167
174
                        anchors.right: parent.right; \n\
168
175
                        anchors.margins: margins;\n\
315
322
            anchors = 'left: parent.left';
316
323
            if (hasMascot || hasTitle) {
317
324
                widthCode = 'height * artShape.aspect'
318
 
                heightCode = 'headerHeight';
 
325
                heightCode = 'headerHeight + 2 * units.gu(1)';
319
326
            } else {
320
327
                // This side of the else is a bit silly, who wants an horizontal layout without mascot and title?
321
328
                // So we define a "random" height of the image height + 2 gu for the margins
356
363
        }
357
364
    }
358
365
    var headerLeftAnchor;
359
 
    var headerLeftAnchorHasMagin = false;
 
366
    var headerLeftAnchorHasMargin = false;
360
367
    if (isHorizontal && hasArt) {
361
368
        headerLeftAnchor = 'left: artShapeHolder.right; \n\
362
369
                            leftMargin: units.gu(1);\n';
363
 
        headerLeftAnchorHasMagin = true;
 
370
        headerLeftAnchorHasMargin = true;
364
371
    } else {
365
372
        headerLeftAnchor = 'left: parent.left;\n';
366
373
    }
367
374
 
368
375
    if (hasHeaderRow) {
369
 
        code += 'readonly property int headerHeight: row.height + row.margins * 2;\n'
 
376
        code += 'readonly property int headerHeight: row.height;\n'
370
377
    } else if (hasMascot) {
371
 
        code += 'readonly property int headerHeight: mascotImage.height + units.gu(1) * 2;\n'
 
378
        code += 'readonly property int headerHeight: mascotImage.height;\n'
372
379
    } else if (hasSubtitle) {
373
 
        code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2 + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
 
380
        code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
374
381
    } else if (hasTitle) {
375
 
        code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2;\n'
 
382
        code += 'readonly property int headerHeight: titleLabel.height;\n'
376
383
    } else {
377
384
        code += 'readonly property int headerHeight: 0;\n'
378
385
    }
385
392
        if (!hasHeaderRow) {
386
393
            anchors += headerLeftAnchor;
387
394
            anchors += headerVerticalAnchors;
388
 
            if (!headerLeftAnchorHasMagin) {
 
395
            if (!headerLeftAnchorHasMargin) {
389
396
                anchors += 'leftMargin: units.gu(1);\n'
390
397
            }
391
398
        } else {
437
444
                titleAnchors = "right: parent.right;";
438
445
                titleAnchors += headerLeftAnchor;
439
446
                titleAnchors += headerVerticalAnchors;
 
447
                if (!headerLeftAnchorHasMargin) {
 
448
                    titleAnchors += 'leftMargin: units.gu(1);\n'
 
449
                }
440
450
            }
441
451
            subtitleAnchors = 'left: titleLabel.left; \n\
442
452
                               leftMargin: titleLabel.leftMargin; \n\