[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:
parent
7d4cd543c5
commit
b74d57291c
3 changed files with 66 additions and 26 deletions
|
@ -42,7 +42,7 @@ import harbour.books 1.0
|
||||||
|
|
||||||
import "harbour"
|
import "harbour"
|
||||||
|
|
||||||
SilicaFlickable {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property variant book
|
property variant book
|
||||||
|
@ -63,12 +63,10 @@ SilicaFlickable {
|
||||||
{ pager: true, page: true, title: true, tools: true }
|
{ pager: true, page: true, title: true, tools: true }
|
||||||
]
|
]
|
||||||
|
|
||||||
interactive: !selecting && !scrollAnimation.running &&
|
property alias viewInteractive: bookView.interactive
|
||||||
(!linkMenu || !linkMenu.visible) &&
|
property alias pullDownMenu: menu
|
||||||
(!imageView || !imageView.visible) &&
|
|
||||||
(!footnoteView || !footnoteView.visible)
|
|
||||||
|
|
||||||
property bool pageActive
|
property bool pageActive
|
||||||
|
|
||||||
readonly property bool viewActive: pageActive && Qt.application.active && book
|
readonly property bool viewActive: pageActive && Qt.application.active && book
|
||||||
readonly property bool haveVolumeUpAction: Settings.volumeUpAction !== BooksSettings.ActionNone
|
readonly property bool haveVolumeUpAction: Settings.volumeUpAction !== BooksSettings.ActionNone
|
||||||
readonly property bool haveVolumeDownAction: Settings.volumeDownAction !== BooksSettings.ActionNone
|
readonly property bool haveVolumeDownAction: Settings.volumeDownAction !== BooksSettings.ActionNone
|
||||||
|
@ -134,6 +132,8 @@ SilicaFlickable {
|
||||||
}
|
}
|
||||||
|
|
||||||
PullDownMenu {
|
PullDownMenu {
|
||||||
|
id: menu
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
//: Pulley menu item
|
//: Pulley menu item
|
||||||
//% "Settings"
|
//% "Settings"
|
||||||
|
@ -201,7 +201,10 @@ SilicaFlickable {
|
||||||
spacing: Theme.paddingMedium
|
spacing: Theme.paddingMedium
|
||||||
opacity: loading ? 0 : 1
|
opacity: loading ? 0 : 1
|
||||||
visible: opacity > 0
|
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 real maxContentX: Math.max(0, contentWidth - width)
|
||||||
readonly property int currentPage: stackModel.currentPage
|
readonly property int currentPage: stackModel.currentPage
|
||||||
|
|
|
@ -42,12 +42,28 @@ Page {
|
||||||
|
|
||||||
property variant currentShelf: storageView.currentShelf
|
property variant currentShelf: storageView.currentShelf
|
||||||
readonly property bool pageActive: status === PageStatus.Active
|
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() {
|
function createBookViewIfNeeded() {
|
||||||
if (Settings.currentBook && !_bookView) {
|
if (Settings.currentBook && !bookView) {
|
||||||
_bookView = bookViewComponent.createObject(root)
|
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,11 +72,36 @@ Page {
|
||||||
onCurrentBookChanged: createBookViewIfNeeded()
|
onCurrentBookChanged: createBookViewIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: currentView
|
||||||
|
onPullDownMenuChanged: setPullDownMenu(currentView.pullDownMenu)
|
||||||
|
}
|
||||||
|
|
||||||
|
SilicaFlickable {
|
||||||
|
id: flickable
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
flickableDirection: Flickable.VerticalFlick
|
||||||
|
interactive: currentView && currentView.viewInteractive
|
||||||
|
pullDownMenu: currentView ? currentView.pullDownMenu : null
|
||||||
|
|
||||||
|
BooksStorageView {
|
||||||
|
id: storageView
|
||||||
|
anchors.fill: parent
|
||||||
|
pageActive: root.pageActive
|
||||||
|
opacity: Settings.currentBook ? 0 : 1
|
||||||
|
visible: opacity > 0
|
||||||
|
Behavior on opacity { FadeAnimation {} }
|
||||||
|
onOpenBook: Settings.currentBook = book
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: bookViewComponent
|
id: bookViewComponent
|
||||||
|
|
||||||
BooksBookView {
|
BooksBookView {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
opacity: book ? 1 : 0
|
opacity: Settings.currentBook ? 1 : 0
|
||||||
visible: opacity > 0
|
visible: opacity > 0
|
||||||
orientation: root.orientation
|
orientation: root.orientation
|
||||||
pageActive: root.pageActive
|
pageActive: root.pageActive
|
||||||
|
@ -69,16 +110,4 @@ Page {
|
||||||
Behavior on opacity { FadeAnimation {} }
|
Behavior on opacity { FadeAnimation {} }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BooksStorageView {
|
|
||||||
id: storageView
|
|
||||||
anchors.fill: parent
|
|
||||||
pageActive: root.pageActive
|
|
||||||
opacity: Settings.currentBook ? 0 : 1
|
|
||||||
visible: opacity > 0
|
|
||||||
Behavior on opacity { FadeAnimation {} }
|
|
||||||
onOpenBook: Settings.currentBook = book
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: createBookViewIfNeeded()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,11 @@ import QtQuick 2.0
|
||||||
import Sailfish.Silica 1.0
|
import Sailfish.Silica 1.0
|
||||||
import harbour.books 1.0
|
import harbour.books 1.0
|
||||||
|
|
||||||
SilicaFlickable {
|
Item {
|
||||||
id: storageView
|
id: storageView
|
||||||
|
|
||||||
interactive: !dragInProgress
|
property alias viewInteractive: storageList.interactive
|
||||||
|
property alias pullDownMenu: menu
|
||||||
property bool pageActive
|
property bool pageActive
|
||||||
property bool editMode: false
|
property bool editMode: false
|
||||||
|
|
||||||
|
@ -94,6 +94,8 @@ SilicaFlickable {
|
||||||
}
|
}
|
||||||
|
|
||||||
PullDownMenu {
|
PullDownMenu {
|
||||||
|
id: menu
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
//: Pulley menu item
|
//: Pulley menu item
|
||||||
//% "Settings"
|
//% "Settings"
|
||||||
|
@ -137,6 +139,7 @@ SilicaFlickable {
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: importComponent
|
id: importComponent
|
||||||
|
|
||||||
BooksImport {
|
BooksImport {
|
||||||
destination: currentShelf ? currentShelf.path : ""
|
destination: currentShelf ? currentShelf.path : ""
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
|
@ -155,6 +158,7 @@ SilicaFlickable {
|
||||||
|
|
||||||
BookStorage {
|
BookStorage {
|
||||||
id: storageModel
|
id: storageModel
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -168,12 +172,14 @@ SilicaFlickable {
|
||||||
|
|
||||||
ListWatcher {
|
ListWatcher {
|
||||||
id: storageListWatcher
|
id: storageListWatcher
|
||||||
|
|
||||||
listView: storageList
|
listView: storageList
|
||||||
onSizeChanged: _cellWidth = calculateCellWidth()
|
onSizeChanged: _cellWidth = calculateCellWidth()
|
||||||
}
|
}
|
||||||
|
|
||||||
SilicaListView {
|
SilicaListView {
|
||||||
id: storageList
|
id: storageList
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
model: storageModel
|
model: storageModel
|
||||||
flickDeceleration: maximumFlickVelocity
|
flickDeceleration: maximumFlickVelocity
|
||||||
|
@ -286,6 +292,7 @@ SilicaFlickable {
|
||||||
|
|
||||||
BooksShelfItem {
|
BooksShelfItem {
|
||||||
id: dragItem
|
id: dragItem
|
||||||
|
|
||||||
visible: false
|
visible: false
|
||||||
width: storageView._cellWidth
|
width: storageView._cellWidth
|
||||||
height: storageView._cellHeight
|
height: storageView._cellHeight
|
||||||
|
@ -303,6 +310,7 @@ SilicaFlickable {
|
||||||
|
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
id: dragScrollAnimation
|
id: dragScrollAnimation
|
||||||
|
|
||||||
target: storageList
|
target: storageList
|
||||||
property: "contentX"
|
property: "contentX"
|
||||||
duration: 500
|
duration: 500
|
||||||
|
|
Loading…
Reference in a new issue