[app] Don't auto-scroll storage view if it's not visible

User expects to return to the same place where he/she opened the book
or the settings page.
This commit is contained in:
Slava Monich 2020-11-01 17:14:18 +02:00
parent 5fb0779519
commit 7d4cd543c5
2 changed files with 11 additions and 3 deletions

View file

@ -40,8 +40,8 @@ Page {
allowedOrientations: window.allowedOrientations
//property variant shelf
property variant currentShelf: storageView.currentShelf
readonly property bool pageActive: status === PageStatus.Active
property Item _bookView
@ -63,7 +63,7 @@ Page {
opacity: book ? 1 : 0
visible: opacity > 0
orientation: root.orientation
pageActive: root.status === PageStatus.Active
pageActive: root.pageActive
book: Settings.currentBook ? Settings.currentBook : null
onCloseBook: Settings.currentBook = null
Behavior on opacity { FadeAnimation {} }
@ -73,6 +73,7 @@ Page {
BooksStorageView {
id: storageView
anchors.fill: parent
pageActive: root.pageActive
opacity: Settings.currentBook ? 0 : 1
visible: opacity > 0
Behavior on opacity { FadeAnimation {} }

View file

@ -37,8 +37,10 @@ import harbour.books 1.0
SilicaFlickable {
id: storageView
interactive: !dragInProgress
property bool pageActive
property bool editMode: false
signal openBook(var book)
@ -156,7 +158,12 @@ SilicaFlickable {
// Show the contents of SD-card and let use know that he can switch
// between the internal memory and the removable storage by swiping
// the list horizontally
onNewStorage: storageList.scrollToPage(index)
onNewStorage: {
if (pageActive && storageView.visible) {
console.log("showing SD card contents")
storageList.scrollToPage(index)
}
}
}
ListWatcher {