Don't show custom/auto toggle buttons when not connected

In order to prevent suddenly switching to the other side when the connection is lost or restored, we only evaluate this upon opening the popup. This way you might be surprised that closing and then opening it can show something else, but it will never surprise you while working on the popup itself as a user.

Contributes to issue CURA-5876.
This commit is contained in:
Ghostkeeper 2018-11-20 13:55:28 +01:00
parent a04db164e6
commit cbd5238738
No known key found for this signature in database
GPG Key ID: 86BEF881AE2CF276

View File

@ -98,31 +98,37 @@ Cura.ExpandableComponent
popupItem: Item popupItem: Item
{ {
id: popup id: popupItem
width: base.width - 2 * UM.Theme.getSize("default_margin").width width: base.width - 2 * UM.Theme.getSize("default_margin").width
height: 200 height: 200
property var configuration_method: "auto" property var is_connected: false //If current machine is connected to a printer. Only evaluated upon making popup visible.
onVisibleChanged:
{
is_connected = Cura.MachineManager.activeMachineNetworkKey != "" && Cura.MachineManager.printerConnected //Re-evaluate.
}
property var configuration_method: buttonBar.visible ? "auto" : "custom" //Auto if connected to a printer at start-up, or Custom if not.
AutoConfiguration AutoConfiguration
{ {
id: autoConfiguration id: autoConfiguration
visible: popup.configuration_method === "auto" visible: popupItem.configuration_method === "auto"
anchors.top: header.bottom anchors.top: parent.top
height: visible ? childrenRect.height : 0
} }
CustomConfiguration CustomConfiguration
{ {
id: customConfiguration id: customConfiguration
visible: popup.configuration_method === "custom" visible: popupItem.configuration_method === "custom"
anchors.top: header.bottom anchors.top: parent.top
height: visible ? childrenRect.height : 0
} }
Rectangle Rectangle
{ {
id: separator id: separator
visible: buttonBar.visible
anchors anchors
{ {
left: parent.left left: parent.left
@ -131,12 +137,16 @@ Cura.ExpandableComponent
bottomMargin: UM.Theme.getSize("default_margin").height bottomMargin: UM.Theme.getSize("default_margin").height
} }
height: UM.Theme.getSize("default_lining").height height: UM.Theme.getSize("default_lining").height
color: UM.Theme.getColor("lining") color: UM.Theme.getColor("lining")
} }
//Allow switching between custom and auto.
Rectangle Rectangle
{ {
id: buttonBar id: buttonBar
visible: popupItem.is_connected //Switching only makes sense if the "auto" part is possible.
anchors anchors
{ {
left: parent.left left: parent.left
@ -148,7 +158,7 @@ Cura.ExpandableComponent
Cura.ActionButton Cura.ActionButton
{ {
id: goToCustom id: goToCustom
visible: popup.configuration_method === "auto" visible: popupItem.configuration_method === "auto"
text: catalog.i18nc("@label", "Custom") text: catalog.i18nc("@label", "Custom")
anchors anchors
@ -165,13 +175,13 @@ Cura.ExpandableComponent
leftPadding: UM.Theme.getSize("default_margin").width leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width rightPadding: UM.Theme.getSize("default_margin").width
onClicked: popup.configuration_method = "custom" onClicked: popupItem.configuration_method = "custom"
} }
Cura.ActionButton Cura.ActionButton
{ {
id: goToAuto id: goToAuto
visible: popup.configuration_method === "custom" visible: popupItem.configuration_method === "custom"
text: catalog.i18nc("@label", "Configurations") text: catalog.i18nc("@label", "Configurations")
anchors anchors
@ -188,7 +198,7 @@ Cura.ExpandableComponent
leftPadding: UM.Theme.getSize("default_margin").width leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width rightPadding: UM.Theme.getSize("default_margin").width
onClicked: popup.configuration_method = "auto" onClicked: popupItem.configuration_method = "auto"
} }
} }
} }