~mterry/+junk/fp

« back to all changes in this revision

Viewing changes to tests/plugins/Dash/cardcreator/1.res.cardcreator

  • Committer: Michał Sawicz
  • Date: 2016-06-18 22:37:48 UTC
  • mfrom: (2313.34.88 unity8)
  • Revision ID: michal.sawicz@canonical.com-20160618223748-myshjyuyhvrj3nud
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
AbstractButton { 
2
2
                id: root; 
3
3
                property var cardData; 
4
 
                property string artShapeStyle: "inset"; 
5
4
                property string backgroundShapeStyle: "inset"; 
6
5
                property real fontScale: 1.0; 
7
6
                property var scopeStyle: null; 
8
 
                property size fixedArtShapeSize: Qt.size(-1, -1); 
9
7
                readonly property string title: cardData && cardData["title"] || ""; 
10
8
                property bool showHeader: true; 
11
9
                implicitWidth: childrenRect.width; 
14
12
readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
15
13
Item  { 
16
14
                            id: artShapeHolder; 
17
 
                            height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; 
18
 
                            width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; 
 
15
                            height: artShapeLoader.height;
 
16
                            width: artShapeLoader.width;
19
17
                            anchors { horizontalCenter: parent.horizontalCenter; } 
20
18
                            Loader { 
21
19
                                id: artShapeLoader; 
22
20
                                objectName: "artShapeLoader"; 
23
21
                                readonly property string cardArt: cardData && cardData["art"] || "";
 
22
                                onCardArtChanged: { if (item) { item.image.source = cardArt; } }
24
23
                                active: cardArt != "";
25
24
                                asynchronous: false;
26
25
                                visible: status == Loader.Ready; 
29
28
                                    objectName: "artShape";
30
29
                                    visible: image.status == Image.Ready;
31
30
                                    readonly property alias image: artImage;
32
 
                                    Loader {
 
31
                                    UbuntuShape {
33
32
                                        anchors.fill: parent;
34
 
                                        visible: true;
35
 
                                        sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent;
36
 
                                        Component {
37
 
                                            id: artShapeShapeComponent;
38
 
                                            UbuntuShape {
39
 
                                                source: artImage;
40
 
                                                sourceFillMode: UbuntuShape.PreserveAspectCrop;
41
 
                                                radius: "medium";
42
 
                                                aspect: {
43
 
                                                    switch (root.artShapeStyle) {
44
 
                                                        case "inset": return UbuntuShape.Inset;
45
 
                                                        case "shadow": return UbuntuShape.DropShadow;
46
 
                                                        default:
47
 
                                                        case "flat": return UbuntuShape.Flat;
48
 
                                                    }
49
 
                                                }
50
 
                                            }
51
 
                                        }
52
 
                                        Component {
53
 
                                            id: artShapeIconComponent;
54
 
                                            ProportionalShape { source: artImage; aspect: UbuntuShape.DropShadow; }
55
 
                                        }
 
33
                                        source: artImage;
 
34
                                        sourceFillMode: UbuntuShape.PreserveAspectCrop;
 
35
                                        radius: "medium";
 
36
                                        aspect: UbuntuShape.Inset;
56
37
                                    }
57
 
                                    readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
58
 
                                    readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1.6;
59
 
                                    Component.onCompleted: { updateWidthHeightBindings(); }
60
 
                                    Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } 
61
 
                                    function updateWidthHeightBindings() { 
62
 
                                        if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { 
63
 
                                            width = root.fixedArtShapeSize.width; 
64
 
                                            height = root.fixedArtShapeSize.height; 
65
 
                                        } else { 
66
 
                                            width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width });
67
 
                                            height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height });
68
 
                                        } 
69
 
                                    } 
 
38
                                    width: image.status !== Image.Ready ? 0 : image.width;
 
39
                                    height: image.status !== Image.Ready ? 0 : image.height;
70
40
                                    CroppedImageMinimumSourceSize {
71
41
                                        id: artImage;
72
42
                                        objectName: "artImage"; 
73
43
                                        source: artShapeLoader.cardArt;
74
44
                                        asynchronous: false;
75
 
                                        visible: !true;
 
45
                                        visible: false;
76
46
                                        width: root.width; 
77
 
                                        height: width / artShape.aspect; 
 
47
                                        height: width / 1.6;
78
48
                                    } 
79
49
                                } 
80
50
                            } 
104
74
    id: touchdown;
105
75
    objectName: "touchdown";
106
76
    anchors { fill: artShapeHolder }
107
 
    visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
 
77
    visible: root.pressed;
108
78
    radius: "medium";
109
79
    borderSource: "radius_pressed.sci"
110
80
}