2 * Copyright (C) 2014 Canonical, Ltd.
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.
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.
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/>.
18 import Ubuntu.Components 0.1
21 /*! This preview widget shows a header
22 * The title comes in widgetData["title"]
23 * The mascot comes in widgetData["mascot"]
24 * The subtitle comes in widgetData["subtitle"]
30 height: childrenRect.height
34 objectName: "innerPreviewHeader"
35 readonly property url mascot: root.widgetData["mascot"] || ""
36 readonly property string title: root.widgetData["title"] || ""
37 readonly property string subtitle: root.widgetData["subtitle"] || ""
38 readonly property color fontColor: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
40 implicitHeight: row.height + row.margins * 2
45 objectName: "outerRow"
47 property real margins: units.gu(1)
49 spacing: mascotShapeLoader.active ? margins : 0
51 top: parent.top; left: parent.left; right: parent.right
59 objectName: "mascotShapeLoader"
60 active: headerRoot.mascot != ""
63 anchors.verticalCenter: parent.verticalCenter
64 // TODO karni: Icon aspect-ratio is 8:7.5. Revisit these values to avoid fraction of pixels.
66 height: units.gu(5.625)
67 readonly property int maxSize: Math.max(width, height) * 4
70 sourceComponent: UbuntuShape {
71 objectName: "mascotShape"
72 visible: image.status === Image.Ready
74 source: headerRoot.mascot
75 width: source ? mascotShapeLoader.width : 0
76 height: mascotShapeLoader.height
78 sourceSize { width: mascotShapeLoader.maxSize; height: mascotShapeLoader.maxSize }
79 fillMode: Image.PreserveAspectCrop
80 horizontalAlignment: Image.AlignHCenter
81 verticalAlignment: Image.AlignVCenter
88 width: parent.width - x
90 anchors.verticalCenter: parent.verticalCenter
94 objectName: "titleLabel"
95 anchors { left: parent.left; right: parent.right }
96 elide: Text.ElideRight
97 font.weight: Font.Normal
101 color: headerRoot.fontColor
102 text: headerRoot.title
106 active: titleLabel.text && headerRoot.subtitle
107 anchors { left: parent.left; right: parent.right }
108 sourceComponent: Label {
110 objectName: "subtitleLabel"
111 elide: Text.ElideRight
113 font.weight: Font.Light
114 color: headerRoot.fontColor
115 text: headerRoot.subtitle