Cleanup monitoringPrint stuff by properly passing things as properties

Instead of relying on the property magically being propagated from the
root object, which causes crashes.

Contributes to CURA-3964
This commit is contained in:
Arjen Hiemstra 2017-07-04 11:37:04 +02:00
parent edeb2fa787
commit ec25164731
3 changed files with 17 additions and 8 deletions

View file

@ -18,14 +18,14 @@ UM.MainWindow
//: Cura application window title
title: catalog.i18nc("@title:window","Cura");
viewportRect: Qt.rect(0, 0, (base.width - sidebar.width) / base.width, 1.0)
property bool monitoringPrint: false
property bool showPrintMonitor: false
Connections
{
target: Printer
onShowPrintMonitor:
{
monitoringPrint = show;
base.showPrintMonitor = show;
}
}
@ -388,6 +388,9 @@ UM.MainWindow
anchors.left:parent.left
anchors.right: parent.right
anchors.top: parent.top
monitoringPrint: base.showPrintMonitor
onStartMonitoringPrint: base.showPrintMonitor = true
onStopMonitoringPrint: base.showPrintMonitor = false
}
Sidebar
@ -402,6 +405,7 @@ UM.MainWindow
}
z: 1
width: UM.Theme.getSize("sidebar").width;
monitoringPrint: base.showPrintMonitor
}
Button
@ -451,7 +455,7 @@ UM.MainWindow
Loader
{
sourceComponent: Cura.MachineManager.printerOutputDevices.length > 0 ? Cura.MachineManager.printerOutputDevices[0].monitorItem: null
visible: base.monitoringPrint
visible: base.showPrintMonitor
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenterOffset: - UM.Theme.getSize("sidebar").width / 2

View file

@ -22,6 +22,8 @@ Rectangle
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property int backendState: UM.Backend.state;
property bool monitoringPrint: false
color: UM.Theme.getColor("sidebar")
UM.I18nCatalog { id: catalog; name:"cura"}

View file

@ -20,6 +20,9 @@ Rectangle
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property bool monitoringPrint: false
signal startMonitoringPrint()
signal stopMonitoringPrint()
Row
{
@ -32,13 +35,13 @@ Rectangle
{
id: showSettings
height: UM.Theme.getSize("sidebar_header").height
onClicked: monitoringPrint = false
onClicked: base.stopMonitoringPrint()
iconSource: UM.Theme.getIcon("tab_settings");
property color overlayColor: "transparent"
property string overlayIconSource: ""
text: "Prepare"
checkable: true
checked: !monitoringPrint
checked: !base.monitoringPrint
exclusiveGroup: sidebarHeaderBarGroup
style: UM.Theme.styles.topbar_header_tab
@ -48,7 +51,7 @@ Rectangle
{
id: showMonitor
height: UM.Theme.getSize("sidebar_header").height
onClicked: monitoringPrint = true
onClicked: base.startMonitoringPrint()
text: "Print"
iconSource: printerConnected ? UM.Theme.getIcon("tab_monitor_with_status") : UM.Theme.getIcon("tab_monitor")
property color overlayColor:
@ -122,7 +125,7 @@ Rectangle
}
checkable: true
checked: monitoringPrint
checked: base.monitoringPrint
exclusiveGroup: sidebarHeaderBarGroup
style: UM.Theme.styles.topbar_header_tab
@ -205,4 +208,4 @@ Rectangle
menu: PrinterMenu { }
}
}
}