@@ -0,0 +1,186 @@
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+ */
16+
17+import QtQuick 2.0
18+import Ubuntu.Components 0.1
19+
20+Rectangle {
21+ id: root
22+ property string title: ""
23+ property url url: ""
24+ property real previewWidthRatio: 0.5
25+
26+ property Component header
27+ property Component buttons
28+ property Component body
29+
30+ readonly property bool narrowMode: width <= height
31+ readonly property int contentSpacing: units.gu(3)
32+
33+ signal close()
34+ signal previewImageClicked()
35+
36+ color: Qt.rgba(0, 0, 0, .3)
37+ clip: true
38+
39+ Connections {
40+ target: shell.applicationManager
41+ onMainStageFocusedApplicationChanged: {
42+ root.close();
43+ }
44+ onSideStageFocusedApplicationChanged: {
45+ root.close();
46+ }
47+ }
48+
49+ MouseArea {
50+ anchors.fill: parent
51+ }
52+
53+ Item {
54+ id: headerRow
55+ height: units.gu(4)
56+ anchors {
57+ top: parent.top
58+ left: parent.left
59+ right: parent.right
60+ margins: root.contentSpacing
61+ }
62+
63+ MouseArea {
64+ anchors {
65+ fill: parent
66+ leftMargin: -root.contentSpacing
67+ rightMargin: -root.contentSpacing
68+ topMargin: -root.contentSpacing
69+ }
70+
71+ onClicked: root.close();
72+ }
73+
74+ Item {
75+ id: labelItem
76+ anchors {
77+ fill: parent
78+ rightMargin: closePreviewImage.width + spacing
79+ }
80+
81+ property int spacing: units.gu(2)
82+
83+ Label {
84+ id: title
85+ objectName: "titleLabel"
86+ anchors {
87+ left: parent.left
88+ right: parent.right
89+ }
90+
91+ elide: Text.ElideRight
92+ fontSize: "x-large"
93+ font.weight: Font.Light
94+ color: "#f3f3e7"
95+ opacity: 0.9
96+ text: root.title
97+ style: Text.Raised
98+ styleColor: "black"
99+ }
100+ Image {
101+ id: closePreviewImage
102+ source: "graphics/tablet/icon_close_preview.png"
103+ width: units.gu(4)
104+ height: units.gu(1.5)
105+ anchors {
106+ bottom: title.bottom
107+ bottomMargin: units.dp(7)
108+ left: parent.left
109+ leftMargin: title.paintedWidth + labelItem.spacing
110+ }
111+ }
112+ }
113+ }
114+
115+ Row {
116+ id: contentRow
117+ anchors {
118+ left: parent.left
119+ right: parent.right
120+ top: headerRow.bottom
121+ bottom: parent.bottom
122+ margins: root.contentSpacing
123+ }
124+
125+ spacing: units.gu(2)
126+
127+ Flickable {
128+ id: leftFlickable
129+ anchors.top: parent.top
130+ anchors.bottom: parent.bottom
131+ width: root.narrowMode ? contentRow.width : contentRow.width * root.previewWidthRatio
132+ contentHeight: leftColumn.height
133+ clip: true
134+
135+ Column {
136+ id: leftColumn
137+ objectName: "leftColumn"
138+ anchors {
139+ left: parent.left
140+ right: parent.right
141+ }
142+ height: childrenRect.height
143+ spacing: units.gu(1)
144+
145+ Loader {
146+ id: headerLoader
147+ anchors.left: parent.left
148+ anchors.right: parent.right
149+ sourceComponent: root.header
150+ }
151+ Loader {
152+ id: buttonLoader
153+ anchors.left: parent.left
154+ anchors.right: parent.right
155+ sourceComponent: root.buttons
156+ }
157+ }
158+ }
159+
160+ Flickable {
161+ id: rightFlickable
162+ anchors.top: parent.top
163+ anchors.bottom: parent.bottom
164+ width: narrowMode ? 0 : (contentRow.width - leftColumn.width - contentRow.spacing)
165+ contentHeight: rightColumn.height
166+ clip: true
167+
168+ Column {
169+ id: rightColumn
170+ objectName: "rightColumn"
171+ height: childrenRect.height
172+ anchors {
173+ left: parent.left
174+ right: parent.right
175+ }
176+ }
177+ }
178+ }
179+
180+ Loader {
181+ parent: root.narrowMode ? leftColumn : rightColumn
182+ anchors.left: parent.left
183+ anchors.right: parent.right
184+ sourceComponent: root.body
185+ }
186+}