2015-06-28 14:22:35 +03:00
|
|
|
/*
|
2021-08-06 05:08:37 +03:00
|
|
|
Copyright (C) 2015-2021 Jolla Ltd.
|
|
|
|
Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
|
2015-06-28 14:22:35 +03:00
|
|
|
|
|
|
|
You may use this file under the terms of BSD license as follows:
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
2016-10-08 14:56:14 +03:00
|
|
|
|
2019-04-01 02:06:55 +03:00
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer
|
|
|
|
in the documentation and/or other materials provided with the
|
|
|
|
distribution.
|
|
|
|
3. Neither the names of the copyright holders nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived
|
|
|
|
from this software without specific prior written permission.
|
2015-06-28 14:22:35 +03:00
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
|
|
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.0
|
2020-09-17 01:30:34 +03:00
|
|
|
import QtFeedback 5.0
|
2015-06-28 14:22:35 +03:00
|
|
|
import Sailfish.Silica 1.0
|
2017-12-04 01:24:39 +03:00
|
|
|
import org.nemomobile.notifications 1.0
|
2015-06-28 14:22:35 +03:00
|
|
|
import harbour.books 1.0
|
|
|
|
|
2017-08-08 16:09:01 +03:00
|
|
|
//import Sailfish.Media 1.0 // Not allowed
|
|
|
|
//import org.nemomobile.policy 1.0 // Not allowed
|
|
|
|
|
2019-04-01 02:06:55 +03:00
|
|
|
import "harbour"
|
|
|
|
|
2020-11-01 20:03:59 +03:00
|
|
|
Item {
|
2015-06-28 14:22:35 +03:00
|
|
|
id: root
|
|
|
|
|
|
|
|
property variant book
|
2020-09-17 01:30:34 +03:00
|
|
|
readonly property bool selecting: bookView.currentItem && bookView.currentItem.selecting
|
|
|
|
readonly property bool selectionEmpty: !bookView.currentItem || bookView.currentItem.selectionEmpty
|
2015-06-28 14:22:35 +03:00
|
|
|
|
|
|
|
signal closeBook()
|
|
|
|
signal pageClicked(var page)
|
|
|
|
|
2016-11-02 16:33:26 +03:00
|
|
|
property int orientation: Orientation.Portrait
|
2017-08-03 18:48:17 +03:00
|
|
|
property alias stackModel: bookModel.pageStack
|
|
|
|
property bool loading: bookModel.loading
|
2016-10-16 23:36:13 +03:00
|
|
|
property var _currentState: _visibilityStates[Settings.pageDetails % _visibilityStates.length]
|
2015-06-28 14:22:35 +03:00
|
|
|
readonly property var _visibilityStates: [
|
|
|
|
{ pager: false, page: false, title: false, tools: false },
|
|
|
|
{ pager: false, page: true, title: true, tools: false },
|
2017-08-03 21:48:27 +03:00
|
|
|
{ pager: true, page: true, title: true, tools: false },
|
2015-06-28 14:22:35 +03:00
|
|
|
{ pager: true, page: true, title: true, tools: true }
|
|
|
|
]
|
|
|
|
|
2021-11-13 22:09:07 +03:00
|
|
|
property bool viewInteractive: bookView.interactive && !loading
|
2020-11-01 20:03:59 +03:00
|
|
|
property alias pullDownMenu: menu
|
2020-11-03 06:13:33 +03:00
|
|
|
property alias loadingBackgroundOpacity: loadingBackground.opacity
|
2021-11-13 19:03:10 +03:00
|
|
|
property bool isCurrentView
|
2020-10-22 04:13:25 +03:00
|
|
|
property bool pageActive
|
2020-11-01 20:03:59 +03:00
|
|
|
|
2020-11-03 06:30:56 +03:00
|
|
|
readonly property bool viewActive: pageActive && Qt.application.active && !!book
|
2017-08-08 16:09:01 +03:00
|
|
|
readonly property bool haveVolumeUpAction: Settings.volumeUpAction !== BooksSettings.ActionNone
|
|
|
|
readonly property bool haveVolumeDownAction: Settings.volumeDownAction !== BooksSettings.ActionNone
|
|
|
|
readonly property bool haveKeyAction: haveVolumeUpAction || haveVolumeDownAction
|
|
|
|
|
2020-09-17 01:30:34 +03:00
|
|
|
property var hapticFeedback
|
2016-10-08 14:56:14 +03:00
|
|
|
property var linkMenu
|
2016-10-08 19:57:54 +03:00
|
|
|
property var imageView
|
2016-11-02 16:33:26 +03:00
|
|
|
property var footnoteView
|
2020-09-28 02:54:49 +03:00
|
|
|
property var settingsComponent
|
2016-11-02 16:33:26 +03:00
|
|
|
|
2017-08-08 16:09:01 +03:00
|
|
|
function hideViews() {
|
|
|
|
if (linkMenu) linkMenu.hide()
|
|
|
|
if (imageView) imageView.hide()
|
|
|
|
if (footnoteView) footnoteView.hide()
|
|
|
|
}
|
|
|
|
|
2020-09-28 02:37:14 +03:00
|
|
|
function bzzz() {
|
|
|
|
if (!hapticFeedback) {
|
|
|
|
hapticFeedback = hapticFeedbackComponent.createObject(root)
|
|
|
|
}
|
|
|
|
hapticFeedback.play()
|
|
|
|
}
|
|
|
|
|
2016-11-02 16:33:26 +03:00
|
|
|
onOrientationChanged: {
|
|
|
|
if (footnoteView) {
|
|
|
|
footnoteView.cancel()
|
|
|
|
}
|
|
|
|
}
|
2016-10-08 14:56:14 +03:00
|
|
|
|
2020-09-28 03:07:46 +03:00
|
|
|
onBookChanged: if (!book) pager.setPage(0)
|
2020-02-03 04:09:13 +03:00
|
|
|
|
2020-09-17 01:30:34 +03:00
|
|
|
onSelectingChanged: {
|
|
|
|
if (selecting) {
|
2020-09-28 02:37:14 +03:00
|
|
|
bzzz()
|
2020-09-17 01:30:34 +03:00
|
|
|
} else if (!selectionEmpty) {
|
|
|
|
notification.publish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-08 14:56:14 +03:00
|
|
|
Component {
|
|
|
|
id: linkMenuComponent
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2016-11-02 16:33:26 +03:00
|
|
|
BooksLinkMenu { }
|
2016-10-08 14:56:14 +03:00
|
|
|
}
|
|
|
|
|
2016-10-08 19:57:54 +03:00
|
|
|
Component {
|
|
|
|
id: imageViewComponent
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2016-11-02 16:33:26 +03:00
|
|
|
BooksImageView { }
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: footnoteViewComponent
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2016-11-02 16:33:26 +03:00
|
|
|
BooksFootnoteView { }
|
2016-10-08 19:57:54 +03:00
|
|
|
}
|
|
|
|
|
2020-09-17 01:30:34 +03:00
|
|
|
Component {
|
|
|
|
id: hapticFeedbackComponent
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2020-09-17 01:30:34 +03:00
|
|
|
ThemeEffect { effect: ThemeEffect.Press }
|
|
|
|
}
|
|
|
|
|
2020-11-03 04:12:22 +03:00
|
|
|
Behavior on opacity {
|
|
|
|
enabled: menu.backToLibrary === 0
|
|
|
|
FadeAnimation { }
|
|
|
|
}
|
|
|
|
|
|
|
|
Binding on opacity {
|
|
|
|
// Fade out the page while menu is bouncing back
|
|
|
|
when: menu.backToLibrary < 0
|
|
|
|
value: menu.flickable.contentY / menu.backToLibrary
|
|
|
|
}
|
|
|
|
|
2015-06-28 14:22:35 +03:00
|
|
|
PullDownMenu {
|
2020-11-01 20:03:59 +03:00
|
|
|
id: menu
|
|
|
|
|
2021-11-13 22:09:07 +03:00
|
|
|
visible: isCurrentView && !loading && Settings.bookPullDownMenu
|
2020-11-02 03:06:57 +03:00
|
|
|
|
2020-11-03 04:12:22 +03:00
|
|
|
property real backToLibrary
|
|
|
|
|
2020-09-28 02:54:49 +03:00
|
|
|
MenuItem {
|
|
|
|
//: Pulley menu item
|
|
|
|
//% "Settings"
|
|
|
|
text: qsTrId("harbour-books-menu-settings")
|
2020-09-28 03:07:46 +03:00
|
|
|
visible: BooksSettingsMenu
|
2020-09-28 02:54:49 +03:00
|
|
|
onClicked: {
|
|
|
|
if (!settingsComponent) {
|
|
|
|
settingsComponent = Qt.createComponent("../settings/BooksSettings.qml")
|
|
|
|
if (settingsComponent.status !== Component.Ready) {
|
|
|
|
console.log(settingsComponent.errorString())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pageStack.push(settingsComponent, {
|
|
|
|
"title" : text,
|
|
|
|
"allowedOrientations": window.allowedOrientations,
|
2021-08-06 05:08:37 +03:00
|
|
|
"inApp": true
|
2020-09-28 02:54:49 +03:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2015-06-28 14:22:35 +03:00
|
|
|
MenuItem {
|
|
|
|
//% "Back to library"
|
2016-10-07 18:47:27 +03:00
|
|
|
text: qsTrId("harbour-books-book-view-back")
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2020-11-03 04:12:22 +03:00
|
|
|
// Delay the actual action until bounce back is finished
|
|
|
|
onClicked: menu.backToLibrary = flickable.contentY
|
|
|
|
}
|
|
|
|
|
|
|
|
onActiveChanged: {
|
|
|
|
if (!active && backToLibrary < 0) {
|
|
|
|
// The actual "Back to library" action
|
|
|
|
backToLibrary = 0
|
|
|
|
root.closeBook()
|
|
|
|
}
|
2015-06-28 14:22:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BookModel {
|
|
|
|
id: bookModel
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2015-06-28 14:22:35 +03:00
|
|
|
book: root.book ? root.book : null
|
2017-08-03 18:48:17 +03:00
|
|
|
size: bookViewWatcher.size
|
2015-06-28 14:22:35 +03:00
|
|
|
leftMargin: Theme.horizontalPageMargin
|
|
|
|
rightMargin: Theme.horizontalPageMargin
|
|
|
|
topMargin: Theme.itemSizeSmall
|
|
|
|
bottomMargin: Theme.itemSizeSmall
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2020-02-03 03:50:03 +03:00
|
|
|
onJumpToPage: bookView.jumpTo(page)
|
2015-06-28 14:22:35 +03:00
|
|
|
}
|
|
|
|
|
2017-12-04 01:24:39 +03:00
|
|
|
Notification {
|
|
|
|
id: notification
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2017-12-04 01:24:39 +03:00
|
|
|
//: Pop-up notification
|
|
|
|
//% "Copied to clipboard"
|
|
|
|
previewBody: qsTrId("harbour-books-book-view-copied_to_clipboard")
|
|
|
|
expireTimeout: 2000
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2018-02-26 18:39:30 +03:00
|
|
|
Component.onCompleted: {
|
|
|
|
if ("icon" in notification) {
|
|
|
|
notification.icon = "icon-s-clipboard"
|
|
|
|
}
|
|
|
|
}
|
2017-12-04 01:24:39 +03:00
|
|
|
}
|
|
|
|
|
2020-11-03 06:13:33 +03:00
|
|
|
Rectangle {
|
|
|
|
id: loadingBackground
|
|
|
|
anchors.fill: parent
|
|
|
|
color: HarbourTheme.invertedPrimaryColor
|
|
|
|
visible: loading && opacity > 0
|
|
|
|
}
|
|
|
|
|
2015-06-28 14:22:35 +03:00
|
|
|
SilicaListView {
|
|
|
|
id: bookView
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2015-06-28 14:22:35 +03:00
|
|
|
model: bookModel
|
|
|
|
anchors.fill: parent
|
|
|
|
flickDeceleration: maximumFlickVelocity
|
|
|
|
orientation: ListView.Horizontal
|
|
|
|
snapMode: ListView.SnapOneItem
|
2020-11-02 06:19:46 +03:00
|
|
|
preferredHighlightBegin: 0
|
2020-11-03 06:13:33 +03:00
|
|
|
preferredHighlightEnd: width
|
2020-09-17 01:30:34 +03:00
|
|
|
highlightRangeMode: ListView.StrictlyEnforceRange
|
2015-06-28 14:22:35 +03:00
|
|
|
spacing: Theme.paddingMedium
|
2017-08-03 18:48:17 +03:00
|
|
|
opacity: loading ? 0 : 1
|
2015-06-28 14:22:35 +03:00
|
|
|
visible: opacity > 0
|
2020-11-01 20:03:59 +03:00
|
|
|
interactive: !selecting && !scrollAnimation.running &&
|
|
|
|
(!linkMenu || !linkMenu.visible) &&
|
|
|
|
(!imageView || !imageView.visible) &&
|
|
|
|
(!footnoteView || !footnoteView.visible)
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2017-08-08 16:09:01 +03:00
|
|
|
readonly property real maxContentX: Math.max(0, contentWidth - width)
|
2017-08-03 18:48:17 +03:00
|
|
|
readonly property int currentPage: stackModel.currentPage
|
|
|
|
property bool completed
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
bookViewWatcher.positionViewAtIndex(currentPage)
|
2020-09-28 02:37:14 +03:00
|
|
|
pager.setPage(currentPage)
|
2017-08-03 18:48:17 +03:00
|
|
|
completed = true
|
|
|
|
}
|
|
|
|
|
|
|
|
onCurrentPageChanged: {
|
2020-09-17 01:44:58 +03:00
|
|
|
if (completed && !moving && !scrollAnimation.running) {
|
2017-08-03 18:48:17 +03:00
|
|
|
bookViewWatcher.positionViewAtIndex(currentPage)
|
|
|
|
}
|
2020-09-28 02:37:14 +03:00
|
|
|
pager.setPage(currentPage)
|
2017-08-03 18:48:17 +03:00
|
|
|
}
|
|
|
|
|
2020-11-02 06:19:46 +03:00
|
|
|
onCurrentIndexChanged: updateModel()
|
2017-08-03 18:48:17 +03:00
|
|
|
|
2020-11-02 06:19:46 +03:00
|
|
|
onMovingChanged: updateModel()
|
2017-08-03 18:48:17 +03:00
|
|
|
|
2015-06-28 14:22:35 +03:00
|
|
|
delegate: BooksPageView {
|
2017-09-07 19:03:17 +03:00
|
|
|
id: pageView
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2015-06-28 14:22:35 +03:00
|
|
|
width: bookView.width
|
|
|
|
height: bookView.height
|
2020-09-28 02:37:14 +03:00
|
|
|
bookModel: bookView.model
|
|
|
|
page: model.pageIndex
|
|
|
|
bookPos: model.bookPos
|
2015-06-28 14:22:35 +03:00
|
|
|
leftMargin: bookModel.leftMargin
|
|
|
|
rightMargin: bookModel.rightMargin
|
|
|
|
topMargin: bookModel.topMargin
|
|
|
|
bottomMargin: bookModel.bottomMargin
|
2015-08-23 14:47:25 +03:00
|
|
|
leftSpaceReserved: pageTools.visible ? pageTools.leftSpaceUsed : 0
|
|
|
|
rightSpaceReserved: pageTools.visible ? pageTools.rightSpaceUsed: 0
|
2015-06-28 14:22:35 +03:00
|
|
|
titleVisible: _currentState.title
|
|
|
|
pageNumberVisible: _currentState.page
|
2020-09-17 01:44:58 +03:00
|
|
|
currentPage: ListView.isCurrentItem
|
2015-06-28 14:22:35 +03:00
|
|
|
title: bookModel.title
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2016-10-16 20:07:03 +03:00
|
|
|
onJumpToPage: bookView.jumpTo(page)
|
2017-08-03 18:48:17 +03:00
|
|
|
onPushPosition: stackModel.pushPosition(position) // bookView.jumpTo(page)
|
2015-06-28 14:22:35 +03:00
|
|
|
onPageClicked: {
|
|
|
|
root.pageClicked(index)
|
2018-07-23 23:55:56 +03:00
|
|
|
if (Settings.turnPageByTap && mouseY > bookModel.topMargin && mouseY < (pageView.height - bookModel.topMargin)) {
|
|
|
|
if (mouseX < pageView.width/4) {
|
|
|
|
bookView.prevPage()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (mouseX > pageView.width*3/4) {
|
|
|
|
bookView.nextPage()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2018-07-23 00:52:14 +03:00
|
|
|
if (!Settings.pageDetailsFixed) {
|
|
|
|
Settings.pageDetails = (Settings.pageDetails + 1) % _visibilityStates.length
|
|
|
|
}
|
2015-06-28 14:22:35 +03:00
|
|
|
}
|
2016-10-08 19:57:54 +03:00
|
|
|
onImagePressed: {
|
2020-09-17 01:30:34 +03:00
|
|
|
if (!imageView) {
|
|
|
|
imageView = imageViewComponent.createObject(root)
|
2016-10-08 19:57:54 +03:00
|
|
|
}
|
2020-09-17 01:30:34 +03:00
|
|
|
imageView.show(url,rect)
|
2016-10-08 19:57:54 +03:00
|
|
|
}
|
2016-10-08 14:56:14 +03:00
|
|
|
onBrowserLinkPressed: {
|
2020-09-17 01:30:34 +03:00
|
|
|
if (!linkMenu) {
|
|
|
|
linkMenu = linkMenuComponent.createObject(root)
|
2016-11-02 16:33:26 +03:00
|
|
|
}
|
2020-09-17 01:30:34 +03:00
|
|
|
linkMenu.show(url)
|
2016-11-02 16:33:26 +03:00
|
|
|
}
|
|
|
|
onFootnotePressed: {
|
2020-09-17 01:30:34 +03:00
|
|
|
if (!footnoteView) {
|
|
|
|
footnoteView = footnoteViewComponent.createObject(root)
|
2016-10-08 14:56:14 +03:00
|
|
|
}
|
2020-09-17 01:30:34 +03:00
|
|
|
footnoteView.show(touchX,touchY,text,url)
|
2016-10-08 14:56:14 +03:00
|
|
|
}
|
2015-06-28 14:22:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function jumpTo(page) {
|
2020-09-28 02:37:14 +03:00
|
|
|
if (book && page >=0) {
|
|
|
|
console.log("showing page", page)
|
2017-08-03 18:48:17 +03:00
|
|
|
bookViewWatcher.positionViewAtIndex(page)
|
2020-09-28 02:37:14 +03:00
|
|
|
stackModel.currentPage = page
|
2015-06-28 14:22:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-08 16:09:01 +03:00
|
|
|
function prevPage() {
|
|
|
|
if (!scrollAnimation.running && contentX > 0) {
|
|
|
|
hideViews();
|
|
|
|
scrollAnimation.from = contentX
|
|
|
|
scrollAnimation.to = Math.max(0, contentX - width - spacing)
|
|
|
|
scrollAnimation.start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function nextPage() {
|
|
|
|
if (!scrollAnimation.running && contentX < maxContentX) {
|
|
|
|
hideViews();
|
|
|
|
scrollAnimation.from = contentX
|
|
|
|
scrollAnimation.to = Math.min(maxContentX, contentX + width + spacing)
|
|
|
|
scrollAnimation.start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-17 01:44:58 +03:00
|
|
|
function updateModel() {
|
2020-11-02 06:19:46 +03:00
|
|
|
if (completed && !moving && currentIndex >= 0 && !bookViewWatcher.updatingViewPosition) {
|
|
|
|
hideViews()
|
|
|
|
stackModel.currentPage = currentIndex
|
|
|
|
}
|
2020-09-17 01:44:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ListWatcher {
|
|
|
|
id: bookViewWatcher
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2020-09-17 01:44:58 +03:00
|
|
|
listView: bookView
|
|
|
|
}
|
|
|
|
|
2017-08-08 16:09:01 +03:00
|
|
|
NumberAnimation {
|
|
|
|
id: scrollAnimation
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2017-08-08 16:09:01 +03:00
|
|
|
target: bookView
|
|
|
|
property: "contentX"
|
|
|
|
duration: 500
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
}
|
|
|
|
|
2015-06-28 14:22:35 +03:00
|
|
|
Behavior on opacity { FadeAnimation {} }
|
|
|
|
|
2015-08-23 14:47:25 +03:00
|
|
|
BooksPageTools {
|
|
|
|
id: pageTools
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2015-08-23 14:47:25 +03:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
2015-06-28 14:22:35 +03:00
|
|
|
leftMargin: bookModel.leftMargin
|
|
|
|
rightMargin: bookModel.rightMargin
|
2015-08-23 14:47:25 +03:00
|
|
|
opacity: _currentState.tools ? 1 : 0
|
2020-11-03 06:30:56 +03:00
|
|
|
visible: opacity > 0 && !!book && bookModel.pageCount && !loading
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2015-12-13 14:46:53 +03:00
|
|
|
onIncreaseFontSize: bookModel.increaseFontSize()
|
|
|
|
onDecreaseFontSize: bookModel.decreaseFontSize()
|
2020-09-28 02:37:14 +03:00
|
|
|
|
|
|
|
Behavior on opacity { FadeAnimation {} }
|
2015-06-28 14:22:35 +03:00
|
|
|
}
|
|
|
|
|
2015-08-23 14:47:25 +03:00
|
|
|
BooksPager {
|
|
|
|
id: pager
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2015-08-23 14:47:25 +03:00
|
|
|
anchors {
|
2017-08-03 18:48:17 +03:00
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
2015-08-23 14:47:25 +03:00
|
|
|
bottom: parent.bottom
|
|
|
|
bottomMargin: (Theme.itemSizeExtraSmall + 2*(bookModel.bottomMargin - height))/4
|
|
|
|
}
|
2017-08-03 18:48:17 +03:00
|
|
|
leftMargin: bookModel.leftMargin
|
|
|
|
rightMargin: bookModel.rightMargin
|
|
|
|
stack: stackModel
|
2015-08-23 14:47:25 +03:00
|
|
|
pageCount: bookModel.pageCount
|
|
|
|
width: parent.width
|
2020-09-28 02:37:14 +03:00
|
|
|
opacity: (_currentState.pager && pageCount) ? 0.75 : 0
|
2015-08-23 14:47:25 +03:00
|
|
|
visible: opacity > 0
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2015-08-23 14:47:25 +03:00
|
|
|
onPageChanged: bookView.jumpTo(page)
|
2020-09-28 02:37:14 +03:00
|
|
|
onFeedback: bzzz()
|
|
|
|
|
2015-08-23 14:47:25 +03:00
|
|
|
Behavior on opacity { FadeAnimation {} }
|
2015-06-28 14:22:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-12 19:37:02 +03:00
|
|
|
BooksTitleLabel {
|
|
|
|
id: titleLabel
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2015-09-12 19:37:02 +03:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
leftMargin: bookModel.leftMargin
|
|
|
|
rightMargin: bookModel.rightMargin
|
|
|
|
}
|
|
|
|
text: bookModel.title
|
|
|
|
height: Theme.itemSizeExtraSmall
|
|
|
|
color: Theme.highlightColor
|
2017-08-03 18:48:17 +03:00
|
|
|
opacity: loading ? 0.6 : 0
|
2015-09-12 19:37:02 +03:00
|
|
|
}
|
|
|
|
|
2015-07-11 04:56:38 +03:00
|
|
|
BusyIndicator {
|
|
|
|
id: busyIndicator
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2015-06-28 14:22:35 +03:00
|
|
|
anchors.centerIn: parent
|
2015-07-11 04:56:38 +03:00
|
|
|
size: BusyIndicatorSize.Large
|
2017-08-03 18:48:17 +03:00
|
|
|
running: loading
|
2015-07-11 04:56:38 +03:00
|
|
|
}
|
2015-07-16 23:51:57 +03:00
|
|
|
|
2019-04-01 02:06:55 +03:00
|
|
|
HarbourFitLabel {
|
2015-07-16 23:51:57 +03:00
|
|
|
anchors.fill: busyIndicator
|
2015-07-11 04:56:38 +03:00
|
|
|
text: bookModel.progress > 0 ? bookModel.progress : ""
|
2017-08-03 18:48:17 +03:00
|
|
|
opacity: (loading && bookModel.progress > 0) ? 1 : 0
|
2015-07-11 04:56:38 +03:00
|
|
|
}
|
2015-07-16 23:51:57 +03:00
|
|
|
|
2015-09-12 19:37:02 +03:00
|
|
|
Button {
|
|
|
|
//% "Cancel"
|
2016-10-07 18:47:27 +03:00
|
|
|
text: qsTrId("harbour-books-book-view-cancel_loading")
|
2015-09-12 19:37:02 +03:00
|
|
|
height: Theme.itemSizeLarge
|
|
|
|
anchors {
|
|
|
|
bottom: parent.bottom
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
2017-08-03 18:48:17 +03:00
|
|
|
enabled: loading && bookModel.resetReason === BookModel.ReasonLoading
|
2015-10-30 23:59:09 +03:00
|
|
|
visible: opacity > 0
|
2015-09-12 19:37:02 +03:00
|
|
|
opacity: enabled ? 1.0 : 0.0
|
2020-09-28 02:37:14 +03:00
|
|
|
|
|
|
|
onClicked: root.closeBook()
|
|
|
|
|
2015-09-12 19:37:02 +03:00
|
|
|
Behavior on opacity { FadeAnimation { } }
|
|
|
|
}
|
2016-02-21 15:13:40 +03:00
|
|
|
|
|
|
|
Label {
|
|
|
|
anchors {
|
|
|
|
top: busyIndicator.bottom
|
|
|
|
topMargin: Theme.paddingLarge
|
|
|
|
horizontalCenter: busyIndicator.horizontalCenter
|
|
|
|
|
|
|
|
}
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
color: Theme.highlightColor
|
2017-08-03 18:48:17 +03:00
|
|
|
opacity: loading ? 1 : 0
|
2016-02-21 15:13:40 +03:00
|
|
|
visible: opacity > 0
|
2017-08-03 18:48:17 +03:00
|
|
|
text: bookModel ? (bookModel.resetReason == BookModel.ReasonLoading ?
|
|
|
|
//% "Loading..."
|
|
|
|
qsTrId("harbour-books-book-view-loading") :
|
|
|
|
bookModel.resetReason == BookModel.ReasonIncreasingFontSize ?
|
|
|
|
//% "Applying larger fonts..."
|
|
|
|
qsTrId("harbour-books-book-view-applying_larger_fonts") :
|
|
|
|
bookModel.resetReason == BookModel.ReasonDecreasingFontSize ?
|
|
|
|
//% "Applying smaller fonts..."
|
|
|
|
qsTrId("harbour-books-book-view-applying_smaller_fonts") :
|
|
|
|
//% "Formatting..."
|
|
|
|
qsTrId("harbour-books-book-view-formatting")) : ""
|
2020-09-28 02:37:14 +03:00
|
|
|
|
|
|
|
Behavior on opacity { FadeAnimation {} }
|
2016-02-21 15:13:40 +03:00
|
|
|
}
|
2017-08-08 16:09:01 +03:00
|
|
|
|
2020-09-28 02:37:14 +03:00
|
|
|
function performAction(action) {
|
2017-08-08 16:09:01 +03:00
|
|
|
switch (action) {
|
|
|
|
case BooksSettings.ActionPreviousPage:
|
|
|
|
bookView.prevPage()
|
|
|
|
return
|
|
|
|
case BooksSettings.ActionNextPage:
|
|
|
|
bookView.nextPage()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MediaKey {
|
|
|
|
enabled: viewActive && haveVolumeUpAction
|
|
|
|
key: Qt.Key_VolumeUp
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2017-08-08 16:09:01 +03:00
|
|
|
onPressed: volumeUpAction()
|
|
|
|
onRepeat: volumeUpAction()
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2017-08-08 16:09:01 +03:00
|
|
|
function volumeUpAction() {
|
|
|
|
performAction(Settings.volumeUpAction)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MediaKey {
|
|
|
|
enabled: viewActive && haveVolumeDownAction
|
|
|
|
key: Qt.Key_VolumeDown
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2017-08-08 16:09:01 +03:00
|
|
|
onPressed: volumeDownAction()
|
|
|
|
onRepeat: volumeDownAction()
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2017-08-08 16:09:01 +03:00
|
|
|
function volumeDownAction() {
|
|
|
|
performAction(Settings.volumeDownAction)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Permissions {
|
|
|
|
enabled: viewActive && haveKeyAction
|
|
|
|
autoRelease: true
|
|
|
|
applicationClass: "camera"
|
|
|
|
|
|
|
|
Resource {
|
|
|
|
id: volumeKeysResource
|
2020-09-28 02:37:14 +03:00
|
|
|
|
2017-08-08 16:09:01 +03:00
|
|
|
type: Resource.ScaleButton
|
|
|
|
optional: true
|
|
|
|
}
|
|
|
|
}
|
2015-06-28 14:22:35 +03:00
|
|
|
}
|