More gracefully handle cases where no profile is selected in the profiles list

This commit is contained in:
fieldOfView 2016-07-11 15:48:41 +02:00
parent 4d2d889604
commit 7a63f957cb

View File

@ -140,7 +140,7 @@ UM.ManagementPage
Row { Row {
id: currentSettingsActions id: currentSettingsActions
visible: currentItem.id == Cura.MachineManager.activeQualityId visible: currentItem && currentItem.id == Cura.MachineManager.activeQualityId
anchors.left: parent.left anchors.left: parent.left
anchors.top: profileName.bottom anchors.top: profileName.bottom
@ -173,14 +173,14 @@ UM.ManagementPage
Label { Label {
id: defaultsMessage id: defaultsMessage
visible: !currentItem.metadata.has_settings visible: currentItem && !currentItem.metadata.has_settings
text: catalog.i18nc("@action:label", "This profile has no settings and uses the defaults specified by the printer.") text: catalog.i18nc("@action:label", "This profile has no settings and uses the defaults specified by the printer.")
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
width: parent.width width: parent.width
} }
Label { Label {
id: noCurrentSettingsMessage id: noCurrentSettingsMessage
visible: currentItem.id == Cura.MachineManager.activeQualityId && !Cura.MachineManager.hasUserSettings visible: currentItem && currentItem.id == Cura.MachineManager.activeQualityId && !Cura.MachineManager.hasUserSettings
text: catalog.i18nc("@action:label", "Your current settings match the selected profile.") text: catalog.i18nc("@action:label", "Your current settings match the selected profile.")
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
width: parent.width width: parent.width
@ -197,7 +197,17 @@ UM.ManagementPage
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
ListView { ListView {
model: Cura.ContainerSettingsModel{ containers: (currentItem.id == Cura.MachineManager.activeQualityId) ? [base.currentItem.id, Cura.MachineManager.activeUserProfileId] : [base.currentItem.id] } model: Cura.ContainerSettingsModel{ containers:
{
if (!currentItem) {
return []
} else if (currentItem.id == Cura.MachineManager.activeQualityId) {
return [base.currentItem.id, Cura.MachineManager.activeUserProfileId]
} else {
return [base.currentItem.id]
}
}
}
delegate: Row { delegate: Row {
property variant setting: model property variant setting: model
spacing: UM.Theme.getSize("default_margin").width/2 spacing: UM.Theme.getSize("default_margin").width/2
@ -221,7 +231,7 @@ UM.ManagementPage
} }
} }
header: Row { header: Row {
visible: currentItem.id == Cura.MachineManager.activeQualityId visible: currentItem && currentItem.id == Cura.MachineManager.activeQualityId
spacing: UM.Theme.getSize("default_margin").width spacing: UM.Theme.getSize("default_margin").width
Label { Label {
text: catalog.i18nc("@action:label", "Profile:") text: catalog.i18nc("@action:label", "Profile:")
@ -231,7 +241,7 @@ UM.ManagementPage
} }
Label { Label {
text: catalog.i18nc("@action:label", "Current:") text: catalog.i18nc("@action:label", "Current:")
visible: currentItem.id == Cura.MachineManager.activeQualityId visible: currentItem && currentItem.id == Cura.MachineManager.activeQualityId
font.bold: true font.bold: true
} }
} }