on 8dea207 help sign in
unity8/Dash/Generic/GenericPreview.qml
106 lines 3.2 kB history raw
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 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import "../../Components"
20import "../../Components/ListItems" as ListItems
21import "../../Components/IconUtil.js" as IconUtil
22import ".."
24DashPreview {
25 id: genericPreview
27 title: previewData.title
28 previewWidthRatio: 0.6
30 property url url: IconUtil.from_gicon(previewData.image)
32 // TODO: replace this UbuntuShape with the Video component once that lands
33 // with the player.
34 header: UbuntuShape {
35 id: urlLoader
36 anchors.left: parent.left
37 anchors.right: parent.right
38 height: width * previewImage.sourceSize.height / previewImage.sourceSize.width
39 radius: "medium"
40 image: Image {
41 id: previewImage
42 asynchronous: true
43 source: genericPreview.url
44 fillMode: Image.PreserveAspectCrop
45 }
47 MouseArea {
48 id: previewImageMouseArea
49 anchors.fill: parent
50 onClicked: genericPreview.previewImageClicked()
51 }
52 }
54 buttons: GridView {
55 id: buttons
56 model: genericPreview.previewData.actions
58 property int numOfRows: (count + 1) / 2
59 property int spacing: units.gu(1)
60 height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
62 cellWidth: Math.max(units.gu(9), width / 2)
63 cellHeight: buttonHeight + spacing
64 property int buttonWidth: Math.max(0, width / 2 - spacing)
65 property int buttonHeight: units.gu(4)
67 delegate: Button {
68 width: Math.max(units.gu(4), buttons.buttonWidth)
69 height: buttons.buttonHeight
70 color: "#dd4814"
71 text: modelData.displayName
72 iconSource: modelData.iconHint
73 iconPosition: "right"
74 visible: true
75 onClicked: {
76 genericPreview.previewData.execute(modelData.id, { })
77 }
78 }
79 focus: false
80 }
81 body: Column {
82 spacing: units.gu(2)
84 Label {
85 visible: text != ""
86 fontSize: "medium"
87 opacity: 0.6
88 color: "white"
89 text: previewData.subtitle
90 style: Text.Raised
91 styleColor: "black"
92 wrapMode: Text.WordWrap
93 }
95 Label {
96 visible: text != ""
97 fontSize: "small"
98 opacity: 0.6
99 color: "white"
100 text: previewData.description
101 style: Text.Raised
102 styleColor: "black"
103 wrapMode: Text.WordWrap
104 }
105 }