Unity 8
 All Classes Functions
PreviewImageGallery.qml
1 /*
2  * Copyright (C) 2014 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 1.1
19 import "../../Components"
20 
21 /*! This preview widget shows a horizontal list of images.
22  * The URIs for the images should be an array in widgetData["sources"].
23  */
24 
25 PreviewWidget {
26  id: root
27  implicitHeight: units.gu(22)
28 
29  ListView {
30  id: previewImageListView
31  spacing: units.gu(1)
32  anchors.fill: parent
33  orientation: ListView.Horizontal
34  cacheBuffer: width * 3
35  model: root.widgetData["sources"]
36  clip: true
37 
38  // FIXME: Because of ListViews inside ListViews inside Flickables inside ListViews (and some more)
39  // we finally reached the point where this ListView doesn't correctly get swipe input any more but
40  // instead the parent ListView is the one that is swiped. This MouseArea sort of creates a blocking
41  // layer to make sure this ListView can be swiped, regardless of what's behind it.
42  MouseArea {
43  anchors.fill: parent
44  enabled: parent.contentWidth > parent.width
45  }
46 
47  // FIXME: Because of ListViews inside ListViews inside Flickables inside ListViews (and some more)
48  // we finally reached the point where this ListView doesn't correctly get swipe input any more but
49  // instead the parent ListView is the one that is swiped. This MouseArea sort of creates a blocking
50  // layer to make sure this ListView can be swiped, regardless of what's behind it.
51  MouseArea {
52  anchors.fill: parent
53  enabled: parent.contentWidth > parent.width
54  }
55 
56  LazyImage {
57  objectName: "placeholderScreenshot"
58  anchors {
59  top: parent.top
60  bottom: parent.bottom
61  }
62  scaleTo: "height"
63  source: "broken_image"
64  initialWidth: units.gu(13)
65  visible: previewImageListView.count == 0
66  }
67 
68  delegate: LazyImage {
69  anchors {
70  top: parent.top
71  bottom: parent.bottom
72  }
73  source: modelData ? modelData : ""
74  scaleTo: "height"
75  initialWidth: units.gu(13)
76  }
77  }
78 }