[app] Use global Settings object instead of passing it around
As an optimization measure.
This commit is contained in:
parent
5bd39d1b39
commit
d677a150dc
6 changed files with 17 additions and 29 deletions
|
@ -37,14 +37,13 @@ SilicaFlickable {
|
|||
id: root
|
||||
|
||||
property variant book
|
||||
property variant settings
|
||||
|
||||
signal closeBook()
|
||||
signal pageClicked(var page)
|
||||
|
||||
property int _currentPage: bookListWatcher.currentIndex
|
||||
property bool _loading: minLoadingDelay.running || bookModel.loading
|
||||
property var _currentState: _visibilityStates[settings.pageDetails % _visibilityStates.length]
|
||||
property var _currentState: _visibilityStates[globalSettings.pageDetails % _visibilityStates.length]
|
||||
readonly property var _visibilityStates: [
|
||||
{ pager: false, page: false, title: false, tools: false },
|
||||
{ pager: false, page: true, title: true, tools: false },
|
||||
|
@ -56,22 +55,22 @@ SilicaFlickable {
|
|||
id: defaultFontMenuItem
|
||||
//% "Use default fonts"
|
||||
text: qsTrId("book-font-default")
|
||||
enabled: settings.fontSize != Settings.DefaultFontSize
|
||||
onClicked: settings.fontSize = Settings.DefaultFontSize
|
||||
enabled: globalSettings.fontSize != Settings.DefaultFontSize
|
||||
onClicked: globalSettings.fontSize = Settings.DefaultFontSize
|
||||
}
|
||||
MenuItem {
|
||||
id: smallerFontMenuItem
|
||||
//% "Use smaller fonts"
|
||||
text: qsTrId("book-font-smaller")
|
||||
enabled: settings.fontSize >= Settings.MinFontSize
|
||||
onClicked: settings.fontSize -= 1
|
||||
enabled: globalSettings.fontSize >= Settings.MinFontSize
|
||||
onClicked: globalSettings.fontSize -= 1
|
||||
}
|
||||
MenuItem {
|
||||
id: largerFontMenuItem
|
||||
//% "Use larger fonts"
|
||||
text: qsTrId("book-font-larger")
|
||||
enabled: settings.fontSize <= Settings.MaxFontSize
|
||||
onClicked: settings.fontSize += 1
|
||||
enabled: globalSettings.fontSize <= Settings.MaxFontSize
|
||||
onClicked: globalSettings.fontSize += 1
|
||||
}
|
||||
MenuItem {
|
||||
//% "Back to library"
|
||||
|
@ -115,7 +114,6 @@ SilicaFlickable {
|
|||
rightMargin: Theme.horizontalPageMargin
|
||||
topMargin: Theme.itemSizeSmall
|
||||
bottomMargin: Theme.itemSizeSmall
|
||||
settings: root.settings
|
||||
onJumpToPage: bookView.jumpTo(index)
|
||||
onCurrentPageChanged: {
|
||||
if (currentPage >= 0 && bookView._jumpingTo < 0) {
|
||||
|
@ -150,7 +148,6 @@ SilicaFlickable {
|
|||
height: bookView.height
|
||||
model: bookModel
|
||||
page: index
|
||||
settings: root.settings
|
||||
leftMargin: bookModel.leftMargin
|
||||
rightMargin: bookModel.rightMargin
|
||||
topMargin: bookModel.topMargin
|
||||
|
@ -160,7 +157,7 @@ SilicaFlickable {
|
|||
title: bookModel.title
|
||||
onPageClicked: {
|
||||
root.pageClicked(index)
|
||||
settings.pageDetails = (settings.pageDetails+ 1) % _visibilityStates.length
|
||||
globalSettings.pageDetails = (globalSettings.pageDetails+ 1) % _visibilityStates.length
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,10 +41,7 @@ ApplicationWindow {
|
|||
|
||||
Settings { id: globalSettings }
|
||||
|
||||
initialPage: BooksMainPage {
|
||||
id: mainPage
|
||||
settings: globalSettings
|
||||
}
|
||||
initialPage: BooksMainPage { id: mainPage }
|
||||
|
||||
cover: Component {
|
||||
BooksCoverPage {
|
||||
|
|
|
@ -39,19 +39,18 @@ Page {
|
|||
allowedOrientations: window.allowedOrientations
|
||||
|
||||
//property variant shelf
|
||||
property variant settings
|
||||
property variant currentShelf: storageView.currentShelf
|
||||
|
||||
property Item _bookView
|
||||
|
||||
function createBookViewIfNeeded() {
|
||||
if (settings.currentBook && !_bookView) {
|
||||
if (globalSettings.currentBook && !_bookView) {
|
||||
_bookView = bookViewComponent.createObject(root)
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: settings
|
||||
target: globalSettings
|
||||
onCurrentBookChanged: createBookViewIfNeeded()
|
||||
}
|
||||
|
||||
|
@ -61,9 +60,8 @@ Page {
|
|||
anchors.fill: parent
|
||||
opacity: book ? 1 : 0
|
||||
visible: opacity > 0
|
||||
settings: root.settings
|
||||
book: settings.currentBook ? settings.currentBook : null
|
||||
onCloseBook: settings.currentBook = null
|
||||
book: globalSettings.currentBook ? globalSettings.currentBook : null
|
||||
onCloseBook: globalSettings.currentBook = null
|
||||
Behavior on opacity { FadeAnimation {} }
|
||||
}
|
||||
}
|
||||
|
@ -71,11 +69,10 @@ Page {
|
|||
BooksStorageView {
|
||||
id: storageView
|
||||
anchors.fill: parent
|
||||
settings: root.settings
|
||||
opacity: settings.currentBook ? 0 : 1
|
||||
opacity: globalSettings.currentBook ? 0 : 1
|
||||
visible: opacity > 0
|
||||
Behavior on opacity { FadeAnimation {} }
|
||||
onOpenBook: settings.currentBook = book
|
||||
onOpenBook: globalSettings.currentBook = book
|
||||
}
|
||||
|
||||
Component.onCompleted: createBookViewIfNeeded()
|
||||
|
|
|
@ -42,7 +42,6 @@ Item {
|
|||
property alias rightMargin: widget.rightMargin
|
||||
property alias topMargin: widget.topMargin
|
||||
property alias bottomMargin: widget.bottomMargin
|
||||
property alias settings: widget.settings
|
||||
property alias title: titleLabel.text
|
||||
property bool titleVisible
|
||||
property bool pageNumberVisible
|
||||
|
@ -53,6 +52,7 @@ Item {
|
|||
PageWidget {
|
||||
id: widget
|
||||
anchors.fill: parent
|
||||
settings: globalSettings
|
||||
model: bookModel
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ Item {
|
|||
} else {
|
||||
// Otherwise it's a double click
|
||||
clickTimer.stop()
|
||||
settings.invertColors = !settings.invertColors
|
||||
globalSettings.invertColors = !globalSettings.invertColors
|
||||
}
|
||||
}
|
||||
Timer {
|
||||
|
|
|
@ -36,7 +36,6 @@ import harbour.books 1.0
|
|||
SilicaFlickable {
|
||||
id: shelfView
|
||||
|
||||
property variant settings
|
||||
property int shelfIndex
|
||||
property bool singleStorage
|
||||
property bool removableStorage
|
||||
|
|
|
@ -37,7 +37,6 @@ SilicaFlickable {
|
|||
id: storageView
|
||||
interactive: !dragInProgress
|
||||
|
||||
property variant settings
|
||||
property bool editMode: false
|
||||
|
||||
signal openBook(var book)
|
||||
|
@ -149,7 +148,6 @@ SilicaFlickable {
|
|||
height: storageList.height
|
||||
cellWidth: storageView._cellWidth
|
||||
cellHeight: storageView._cellHeight
|
||||
settings: storageView.settings
|
||||
singleStorage: storageModel.count < 2
|
||||
editMode: storageView.editMode
|
||||
deleteAllRequest: model.deleteAllRequest
|
||||
|
|
Loading…
Reference in a new issue