~dandrader/unity8/pixelAlignedWindow

« back to all changes in this revision

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

  • Committer: CI Train Bot
  • Author(s): Andrea Cimitan
  • Date: 2016-05-04 18:08:28 UTC
  • mfrom: (2103.6.33 card-social)
  • Revision ID: ci-train-bot@canonical.com-20160504180828-aetx14xx5yy600eg
Add social actions to cards
Approved by: Josh Arenson

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
AbstractButton { 
 
2
                id: root; 
 
3
                property var cardData; 
 
4
                property string artShapeStyle: "inset"; 
 
5
                property string backgroundShapeStyle: "inset"; 
 
6
                property real fontScale: 1.0; 
 
7
                property var scopeStyle: null; 
 
8
                property size fixedArtShapeSize: Qt.size(-1, -1); 
 
9
                readonly property string title: cardData && cardData["title"] || ""; 
 
10
                property bool showHeader: true; 
 
11
                implicitWidth: childrenRect.width; 
 
12
                enabled: true;
 
13
signal action(var actionId);
 
14
readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
 
15
Item  { 
 
16
                            id: artShapeHolder; 
 
17
                            height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; 
 
18
                            width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; 
 
19
                            anchors { horizontalCenter: parent.horizontalCenter; } 
 
20
                            Loader { 
 
21
                                id: artShapeLoader; 
 
22
                                objectName: "artShapeLoader"; 
 
23
                                readonly property string cardArt: cardData && cardData["art"] || ""; 
 
24
                                active: cardArt != ""; 
 
25
                                asynchronous: false; 
 
26
                                visible: status == Loader.Ready;
 
27
                                sourceComponent: Item {
 
28
                                    id: artShape;
 
29
                                    objectName: "artShape";
 
30
                                    visible: image.status == Image.Ready;
 
31
                                    readonly property alias image: artImage;
 
32
                                    Loader {
 
33
                                        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
                                        }
 
56
                                    }
 
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 : 0.75;
 
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
                                    }
 
70
                                    CroppedImageMinimumSourceSize {
 
71
                                        id: artImage;
 
72
                                        objectName: "artImage";
 
73
                                        source: artShapeLoader.cardArt;
 
74
                                        asynchronous: false;
 
75
                                        visible: !true;
 
76
                                        width: root.width;
 
77
                                        height: width / artShape.aspect;
 
78
                                    }
 
79
                                } 
 
80
                            } 
 
81
                        }
 
82
readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
 
83
Label { 
 
84
                        id: titleLabel; 
 
85
                        objectName: "titleLabel"; 
 
86
                        anchors { right: parent.right;
 
87
                        left: parent.left;
 
88
                        top: artShapeHolder.bottom; 
 
89
                        topMargin: units.gu(1);
 
90
                        } 
 
91
                        elide: Text.ElideRight; 
 
92
                        fontSize: "small"; 
 
93
                        wrapMode: Text.Wrap; 
 
94
                        maximumLineCount: 2; 
 
95
                        font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 
 
96
                        color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
 
97
                        visible: showHeader ; 
 
98
                        width: undefined;
 
99
                        text: root.title; 
 
100
                        font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; 
 
101
                        horizontalAlignment: Text.AlignLeft; 
 
102
                    }
 
103
Label { 
 
104
                            id: subtitleLabel; 
 
105
                            objectName: "subtitleLabel"; 
 
106
                            anchors { left: titleLabel.left; 
 
107
                            leftMargin: titleLabel.leftMargin; 
 
108
                            right: titleLabel.right; 
 
109
                            top: titleLabel.bottom; 
 
110
                            } 
 
111
                            anchors.topMargin: units.dp(2);
 
112
                            elide: Text.ElideRight; 
 
113
                            maximumLineCount: 1; 
 
114
                            fontSize: "x-small"; 
 
115
                            font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 
 
116
                            color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
 
117
                            visible: titleLabel.visible && titleLabel.text; 
 
118
                            text: cardData && cardData["subtitle"] || ""; 
 
119
                            font.weight: Font.Light; 
 
120
                        }
 
121
CardSocialActions {
 
122
    id: socialActionsRow;
 
123
    objectName: "socialActionsRow";
 
124
    anchors { top: subtitleLabel.bottom; left: parent.left; right: parent.right; topMargin: units.gu(1); }
 
125
    color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
 
126
    model: cardData && cardData["socialActions"];
 
127
    onClicked: root.action(actionId);
 
128
}
 
129
UbuntuShape {
 
130
    id: touchdown;
 
131
    objectName: "touchdown";
 
132
    anchors { fill: artShapeHolder }
 
133
    visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
 
134
    radius: "medium";
 
135
    borderSource: "radius_pressed.sci"
 
136
}
 
137
implicitHeight: socialActionsRow.y + socialActionsRow.height + units.gu(1);
 
138
}