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 1.1
19 import "../../Components"
20 import "../../Components/Flickables" as Flickables
22 /*! This preview widget shows a horizontal list of images.
23 * The URIs for the images should be an array in widgetData["sources"].
28 implicitHeight: units.gu(22)
30 property Item rootItem: QuickUtils.rootItem(root)
33 id: previewImageListView
34 objectName: "previewImageListView"
37 orientation: ListView.Horizontal
38 cacheBuffer: width * 3
39 model: root.widgetData["sources"]
43 objectName: "placeholderScreenshot"
49 source: "broken_image"
50 initialWidth: units.gu(13)
51 visible: previewImageListView.count == 0
55 objectName: "previewImage" + index
60 source: modelData ? modelData : ""
62 initialWidth: units.gu(13)
63 borderSource: mouseArea.pressed ? "radius_pressed.sci" : "radius_idle.sci"
69 slideShowListView.currentIndex = index;
70 slideShow.initialX = rootItem.mapFromItem(parent, 0, 0).x
71 slideShow.initialY = rootItem.mapFromItem(parent, 0, 0).y
72 slideShow.visible = true;
80 objectName: "slideShow"
82 readonly property real initialScale: previewImageListView.height / rootItem.height
83 readonly property real scaleProgress: (scale - initialScale) / (1.0 - initialScale)
84 property real initialX: 0
85 property real initialY: 0
91 clip: visible && scale < 1.0
92 scale: visible ? 1.0 : initialScale
93 transformOrigin: Item.TopLeft
94 transform: Translate {
95 x: slideShow.initialX - slideShow.initialX * slideShow.scaleProgress
96 y: slideShow.initialY - slideShow.initialY * slideShow.scaleProgress
99 radius: units.gu(1) - units.gu(1) * slideShow.scaleProgress
102 enabled: !slideShow.visible
103 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
106 Flickables.ListView {
107 id: slideShowListView
108 objectName: "slideShowListView"
110 orientation: ListView.Horizontal
111 highlightRangeMode: ListView.StrictlyEnforceRange
112 highlightMoveDuration: 0
113 snapMode: ListView.SnapOneItem
114 boundsBehavior: Flickable.DragAndOvershootBounds
115 model: root.widgetData["sources"]
121 bottom: parent.bottom
123 width: slideShow.width
124 source: modelData ? modelData : ""
125 fillMode: Image.PreserveAspectFit
126 sourceSize { width: screenshot.width; height: screenshot.height }
131 onClicked: slideShowHeader.shown = !slideShowHeader.shown
138 property bool shown: true
146 opacity: slideShow.scaleProgress > 0.6 && shown ? 0.8 : 0
149 Behavior on opacity {
150 UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
154 id: slideShowCloseButton
155 objectName: "slideShowCloseButton"
158 bottom: parent.bottom
163 onClicked: slideShow.visible = false
167 color: Qt.rgba(1.0, 1.0, 1.0, 0.3)
168 visible: slideShowCloseButton.pressed
173 anchors.centerIn: parent
176 color: Theme.palette.normal.foregroundText