From 7d4cd543c505bc0d5c303a0a9dd74d60c3f60b5e Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sun, 1 Nov 2020 17:14:18 +0200 Subject: [PATCH] [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. --- app/qml/BooksMainPage.qml | 5 +++-- app/qml/BooksStorageView.qml | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/qml/BooksMainPage.qml b/app/qml/BooksMainPage.qml index f1614db..1b6cedc 100644 --- a/app/qml/BooksMainPage.qml +++ b/app/qml/BooksMainPage.qml @@ -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 {} } diff --git a/app/qml/BooksStorageView.qml b/app/qml/BooksStorageView.qml index 2d2f816..3e60b38 100644 --- a/app/qml/BooksStorageView.qml +++ b/app/qml/BooksStorageView.qml @@ -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 {