Merge pull request #13848 from Ultimaker/CURA-9424_workspace_dialog_fixes

[CURA-9424] Workspace dialog fixes
This commit is contained in:
Casper Lamboo 2022-11-17 17:15:34 +01:00 committed by GitHub
commit ee75fa02aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 8 deletions

View file

@ -600,7 +600,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
self._dialog.setNumUserSettings(num_user_settings)
self._dialog.setActiveMode(active_mode)
self._dialog.setUpdatableMachines(updatable_machines)
self._dialog.setMachineToOverride(global_stack_id)
self._dialog.setMaterialLabels(material_labels)
self._dialog.setMachineType(machine_type)
self._dialog.setExtruders(extruders)
@ -616,6 +615,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
# The machine included in the project file exists locally already, no need to change selected printers.
is_networked_machine = global_stack.hasNetworkedConnection()
is_abstract_machine = parseBool(existing_global_stack.getMetaDataEntry("is_abstract_machine", False))
self._dialog.setMachineToOverride(global_stack.getId())
self._dialog.setResolveStrategy("machine", "override")
elif self._dialog.updatableMachinesModel.count > 0:
# The machine included in the project file does not exist. There is another machine of the same type.
# This will always default to an abstract machine first.
@ -623,13 +624,14 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
machine_name = machine["name"]
is_networked_machine = machine["isNetworked"]
is_abstract_machine = machine["isAbstractMachine"]
self._dialog.setResolveStrategy("machine", "override")
self._dialog.setMachineToOverride(machine["id"])
self._dialog.setResolveStrategy("machine", "override")
else:
# The machine included in the project file does not exist. There are no other printers of the same type. Default to "Create New".
machine_name = i18n_catalog.i18nc("@button", "Create new")
self._dialog.setIsAbstractMachine(False)
self._dialog.setIsNetworkedMachine(False)
is_networked_machine = False
is_abstract_machine = False
self._dialog.setMachineToOverride(None)
self._dialog.setResolveStrategy("machine", "new")
self._dialog.setIsNetworkedMachine(is_networked_machine)
@ -730,7 +732,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
application.expandedCategoriesChanged.emit() # Notify the GUI of the change
# If there are no machines of the same type, create a new machine.
if self._resolve_strategies["machine"] != "override" or self._dialog.updatableMachinesModel.count <= 1:
if self._resolve_strategies["machine"] != "override" or self._dialog.updatableMachinesModel.count == 0:
# We need to create a new machine
machine_name = self._container_registry.uniqueName(self._machine_info.name)

View file

@ -96,7 +96,7 @@ UM.Dialog
WorkspaceRow
{
leftLabelText: catalog.i18nc("@action:label", manager.isPrinterGroup ? "Printer Group" : "Printer Name")
rightLabelText: manager.machineName
rightLabelText: manager.machineName == catalog.i18nc("@button", "Create new") ? "" : manager.machineName
}
}
@ -195,6 +195,17 @@ UM.Dialog
model: resolveStrategiesModel
textRole: "label"
visible: manager.qualityChangesConflict
contentLeftPadding: UM.Theme.getSize("default_margin").width
textFont: UM.Theme.getFont("medium")
background: Cura.RoundedRectangle
{
border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("lining")
color: qualityChangesResolveComboBox.hovered ? UM.Theme.getColor("expandable_hover") : UM.Theme.getColor("action_button")
cornerSide: Cura.RoundedRectangle.Direction.All
radius: UM.Theme.getSize("default_radius").width
}
// This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded
currentIndex:
@ -238,6 +249,17 @@ UM.Dialog
model: resolveStrategiesModel
textRole: "label"
visible: manager.materialConflict
contentLeftPadding: UM.Theme.getSize("default_margin").width
textFont: UM.Theme.getFont("medium")
background: Cura.RoundedRectangle
{
border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("lining")
color: materialResolveComboBox.hovered ? UM.Theme.getColor("expandable_hover") : UM.Theme.getColor("action_button")
cornerSide: Cura.RoundedRectangle.Direction.All
radius: UM.Theme.getSize("default_radius").width
}
// This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded
currentIndex:

View file

@ -36,6 +36,7 @@ Item
anchors.verticalCenter: parent.verticalCenter
source: ""
height: UM.Theme.getSize("medium_button_icon").height
color: UM.Theme.getColor("text")
width: height
}
UM.Label
@ -95,6 +96,7 @@ Item
visible: comboboxTooltipText != ""
source: UM.Theme.getIcon("Help")
color: UM.Theme.getColor("text")
UM.ToolTip
{

View file

@ -20,6 +20,8 @@ ComboBox
property alias textFormat: contentLabel.textFormat
property alias backgroundColor: background.color
property bool forceHighlight: false
property int contentLeftPadding: UM.Theme.getSize("setting_unit_margin").width
property var textFont: UM.Theme.getFont("default")
enabled: delegateModel.count > 0
@ -104,9 +106,10 @@ ComboBox
contentItem: UM.Label
{
id: contentLabel
leftPadding: UM.Theme.getSize("setting_unit_margin").width + UM.Theme.getSize("default_margin").width
leftPadding: contentLeftPadding + UM.Theme.getSize("default_margin").width
anchors.right: downArrow.left
wrapMode: Text.NoWrap
font: textFont
text:
{
if (control.delegateModel.count == 0)
@ -176,11 +179,12 @@ ComboBox
id: delegateLabel
// FIXME: Somehow the top/bottom anchoring is not correct on Linux and it results in invisible texts.
anchors.fill: parent
anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width
anchors.leftMargin: contentLeftPadding
anchors.rightMargin: UM.Theme.getSize("setting_unit_margin").width
text: delegateItem.text
textFormat: control.textFormat
font: textFont
color: UM.Theme.getColor("setting_control_text")
elide: Text.ElideRight
wrapMode: Text.NoWrap