Remove usage of some deprecated functions

This commit is contained in:
Jaime van Kessel 2019-05-16 14:49:53 +02:00
parent 2eb8203c70
commit a0c705e900
4 changed files with 12 additions and 11 deletions

View file

@ -70,7 +70,7 @@ Item
OldControls.ToolButton OldControls.ToolButton
{ {
id: printerTypeSelector id: printerTypeSelector
text: Cura.MachineManager.activeMachine.definition.name text: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.definition.name: ""
tooltip: text tooltip: text
height: UM.Theme.getSize("print_setup_big_item").height height: UM.Theme.getSize("print_setup_big_item").height
width: Math.round(parent.width * 0.7) + UM.Theme.getSize("default_margin").width width: Math.round(parent.width * 0.7) + UM.Theme.getSize("default_margin").width
@ -201,7 +201,7 @@ Item
return paddedWidth - textWidth - UM.Theme.getSize("print_setup_big_item").height * 0.5 - UM.Theme.getSize("default_margin").width return paddedWidth - textWidth - UM.Theme.getSize("print_setup_big_item").height * 0.5 - UM.Theme.getSize("default_margin").width
} }
} }
property string instructionLink: Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeStack.material.id, "instruction_link", "") property string instructionLink: Cura.MachineManager.activeStack != null ? Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeStack.material.id, "instruction_link", ""): ""
Row Row
{ {

View file

@ -15,7 +15,7 @@ Instantiator
{ {
text: model.name text: model.name
checkable: true checkable: true
checked: Cura.MachineManager.activeMachineId == model.id checked: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.id == model.id: false
exclusiveGroup: group exclusiveGroup: group
visible: !model.hasRemoteConnection visible: !model.hasRemoteConnection
onTriggered: Cura.MachineManager.setActiveMachine(model.id) onTriggered: Cura.MachineManager.setActiveMachine(model.id)

View file

@ -18,7 +18,7 @@ UM.ManagementPage
sectionRole: "discoverySource" sectionRole: "discoverySource"
activeId: Cura.MachineManager.activeMachineId activeId: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.id: ""
activeIndex: activeMachineIndex() activeIndex: activeMachineIndex()
function activeMachineIndex() function activeMachineIndex()

View file

@ -271,6 +271,8 @@ Item
property var globalPropertyProvider: inheritStackProvider property var globalPropertyProvider: inheritStackProvider
property var externalResetHandler: false property var externalResetHandler: false
property string activeMachineId: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.id : ""
//Qt5.4.2 and earlier has a bug where this causes a crash: https://bugreports.qt.io/browse/QTBUG-35989 //Qt5.4.2 and earlier has a bug where this causes a crash: https://bugreports.qt.io/browse/QTBUG-35989
//In addition, while it works for 5.5 and higher, the ordering of the actual combo box drop down changes, //In addition, while it works for 5.5 and higher, the ordering of the actual combo box drop down changes,
//causing nasty issues when selecting different options. So disable asynchronous loading of enum type completely. //causing nasty issues when selecting different options. So disable asynchronous loading of enum type completely.
@ -314,16 +316,15 @@ Item
when: model.settable_per_extruder || (inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0); when: model.settable_per_extruder || (inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0);
value: value:
{ {
// associate this binding with Cura.MachineManager.activeMachineId in the beginning so this // Associate this binding with Cura.MachineManager.activeMachine.id in the beginning so this
// binding will be triggered when activeMachineId is changed too. // binding will be triggered when activeMachineId is changed too.
// Otherwise, if this value only depends on the extruderIds, it won't get updated when the // Otherwise, if this value only depends on the extruderIds, it won't get updated when the
// machine gets changed. // machine gets changed.
var activeMachineId = Cura.MachineManager.activeMachineId;
if (!model.settable_per_extruder) if (!model.settable_per_extruder)
{ {
//Not settable per extruder or there only is global, so we must pick global. //Not settable per extruder or there only is global, so we must pick global.
return activeMachineId; return delegate.activeMachineId
} }
if (inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0) if (inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0)
{ {
@ -336,7 +337,7 @@ Item
return Cura.ExtruderManager.activeExtruderStackId; return Cura.ExtruderManager.activeExtruderStackId;
} }
//No extruder tab is selected. Pick the global stack. Shouldn't happen any more since we removed the global tab. //No extruder tab is selected. Pick the global stack. Shouldn't happen any more since we removed the global tab.
return activeMachineId; return delegate.activeMachineId
} }
} }
@ -345,7 +346,7 @@ Item
UM.SettingPropertyProvider UM.SettingPropertyProvider
{ {
id: inheritStackProvider id: inheritStackProvider
containerStackId: Cura.MachineManager.activeMachineId containerStackId: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.id: ""
key: model.key key: model.key
watchedProperties: [ "limit_to_extruder" ] watchedProperties: [ "limit_to_extruder" ]
} }
@ -354,7 +355,7 @@ Item
{ {
id: provider id: provider
containerStackId: Cura.MachineManager.activeMachineId containerStackId: delegate.activeMachineId
key: model.key ? model.key : "" key: model.key ? model.key : ""
watchedProperties: [ "value", "enabled", "state", "validationState", "settable_per_extruder", "resolve" ] watchedProperties: [ "value", "enabled", "state", "validationState", "settable_per_extruder", "resolve" ]
storeIndex: 0 storeIndex: 0
@ -564,7 +565,7 @@ Item
{ {
id: machineExtruderCount id: machineExtruderCount
containerStackId: Cura.MachineManager.activeMachineId containerStackId: delegate.activeMachineId
key: "machine_extruder_count" key: "machine_extruder_count"
watchedProperties: [ "value" ] watchedProperties: [ "value" ]
storeIndex: 0 storeIndex: 0