1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Refactored nav switch into function

This commit is contained in:
kelteseth 2017-12-30 14:16:37 +01:00
parent a24fbdd315
commit f329929200

View File

@ -125,7 +125,6 @@ ApplicationWindow {
id:timerLoader
interval: 500
onTriggered: {
print("AAAAAA")
pageLoaderCreate.source = "qrc:/qml/Create/Create.qml"
}
@ -141,12 +140,7 @@ ApplicationWindow {
bottom: parent.bottom
left: parent.left
}
onStatusChanged: {
if(status == Loader.Ready){
pageLoaderWorkshop.source = "qrc:/qml/Workshop/Workshop.qml"
}
}
}
Loader {
id: pageLoaderWorkshop
@ -158,6 +152,22 @@ ApplicationWindow {
bottom: parent.bottom
left: parent.left
}
onStatusChanged: {
if(status == Loader.Ready){
connectionsPageLoaderWorkshop.target = pageLoaderWorkshop
}
}
}
Connections{
id:connectionsPageLoaderWorkshop
ignoreUnknownSignals: true
onOpenCreate: {
print("lellele")
if (!ignoreWorkshopBanner) {
switchPage("Workshop")
ignoreWorkshopBanner = true
}
}
}
Connections {
target: pageLoader.item
@ -182,12 +192,6 @@ ApplicationWindow {
nav.onPageChanged("Workshop")
}
}
onOpenCreate: {
if (!ignoreWorkshopBanner) {
nav.onPageChanged("Create")
ignoreWorkshopBanner = true
}
}
}
Sidebar {
@ -209,26 +213,7 @@ ApplicationWindow {
left: parent.left
}
onChangePage: {
if(name === "Create"){
pageLoader.visible = false
pageLoaderCreate.setSource("qrc:/qml/Create/Create.qml")
pageLoaderCreate.visible = true
pageLoaderWorkshop.visible = false
sidebar.state = "inactive"
} else if(name === "Workshop"){
pageLoader.visible = false
pageLoaderCreate.visible = false
pageLoaderWorkshop.setSource("qrc:/qml/Workshop/Workshop.qml")
pageLoaderWorkshop.visible = true
sidebar.state = "inactive"
} else {
pageLoader.visible = true
pageLoaderCreate.visible = false
pageLoaderWorkshop.visible = false
pageLoader.setSource("qrc:/qml/" + name + "/" + name + ".qml")
sidebar.state = "inactive"
}
switchPage(name)
}
onToggleMonitors: {
@ -236,6 +221,28 @@ ApplicationWindow {
}
}
function switchPage(name){
if(name === "Create"){
pageLoader.visible = false
pageLoaderCreate.setSource("qrc:/qml/Create/Create.qml")
pageLoaderCreate.visible = true
pageLoaderWorkshop.visible = false
sidebar.state = "inactive"
} else if(name === "Workshop"){
pageLoader.visible = false
pageLoaderCreate.visible = false
pageLoaderWorkshop.setSource("qrc:/qml/Workshop/Workshop.qml")
pageLoaderWorkshop.visible = true
sidebar.state = "inactive"
} else {
pageLoader.visible = true
pageLoaderCreate.visible = false
pageLoaderWorkshop.visible = false
pageLoader.setSource("qrc:/qml/" + name + "/" + name + ".qml")
sidebar.state = "inactive"
}
}
Monitors {
id: monitors
state: "inactive"