mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 11:17:49 -06:00
WIP: Refactor Profile management code
This commit is contained in:
parent
c29f3130a7
commit
65e01d6203
3 changed files with 40 additions and 50 deletions
|
@ -20,14 +20,6 @@ class QualitySettingsModel(ListModel):
|
|||
def __init__(self, parent = None):
|
||||
super().__init__(parent = parent)
|
||||
|
||||
self._container_registry = ContainerRegistry.getInstance()
|
||||
self._application = Application.getInstance()
|
||||
self._quality_manager = self._application._quality_manager
|
||||
|
||||
self._extruder_position = ""
|
||||
self._quality = None
|
||||
self._i18n_catalog = None
|
||||
|
||||
self.addRoleName(self.KeyRole, "key")
|
||||
self.addRoleName(self.LabelRole, "label")
|
||||
self.addRoleName(self.UnitRole, "unit")
|
||||
|
@ -36,36 +28,43 @@ class QualitySettingsModel(ListModel):
|
|||
self.addRoleName(self.UserValueRole, "user_value")
|
||||
self.addRoleName(self.CategoryRole, "category")
|
||||
|
||||
self._empty_quality = self._container_registry.findInstanceContainers(id = "empty_quality")[0]
|
||||
self._container_registry = ContainerRegistry.getInstance()
|
||||
self._application = Application.getInstance()
|
||||
self._quality_manager = self._application._quality_manager
|
||||
|
||||
self._extruder_position = ""
|
||||
self._quality_item = None
|
||||
self._i18n_catalog = None
|
||||
|
||||
self._update()
|
||||
self._quality_manager.qualitiesUpdated.connect(self._update)
|
||||
|
||||
self._update()
|
||||
|
||||
extruderPositionChanged = pyqtSignal()
|
||||
qualityChanged = pyqtSignal()
|
||||
qualityItemChanged = pyqtSignal()
|
||||
|
||||
def setExtruderPosition(self, extruder_position):
|
||||
if extruder_position != self._extruder_position:
|
||||
self._extruder_position = extruder_position
|
||||
self._update()
|
||||
self.extruderPositionChanged.emit()
|
||||
self._update()
|
||||
|
||||
@pyqtProperty(str, fset = setExtruderPosition, notify = extruderPositionChanged)
|
||||
def extruderPosition(self):
|
||||
return self._extruder_position
|
||||
|
||||
def setQuality(self, quality):
|
||||
if quality != self._quality:
|
||||
self._quality = quality
|
||||
def setQualityItem(self, quality_item):
|
||||
if quality_item != self._quality_item:
|
||||
self._quality_item = quality_item
|
||||
self.qualityItemChanged.emit()
|
||||
self._update()
|
||||
self.qualityChanged.emit()
|
||||
|
||||
@pyqtProperty("QVariantMap", fset = setQuality, notify = qualityChanged)
|
||||
def quality(self):
|
||||
return self._quality
|
||||
@pyqtProperty("QVariantMap", fset = setQualityItem, notify = qualityItemChanged)
|
||||
def qualityItem(self):
|
||||
return self._quality_item
|
||||
|
||||
def _update(self):
|
||||
if self._quality is None:
|
||||
if self._quality_item is None:
|
||||
self.setItems([])
|
||||
return
|
||||
|
||||
|
@ -74,8 +73,8 @@ class QualitySettingsModel(ListModel):
|
|||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||
definition_container = global_container_stack.definition
|
||||
|
||||
quality_group = self._quality["quality_group"]
|
||||
quality_changes_group = self._quality["quality_changes_group"]
|
||||
quality_group = self._quality_item["quality_group"]
|
||||
quality_changes_group = self._quality_item["quality_changes_group"]
|
||||
|
||||
if self._extruder_position == "":
|
||||
quality_node = quality_group.node_for_global
|
||||
|
|
|
@ -11,8 +11,8 @@ Tab
|
|||
{
|
||||
id: base
|
||||
|
||||
property string extruderPosition: "";
|
||||
property var quality: null;
|
||||
property string extruderPosition: ""
|
||||
property var qualityItem: null
|
||||
|
||||
TableView
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ Tab
|
|||
{
|
||||
id: qualitySettings
|
||||
extruderPosition: base.extruderPosition
|
||||
quality: base.quality != null ? base.quality : ""
|
||||
qualityItem: base.qualityItem
|
||||
}
|
||||
|
||||
SystemPalette { id: palette }
|
||||
|
|
|
@ -14,7 +14,7 @@ Item
|
|||
{
|
||||
id: base
|
||||
property var resetEnabled: false // Keep PreferencesDialog happy
|
||||
property var extrudersModel: Cura.ExtrudersModel{}
|
||||
property var extrudersModel: Cura.ExtrudersModel {}
|
||||
|
||||
UM.I18nCatalog { id: catalog; name: "cura"; }
|
||||
|
||||
|
@ -24,14 +24,12 @@ Item
|
|||
|
||||
Label {
|
||||
id: titleLabel
|
||||
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
margins: 5 * screenScaleFactor
|
||||
}
|
||||
|
||||
font.pointSize: 18
|
||||
text: catalog.i18nc("@title:tab", "Profiles")
|
||||
}
|
||||
|
@ -160,12 +158,12 @@ Item
|
|||
UM.RenameDialog
|
||||
{
|
||||
title: catalog.i18nc("@title:window", "Create Profile")
|
||||
id: newNameDialog;
|
||||
object: "<new name>";
|
||||
id: newNameDialog
|
||||
object: "<new name>"
|
||||
onAccepted:
|
||||
{
|
||||
var selectedContainer = Cura.ContainerManager.createQualityChanges(newName);
|
||||
objectList.currentIndex = -1 //Reset selection.
|
||||
qualityListView.currentIndex = -1 // TODO: Reset selection.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,12 +171,12 @@ Item
|
|||
UM.RenameDialog
|
||||
{
|
||||
title: catalog.i18nc("@title:window", "Duplicate Profile")
|
||||
id: newDuplicateNameDialog;
|
||||
object: "<new name>";
|
||||
id: newDuplicateNameDialog
|
||||
object: "<new name>"
|
||||
onAccepted:
|
||||
{
|
||||
Cura.ContainerManager.duplicateQualityChanges(newName, base.currentItem);
|
||||
objectList.currentIndex = -1 //Reset selection.
|
||||
qualityListView.currentIndex = -1; // TODO: Reset selection.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,10 +215,7 @@ Item
|
|||
left: parent.left
|
||||
}
|
||||
visible: text != ""
|
||||
text: {
|
||||
// OLD STUFF
|
||||
return catalog.i18nc("@label %1 is printer name", "Printer: %1").arg(Cura.MachineManager.activeMachineName);
|
||||
}
|
||||
text: catalog.i18nc("@label %1 is printer name", "Printer: %1").arg(Cura.MachineManager.activeMachineName)
|
||||
width: profileScrollView.width
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
@ -280,10 +275,8 @@ Item
|
|||
width: Math.floor((parent.width * 0.3))
|
||||
text: model.name
|
||||
elide: Text.ElideRight
|
||||
font.italic: { // TODO: make it easier
|
||||
return model.name == Cura.MachineManager.activeQualityOrQualityChangesName;
|
||||
}
|
||||
color: parent.ListView.isCurrentItem ? palette.highlightedText : palette.text;
|
||||
font.italic: model.name == Cura.MachineManager.activeQualityOrQualityChangesName // TODO: make it easier
|
||||
color: parent.ListView.isCurrentItem ? palette.highlightedText : palette.text
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -345,9 +338,7 @@ Item
|
|||
|
||||
Button
|
||||
{
|
||||
text: {
|
||||
return catalog.i18nc("@action:button", "Update profile with current settings/overrides");
|
||||
}
|
||||
text: catalog.i18nc("@action:button", "Update profile with current settings/overrides")
|
||||
enabled: Cura.MachineManager.hasUserSettings && !Cura.MachineManager.isReadOnly(Cura.MachineManager.activeQualityId)
|
||||
onClicked: Cura.ContainerManager.updateQualityChanges()
|
||||
}
|
||||
|
@ -397,8 +388,8 @@ Item
|
|||
|
||||
ProfileTab
|
||||
{
|
||||
title: catalog.i18nc("@title:tab", "Global Settings");
|
||||
quality: base.currentItem;
|
||||
title: catalog.i18nc("@title:tab", "Global Settings")
|
||||
qualityItem: base.currentItem
|
||||
}
|
||||
|
||||
Repeater
|
||||
|
@ -407,9 +398,9 @@ Item
|
|||
|
||||
ProfileTab
|
||||
{
|
||||
title: model.name;
|
||||
extruderPosition: model.index;
|
||||
quality: base.currentItem;
|
||||
title: model.name
|
||||
extruderPosition: model.index
|
||||
qualityItem: base.currentItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue