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

View file

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