Changeset View
Changeset View
Standalone View
Standalone View
qmlUiKirigami/ImageViewer.qml
Show All 17 Lines | |||||
18 | * | 18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | 19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 20 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
21 | * | 21 | * | ||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | import QtQuick 2.7 | 24 | import QtQuick 2.7 | ||
25 | import QtQuick.Window 2.2 | 25 | import QtQuick.Window 2.2 | ||
26 | import QtQuick.Controls 2.0 as Controls | 26 | import QtQuick.Controls 2.2 as Controls | ||
27 | import org.kde.kirigami 2.0 as Kirigami | 27 | import org.kde.kirigami 2.0 as Kirigami | ||
28 | import org.kde.koko 0.1 as Koko | 28 | import org.kde.koko 0.1 as Koko | ||
29 | import org.kde.kquickcontrolsaddons 2.0 as KQA | 29 | import org.kde.kquickcontrolsaddons 2.0 as KQA | ||
30 | 30 | | |||
31 | Kirigami.Page { | 31 | Kirigami.Page { | ||
32 | id: root | 32 | id: root | ||
33 | 33 | | |||
34 | property alias sourceModel: imagesListModel.sourceModel | 34 | property alias sourceModel: imagesListModel.sourceModel | ||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 157 | Timer { | |||
160 | onTriggered: footerList.opacity = 0 | 160 | onTriggered: footerList.opacity = 0 | ||
161 | } | 161 | } | ||
162 | 162 | | |||
163 | onCurrentIndexChanged: { | 163 | onCurrentIndexChanged: { | ||
164 | currentImage.index = model.sourceIndex( currentIndex) | 164 | currentImage.index = model.sourceIndex( currentIndex) | ||
165 | listView.positionViewAtIndex(currentIndex, ListView.Beginning) | 165 | listView.positionViewAtIndex(currentIndex, ListView.Beginning) | ||
166 | footerList.opacity = 1.0 | 166 | footerList.opacity = 1.0 | ||
167 | timer.restart() | 167 | timer.restart() | ||
168 | toolBar.visible = false | ||||
168 | } | 169 | } | ||
169 | 170 | | |||
170 | delegate: Flickable { | 171 | delegate: Flickable { | ||
171 | id: flick | 172 | id: flick | ||
173 | property alias currentImage: image | ||||
172 | width: imageWidth | 174 | width: imageWidth | ||
173 | height: imageHeight | 175 | height: imageHeight | ||
174 | contentWidth: imageWidth | 176 | contentWidth: imageWidth | ||
175 | contentHeight: imageHeight | 177 | contentHeight: imageHeight | ||
176 | interactive: contentWidth > width || contentHeight > height | 178 | interactive: contentWidth > width || contentHeight > height | ||
177 | onInteractiveChanged: listView.interactive = !interactive; | 179 | onInteractiveChanged: listView.interactive = !interactive; | ||
178 | clip: true | 180 | clip: true | ||
179 | z: index == listView.currentIndex ? 1000 : 0 | 181 | z: index == listView.currentIndex ? 1000 : 0 | ||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 261 | Image { | |||
263 | source: model.imageurl | 265 | source: model.imageurl | ||
264 | fillMode: Image.PreserveAspectFit | 266 | fillMode: Image.PreserveAspectFit | ||
265 | asynchronous: true | 267 | asynchronous: true | ||
266 | autoTransform: true | 268 | autoTransform: true | ||
267 | sourceSize.width: imageWidth * 2 | 269 | sourceSize.width: imageWidth * 2 | ||
268 | sourceSize.height: imageHeight * 2 | 270 | sourceSize.height: imageHeight * 2 | ||
269 | MouseArea { | 271 | MouseArea { | ||
270 | anchors.fill: parent | 272 | anchors.fill: parent | ||
273 | onPressAndHold: { | ||||
274 | if (root.state != "fullscreen") | ||||
275 | toolBar.visible = true | ||||
276 | } | ||||
271 | onDoubleClicked: { | 277 | onDoubleClicked: { | ||
272 | if (flick.interactive) { | 278 | if (flick.interactive) { | ||
273 | zoomAnim.x = 0; | 279 | zoomAnim.x = 0; | ||
274 | zoomAnim.y = 0; | 280 | zoomAnim.y = 0; | ||
275 | zoomAnim.width = root.imageWidth; | 281 | zoomAnim.width = root.imageWidth; | ||
276 | zoomAnim.height = root.imageHeight; | 282 | zoomAnim.height = root.imageHeight; | ||
277 | zoomAnim.running = true; | 283 | zoomAnim.running = true; | ||
278 | } else { | 284 | } else { | ||
Show All 31 Lines | |||||
310 | } | 316 | } | ||
311 | } | 317 | } | ||
312 | } | 318 | } | ||
313 | } | 319 | } | ||
314 | } | 320 | } | ||
315 | 321 | | |||
316 | PathView { | 322 | PathView { | ||
317 | id: footerList | 323 | id: footerList | ||
324 | visible: root.state == "fullscreen" | ||||
318 | height: Kirigami.Units.gridUnit * 4 | 325 | height: Kirigami.Units.gridUnit * 4 | ||
319 | model: listView.model | 326 | model: listView.model | ||
320 | currentIndex: listView.currentIndex | 327 | currentIndex: listView.currentIndex | ||
321 | pathItemCount: applicationWindow().width / (Kirigami.Units.gridUnit * 5) | 328 | pathItemCount: applicationWindow().width / (Kirigami.Units.gridUnit * 5) | ||
322 | interactive: false | 329 | interactive: false | ||
323 | 330 | | |||
324 | preferredHighlightBegin: 0.5 | 331 | preferredHighlightBegin: 0.5 | ||
325 | preferredHighlightEnd: 0.5 | 332 | preferredHighlightEnd: 0.5 | ||
Show All 30 Lines | |||||
356 | } | 363 | } | ||
357 | } | 364 | } | ||
358 | 365 | | |||
359 | //FIXME: placeholder, will have to use the state machine | 366 | //FIXME: placeholder, will have to use the state machine | ||
360 | Controls.Button { | 367 | Controls.Button { | ||
361 | text: i18n("Back") | 368 | text: i18n("Back") | ||
362 | onClicked: root.state = "closed" | 369 | onClicked: root.state = "closed" | ||
363 | } | 370 | } | ||
371 | | ||||
372 | Controls.ToolBar { | ||||
373 | id: toolBar | ||||
374 | visible: false | ||||
375 | anchors.bottom: parent.bottom | ||||
376 | anchors.left: parent.left | ||||
377 | anchors.right: parent.right | ||||
378 | Row { | ||||
379 | anchors.fill: parent | ||||
380 | Controls.ToolButton { | ||||
381 | text: i18n("Rotate left") | ||||
382 | onClicked: listView.currentItem.currentImage.rotation -= 90 | ||||
383 | } | ||||
384 | Controls.ToolSeparator {} | ||||
385 | Controls.ToolButton { | ||||
386 | text: i18n("Rotate right") | ||||
387 | onClicked: listView.currentItem.currentImage.rotation += 90 | ||||
388 | } | ||||
389 | Controls.ToolSeparator {} | ||||
390 | Controls.ToolButton { | ||||
391 | text: i18n("Hide") | ||||
392 | onClicked: toolBar.visible = false | ||||
393 | } | ||||
394 | } | ||||
395 | } | ||||
364 | } | 396 | } |