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