2
* Copyright 2011 Marco Martin <mart@kde.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Library General Public License as
6
* published by the Free Software Foundation; either version 2, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU Library General Public License for more details
14
* You should have received a copy of the GNU Library General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
import org.kde.metadatamodels 0.1 as MetadataModels
22
import org.kde.plasma.components 0.1 as PlasmaComponents
23
import org.kde.plasma.core 0.1 as PlasmaCore
24
import org.kde.plasma.mobilecomponents 0.1 as MobileComponents
25
import org.kde.plasma.slccomponents 0.1 as SlcComponents
26
import org.kde.qtextracomponents 0.1
29
PlasmaComponents.Page {
40
height: childrenRect.height
41
PlasmaComponents.ToolButton {
43
anchors.left: parent.left
44
iconSource: "go-previous"
45
width: theme.largeIconSize
49
//we want to tell the current image was closed
50
resourceInstance.uri = ""
51
fileBrowserRoot.goBack()
55
text: i18n("%1 (%2 of %3)", quickBrowserBar.currentItem.name, quickBrowserBar.currentIndex+1, quickBrowserBar.count)
56
anchors.centerIn: parent
59
color: theme.textColor
61
styleColor: theme.backgroundColor
64
visible: !deviceCapabilitiesSource.data["Input"]["hasMultiTouch"]
65
anchors.right: parent.right
66
PlasmaComponents.ToolButton {
68
width: theme.largeIconSize
71
onClicked: viewerPage.zoomIn()
73
PlasmaComponents.ToolButton {
74
iconSource: "zoom-out"
75
width: theme.largeIconSize
78
onClicked: viewerPage.zoomOut()
83
function loadFile(path)
85
if (path.length == 0) {
89
if (String(path).indexOf("/") === 0) {
93
viewerPage.path = path
95
var index = metadataModel.find(path);
97
fileBrowserRoot.model = metadataModel
98
quickBrowserBar.currentIndex = index
101
index = dirModel.indexForUrl(path)
104
fileBrowserRoot.model = dirModel
105
quickBrowserBar.currentIndex = index
106
//don't know where it is, just load
108
imageArea.delegate.source = path
113
PlasmaCore.DataSource {
114
id: deviceCapabilitiesSource
115
engine: "org.kde.devicecapabilities"
117
connectedSources: ["Input"]
122
target: metadataModel
125
viewerPage.loadFile(viewerPage.path)
140
//enabled: !delegate.interactive
141
property Item delegate: delegate1
142
property Item oldDelegate: delegate2
143
property bool incrementing: delegate.delta > 0
145
target: imageArea.delegate
147
imageArea.oldDelegate.delta = imageArea.delegate.delta
148
if (imageArea.delegate.delta > 0) {
149
imageArea.oldDelegate.source = fileBrowserRoot.model.get(quickBrowserBar.currentIndex + 1).url
150
} else if (imageArea.delegate.delta < 0) {
151
imageArea.oldDelegate.source = fileBrowserRoot.model.get(quickBrowserBar.currentIndex - 1).url
159
startX = mouse.screenX
160
startY = mouse.screenY
163
if (Math.abs(mouse.screenX - startX) < 20 &&
164
Math.abs(mouse.screenY - startY) < 20) {
165
if (viewerPage.state == "toolsOpen") {
166
viewerPage.state = "toolsClosed"
168
viewerPage.state = "toolsOpen"
170
} else if (delegate.delta != 0 && delegate.doSwitch) {
171
oldDelegate = delegate
172
delegate = (delegate == delegate1) ? delegate2 : delegate1
173
switchAnimation.running = true
179
height: parent.height
184
height: parent.height
186
SequentialAnimation {
189
target: imageArea.oldDelegate
191
to: imageArea.incrementing ? -imageArea.oldDelegate.width : imageArea.oldDelegate.width
192
easing.type: Easing.InQuad
197
if (imageArea.incrementing) {
198
quickBrowserBar.currentIndex += 1
200
quickBrowserBar.currentIndex -= 1
202
imageArea.oldDelegate.z = 0
203
imageArea.delegate.z = 10
204
imageArea.oldDelegate.x = 0
205
imageArea.delegate.x = 0
209
script: delegate1.delta = delegate2.delta = 0
216
model: fileBrowserRoot.model
217
onCurrentIndexChanged: {
218
var path = fileBrowserRoot.model.get(currentIndex).url
219
imageArea.delegate.source = path
220
viewerPage.path = path
221
resourceInstance.uri = path
233
target: quickBrowserBar
234
y: fileBrowserRoot.height - quickBrowserBar.height
244
target: quickBrowserBar
245
y: fileBrowserRoot.height+20
254
easing.type: Easing.InOutQuad