[app] Make pulley menus initially invisible

They will be made visible by BooksMainPage when needed.
This commit is contained in:
Slava Monich 2020-11-02 02:06:57 +02:00
parent b74d57291c
commit 6c2354d2e5
3 changed files with 16 additions and 10 deletions

View file

@ -134,6 +134,8 @@ Item {
PullDownMenu { PullDownMenu {
id: menu id: menu
visible: false // BooksMainPage will make it visible when it's needed
MenuItem { MenuItem {
//: Pulley menu item //: Pulley menu item
//% "Settings" //% "Settings"

View file

@ -47,23 +47,26 @@ Page {
Component.onCompleted: createBookViewIfNeeded() Component.onCompleted: createBookViewIfNeeded()
onCurrentViewChanged: setPullDownMenu(currentView ? currentView.pullDownMenu : null) onCurrentViewChanged: updatePullDownMenu()
function createBookViewIfNeeded() { function createBookViewIfNeeded() {
if (Settings.currentBook && !bookView) { if (Settings.currentBook && !bookView) {
bookView = bookViewComponent.createObject(flickable.contentItem) bookView = bookViewComponent.createObject(flickable.contentItem)
updatePullDownMenu()
} }
} }
function setPullDownMenu(menu) { function updatePullDownMenu() {
var menu = currentView ? currentView.pullDownMenu : null
if (menu) {
menu.visible = true
}
if (flickable.pullDownMenu !== menu) { if (flickable.pullDownMenu !== menu) {
if (flickable.pullDownMenu) { var prevMenu = flickable.pullDownMenu
flickable.pullDownMenu.visible = false
}
if (menu) {
menu.visible = true
}
flickable.pullDownMenu = menu flickable.pullDownMenu = menu
if (prevMenu) {
prevMenu.visible = false
}
} }
} }
@ -74,7 +77,7 @@ Page {
Connections { Connections {
target: currentView target: currentView
onPullDownMenuChanged: setPullDownMenu(currentView.pullDownMenu) onPullDownMenuChanged: updatePullDownMenu()
} }
SilicaFlickable { SilicaFlickable {
@ -83,7 +86,6 @@ Page {
anchors.fill: parent anchors.fill: parent
flickableDirection: Flickable.VerticalFlick flickableDirection: Flickable.VerticalFlick
interactive: currentView && currentView.viewInteractive interactive: currentView && currentView.viewInteractive
pullDownMenu: currentView ? currentView.pullDownMenu : null
BooksStorageView { BooksStorageView {
id: storageView id: storageView

View file

@ -96,6 +96,8 @@ Item {
PullDownMenu { PullDownMenu {
id: menu id: menu
visible: false // BooksMainPage will make it visible when it's needed
MenuItem { MenuItem {
//: Pulley menu item //: Pulley menu item
//% "Settings" //% "Settings"