[app] Reduced number of flickables

That makes scrolling easier. It appears that nested flickables with the
same flicking direction are having hard time fighting for mouse events.
This commit is contained in:
Slava Monich 2020-11-01 19:03:59 +02:00
parent 7d4cd543c5
commit b74d57291c
3 changed files with 66 additions and 26 deletions

View file

@ -42,7 +42,7 @@ import harbour.books 1.0
import "harbour"
SilicaFlickable {
Item {
id: root
property variant book
@ -63,12 +63,10 @@ SilicaFlickable {
{ pager: true, page: true, title: true, tools: true }
]
interactive: !selecting && !scrollAnimation.running &&
(!linkMenu || !linkMenu.visible) &&
(!imageView || !imageView.visible) &&
(!footnoteView || !footnoteView.visible)
property alias viewInteractive: bookView.interactive
property alias pullDownMenu: menu
property bool pageActive
readonly property bool viewActive: pageActive && Qt.application.active && book
readonly property bool haveVolumeUpAction: Settings.volumeUpAction !== BooksSettings.ActionNone
readonly property bool haveVolumeDownAction: Settings.volumeDownAction !== BooksSettings.ActionNone
@ -134,6 +132,8 @@ SilicaFlickable {
}
PullDownMenu {
id: menu
MenuItem {
//: Pulley menu item
//% "Settings"
@ -201,7 +201,10 @@ SilicaFlickable {
spacing: Theme.paddingMedium
opacity: loading ? 0 : 1
visible: opacity > 0
interactive: root.interactive
interactive: !selecting && !scrollAnimation.running &&
(!linkMenu || !linkMenu.visible) &&
(!imageView || !imageView.visible) &&
(!footnoteView || !footnoteView.visible)
readonly property real maxContentX: Math.max(0, contentWidth - width)
readonly property int currentPage: stackModel.currentPage

View file

@ -42,12 +42,28 @@ Page {
property variant currentShelf: storageView.currentShelf
readonly property bool pageActive: status === PageStatus.Active
readonly property Item currentView: Settings.currentBook ? bookView : storageView
property Item bookView
property Item _bookView
Component.onCompleted: createBookViewIfNeeded()
onCurrentViewChanged: setPullDownMenu(currentView ? currentView.pullDownMenu : null)
function createBookViewIfNeeded() {
if (Settings.currentBook && !_bookView) {
_bookView = bookViewComponent.createObject(root)
if (Settings.currentBook && !bookView) {
bookView = bookViewComponent.createObject(flickable.contentItem)
}
}
function setPullDownMenu(menu) {
if (flickable.pullDownMenu !== menu) {
if (flickable.pullDownMenu) {
flickable.pullDownMenu.visible = false
}
if (menu) {
menu.visible = true
}
flickable.pullDownMenu = menu
}
}
@ -56,19 +72,18 @@ Page {
onCurrentBookChanged: createBookViewIfNeeded()
}
Component {
id: bookViewComponent
BooksBookView {
Connections {
target: currentView
onPullDownMenuChanged: setPullDownMenu(currentView.pullDownMenu)
}
SilicaFlickable {
id: flickable
anchors.fill: parent
opacity: book ? 1 : 0
visible: opacity > 0
orientation: root.orientation
pageActive: root.pageActive
book: Settings.currentBook ? Settings.currentBook : null
onCloseBook: Settings.currentBook = null
Behavior on opacity { FadeAnimation {} }
}
}
flickableDirection: Flickable.VerticalFlick
interactive: currentView && currentView.viewInteractive
pullDownMenu: currentView ? currentView.pullDownMenu : null
BooksStorageView {
id: storageView
@ -79,6 +94,20 @@ Page {
Behavior on opacity { FadeAnimation {} }
onOpenBook: Settings.currentBook = book
}
}
Component.onCompleted: createBookViewIfNeeded()
Component {
id: bookViewComponent
BooksBookView {
anchors.fill: parent
opacity: Settings.currentBook ? 1 : 0
visible: opacity > 0
orientation: root.orientation
pageActive: root.pageActive
book: Settings.currentBook ? Settings.currentBook : null
onCloseBook: Settings.currentBook = null
Behavior on opacity { FadeAnimation {} }
}
}
}

View file

@ -35,11 +35,11 @@ import QtQuick 2.0
import Sailfish.Silica 1.0
import harbour.books 1.0
SilicaFlickable {
Item {
id: storageView
interactive: !dragInProgress
property alias viewInteractive: storageList.interactive
property alias pullDownMenu: menu
property bool pageActive
property bool editMode: false
@ -94,6 +94,8 @@ SilicaFlickable {
}
PullDownMenu {
id: menu
MenuItem {
//: Pulley menu item
//% "Settings"
@ -137,6 +139,7 @@ SilicaFlickable {
Component {
id: importComponent
BooksImport {
destination: currentShelf ? currentShelf.path : ""
onAccepted: {
@ -155,6 +158,7 @@ SilicaFlickable {
BookStorage {
id: storageModel
// 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
@ -168,12 +172,14 @@ SilicaFlickable {
ListWatcher {
id: storageListWatcher
listView: storageList
onSizeChanged: _cellWidth = calculateCellWidth()
}
SilicaListView {
id: storageList
anchors.fill: parent
model: storageModel
flickDeceleration: maximumFlickVelocity
@ -286,6 +292,7 @@ SilicaFlickable {
BooksShelfItem {
id: dragItem
visible: false
width: storageView._cellWidth
height: storageView._cellHeight
@ -303,6 +310,7 @@ SilicaFlickable {
NumberAnimation {
id: dragScrollAnimation
target: storageList
property: "contentX"
duration: 500