Skip to content

Commit

Permalink
add cover actions to skip forwards or backwards in the image list
Browse files Browse the repository at this point in the history
  • Loading branch information
rabauke committed Sep 24, 2023
1 parent 1192223 commit de88780
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
13 changes: 13 additions & 0 deletions qml/cover/CoverPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions qml/harbour-raw-view.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
10 changes: 9 additions & 1 deletion qml/pages/MainPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Page {
MenuItem {
text: qsTr('Show image')
onClicked: {
view.currentIndex = index
appView.imageListCurrentIndex = index
pageStack.pop()
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit de88780

Please sign in to comment.