From de88780c4396bf2fc5cf50d3953828a479ca2ab0 Mon Sep 17 00:00:00 2001 From: Heiko Bauke Date: Mon, 25 Sep 2023 00:02:11 +0200 Subject: [PATCH] add cover actions to skip forwards or backwards in the image list --- qml/cover/CoverPage.qml | 13 +++++++++++++ qml/harbour-raw-view.qml | 5 +++-- qml/pages/MainPage.qml | 10 +++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/qml/cover/CoverPage.qml b/qml/cover/CoverPage.qml index 3d89979..b544d85 100644 --- a/qml/cover/CoverPage.qml +++ b/qml/cover/CoverPage.qml @@ -10,6 +10,19 @@ CoverBackground { visible: appView.imageListEmpty } + CoverActionList { + CoverAction { + iconSource: 'image://theme/icon-cover-previous' + onTriggered: appView.imageListCurrentIndex = appView.imageListCurrentIndex - 1 >= 0 ? appView.imageListCurrentIndex - 1 : appView.imageListCurrentIndex + + } + CoverAction { + iconSource: 'image://theme/icon-cover-next' + onTriggered: appView.imageListCurrentIndex = appView.imageListCurrentIndex + 1 < appView.imageListCount ? appView.imageListCurrentIndex + 1 : view.currentIndex + } + enabled: !appView.imageListEmpty + } + PagedView { id: view diff --git a/qml/harbour-raw-view.qml b/qml/harbour-raw-view.qml index 8e01096..74b5cf1 100644 --- a/qml/harbour-raw-view.qml +++ b/qml/harbour-raw-view.qml @@ -10,12 +10,13 @@ ApplicationWindow { id: appModel } - property int imageListCurrentIndex + property int imageListCurrentIndex: 0 + property int imageListCount property bool imageListEmpty: appModel.imageList.rowCount() === 0 initialPage: Component { MainPage {} } - cover: Qt.resolvedUrl("cover/CoverPage.qml") + cover: Qt.resolvedUrl('cover/CoverPage.qml') allowedOrientations: defaultAllowedOrientations } diff --git a/qml/pages/MainPage.qml b/qml/pages/MainPage.qml index 8c0fbb0..8500346 100644 --- a/qml/pages/MainPage.qml +++ b/qml/pages/MainPage.qml @@ -63,7 +63,7 @@ Page { MenuItem { text: qsTr('Show image') onClicked: { - view.currentIndex = index + appView.imageListCurrentIndex = index pageStack.pop() } } @@ -180,12 +180,20 @@ Page { } } + currentIndex: appView.imageListCurrentIndex + Binding { target: appView property: 'imageListCurrentIndex' value: view.currentIndex } + Binding { + target: appView + property: 'imageListCount' + value: view.count + } + PinchArea { id: pinchArea anchors.fill: parent