Fix quality management page QML

CURA-5063
This commit is contained in:
Lipu Fei 2018-03-09 10:59:33 +01:00
parent 6bee5bf1b0
commit 3550ef80e0
3 changed files with 21 additions and 9 deletions

View file

@ -69,7 +69,7 @@ class QualitySettingsModel(ListModel):
return self._selected_quality_item return self._selected_quality_item
def _update(self): def _update(self):
if self._selected_quality_item is None: if not self._selected_quality_item:
self.setItems([]) self.setItems([])
return return

View file

@ -14,6 +14,15 @@ Tab
property string extruderPosition: "" property string extruderPosition: ""
property var qualityItem: null property var qualityItem: null
property bool isQualityItemCurrentlyActivated:
{
if (qualityItem == null)
{
return false;
}
return qualityItem.name == Cura.MachineManager.activeQualityOrQualityChangesName;
}
TableView TableView
{ {
anchors.fill: parent anchors.fill: parent
@ -36,8 +45,8 @@ Tab
anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.right: parent.right anchors.right: parent.right
text: (styleData.value.substr(0,1) == "=") ? catalog.i18nc("@info:status", "Calculated") : styleData.value text: (styleData.value.substr(0,1) == "=") ? catalog.i18nc("@info:status", "Calculated") : styleData.value
font.strikeout: styleData.column == 1 && setting.user_value != "" && qualityItem.name == Cura.MachineManager.activeQualityOrQualityChangesName font.strikeout: styleData.column == 1 && setting.user_value != "" && base.isQualityItemCurrentlyActivated
font.italic: setting.profile_value_source == "quality_changes" || (setting.user_value != "" && qualityItem.name == Cura.MachineManager.activeQualityOrQualityChangesName) font.italic: setting.profile_value_source == "quality_changes" || (setting.user_value != "" && base.isQualityItemCurrentlyActivated)
opacity: font.strikeout ? 0.5 : 1 opacity: font.strikeout ? 0.5 : 1
color: styleData.textColor color: styleData.textColor
elide: Text.ElideRight elide: Text.ElideRight
@ -63,7 +72,7 @@ Tab
{ {
role: "user_value" role: "user_value"
title: catalog.i18nc("@title:column", "Current"); title: catalog.i18nc("@title:column", "Current");
visible: qualityItem.name == Cura.MachineManager.activeQualityOrQualityChangesName visible: base.isQualityItemCurrentlyActivated
width: (parent.width * 0.18) | 0 width: (parent.width * 0.18) | 0
delegate: itemDelegate delegate: itemDelegate
} }
@ -86,7 +95,7 @@ Tab
{ {
id: qualitySettings id: qualitySettings
selectedPosition: base.extruderPosition selectedPosition: base.extruderPosition
selectedQualityItem: base.qualityItem selectedQualityItem: base.qualityItem == null ? {} : base.qualityItem
} }
SystemPalette { id: palette } SystemPalette { id: palette }

View file

@ -36,13 +36,15 @@ Item
text: catalog.i18nc("@title:tab", "Profiles") text: catalog.i18nc("@title:tab", "Profiles")
} }
property var hasCurrentItem: qualityListView.currentItem != null property var hasCurrentItem: base.currentItem != null
property var currentItem: { property var currentItem: {
var current_index = qualityListView.currentIndex; var current_index = qualityListView.currentIndex;
return qualitiesModel.getItem(current_index); return (current_index == -1) ? null : qualitiesModel.getItem(current_index);
} }
property var currentItemName: hasCurrentItem ? base.currentItem.name : ""
property var isCurrentItemActivated: { property var isCurrentItemActivated: {
if (!base.currentItem) { if (!base.currentItem) {
return false; return false;
@ -235,7 +237,7 @@ Item
icon: StandardIcon.Question; icon: StandardIcon.Question;
title: catalog.i18nc("@title:window", "Confirm Remove") title: catalog.i18nc("@title:window", "Confirm Remove")
text: catalog.i18nc("@label (%1 is object name)", "Are you sure you wish to remove %1? This cannot be undone!").arg(base.currentItem.name) text: catalog.i18nc("@label (%1 is object name)", "Are you sure you wish to remove %1? This cannot be undone!").arg(base.currentItemName)
standardButtons: StandardButton.Yes | StandardButton.No standardButtons: StandardButton.Yes | StandardButton.No
modality: Qt.ApplicationModal modality: Qt.ApplicationModal
@ -437,6 +439,7 @@ Item
Item Item
{ {
anchors.fill: parent anchors.fill: parent
visible: base.currentItem != null
Item // Profile title Label Item // Profile title Label
{ {
@ -446,7 +449,7 @@ Item
height: childrenRect.height height: childrenRect.height
Label { Label {
text: base.currentItem.name text: base.currentItemName
font: UM.Theme.getFont("large") font: UM.Theme.getFont("large")
} }
} }