From 25a0355cfee91112e381dfd35813fdd9aa05d3b1 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 1 Nov 2022 16:20:09 +0100 Subject: [PATCH 01/48] Update dialog size CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 4899c6873a..30db1174cc 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -14,9 +14,11 @@ UM.Dialog id: base title: catalog.i18nc("@title:window", "Open Project") - minimumWidth: UM.Theme.getSize("popup_dialog").width - minimumHeight: UM.Theme.getSize("popup_dialog").height + minimumWidth: UM.Theme.getSize("modal_window_minimum").width + minimumHeight: UM.Theme.getSize("modal_window_minimum").height width: minimumWidth + height: minimumHeight + backgroundColor: UM.Theme.getColor("main_background") margin: UM.Theme.getSize("default_margin").width property int comboboxHeight: UM.Theme.getSize("default_margin").height From afd3d92c5ee07bb8c850dfe882b1ce2a843734c6 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 1 Nov 2022 16:28:23 +0100 Subject: [PATCH 02/48] Use wide button spacing CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 30db1174cc..4f7d5737e6 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -502,7 +502,7 @@ UM.Dialog } } - buttonSpacing: UM.Theme.getSize("default_margin").width + buttonSpacing: UM.Theme.getSize("wide_margin").width rightButtons: [ Cura.TertiaryButton From fa317a9e140b144cb36c2eb4e97b84782921687b Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 1 Nov 2022 16:31:24 +0100 Subject: [PATCH 03/48] Use unique id for WorkspaceDialog CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 4f7d5737e6..d56ffef7dd 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -11,7 +11,7 @@ import Cura 1.1 as Cura UM.Dialog { - id: base + id: workspaceDialog title: catalog.i18nc("@title:window", "Open Project") minimumWidth: UM.Theme.getSize("modal_window_minimum").width @@ -107,7 +107,7 @@ UM.Dialog anchors.right: parent.right width: (parent.width / 3) | 0 height: visible ? comboboxHeight : 0 - visible: base.visible && machineResolveComboBox.model.count > 1 + visible: workspaceDialog.visible && machineResolveComboBox.model.count > 1 text: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?") Cura.ComboBox { @@ -461,14 +461,14 @@ UM.Dialog color: warning ? UM.Theme.getColor("warning") : "transparent" anchors.bottom: parent.bottom width: parent.width - height: childrenRect.height + 2 * base.margin + height: childrenRect.height + 2 * workspaceDialog.margin Column { height: childrenRect.height - spacing: base.margin + spacing: workspaceDialog.margin - anchors.margins: base.margin + anchors.margins: workspaceDialog.margin anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top @@ -478,7 +478,7 @@ UM.Dialog id: warningRow height: childrenRect.height visible: warning - spacing: base.margin + spacing: workspaceDialog.margin UM.ColorImage { width: UM.Theme.getSize("extruder_icon").width From 41fd36a03836eb6d90d88560fcacad380dfafce6 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 1 Nov 2022 17:10:24 +0100 Subject: [PATCH 04/48] Adjust margins CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index d56ffef7dd..1bd2cf32c0 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -82,17 +82,10 @@ UM.Dialog UM.Label { id: titleLabel + anchors.margins: UM.Theme.getSize("default_margin").height text: catalog.i18nc("@action:title", "Summary - Cura Project") font: UM.Theme.getFont("large") } - - Rectangle - { - id: separator - color: UM.Theme.getColor("text") - width: parent.width - height: UM.Theme.getSize("default_lining").height - } } Item @@ -160,6 +153,7 @@ UM.Dialog { width: parent.width height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").height UM.Label { @@ -236,6 +230,7 @@ UM.Dialog { width: parent.width height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").height UM.Label { @@ -352,6 +347,7 @@ UM.Dialog { width: parent.width height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").height Row { height: childrenRect.height @@ -393,6 +389,7 @@ UM.Dialog { width: parent.width height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").height UM.Label { From b01ff2f57e743acd84677e9a21a1e539f57a8c0f Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 1 Nov 2022 17:10:59 +0100 Subject: [PATCH 05/48] Add open with above printer drop down. CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 1bd2cf32c0..51b9e8e4e9 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -78,6 +78,7 @@ UM.Dialog { width: parent.width height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").height UM.Label { @@ -102,9 +103,21 @@ UM.Dialog height: visible ? comboboxHeight : 0 visible: workspaceDialog.visible && machineResolveComboBox.model.count > 1 text: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?") + + UM.Label + { + id: open_with_label + anchors.top: parent.top + anchors.left: parent.left + text: catalog.i18nc("@action:label", "Open With") + font: UM.Theme.getFont("default_bold") + } + Cura.ComboBox { id: machineResolveComboBox + anchors.top: open_with_label.bottom + anchors.left: parent.left model: manager.updatableMachinesModel visible: machineResolveStrategyTooltip.visible textRole: "displayName" From f72c980c208ac25e7c05380c69ed4e3e0c90f966 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 1 Nov 2022 18:19:50 +0100 Subject: [PATCH 06/48] Add icons to the left of titles Align title text with values in table CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 213 +++++++++++++++++--------- 1 file changed, 144 insertions(+), 69 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 51b9e8e4e9..48499c1d91 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -93,6 +93,7 @@ UM.Dialog { width: parent.width height: childrenRect.height + anchors.leftMargin: UM.Theme.getSize("default_margin") UM.TooltipArea { @@ -109,6 +110,7 @@ UM.Dialog id: open_with_label anchors.top: parent.top anchors.left: parent.left + anchors.bottomMargin: UM.Theme.getSize("default_margin").height text: catalog.i18nc("@action:label", "Open With") font: UM.Theme.getFont("default_bold") } @@ -162,18 +164,36 @@ UM.Dialog } } + Row + { + id: printerSettingsTitleRow + anchors.top: parent.top + anchors.bottomMargin: UM.Theme.getSize("default_margin").height + spacing: UM.Theme.getSize("default_margin").width + + UM.ColorImage + { + anchors.verticalCenter: parent.verticalCenter + source: UM.Theme.getIcon("Printer") + height: UM.Theme.getSize("medium_button_icon").height + width: height + } + UM.Label + { + text: catalog.i18nc("@action:label", "Printer settings") + anchors.verticalCenter: parent.verticalCenter + font: UM.Theme.getFont("default_bold") + } + } + Column { + id: printerSettingsValuesTable width: parent.width height: childrenRect.height spacing: UM.Theme.getSize("default_margin").height - - UM.Label - { - id: printer_settings_label - text: catalog.i18nc("@action:label", "Printer settings") - font: UM.Theme.getFont("default_bold") - } + leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + anchors.top: printerSettingsTitleRow.bottom Row { @@ -239,17 +259,36 @@ UM.Dialog } } - Column + Row { - width: parent.width - height: childrenRect.height - spacing: UM.Theme.getSize("default_margin").height + id: profileSettingsTitleRow + anchors.top: parent.top + anchors.bottomMargin: UM.Theme.getSize("default_margin").height + spacing: UM.Theme.getSize("default_margin").width + UM.ColorImage + { + anchors.verticalCenter: parent.verticalCenter + source: UM.Theme.getIcon("Printer") + height: UM.Theme.getSize("medium_button_icon").height + width: height + } UM.Label { text: catalog.i18nc("@action:label", "Profile settings") + anchors.verticalCenter: parent.verticalCenter font: UM.Theme.getFont("default_bold") } + } + + Column + { + id: profileSettingsValuesTable + width: parent.width + height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").height + leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + anchors.top: profileSettingsTitleRow.bottom Row { @@ -356,24 +395,35 @@ UM.Dialog } } + Row + { + id: materialSettingsTitleRow + anchors.top: parent.top + anchors.bottomMargin: UM.Theme.getSize("default_margin").height + spacing: UM.Theme.getSize("default_margin").width + + UM.ColorImage + { + anchors.verticalCenter: parent.verticalCenter + source: UM.Theme.getIcon("Printer") + height: UM.Theme.getSize("medium_button_icon").height + width: height + } + UM.Label + { + text: catalog.i18nc("@action:label", "Material settings") + anchors.verticalCenter: parent.verticalCenter + font: UM.Theme.getFont("default_bold") + } + } + Column { width: parent.width height: childrenRect.height spacing: UM.Theme.getSize("default_margin").height - Row - { - height: childrenRect.height - width: parent.width - spacing: UM.Theme.getSize("narrow_margin").width - - UM.Label - { - text: catalog.i18nc("@action:label", "Material settings") - font: UM.Theme.getFont("default_bold") - width: (parent.width / 3) | 0 - } - } + leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + anchors.top: materialSettingsTitleRow.bottom Repeater { @@ -398,67 +448,92 @@ UM.Dialog } } - Column + Item { width: parent.width height: childrenRect.height - spacing: UM.Theme.getSize("default_margin").height - UM.Label + Row { - text: catalog.i18nc("@action:label", "Setting visibility") - font: UM.Theme.getFont("default_bold") + id: visibilitySettingsTitleRow + anchors.top: parent.top + anchors.bottomMargin: UM.Theme.getSize("default_margin").height + spacing: UM.Theme.getSize("default_margin").width + + UM.ColorImage + { + anchors.verticalCenter: parent.verticalCenter + source: UM.Theme.getIcon("Printer") + height: UM.Theme.getSize("medium_button_icon").height + width: height + } + UM.Label + { + text: catalog.i18nc("@action:label", "Setting visibility") + anchors.verticalCenter: parent.verticalCenter + font: UM.Theme.getFont("default_bold") + } } + + Column + { + width: parent.width + height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").height + leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + anchors.top: visibilitySettingsTitleRow.bottom + + Row + { + width: parent.width + height: childrenRect.height + UM.Label + { + text: catalog.i18nc("@action:label", "Mode") + width: (parent.width / 3) | 0 + } + UM.Label + { + text: manager.activeMode + width: (parent.width / 3) | 0 + } + } + Row + { + width: parent.width + height: childrenRect.height + visible: manager.hasVisibleSettingsField + UM.Label + { + text: catalog.i18nc("@action:label", "Visible settings:") + width: (parent.width / 3) | 0 + } + UM.Label + { + text: catalog.i18nc("@action:label", "%1 out of %2" ).arg(manager.numVisibleSettings).arg(manager.totalNumberOfSettings) + width: (parent.width / 3) | 0 + } + } + } + Row { width: parent.width height: childrenRect.height - UM.Label + visible: manager.hasObjectsOnPlate + UM.ColorImage { - text: catalog.i18nc("@action:label", "Mode") - width: (parent.width / 3) | 0 + width: warningLabel.height + height: width + source: UM.Theme.getIcon("Information") + color: UM.Theme.getColor("text") } UM.Label { - text: manager.activeMode - width: (parent.width / 3) | 0 + id: warningLabel + text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the build plate.") } } - Row - { - width: parent.width - height: childrenRect.height - visible: manager.hasVisibleSettingsField - UM.Label - { - text: catalog.i18nc("@action:label", "Visible settings:") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: catalog.i18nc("@action:label", "%1 out of %2" ).arg(manager.numVisibleSettings).arg(manager.totalNumberOfSettings) - width: (parent.width / 3) | 0 - } - } - } - - Row - { - width: parent.width - height: childrenRect.height - visible: manager.hasObjectsOnPlate - UM.ColorImage - { - width: warningLabel.height - height: width - source: UM.Theme.getIcon("Information") - color: UM.Theme.getColor("text") - } - UM.Label - { - id: warningLabel - text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the build plate.") - } } } } From d12b59ec0f47e2c92b7fd03b31f55c26dd25113b Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 2 Nov 2022 14:17:05 +0100 Subject: [PATCH 07/48] Refactor workspace sections into separate qml file. Refactor an existing hack to force trigger the onIndexChanged functions of the comboboxes. CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 367 +++++++++---------------- plugins/3MFReader/WorkspaceSection.qml | 99 +++++++ 2 files changed, 222 insertions(+), 244 deletions(-) create mode 100644 plugins/3MFReader/WorkspaceSection.qml diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 48499c1d91..187d49693a 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Ultimaker B.V. +// Copyright (c) 2022 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10 @@ -28,9 +28,12 @@ UM.Dialog { if (visible) { - machineResolveComboBox.currentIndex = 0 - qualityChangesResolveComboBox.currentIndex = 0 - materialResolveComboBox.currentIndex = 0 + // Force relead the comboboxes + // Since this dialog is only created once the first time you open it, these comboxes need to be reloaded + // each time it is shown after the first time so that the indexes will update correctly. + materialSection.reloadValues() + profileSection.reloadValues() + printerSection.reloadValues() } } @@ -89,111 +92,15 @@ UM.Dialog } } - Item + WorkspaceSection { - width: parent.width - height: childrenRect.height - anchors.leftMargin: UM.Theme.getSize("default_margin") - - UM.TooltipArea + id: printerSection + title: catalog.i18nc("@action:label", "Printer settings") + iconSource: UM.Theme.getIcon("Printer") + content: Column { - id: machineResolveStrategyTooltip - anchors.top: parent.top - anchors.right: parent.right - width: (parent.width / 3) | 0 - height: visible ? comboboxHeight : 0 - visible: workspaceDialog.visible && machineResolveComboBox.model.count > 1 - text: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?") - - UM.Label - { - id: open_with_label - anchors.top: parent.top - anchors.left: parent.left - anchors.bottomMargin: UM.Theme.getSize("default_margin").height - text: catalog.i18nc("@action:label", "Open With") - font: UM.Theme.getFont("default_bold") - } - - Cura.ComboBox - { - id: machineResolveComboBox - anchors.top: open_with_label.bottom - anchors.left: parent.left - model: manager.updatableMachinesModel - visible: machineResolveStrategyTooltip.visible - textRole: "displayName" - width: parent.width - height: UM.Theme.getSize("button").height - onCurrentIndexChanged: - { - if (model.getItem(currentIndex).id == "new" - && model.getItem(currentIndex).type == "default_option") - { - manager.setResolveStrategy("machine", "new") - } - else - { - manager.setResolveStrategy("machine", "override") - manager.setMachineToOverride(model.getItem(currentIndex).id) - } - } - - onVisibleChanged: - { - if (!visible) {return} - - currentIndex = 0 - // If the project printer exists in Cura, set it as the default dropdown menu option. - // No need to check object 0, which is the "Create new" option - for (var i = 1; i < model.count; i++) - { - if (model.getItem(i).name == manager.machineName) - { - currentIndex = i - break - } - } - // The project printer does not exist in Cura. If there is at least one printer of the same - // type, select the first one, else set the index to "Create new" - if (currentIndex == 0 && model.count > 1) - { - currentIndex = 1 - } - } - } - } - - Row - { - id: printerSettingsTitleRow - anchors.top: parent.top - anchors.bottomMargin: UM.Theme.getSize("default_margin").height - spacing: UM.Theme.getSize("default_margin").width - - UM.ColorImage - { - anchors.verticalCenter: parent.verticalCenter - source: UM.Theme.getIcon("Printer") - height: UM.Theme.getSize("medium_button_icon").height - width: height - } - UM.Label - { - text: catalog.i18nc("@action:label", "Printer settings") - anchors.verticalCenter: parent.verticalCenter - font: UM.Theme.getFont("default_bold") - } - } - - Column - { - id: printerSettingsValuesTable - width: parent.width - height: childrenRect.height spacing: UM.Theme.getSize("default_margin").height leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - anchors.top: printerSettingsTitleRow.bottom Row { @@ -230,65 +137,66 @@ UM.Dialog } } } - } - Item - { - width: parent.width - height: childrenRect.height - - UM.TooltipArea + comboboxTitle: catalog.i18nc("@action:label", "Open With") + comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?") + combobox: Cura.ComboBox { - anchors.right: parent.right - anchors.top: parent.top - width: (parent.width / 3) | 0 - height: visible ? comboboxHeight : 0 - visible: manager.qualityChangesConflict - text: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?") - Cura.ComboBox + id: machineResolveComboBox + model: manager.updatableMachinesModel + textRole: "displayName" + visible: workspaceDialog.visible && model.count > 1 + currentIndex: machineVisibleChanged() + + onCurrentIndexChanged: { - model: resolveStrategiesModel - textRole: "label" - id: qualityChangesResolveComboBox - width: parent.width - height: UM.Theme.getSize("button").height - onActivated: + if (model.getItem(currentIndex).id == "new" + && model.getItem(currentIndex).type == "default_option") { - manager.setResolveStrategy("quality_changes", resolveStrategiesModel.get(index).key) + manager.setResolveStrategy("machine", "new") + } + else + { + manager.setResolveStrategy("machine", "override") + manager.setMachineToOverride(model.getItem(currentIndex).id) + } + } + + function machineVisibleChanged() + { + if (!visible) {return} + + currentIndex = 0 + // If the project printer exists in Cura, set it as the default dropdown menu option. + // No need to check object 0, which is the "Create new" option + for (var i = 1; i < model.count; i++) + { + if (model.getItem(i).name == manager.machineName) + { + currentIndex = i + break + } + } + // The project printer does not exist in Cura. If there is at least one printer of the same + // type, select the first one, else set the index to "Create new" + if (currentIndex == 0 && model.count > 1) + { + currentIndex = 1 } } } + } - Row - { - id: profileSettingsTitleRow - anchors.top: parent.top - anchors.bottomMargin: UM.Theme.getSize("default_margin").height - spacing: UM.Theme.getSize("default_margin").width - - UM.ColorImage - { - anchors.verticalCenter: parent.verticalCenter - source: UM.Theme.getIcon("Printer") - height: UM.Theme.getSize("medium_button_icon").height - width: height - } - UM.Label - { - text: catalog.i18nc("@action:label", "Profile settings") - anchors.verticalCenter: parent.verticalCenter - font: UM.Theme.getFont("default_bold") - } - } - - Column + WorkspaceSection + { + id: profileSection + title: catalog.i18nc("@action:label", "Profile settings") + iconSource: UM.Theme.getIcon("Printer") + content: Column { id: profileSettingsValuesTable - width: parent.width - height: childrenRect.height spacing: UM.Theme.getSize("default_margin").height leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - anchors.top: profileSettingsTitleRow.bottom Row { @@ -365,65 +273,38 @@ UM.Dialog } } } + + comboboxTitle: catalog.i18nc("@action:label", "Open With") + comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?") + combobox: Cura.ComboBox + { + id: qualityChangesResolveComboBox + model: resolveStrategiesModel + textRole: "label" + visible: manager.qualityChangesConflict + + // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded + currentIndex: + { + currentIndex = 0 + } + + onCurrentIndexChanged: + { + manager.setResolveStrategy("quality_changes", resolveStrategiesModel.get(currentIndex).key) + } + } } - Item + WorkspaceSection { - width: parent.width - height: childrenRect.height - - UM.TooltipArea + id: materialSection + title: catalog.i18nc("@action:label", "Material settings") + iconSource: UM.Theme.getIcon("Printer") + content: Column { - id: materialResolveTooltip - anchors.right: parent.right - anchors.top: parent.top - width: (parent.width / 3) | 0 - height: visible ? comboboxHeight : 0 - visible: manager.materialConflict - text: catalog.i18nc("@info:tooltip", "How should the conflict in the material be resolved?") - Cura.ComboBox - { - model: resolveStrategiesModel - textRole: "label" - id: materialResolveComboBox - width: parent.width - height: UM.Theme.getSize("button").height - onActivated: - { - manager.setResolveStrategy("material", resolveStrategiesModel.get(index).key) - } - } - } - - Row - { - id: materialSettingsTitleRow - anchors.top: parent.top - anchors.bottomMargin: UM.Theme.getSize("default_margin").height - spacing: UM.Theme.getSize("default_margin").width - - UM.ColorImage - { - anchors.verticalCenter: parent.verticalCenter - source: UM.Theme.getIcon("Printer") - height: UM.Theme.getSize("medium_button_icon").height - width: height - } - UM.Label - { - text: catalog.i18nc("@action:label", "Material settings") - anchors.verticalCenter: parent.verticalCenter - font: UM.Theme.getFont("default_bold") - } - } - - Column - { - width: parent.width - height: childrenRect.height spacing: UM.Theme.getSize("default_margin").height leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - anchors.top: materialSettingsTitleRow.bottom Repeater { @@ -446,42 +327,39 @@ UM.Dialog } } } - } - Item - { - width: parent.width - height: childrenRect.height + comboboxTitle: catalog.i18nc("@action:label", "Open With") + comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the material be resolved?") - Row + combobox: Cura.ComboBox { - id: visibilitySettingsTitleRow - anchors.top: parent.top - anchors.bottomMargin: UM.Theme.getSize("default_margin").height - spacing: UM.Theme.getSize("default_margin").width + id: materialResolveComboBox + model: resolveStrategiesModel + textRole: "label" + visible: manager.materialConflict - UM.ColorImage + // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded + currentIndex: { - anchors.verticalCenter: parent.verticalCenter - source: UM.Theme.getIcon("Printer") - height: UM.Theme.getSize("medium_button_icon").height - width: height + currentIndex = 0 } - UM.Label + + onCurrentIndexChanged: { - text: catalog.i18nc("@action:label", "Setting visibility") - anchors.verticalCenter: parent.verticalCenter - font: UM.Theme.getFont("default_bold") + manager.setResolveStrategy("material", resolveStrategiesModel.get(currentIndex).key) } } + } - Column + WorkspaceSection + { + id: visibilitySection + title: catalog.i18nc("@action:label", "Setting visibility") + iconSource: UM.Theme.getIcon("Printer") + content: Column { - width: parent.width - height: childrenRect.height spacing: UM.Theme.getSize("default_margin").height leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - anchors.top: visibilitySettingsTitleRow.bottom Row { @@ -515,24 +393,25 @@ UM.Dialog } } } + } - Row + Row + { + id: clearBuildPlateWarning + width: parent.width + height: childrenRect.height + visible: manager.hasObjectsOnPlate + UM.ColorImage { - width: parent.width - height: childrenRect.height - visible: manager.hasObjectsOnPlate - UM.ColorImage - { - width: warningLabel.height - height: width - source: UM.Theme.getIcon("Information") - color: UM.Theme.getColor("text") - } - UM.Label - { - id: warningLabel - text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the build plate.") - } + width: warningLabel.height + height: width + source: UM.Theme.getIcon("Information") + color: UM.Theme.getColor("text") + } + UM.Label + { + id: warningLabel + text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the build plate.") } } } diff --git a/plugins/3MFReader/WorkspaceSection.qml b/plugins/3MFReader/WorkspaceSection.qml new file mode 100644 index 0000000000..03cf18ccdb --- /dev/null +++ b/plugins/3MFReader/WorkspaceSection.qml @@ -0,0 +1,99 @@ +// Copyright (c) 2022 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 +import QtQuick.Window 2.2 + +import UM 1.5 as UM +import Cura 1.1 as Cura + + +Item +{ + property alias title: sectionTitle.text + property alias iconSource: sectionTitleIcon.source + property Component content: Item { visible: false } + + property alias comboboxTitle: comboboxLabel.text + property Component combobox: Item { visible: false } + property var comboboxTooltipText: "" + property var comboboxVisible: false + + + + width: parent.width + height: childrenRect.height + anchors.leftMargin: UM.Theme.getSize("default_margin").width + + UM.TooltipArea + { + id: comboboxTooltip + width: (parent.width / 3) | 0 + height: visible ? UM.Theme.getSize("default_margin").heightcomboboxHeight : 0 + anchors.top: parent.top + anchors.right: parent.right + visible: combobox.visible + text: comboboxTooltipText + + UM.Label + { + id: comboboxLabel + anchors.top: parent.top + anchors.left: parent.left + anchors.bottomMargin: UM.Theme.getSize("default_margin").height + visible: combobox.visible + text: "" + font: UM.Theme.getFont("default_bold") + } + + Loader + { + id: comboboxLoader + width: parent.width + height: UM.Theme.getSize("button").height + anchors.top: comboboxLabel.bottom + anchors.left: parent.left + sourceComponent: combobox + } + } + + Row + { + id: sectionTitleRow + anchors.top: parent.top + anchors.bottomMargin: UM.Theme.getSize("default_margin").height + spacing: UM.Theme.getSize("default_margin").width + + UM.ColorImage + { + id: sectionTitleIcon + anchors.verticalCenter: parent.verticalCenter + source: "" + height: UM.Theme.getSize("medium_button_icon").height + width: height + } + UM.Label + { + id: sectionTitle + text: "" + anchors.verticalCenter: parent.verticalCenter + font: UM.Theme.getFont("default_bold") + } + } + + Loader + { + width: parent.width + height: content.height + anchors.top: sectionTitleRow.bottom + sourceComponent: content + } + + function reloadValues() + { + comboboxLoader.sourceComponent = null + comboboxLoader.sourceComponent = combobox + } +} \ No newline at end of file From cde07b9fe443a21339917e60cd5ba36e924c4692 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 2 Nov 2022 14:18:47 +0100 Subject: [PATCH 08/48] move signal function to bottom of file CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 187d49693a..705fe2afe8 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -23,20 +23,6 @@ UM.Dialog margin: UM.Theme.getSize("default_margin").width property int comboboxHeight: UM.Theme.getSize("default_margin").height - onClosing: manager.notifyClosed() - onVisibleChanged: - { - if (visible) - { - // Force relead the comboboxes - // Since this dialog is only created once the first time you open it, these comboxes need to be reloaded - // each time it is shown after the first time so that the indexes will update correctly. - materialSection.reloadValues() - profileSection.reloadValues() - printerSection.reloadValues() - } - } - Flickable { clip: true @@ -498,6 +484,19 @@ UM.Dialog } ] + onClosing: manager.notifyClosed() onRejected: manager.onCancelButtonClicked() onAccepted: manager.onOkButtonClicked() + onVisibleChanged: + { + if (visible) + { + // Force relead the comboboxes + // Since this dialog is only created once the first time you open it, these comboxes need to be reloaded + // each time it is shown after the first time so that the indexes will update correctly. + materialSection.reloadValues() + profileSection.reloadValues() + printerSection.reloadValues() + } + } } From 3a07d14b4b588ee94636515ab42dbf40c391a3b3 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 2 Nov 2022 14:19:35 +0100 Subject: [PATCH 09/48] remove comboboxheight CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 1 - plugins/3MFReader/WorkspaceSection.qml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 705fe2afe8..f6d60be46b 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -21,7 +21,6 @@ UM.Dialog backgroundColor: UM.Theme.getColor("main_background") margin: UM.Theme.getSize("default_margin").width - property int comboboxHeight: UM.Theme.getSize("default_margin").height Flickable { diff --git a/plugins/3MFReader/WorkspaceSection.qml b/plugins/3MFReader/WorkspaceSection.qml index 03cf18ccdb..572018dea9 100644 --- a/plugins/3MFReader/WorkspaceSection.qml +++ b/plugins/3MFReader/WorkspaceSection.qml @@ -31,7 +31,7 @@ Item { id: comboboxTooltip width: (parent.width / 3) | 0 - height: visible ? UM.Theme.getSize("default_margin").heightcomboboxHeight : 0 + height: visible ? UM.Theme.getSize("default_margin").height : 0 anchors.top: parent.top anchors.right: parent.right visible: combobox.visible From 25ecb0e62161ee9c0cf9b5bb8eb7479d37080813 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 2 Nov 2022 14:21:37 +0100 Subject: [PATCH 10/48] Make types specific Remove unused imports CURA-9424 --- plugins/3MFReader/WorkspaceSection.qml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/plugins/3MFReader/WorkspaceSection.qml b/plugins/3MFReader/WorkspaceSection.qml index 572018dea9..b3296a8b67 100644 --- a/plugins/3MFReader/WorkspaceSection.qml +++ b/plugins/3MFReader/WorkspaceSection.qml @@ -3,11 +3,9 @@ import QtQuick 2.10 import QtQuick.Controls 2.3 -import QtQuick.Layouts 1.3 -import QtQuick.Window 2.2 + import UM 1.5 as UM -import Cura 1.1 as Cura Item @@ -18,10 +16,8 @@ Item property alias comboboxTitle: comboboxLabel.text property Component combobox: Item { visible: false } - property var comboboxTooltipText: "" - property var comboboxVisible: false - - + property string comboboxTooltipText: "" + property bool comboboxVisible: false width: parent.width height: childrenRect.height From 1764c338a044080c3f310dc11c4e9ac9c4ba3c8f Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 2 Nov 2022 14:23:36 +0100 Subject: [PATCH 11/48] fix visibility check CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 3 +++ plugins/3MFReader/WorkspaceSection.qml | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index f6d60be46b..30ffe05665 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -125,6 +125,7 @@ UM.Dialog comboboxTitle: catalog.i18nc("@action:label", "Open With") comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?") + comboboxVisible: workspaceDialog.visible && manager.updatableMachinesModel.count > 1 combobox: Cura.ComboBox { id: machineResolveComboBox @@ -261,6 +262,7 @@ UM.Dialog comboboxTitle: catalog.i18nc("@action:label", "Open With") comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?") + comboboxVisible: manager.qualityChangesConflict combobox: Cura.ComboBox { id: qualityChangesResolveComboBox @@ -315,6 +317,7 @@ UM.Dialog comboboxTitle: catalog.i18nc("@action:label", "Open With") comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the material be resolved?") + comboboxVisible: manager.materialConflict combobox: Cura.ComboBox { diff --git a/plugins/3MFReader/WorkspaceSection.qml b/plugins/3MFReader/WorkspaceSection.qml index b3296a8b67..cc0ddfbb65 100644 --- a/plugins/3MFReader/WorkspaceSection.qml +++ b/plugins/3MFReader/WorkspaceSection.qml @@ -30,7 +30,7 @@ Item height: visible ? UM.Theme.getSize("default_margin").height : 0 anchors.top: parent.top anchors.right: parent.right - visible: combobox.visible + visible: comboboxVisible text: comboboxTooltipText UM.Label @@ -39,7 +39,7 @@ Item anchors.top: parent.top anchors.left: parent.left anchors.bottomMargin: UM.Theme.getSize("default_margin").height - visible: combobox.visible + visible: comboboxVisible text: "" font: UM.Theme.getFont("default_bold") } From dbba1c411035a837725894729eb89f7a390b9e3f Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 2 Nov 2022 15:14:33 +0100 Subject: [PATCH 12/48] patch checking for base parent component of Combobox to check if it exists first. This should be refactored out some time. CURA-9424 --- resources/qml/Widgets/ComboBox.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/qml/Widgets/ComboBox.qml b/resources/qml/Widgets/ComboBox.qml index eac85bfb44..a7eeb33f6a 100644 --- a/resources/qml/Widgets/ComboBox.qml +++ b/resources/qml/Widgets/ComboBox.qml @@ -18,6 +18,7 @@ ComboBox property var defaultTextOnEmptyModel: catalog.i18nc("@label", "No items to select from") // Text displayed in the combobox when the model is empty property var defaultTextOnEmptyIndex: "" // Text displayed in the combobox when the model has items but no item is selected property alias textFormat: contentLabel.textFormat + property alias backgroundColor: background.color enabled: delegateModel.count > 0 @@ -45,7 +46,7 @@ ComboBox State { name: "highlighted" - when: (base.hovered || control.hovered) && !control.activeFocus + when: ((base != undefined && base.hovered) || control.hovered) && !control.activeFocus PropertyChanges { target: background @@ -56,6 +57,7 @@ ComboBox background: UM.UnderlineBackground { + id: background // Rectangle for highlighting when this combobox needs to pulse. Rectangle { From 7171249d3f56745acc227f57e8f07cf7a547a36a Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 2 Nov 2022 15:33:47 +0100 Subject: [PATCH 13/48] Adjust margins on dialog to match designs CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 616 ++++++++++++------------- plugins/3MFReader/WorkspaceSection.qml | 4 +- 2 files changed, 309 insertions(+), 311 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 30ffe05665..4a6ade7d08 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -20,7 +20,6 @@ UM.Dialog height: minimumHeight backgroundColor: UM.Theme.getColor("main_background") - margin: UM.Theme.getSize("default_margin").width Flickable { @@ -60,246 +59,135 @@ UM.Dialog { width: parent.width height: childrenRect.height - spacing: UM.Theme.getSize("default_margin").height + spacing: UM.Theme.getSize("wide_margin").height + + UM.Label + { + id: titleLabel + text: catalog.i18nc("@action:title", "Summary - Cura Project") + font: UM.Theme.getFont("large") + } Column { width: parent.width height: childrenRect.height spacing: UM.Theme.getSize("default_margin").height + leftPadding: UM.Theme.getSize("default_margin").width + rightPadding: UM.Theme.getSize("default_margin").width - UM.Label + WorkspaceSection { - id: titleLabel - anchors.margins: UM.Theme.getSize("default_margin").height - text: catalog.i18nc("@action:title", "Summary - Cura Project") - font: UM.Theme.getFont("large") - } - } - - WorkspaceSection - { - id: printerSection - title: catalog.i18nc("@action:label", "Printer settings") - iconSource: UM.Theme.getIcon("Printer") - content: Column - { - spacing: UM.Theme.getSize("default_margin").height - leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - - Row + id: printerSection + title: catalog.i18nc("@action:label", "Printer settings") + iconSource: UM.Theme.getIcon("Printer") + content: Column { - width: parent.width - height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").height + leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - UM.Label - { - text: catalog.i18nc("@action:label", "Type") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: manager.machineType - width: (parent.width / 3) | 0 - } - } - - Row - { - width: parent.width - height: childrenRect.height - - UM.Label - { - text: catalog.i18nc("@action:label", manager.isPrinterGroup ? "Printer Group" : "Printer Name") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: manager.machineName - width: (parent.width / 3) | 0 - wrapMode: Text.WordWrap - } - } - } - - comboboxTitle: catalog.i18nc("@action:label", "Open With") - comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?") - comboboxVisible: workspaceDialog.visible && manager.updatableMachinesModel.count > 1 - combobox: Cura.ComboBox - { - id: machineResolveComboBox - model: manager.updatableMachinesModel - textRole: "displayName" - visible: workspaceDialog.visible && model.count > 1 - currentIndex: machineVisibleChanged() - - onCurrentIndexChanged: - { - if (model.getItem(currentIndex).id == "new" - && model.getItem(currentIndex).type == "default_option") - { - manager.setResolveStrategy("machine", "new") - } - else - { - manager.setResolveStrategy("machine", "override") - manager.setMachineToOverride(model.getItem(currentIndex).id) - } - } - - function machineVisibleChanged() - { - if (!visible) {return} - - currentIndex = 0 - // If the project printer exists in Cura, set it as the default dropdown menu option. - // No need to check object 0, which is the "Create new" option - for (var i = 1; i < model.count; i++) - { - if (model.getItem(i).name == manager.machineName) - { - currentIndex = i - break - } - } - // The project printer does not exist in Cura. If there is at least one printer of the same - // type, select the first one, else set the index to "Create new" - if (currentIndex == 0 && model.count > 1) - { - currentIndex = 1 - } - } - } - } - - WorkspaceSection - { - id: profileSection - title: catalog.i18nc("@action:label", "Profile settings") - iconSource: UM.Theme.getIcon("Printer") - content: Column - { - id: profileSettingsValuesTable - spacing: UM.Theme.getSize("default_margin").height - leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - - Row - { - width: parent.width - height: childrenRect.height - - UM.Label - { - text: catalog.i18nc("@action:label", "Name") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: manager.qualityName - width: (parent.width / 3) | 0 - wrapMode: Text.WordWrap - } - } - - Row - { - width: parent.width - height: childrenRect.height - - UM.Label - { - text: catalog.i18nc("@action:label", "Intent") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: manager.intentName - width: (parent.width / 3) | 0 - wrapMode: Text.WordWrap - } - } - - Row - { - width: parent.width - height: childrenRect.height - - UM.Label - { - text: catalog.i18nc("@action:label", "Not in profile") - visible: manager.numUserSettings != 0 - width: (parent.width / 3) | 0 - } - UM.Label - { - text: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.numUserSettings).arg(manager.numUserSettings) - visible: manager.numUserSettings != 0 - width: (parent.width / 3) | 0 - } - } - - Row - { - width: parent.width - height: childrenRect.height - - UM.Label - { - text: catalog.i18nc("@action:label", "Derivative from") - visible: manager.numSettingsOverridenByQualityChanges != 0 - width: (parent.width / 3) | 0 - } - UM.Label - { - text: catalog.i18ncp("@action:label", "%1, %2 override", "%1, %2 overrides", manager.numSettingsOverridenByQualityChanges).arg(manager.qualityType).arg(manager.numSettingsOverridenByQualityChanges) - width: (parent.width / 3) | 0 - visible: manager.numSettingsOverridenByQualityChanges != 0 - wrapMode: Text.WordWrap - } - } - } - - comboboxTitle: catalog.i18nc("@action:label", "Open With") - comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?") - comboboxVisible: manager.qualityChangesConflict - combobox: Cura.ComboBox - { - id: qualityChangesResolveComboBox - model: resolveStrategiesModel - textRole: "label" - visible: manager.qualityChangesConflict - - // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded - currentIndex: - { - currentIndex = 0 - } - - onCurrentIndexChanged: - { - manager.setResolveStrategy("quality_changes", resolveStrategiesModel.get(currentIndex).key) - } - } - } - - WorkspaceSection - { - id: materialSection - title: catalog.i18nc("@action:label", "Material settings") - iconSource: UM.Theme.getIcon("Printer") - content: Column - { - spacing: UM.Theme.getSize("default_margin").height - leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - - Repeater - { - model: manager.materialLabels - delegate: Row + Row { width: parent.width height: childrenRect.height + + UM.Label + { + text: catalog.i18nc("@action:label", "Type") + width: (parent.width / 3) | 0 + } + UM.Label + { + text: manager.machineType + width: (parent.width / 3) | 0 + } + } + + Row + { + width: parent.width + height: childrenRect.height + + UM.Label + { + text: catalog.i18nc("@action:label", manager.isPrinterGroup ? "Printer Group" : "Printer Name") + width: (parent.width / 3) | 0 + } + UM.Label + { + text: manager.machineName + width: (parent.width / 3) | 0 + wrapMode: Text.WordWrap + } + } + } + + comboboxTitle: catalog.i18nc("@action:label", "Open With") + comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?") + comboboxVisible: workspaceDialog.visible && manager.updatableMachinesModel.count > 1 + combobox: Cura.ComboBox + { + id: machineResolveComboBox + model: manager.updatableMachinesModel + textRole: "displayName" + visible: workspaceDialog.visible && model.count > 1 + currentIndex: machineVisibleChanged() + + onCurrentIndexChanged: + { + if (model.getItem(currentIndex).id == "new" + && model.getItem(currentIndex).type == "default_option") + { + manager.setResolveStrategy("machine", "new") + } + else + { + manager.setResolveStrategy("machine", "override") + manager.setMachineToOverride(model.getItem(currentIndex).id) + } + } + + function machineVisibleChanged() + { + if (!visible) {return} + + currentIndex = 0 + // If the project printer exists in Cura, set it as the default dropdown menu option. + // No need to check object 0, which is the "Create new" option + for (var i = 1; i < model.count; i++) + { + if (model.getItem(i).name == manager.machineName) + { + currentIndex = i + break + } + } + // The project printer does not exist in Cura. If there is at least one printer of the same + // type, select the first one, else set the index to "Create new" + if (currentIndex == 0 && model.count > 1) + { + currentIndex = 1 + } + } + } + } + + WorkspaceSection + { + id: profileSection + title: catalog.i18nc("@action:label", "Profile settings") + iconSource: UM.Theme.getIcon("Printer") + content: Column + { + id: profileSettingsValuesTable + spacing: UM.Theme.getSize("default_margin").height + leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + + Row + { + width: parent.width + height: childrenRect.height + UM.Label { text: catalog.i18nc("@action:label", "Name") @@ -307,101 +195,211 @@ UM.Dialog } UM.Label { - text: modelData + text: manager.qualityName width: (parent.width / 3) | 0 wrapMode: Text.WordWrap } } + + Row + { + width: parent.width + height: childrenRect.height + + UM.Label + { + text: catalog.i18nc("@action:label", "Intent") + width: (parent.width / 3) | 0 + } + UM.Label + { + text: manager.intentName + width: (parent.width / 3) | 0 + wrapMode: Text.WordWrap + } + } + + Row + { + width: parent.width + height: childrenRect.height + + UM.Label + { + text: catalog.i18nc("@action:label", "Not in profile") + visible: manager.numUserSettings != 0 + width: (parent.width / 3) | 0 + } + UM.Label + { + text: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.numUserSettings).arg(manager.numUserSettings) + visible: manager.numUserSettings != 0 + width: (parent.width / 3) | 0 + } + } + + Row + { + width: parent.width + height: childrenRect.height + + UM.Label + { + text: catalog.i18nc("@action:label", "Derivative from") + visible: manager.numSettingsOverridenByQualityChanges != 0 + width: (parent.width / 3) | 0 + } + UM.Label + { + text: catalog.i18ncp("@action:label", "%1, %2 override", "%1, %2 overrides", manager.numSettingsOverridenByQualityChanges).arg(manager.qualityType).arg(manager.numSettingsOverridenByQualityChanges) + width: (parent.width / 3) | 0 + visible: manager.numSettingsOverridenByQualityChanges != 0 + wrapMode: Text.WordWrap + } + } + } + + comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?") + comboboxVisible: manager.qualityChangesConflict + combobox: Cura.ComboBox + { + id: qualityChangesResolveComboBox + model: resolveStrategiesModel + textRole: "label" + visible: manager.qualityChangesConflict + + // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded + currentIndex: + { + currentIndex = 0 + } + + onCurrentIndexChanged: + { + manager.setResolveStrategy("quality_changes", resolveStrategiesModel.get(currentIndex).key) + } + } + } + + WorkspaceSection + { + id: materialSection + title: catalog.i18nc("@action:label", "Material settings") + iconSource: UM.Theme.getIcon("Printer") + content: Column + { + spacing: UM.Theme.getSize("default_margin").height + leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + + Repeater + { + model: manager.materialLabels + delegate: Row + { + width: parent.width + height: childrenRect.height + UM.Label + { + text: catalog.i18nc("@action:label", "Name") + width: (parent.width / 3) | 0 + } + UM.Label + { + text: modelData + width: (parent.width / 3) | 0 + wrapMode: Text.WordWrap + } + } + } + } + + comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the material be resolved?") + comboboxVisible: manager.materialConflict + + combobox: Cura.ComboBox + { + id: materialResolveComboBox + model: resolveStrategiesModel + textRole: "label" + visible: manager.materialConflict + + // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded + currentIndex: + { + currentIndex = 0 + } + + onCurrentIndexChanged: + { + manager.setResolveStrategy("material", resolveStrategiesModel.get(currentIndex).key) + } + } + } + + WorkspaceSection + { + id: visibilitySection + title: catalog.i18nc("@action:label", "Setting visibility") + iconSource: UM.Theme.getIcon("Printer") + content: Column + { + spacing: UM.Theme.getSize("default_margin").height + leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + + Row + { + width: parent.width + height: childrenRect.height + UM.Label + { + text: catalog.i18nc("@action:label", "Mode") + width: (parent.width / 3) | 0 + } + UM.Label + { + text: manager.activeMode + width: (parent.width / 3) | 0 + } + } + Row + { + width: parent.width + height: childrenRect.height + visible: manager.hasVisibleSettingsField + UM.Label + { + text: catalog.i18nc("@action:label", "Visible settings:") + width: (parent.width / 3) | 0 + } + UM.Label + { + text: catalog.i18nc("@action:label", "%1 out of %2" ).arg(manager.numVisibleSettings).arg(manager.totalNumberOfSettings) + width: (parent.width / 3) | 0 + } + } } } - comboboxTitle: catalog.i18nc("@action:label", "Open With") - comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the material be resolved?") - comboboxVisible: manager.materialConflict - - combobox: Cura.ComboBox + Row { - id: materialResolveComboBox - model: resolveStrategiesModel - textRole: "label" - visible: manager.materialConflict - - // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded - currentIndex: + id: clearBuildPlateWarning + width: parent.width + height: childrenRect.height + visible: manager.hasObjectsOnPlate + UM.ColorImage { - currentIndex = 0 + width: warningLabel.height + height: width + source: UM.Theme.getIcon("Information") + color: UM.Theme.getColor("text") } - - onCurrentIndexChanged: + UM.Label { - manager.setResolveStrategy("material", resolveStrategiesModel.get(currentIndex).key) + id: warningLabel + text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the build plate.") } } } - - WorkspaceSection - { - id: visibilitySection - title: catalog.i18nc("@action:label", "Setting visibility") - iconSource: UM.Theme.getIcon("Printer") - content: Column - { - spacing: UM.Theme.getSize("default_margin").height - leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - - Row - { - width: parent.width - height: childrenRect.height - UM.Label - { - text: catalog.i18nc("@action:label", "Mode") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: manager.activeMode - width: (parent.width / 3) | 0 - } - } - Row - { - width: parent.width - height: childrenRect.height - visible: manager.hasVisibleSettingsField - UM.Label - { - text: catalog.i18nc("@action:label", "Visible settings:") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: catalog.i18nc("@action:label", "%1 out of %2" ).arg(manager.numVisibleSettings).arg(manager.totalNumberOfSettings) - width: (parent.width / 3) | 0 - } - } - } - } - - Row - { - id: clearBuildPlateWarning - width: parent.width - height: childrenRect.height - visible: manager.hasObjectsOnPlate - UM.ColorImage - { - width: warningLabel.height - height: width - source: UM.Theme.getIcon("Information") - color: UM.Theme.getColor("text") - } - UM.Label - { - id: warningLabel - text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the build plate.") - } - } } } } diff --git a/plugins/3MFReader/WorkspaceSection.qml b/plugins/3MFReader/WorkspaceSection.qml index cc0ddfbb65..f4e53b7cd7 100644 --- a/plugins/3MFReader/WorkspaceSection.qml +++ b/plugins/3MFReader/WorkspaceSection.qml @@ -38,8 +38,7 @@ Item id: comboboxLabel anchors.top: parent.top anchors.left: parent.left - anchors.bottomMargin: UM.Theme.getSize("default_margin").height - visible: comboboxVisible + visible: comboboxVisible && text != "" text: "" font: UM.Theme.getFont("default_bold") } @@ -50,6 +49,7 @@ Item width: parent.width height: UM.Theme.getSize("button").height anchors.top: comboboxLabel.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height anchors.left: parent.left sourceComponent: combobox } From b1e559ff1a831ef3675628096bae335f641da74b Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 2 Nov 2022 18:09:49 +0100 Subject: [PATCH 14/48] Add padding below section titles CURA-9424 --- plugins/3MFReader/WorkspaceSection.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/3MFReader/WorkspaceSection.qml b/plugins/3MFReader/WorkspaceSection.qml index f4e53b7cd7..575fc8fea5 100644 --- a/plugins/3MFReader/WorkspaceSection.qml +++ b/plugins/3MFReader/WorkspaceSection.qml @@ -59,7 +59,7 @@ Item { id: sectionTitleRow anchors.top: parent.top - anchors.bottomMargin: UM.Theme.getSize("default_margin").height + bottomPadding: UM.Theme.getSize("default_margin").height spacing: UM.Theme.getSize("default_margin").width UM.ColorImage From 8bb608348115cf6758ab4db8c9ef903bd1772919 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 2 Nov 2022 18:25:05 +0100 Subject: [PATCH 15/48] Create custom component for rows in WorkplaceDialog. CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 162 +++++--------------------- plugins/3MFReader/WorkspaceRow.qml | 34 ++++++ 2 files changed, 64 insertions(+), 132 deletions(-) create mode 100644 plugins/3MFReader/WorkspaceRow.qml diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 4a6ade7d08..b1428cd878 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -86,39 +86,16 @@ UM.Dialog spacing: UM.Theme.getSize("default_margin").height leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - Row + WorkspaceRow { - width: parent.width - height: childrenRect.height - - UM.Label - { - text: catalog.i18nc("@action:label", "Type") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: manager.machineType - width: (parent.width / 3) | 0 - } + leftLabelText: catalog.i18nc("@action:label", "Type") + rightLabelText: manager.machineType } - Row + WorkspaceRow { - width: parent.width - height: childrenRect.height - - UM.Label - { - text: catalog.i18nc("@action:label", manager.isPrinterGroup ? "Printer Group" : "Printer Name") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: manager.machineName - width: (parent.width / 3) | 0 - wrapMode: Text.WordWrap - } + leftLabelText: catalog.i18nc("@action:label", manager.isPrinterGroup ? "Printer Group" : "Printer Name") + rightLabelText: manager.machineName } } @@ -183,79 +160,30 @@ UM.Dialog spacing: UM.Theme.getSize("default_margin").height leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - Row + WorkspaceRow { - width: parent.width - height: childrenRect.height - - UM.Label - { - text: catalog.i18nc("@action:label", "Name") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: manager.qualityName - width: (parent.width / 3) | 0 - wrapMode: Text.WordWrap - } + leftLabelText: catalog.i18nc("@action:label", "Name") + rightLabelText: manager.qualityName } - Row + WorkspaceRow { - width: parent.width - height: childrenRect.height - - UM.Label - { - text: catalog.i18nc("@action:label", "Intent") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: manager.intentName - width: (parent.width / 3) | 0 - wrapMode: Text.WordWrap - } + leftLabelText: catalog.i18nc("@action:label", "Intent") + rightLabelText: manager.intentName } - Row + WorkspaceRow { - width: parent.width - height: childrenRect.height - - UM.Label - { - text: catalog.i18nc("@action:label", "Not in profile") - visible: manager.numUserSettings != 0 - width: (parent.width / 3) | 0 - } - UM.Label - { - text: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.numUserSettings).arg(manager.numUserSettings) - visible: manager.numUserSettings != 0 - width: (parent.width / 3) | 0 - } + leftLabelText: catalog.i18nc("@action:label", "Not in profile") + rightLabelText: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.numUserSettings).arg(manager.numUserSettings) + visible: manager.numUserSettings != 0 } - Row + WorkspaceRow { - width: parent.width - height: childrenRect.height - - UM.Label - { - text: catalog.i18nc("@action:label", "Derivative from") - visible: manager.numSettingsOverridenByQualityChanges != 0 - width: (parent.width / 3) | 0 - } - UM.Label - { - text: catalog.i18ncp("@action:label", "%1, %2 override", "%1, %2 overrides", manager.numSettingsOverridenByQualityChanges).arg(manager.qualityType).arg(manager.numSettingsOverridenByQualityChanges) - width: (parent.width / 3) | 0 - visible: manager.numSettingsOverridenByQualityChanges != 0 - wrapMode: Text.WordWrap - } + leftLabelText: catalog.i18nc("@action:label", "Derivative from") + rightLabelText: catalog.i18ncp("@action:label", "%1, %2 override", "%1, %2 overrides", manager.numSettingsOverridenByQualityChanges).arg(manager.qualityType).arg(manager.numSettingsOverridenByQualityChanges) + visible: manager.numSettingsOverridenByQualityChanges != 0 } } @@ -294,21 +222,10 @@ UM.Dialog Repeater { model: manager.materialLabels - delegate: Row + delegate: WorkspaceRow { - width: parent.width - height: childrenRect.height - UM.Label - { - text: catalog.i18nc("@action:label", "Name") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: modelData - width: (parent.width / 3) | 0 - wrapMode: Text.WordWrap - } + leftLabelText: catalog.i18nc("@action:label", "Name") + rightLabelText: modelData } } } @@ -346,36 +263,17 @@ UM.Dialog spacing: UM.Theme.getSize("default_margin").height leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - Row + WorkspaceRow { - width: parent.width - height: childrenRect.height - UM.Label - { - text: catalog.i18nc("@action:label", "Mode") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: manager.activeMode - width: (parent.width / 3) | 0 - } + leftLabelText: catalog.i18nc("@action:label", "Mode") + rightLabelText: manager.activeMode } - Row + + WorkspaceRow { - width: parent.width - height: childrenRect.height + leftLabelText: catalog.i18nc("@action:label", "%1 out of %2" ).arg(manager.numVisibleSettings).arg(manager.totalNumberOfSettings) + rightLabelText: manager.activeMode visible: manager.hasVisibleSettingsField - UM.Label - { - text: catalog.i18nc("@action:label", "Visible settings:") - width: (parent.width / 3) | 0 - } - UM.Label - { - text: catalog.i18nc("@action:label", "%1 out of %2" ).arg(manager.numVisibleSettings).arg(manager.totalNumberOfSettings) - width: (parent.width / 3) | 0 - } } } } diff --git a/plugins/3MFReader/WorkspaceRow.qml b/plugins/3MFReader/WorkspaceRow.qml new file mode 100644 index 0000000000..72cea7b5bd --- /dev/null +++ b/plugins/3MFReader/WorkspaceRow.qml @@ -0,0 +1,34 @@ +// Copyright (c) 2022 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 +import QtQuick.Window 2.2 + +import UM 1.5 as UM +import Cura 1.1 as Cura + +Row +{ + property alias leftLabelText: leftLabel.text + property alias rightLabelText: rightLabel.text + + width: parent.width + height: visible ? childrenRect.height : 0 + + UM.Label + { + id: leftLabel + text: catalog.i18nc("@action:label", "Type") + width: (parent.width / 4) | 0 + wrapMode: Text.WordWrap + } + UM.Label + { + id: rightLabel + text: manager.machineType + width: (parent.width / 3) | 0 + wrapMode: Text.WordWrap + } +} \ No newline at end of file From c987ef53159d9f561e4f0adea277a37367ea71c6 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 2 Nov 2022 18:30:46 +0100 Subject: [PATCH 16/48] Adjust warning label margins CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index b1428cd878..3467dfe90d 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -262,6 +262,7 @@ UM.Dialog { spacing: UM.Theme.getSize("default_margin").height leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + bottomPadding: UM.Theme.getSize("narrow_margin").height WorkspaceRow { @@ -283,7 +284,9 @@ UM.Dialog id: clearBuildPlateWarning width: parent.width height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").width visible: manager.hasObjectsOnPlate + UM.ColorImage { width: warningLabel.height From 6126135adb5798067622ca8135e9f7b308625213 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 3 Nov 2022 16:43:01 +0100 Subject: [PATCH 17/48] Adjust dialog margins. Move title into full width white square. CURA-9424 Co-authored-by: Casper Lamboo --- plugins/3MFReader/WorkspaceDialog.qml | 63 ++++++++++++++------------ plugins/3MFReader/WorkspaceSection.qml | 7 ++- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 3467dfe90d..f79fb6266a 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -14,33 +14,45 @@ UM.Dialog id: workspaceDialog title: catalog.i18nc("@title:window", "Open Project") + margin: UM.Theme.getSize("default_margin").width minimumWidth: UM.Theme.getSize("modal_window_minimum").width minimumHeight: UM.Theme.getSize("modal_window_minimum").height - width: minimumWidth - height: minimumHeight - backgroundColor: UM.Theme.getColor("main_background") + backgroundColor: UM.Theme.getColor("detail_background") - Flickable + headerComponent: Rectangle { - clip: true - width: parent.width - height: parent.height - contentHeight: dialogSummaryItem.height - ScrollBar.vertical: UM.ScrollBar { id: verticalScrollBar } + height: childrenRect.height + 2 * UM.Theme.getSize("default_margin").height + color: UM.Theme.getColor("main_background") - Item + UM.Label + { + id: titleLabel + text: catalog.i18nc("@action:title", "Summary - Cura Project") + font: UM.Theme.getFont("large") + anchors.top: parent.top + anchors.left: parent.left + anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.leftMargin: UM.Theme.getSize("default_margin").height + } + } + + Rectangle + { + anchors.fill: parent + UM.I18nCatalog { id: catalog; name: "cura" } + color: UM.Theme.getColor("main_background") + + Flickable { id: dialogSummaryItem - width: verticalScrollBar.visible ? parent.width - verticalScrollBar.width - UM.Theme.getSize("default_margin").width : parent.width - height: childrenRect.height - anchors.margins: 10 * screenScaleFactor + width: parent.width + height: parent.height - UM.I18nCatalog - { - id: catalog - name: "cura" - } + clip: true + + contentHeight: contentColumn.height + ScrollBar.vertical: UM.ScrollBar { id: scrollbar } ListModel { @@ -57,20 +69,13 @@ UM.Dialog Column { - width: parent.width + id: contentColumn + width: parent.width - scrollbar.width height: childrenRect.height - spacing: UM.Theme.getSize("wide_margin").height - - UM.Label - { - id: titleLabel - text: catalog.i18nc("@action:title", "Summary - Cura Project") - font: UM.Theme.getFont("large") - } Column { - width: parent.width + width: parent.width - UM.Theme.getSize("default_margin").width height: childrenRect.height spacing: UM.Theme.getSize("default_margin").height leftPadding: UM.Theme.getSize("default_margin").width @@ -312,7 +317,7 @@ UM.Dialog color: warning ? UM.Theme.getColor("warning") : "transparent" anchors.bottom: parent.bottom width: parent.width - height: childrenRect.height + 2 * workspaceDialog.margin + height: childrenRect.height + (warning ? 2 * workspaceDialog.margin : workspaceDialog.margin) Column { diff --git a/plugins/3MFReader/WorkspaceSection.qml b/plugins/3MFReader/WorkspaceSection.qml index 575fc8fea5..211d8776f3 100644 --- a/plugins/3MFReader/WorkspaceSection.qml +++ b/plugins/3MFReader/WorkspaceSection.qml @@ -26,18 +26,21 @@ Item UM.TooltipArea { id: comboboxTooltip - width: (parent.width / 3) | 0 + width: (parent.width / 2.5) | 0 height: visible ? UM.Theme.getSize("default_margin").height : 0 anchors.top: parent.top anchors.right: parent.right - visible: comboboxVisible + anchors.rightMargin: UM.Theme.getSize("default_margin").width + text: comboboxTooltipText + visible: comboboxVisible UM.Label { id: comboboxLabel anchors.top: parent.top anchors.left: parent.left + anchors.topMargin: UM.Theme.getSize("default_margin").height visible: comboboxVisible && text != "" text: "" font: UM.Theme.getFont("default_bold") From e954de7f0120fbf9cafec9b71b4efb0609e08b4f Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 3 Nov 2022 16:43:19 +0100 Subject: [PATCH 18/48] Adjust dialog margins. Move title into full width white square. CURA-9424 Co-authored-by: Casper Lamboo --- plugins/3MFReader/WorkspaceDialog.qml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index f79fb6266a..d40f54a34b 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -324,7 +324,11 @@ UM.Dialog height: childrenRect.height spacing: workspaceDialog.margin - anchors.margins: workspaceDialog.margin + anchors.leftMargin: workspaceDialog.margin + anchors.rightMargin: workspaceDialog.margin + anchors.bottomMargin: workspaceDialog.margin + anchors.topMargin: warning ? workspaceDialog.margin : 0 + anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top From f8ed660d58135b5a6b2a39f3c9d5548617c85bb5 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 3 Nov 2022 16:54:56 +0100 Subject: [PATCH 19/48] Update icons CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index d40f54a34b..46eef227dc 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -158,7 +158,7 @@ UM.Dialog { id: profileSection title: catalog.i18nc("@action:label", "Profile settings") - iconSource: UM.Theme.getIcon("Printer") + iconSource: UM.Theme.getIcon("Sliders") content: Column { id: profileSettingsValuesTable @@ -218,7 +218,7 @@ UM.Dialog { id: materialSection title: catalog.i18nc("@action:label", "Material settings") - iconSource: UM.Theme.getIcon("Printer") + iconSource: UM.Theme.getIcon("Spool") content: Column { spacing: UM.Theme.getSize("default_margin").height @@ -262,7 +262,7 @@ UM.Dialog { id: visibilitySection title: catalog.i18nc("@action:label", "Setting visibility") - iconSource: UM.Theme.getIcon("Printer") + iconSource: UM.Theme.getIcon("Eye") content: Column { spacing: UM.Theme.getSize("default_margin").height From 2019d8f3af63ff28a566c2953aca6ca4553f7252 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 4 Nov 2022 15:11:04 +0100 Subject: [PATCH 20/48] Start MachineSelector refactor by allowing list model to be passed in. CURA-9424 --- plugins/MonitorStage/MonitorMenu.qml | 2 ++ plugins/PrepareStage/PrepareMenu.qml | 2 ++ resources/qml/PrinterSelector/MachineSelector.qml | 5 ++++- resources/qml/PrinterSelector/MachineSelectorList.qml | 1 - 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/MonitorStage/MonitorMenu.qml b/plugins/MonitorStage/MonitorMenu.qml index bc95c276e8..ba99c3119e 100644 --- a/plugins/MonitorStage/MonitorMenu.qml +++ b/plugins/MonitorStage/MonitorMenu.qml @@ -19,5 +19,7 @@ Item width: UM.Theme.getSize("machine_selector_widget").width height: parent.height anchors.centerIn: parent + + machineListModel: Cura.MachineListModel {} } } \ No newline at end of file diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index 42c3c8dde6..01e378c2d4 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -55,6 +55,8 @@ Item Layout.preferredWidth: parent.machineSelectorWidth Layout.fillWidth: true Layout.fillHeight: true + + machineListModel: Cura.MachineListModel {} } Cura.ConfigurationMenu diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index 0008529408..ef9112eead 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -16,6 +16,8 @@ Cura.ExpandablePopup property bool isCloudRegistered: Cura.MachineManager.activeMachineHasCloudRegistration property bool isGroup: Cura.MachineManager.activeMachineIsGroup + property alias machineListModel: machineSelectorList.model + readonly property string connectionStatus: { if (isNetworkPrinter) { @@ -156,7 +158,8 @@ Cura.ExpandablePopup } - MouseArea // Connection status tooltip hover area + // Connection status tooltip hover area + MouseArea { id: connectionStatusTooltipHoverArea anchors.fill: parent diff --git a/resources/qml/PrinterSelector/MachineSelectorList.qml b/resources/qml/PrinterSelector/MachineSelectorList.qml index a328ae69d9..0fa19a51ff 100644 --- a/resources/qml/PrinterSelector/MachineSelectorList.qml +++ b/resources/qml/PrinterSelector/MachineSelectorList.qml @@ -10,7 +10,6 @@ import Cura 1.0 as Cura ListView { id: listView - model: Cura.MachineListModel {} section.property: "isOnline" property real contentHeight: childrenRect.height From ccb4d181e632d515a302992d63070dced2f37d91 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 4 Nov 2022 15:37:57 +0100 Subject: [PATCH 21/48] Allow buttons to be passed in for drop down. The change also remove the "Add Printer" and "Manage Printer" buttons from the monitor page drop down. CURA-9424 --- plugins/PrepareStage/PrepareMenu.qml | 35 ++++++++++++ .../qml/PrinterSelector/MachineSelector.qml | 54 ++++++++----------- 2 files changed, 56 insertions(+), 33 deletions(-) diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index 01e378c2d4..719c598469 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -57,6 +57,41 @@ Item Layout.fillHeight: true machineListModel: Cura.MachineListModel {} + + buttons: [ + Cura.SecondaryButton + { + id: addPrinterButton + leftPadding: UM.Theme.getSize("default_margin").width + rightPadding: UM.Theme.getSize("default_margin").width + text: catalog.i18nc("@button", "Add printer") + // The maximum width of the button is half of the total space, minus the padding of the parent, the left + // padding of the component and half the spacing because of the space between buttons. + fixedWidthMode: true + width: parent.width / 2 - leftPadding * 1.5 + onClicked: + { + toggleContent() + Cura.Actions.addMachine.trigger() + } + }, + Cura.SecondaryButton + { + id: managePrinterButton + leftPadding: UM.Theme.getSize("default_margin").width + rightPadding: UM.Theme.getSize("default_margin").width + text: catalog.i18nc("@button", "Manage printers") + fixedWidthMode: true + // The maximum width of the button is half of the total space, minus the padding of the parent, the right + // padding of the component and half the spacing because of the space between buttons. + width: parent.width / 2 - rightPadding * 1.5 + onClicked: + { + toggleContent() + Cura.Actions.configureMachines.trigger() + } + } + ] } Cura.ConfigurationMenu diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index ef9112eead..a395ea3913 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -18,6 +18,8 @@ Cura.ExpandablePopup property alias machineListModel: machineSelectorList.model + property list buttons + readonly property string connectionStatus: { if (isNetworkPrinter) { @@ -232,39 +234,25 @@ Cura.ExpandablePopup padding: UM.Theme.getSize("default_margin").width spacing: UM.Theme.getSize("default_margin").width - Cura.SecondaryButton - { - id: addPrinterButton - leftPadding: UM.Theme.getSize("default_margin").width - rightPadding: UM.Theme.getSize("default_margin").width - text: catalog.i18nc("@button", "Add printer") - // The maximum width of the button is half of the total space, minus the padding of the parent, the left - // padding of the component and half the spacing because of the space between buttons. - fixedWidthMode: true - width: buttonRow.width / 2 - leftPadding * 1.5 - onClicked: - { - toggleContent() - Cura.Actions.addMachine.trigger() - } - } - - Cura.SecondaryButton - { - id: managePrinterButton - leftPadding: UM.Theme.getSize("default_margin").width - rightPadding: UM.Theme.getSize("default_margin").width - text: catalog.i18nc("@button", "Manage printers") - fixedWidthMode: true - // The maximum width of the button is half of the total space, minus the padding of the parent, the right - // padding of the component and half the spacing because of the space between buttons. - width: buttonRow.width / 2 - rightPadding * 1.5 - onClicked: - { - toggleContent() - Cura.Actions.configureMachines.trigger() - } - } + children: buttons } + + states: [ + State { + name: "noButtons" + when: !buttons || buttons.length == 0 + PropertyChanges + { + target: buttonRow + height: 0 + padding: 0 + } + PropertyChanges + { + target: separator + height: 0 + } + } + ] } } From 1ebf5bb650d1b46ed29d7561630ce1a4113c7c79 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 4 Nov 2022 16:42:07 +0100 Subject: [PATCH 22/48] Update MachineListModel to optionally take a list of global stack to show in list instead of searching the container registry. Add option not to listen to container change events in MachineListModel. CURA-9424 --- cura/Machines/Models/MachineListModel.py | 36 +++++++++++++++++------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index 24375b72ce..04faa4d1fc 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -5,7 +5,7 @@ # online cloud connected printers are represented within this ListModel. Additional information such as the number of # connected printers for each printer type is gathered. -from typing import Optional +from typing import Optional, List from PyQt6.QtCore import Qt, QTimer, QObject, pyqtSlot, pyqtProperty, pyqtSignal @@ -14,7 +14,6 @@ from UM.Settings.ContainerStack import ContainerStack from UM.Settings.Interfaces import ContainerInterface from UM.i18n import i18nCatalog from UM.Util import parseBool -from cura.PrinterOutput.PrinterOutputDevice import ConnectionType from cura.Settings.CuraContainerRegistry import CuraContainerRegistry from cura.Settings.GlobalStack import GlobalStack @@ -30,10 +29,11 @@ class MachineListModel(ListModel): IsAbstractMachineRole = Qt.ItemDataRole.UserRole + 7 ComponentTypeRole = Qt.ItemDataRole.UserRole + 8 - def __init__(self, parent: Optional[QObject] = None) -> None: + def __init__(self, parent: Optional[QObject] = None, machines: List[GlobalStack] = None, listenToChanges: bool = True) -> None: super().__init__(parent) self._show_cloud_printers = False + self._machines = machines self._catalog = i18nCatalog("cura") @@ -51,11 +51,11 @@ class MachineListModel(ListModel): self._change_timer.setSingleShot(True) self._change_timer.timeout.connect(self._update) - # Listen to changes - CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerChanged) - CuraContainerRegistry.getInstance().containerMetaDataChanged.connect(self._onContainerChanged) - CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged) - self._updateDelayed() + if listenToChanges: + CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerChanged) + CuraContainerRegistry.getInstance().containerMetaDataChanged.connect(self._onContainerChanged) + CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged) + self._updateDelayed() showCloudPrintersChanged = pyqtSignal(bool) @@ -79,16 +79,32 @@ class MachineListModel(ListModel): def _updateDelayed(self) -> None: self._change_timer.start() + def _getMachineStacks(self) -> List[ContainerStack]: + if self._machines is not None: + return self._machines + return CuraContainerRegistry.getInstance().findContainerStacks(type="machine") + + def _getAbstractMachineStacks(self) -> List[ContainerStack]: + if self._machines is not None: + return list(filter(lambda machine: parseBool(machine.getMetaDataEntry("is_abstract_machine", False)), self._machines)) + return CuraContainerRegistry.getInstance().findContainerStacks(is_abstract_machine = "True") + + def update(self, machines: List[ContainerStack] = None) -> None: + if machines is not None: + self._machines = machines + + self._update() + def _update(self) -> None: self.clear() from cura.CuraApplication import CuraApplication machines_manager = CuraApplication.getInstance().getMachineManager() - other_machine_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type="machine") + other_machine_stacks = self._getMachineStacks() other_machine_stacks.sort(key = lambda machine: machine.getName().upper()) - abstract_machine_stacks = CuraContainerRegistry.getInstance().findContainerStacks(is_abstract_machine = "True") + abstract_machine_stacks = self._getAbstractMachineStacks() abstract_machine_stacks.sort(key = lambda machine: machine.getName().upper(), reverse = True) for abstract_machine in abstract_machine_stacks: definition_id = abstract_machine.definition.getId() From 088ea0a768f6f211be376ca8b58f552a67aca057 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 4 Nov 2022 16:44:04 +0100 Subject: [PATCH 23/48] Swap out UpdatableMachinesModel for MachineListModel. This has to be instantiated with the WorkspaceDialog but attaching the listeners throws an error because it is done too early. The listeners are not needed anyway, so they have been disabled. Update WorkspaceDialog.qml to use MachineListModel CURA-9424 --- plugins/3MFReader/WorkspaceDialog.py | 9 ++- plugins/3MFReader/WorkspaceDialog.qml | 86 +++++++++++++-------------- 2 files changed, 47 insertions(+), 48 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.py b/plugins/3MFReader/WorkspaceDialog.py index 0a8f7784b2..9e0c8158cd 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -5,6 +5,7 @@ from PyQt6.QtCore import pyqtSignal, QObject, pyqtProperty, QCoreApplication, QU from PyQt6.QtGui import QDesktopServices from typing import List, Optional, Dict, cast +from cura.Machines.Models.MachineListModel import MachineListModel from cura.Settings.GlobalStack import GlobalStack from UM.Application import Application from UM.FlameProfiler import pyqtSlot @@ -14,8 +15,6 @@ from UM.Message import Message from UM.PluginRegistry import PluginRegistry from UM.Settings.ContainerRegistry import ContainerRegistry -from .UpdatableMachinesModel import UpdatableMachinesModel - import os import threading import time @@ -63,7 +62,7 @@ class WorkspaceDialog(QObject): self._extruders = [] self._objects_on_plate = False self._is_printer_group = False - self._updatable_machines_model = UpdatableMachinesModel(self) + self._updatable_machines_model = MachineListModel(self, listenToChanges=False) self._missing_package_metadata: List[Dict[str, str]] = [] self._plugin_registry: PluginRegistry = CuraApplication.getInstance().getPluginRegistry() self._install_missing_package_dialog: Optional[QObject] = None @@ -161,8 +160,8 @@ class WorkspaceDialog(QObject): self.machineNameChanged.emit() @pyqtProperty(QObject, notify = updatableMachinesChanged) - def updatableMachinesModel(self) -> UpdatableMachinesModel: - return cast(UpdatableMachinesModel, self._updatable_machines_model) + def updatableMachinesModel(self) -> MachineListModel: + return cast(MachineListModel, self._updatable_machines_model) def setUpdatableMachines(self, updatable_machines: List[GlobalStack]) -> None: self._updatable_machines_model.update(updatable_machines) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 46eef227dc..64444004d5 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -107,50 +107,50 @@ UM.Dialog comboboxTitle: catalog.i18nc("@action:label", "Open With") comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?") comboboxVisible: workspaceDialog.visible && manager.updatableMachinesModel.count > 1 - combobox: Cura.ComboBox + combobox: Cura.MachineSelector { - id: machineResolveComboBox - model: manager.updatableMachinesModel - textRole: "displayName" - visible: workspaceDialog.visible && model.count > 1 - currentIndex: machineVisibleChanged() - - onCurrentIndexChanged: - { - if (model.getItem(currentIndex).id == "new" - && model.getItem(currentIndex).type == "default_option") - { - manager.setResolveStrategy("machine", "new") - } - else - { - manager.setResolveStrategy("machine", "override") - manager.setMachineToOverride(model.getItem(currentIndex).id) - } - } - - function machineVisibleChanged() - { - if (!visible) {return} - - currentIndex = 0 - // If the project printer exists in Cura, set it as the default dropdown menu option. - // No need to check object 0, which is the "Create new" option - for (var i = 1; i < model.count; i++) - { - if (model.getItem(i).name == manager.machineName) - { - currentIndex = i - break - } - } - // The project printer does not exist in Cura. If there is at least one printer of the same - // type, select the first one, else set the index to "Create new" - if (currentIndex == 0 && model.count > 1) - { - currentIndex = 1 - } - } + id: machineSelector + headerCornerSide: Cura.RoundedRectangle.Direction.All + width: UM.Theme.getSize("machine_selector_widget").width + height: parent.height + anchors.centerIn: parent + machineListModel: manager.updatableMachinesModel +// onCurrentIndexChanged: +// { +// if (model.getItem(currentIndex).id == "new" +// && model.getItem(currentIndex).type == "default_option") +// { +// manager.setResolveStrategy("machine", "new") +// } +// else +// { +// manager.setResolveStrategy("machine", "override") +// manager.setMachineToOverride(model.getItem(currentIndex).id) +// } +// } +// +// function machineVisibleChanged() +// { +// if (!visible) {return} +// +// currentIndex = 0 +// // If the project printer exists in Cura, set it as the default dropdown menu option. +// // No need to check object 0, which is the "Create new" option +// for (var i = 1; i < model.count; i++) +// { +// if (model.getItem(i).name == manager.machineName) +// { +// currentIndex = i +// break +// } +// } +// // The project printer does not exist in Cura. If there is at least one printer of the same +// // type, select the first one, else set the index to "Create new" +// if (currentIndex == 0 && model.count > 1) +// { +// currentIndex = 1 +// } +// } } } From dd4e1c66b71f17ef8e5eca8cc42065aff86e2f2c Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 9 Nov 2022 12:54:38 +0100 Subject: [PATCH 24/48] Make `MachineSelector` more generic by detaching logic from view By detaching the logic from the view custom handlers can be added to selecting printers. This was needed as the MachineSelector in the `WorkspaceDialog` needed to do something different from the `PreparMenu`. CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 50 ++++++------------- plugins/PrepareStage/PrepareMenu.qml | 7 +++ .../qml/PrinterSelector/MachineSelector.qml | 40 ++++++++------- .../PrinterSelector/MachineSelectorList.qml | 4 +- 4 files changed, 45 insertions(+), 56 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 64444004d5..97cd2eed51 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -115,42 +115,20 @@ UM.Dialog height: parent.height anchors.centerIn: parent machineListModel: manager.updatableMachinesModel -// onCurrentIndexChanged: -// { -// if (model.getItem(currentIndex).id == "new" -// && model.getItem(currentIndex).type == "default_option") -// { -// manager.setResolveStrategy("machine", "new") -// } -// else -// { -// manager.setResolveStrategy("machine", "override") -// manager.setMachineToOverride(model.getItem(currentIndex).id) -// } -// } -// -// function machineVisibleChanged() -// { -// if (!visible) {return} -// -// currentIndex = 0 -// // If the project printer exists in Cura, set it as the default dropdown menu option. -// // No need to check object 0, which is the "Create new" option -// for (var i = 1; i < model.count; i++) -// { -// if (model.getItem(i).name == manager.machineName) -// { -// currentIndex = i -// break -// } -// } -// // The project printer does not exist in Cura. If there is at least one printer of the same -// // type, select the first one, else set the index to "Create new" -// if (currentIndex == 0 && model.count > 1) -// { -// currentIndex = 1 -// } -// } + machineName: manager.machineName + + isNetworkPrinter: false + isConnectedCloudPrinter: false + isCloudRegistered: false + isGroup: false + + onSelectPrinter: function(machine) + { + toggleContent(); + manager.setResolveStrategy("machine", "override") + manager.setMachineToOverride(machine.id) + machineSelector.machineName = machine.name + } } } diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index 719c598469..59508dd102 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -56,6 +56,13 @@ Item Layout.fillWidth: true Layout.fillHeight: true + machineManager: Cura.MachineManager + onSelectPrinter: function(machine) + { + toggleContent(); + Cura.MachineManager.setActiveMachine(machine.id); + } + machineListModel: Cura.MachineListModel {} buttons: [ diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index a395ea3913..8bf5e3cf1d 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -11,12 +11,25 @@ Cura.ExpandablePopup { id: machineSelector - property bool isNetworkPrinter: Cura.MachineManager.activeMachineHasNetworkConnection - property bool isConnectedCloudPrinter: Cura.MachineManager.activeMachineHasCloudConnection - property bool isCloudRegistered: Cura.MachineManager.activeMachineHasCloudRegistration - property bool isGroup: Cura.MachineManager.activeMachineIsGroup + property Cura.MachineManager machineManager + property bool isNetworkPrinter: machineManager.activeMachineHasNetworkConnection + property bool isConnectedCloudPrinter: machineManager.activeMachineHasCloudConnection + property bool isCloudRegistered: machineManager.activeMachineHasCloudRegistration + property bool isGroup: machineManager.activeMachineIsGroup + property string machineName: { + if (isNetworkPrinter && machineManager.activeMachineNetworkGroupName != "") + { + return machineManager.activeMachineNetworkGroupName + } + if (machineManager.activeMachine != null) + { + return machineManager.activeMachine.name + } + return "" + } property alias machineListModel: machineSelectorList.model + property alias onSelectPrinter: machineSelectorList.onSelectPrinter property list buttons @@ -46,7 +59,7 @@ Cura.ExpandablePopup { if (Cura.API.account.isLoggedIn) { - if (Cura.MachineManager.activeMachineIsLinkedToCurrentAccount) + if (machineManager.activeMachineIsLinkedToCurrentAccount) { return catalog.i18nc("@status", "The cloud printer is offline. Please check if the printer is turned on and connected to the internet.") } @@ -59,7 +72,8 @@ Cura.ExpandablePopup { return catalog.i18nc("@status", "The cloud connection is currently unavailable. Please sign in to connect to the cloud printer.") } - } else + } + else { return catalog.i18nc("@status", "The cloud connection is currently unavailable. Please check your internet connection.") } @@ -81,18 +95,8 @@ Cura.ExpandablePopup headerItem: Cura.IconWithText { - text: - { - if (isNetworkPrinter && Cura.MachineManager.activeMachineNetworkGroupName != "") - { - return Cura.MachineManager.activeMachineNetworkGroupName - } - if(Cura.MachineManager.activeMachine != null) - { - return Cura.MachineManager.activeMachine.name - } - return "" - } + text: machineName + source: { if (isGroup) diff --git a/resources/qml/PrinterSelector/MachineSelectorList.qml b/resources/qml/PrinterSelector/MachineSelectorList.qml index 0fa19a51ff..1b0264929d 100644 --- a/resources/qml/PrinterSelector/MachineSelectorList.qml +++ b/resources/qml/PrinterSelector/MachineSelectorList.qml @@ -12,6 +12,7 @@ ListView id: listView section.property: "isOnline" property real contentHeight: childrenRect.height + property var onSelectPrinter ScrollBar.vertical: UM.ScrollBar { @@ -42,8 +43,7 @@ ListView listView.model.setShowCloudPrinters(true); break; case "MACHINE": - toggleContent() - Cura.MachineManager.setActiveMachine(model.id) + if (typeof onSelectPrinter === "function") onSelectPrinter(model); break; default: } From 948ac84070f55834c0461cea888935cc31bfbbed Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 9 Nov 2022 15:49:04 +0100 Subject: [PATCH 25/48] Add create new button CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 97cd2eed51..ae4c44d0a6 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -122,6 +122,27 @@ UM.Dialog isCloudRegistered: false isGroup: false + buttons: [ + Cura.SecondaryButton + { + id: createNewPrinter + text: catalog.i18nc("@button", "Create new") + fixedWidthMode: true + width: parent.width - leftPadding * 1.5 + onClicked: + { + machineSelector.machineName = catalog.i18nc("@button", "Create new") + machineSelector.isNetworkPrinter = false + machineSelector.isConnectedCloudPrinter = false + machineSelector.isCloudRegistered = false + machineSelector.isGroup = false + + toggleContent() + manager.setResolveStrategy("machine", "new") + } + } + ] + onSelectPrinter: function(machine) { toggleContent(); From 95e0021cce61ca8287e1c7565447bd9d1855caac Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 9 Nov 2022 15:55:48 +0100 Subject: [PATCH 26/48] Align dropdown in open project dialog CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 5 +++-- resources/qml/PrinterSelector/MachineSelector.qml | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index ae4c44d0a6..f452ab0252 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -111,9 +111,8 @@ UM.Dialog { id: machineSelector headerCornerSide: Cura.RoundedRectangle.Direction.All - width: UM.Theme.getSize("machine_selector_widget").width + width: parent.width height: parent.height - anchors.centerIn: parent machineListModel: manager.updatableMachinesModel machineName: manager.machineName @@ -122,6 +121,8 @@ UM.Dialog isCloudRegistered: false isGroup: false + minDropDownWidth: machineSelector.width + buttons: [ Cura.SecondaryButton { diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index 8bf5e3cf1d..b8bacc8f36 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -198,11 +198,14 @@ Cura.ExpandablePopup } } + property int minDropDownWidth: UM.Theme.getSize("machine_selector_widget_content").width + property int maxDropDownHeight: UM.Theme.getSize("machine_selector_widget_content").height + contentItem: Item { id: popup - implicitWidth: Math.max(machineSelector.width, UM.Theme.getSize("machine_selector_widget_content").width) - implicitHeight: Math.min(machineSelectorList.contentHeight + separator.height + buttonRow.height, UM.Theme.getSize("machine_selector_widget_content").height) //Maximum height is the theme entry. + implicitWidth: Math.max(machineSelector.width, minDropDownWidth) + implicitHeight: Math.min(machineSelectorList.contentHeight + separator.height + buttonRow.height, maxDropDownHeight) //Maximum height is the theme entry. MachineSelectorList { id: machineSelectorList From 8ee5bc2bd46804aaae92df87d965007efd1f08fa Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 9 Nov 2022 16:04:39 +0100 Subject: [PATCH 27/48] Remove column with single child Just rendering the single child produces the same result CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 397 +++++++++++++------------- 1 file changed, 196 insertions(+), 201 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index f452ab0252..23f9231230 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -70,240 +70,235 @@ UM.Dialog Column { id: contentColumn - width: parent.width - scrollbar.width + width: parent.width - scrollbar.width - UM.Theme.getSize("default_margin").width height: childrenRect.height - Column + spacing: UM.Theme.getSize("default_margin").height + leftPadding: UM.Theme.getSize("default_margin").width + rightPadding: UM.Theme.getSize("default_margin").width + + WorkspaceSection { - width: parent.width - UM.Theme.getSize("default_margin").width - height: childrenRect.height - spacing: UM.Theme.getSize("default_margin").height - leftPadding: UM.Theme.getSize("default_margin").width - rightPadding: UM.Theme.getSize("default_margin").width - - WorkspaceSection + id: printerSection + title: catalog.i18nc("@action:label", "Printer settings") + iconSource: UM.Theme.getIcon("Printer") + content: Column { - id: printerSection - title: catalog.i18nc("@action:label", "Printer settings") - iconSource: UM.Theme.getIcon("Printer") - content: Column + spacing: UM.Theme.getSize("default_margin").height + leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + + WorkspaceRow { - spacing: UM.Theme.getSize("default_margin").height - leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - - WorkspaceRow - { - leftLabelText: catalog.i18nc("@action:label", "Type") - rightLabelText: manager.machineType - } - - WorkspaceRow - { - leftLabelText: catalog.i18nc("@action:label", manager.isPrinterGroup ? "Printer Group" : "Printer Name") - rightLabelText: manager.machineName - } + leftLabelText: catalog.i18nc("@action:label", "Type") + rightLabelText: manager.machineType } - comboboxTitle: catalog.i18nc("@action:label", "Open With") - comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?") - comboboxVisible: workspaceDialog.visible && manager.updatableMachinesModel.count > 1 - combobox: Cura.MachineSelector + WorkspaceRow { - id: machineSelector - headerCornerSide: Cura.RoundedRectangle.Direction.All - width: parent.width - height: parent.height - machineListModel: manager.updatableMachinesModel - machineName: manager.machineName - - isNetworkPrinter: false - isConnectedCloudPrinter: false - isCloudRegistered: false - isGroup: false - - minDropDownWidth: machineSelector.width - - buttons: [ - Cura.SecondaryButton - { - id: createNewPrinter - text: catalog.i18nc("@button", "Create new") - fixedWidthMode: true - width: parent.width - leftPadding * 1.5 - onClicked: - { - machineSelector.machineName = catalog.i18nc("@button", "Create new") - machineSelector.isNetworkPrinter = false - machineSelector.isConnectedCloudPrinter = false - machineSelector.isCloudRegistered = false - machineSelector.isGroup = false - - toggleContent() - manager.setResolveStrategy("machine", "new") - } - } - ] - - onSelectPrinter: function(machine) - { - toggleContent(); - manager.setResolveStrategy("machine", "override") - manager.setMachineToOverride(machine.id) - machineSelector.machineName = machine.name - } + leftLabelText: catalog.i18nc("@action:label", manager.isPrinterGroup ? "Printer Group" : "Printer Name") + rightLabelText: manager.machineName } } - WorkspaceSection + comboboxTitle: catalog.i18nc("@action:label", "Open With") + comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?") + comboboxVisible: workspaceDialog.visible && manager.updatableMachinesModel.count > 1 + combobox: Cura.MachineSelector { - id: profileSection - title: catalog.i18nc("@action:label", "Profile settings") - iconSource: UM.Theme.getIcon("Sliders") - content: Column - { - id: profileSettingsValuesTable - spacing: UM.Theme.getSize("default_margin").height - leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + id: machineSelector + headerCornerSide: Cura.RoundedRectangle.Direction.All + width: parent.width + height: parent.height + machineListModel: manager.updatableMachinesModel + machineName: manager.machineName - WorkspaceRow + isNetworkPrinter: false + isConnectedCloudPrinter: false + isCloudRegistered: false + isGroup: false + + minDropDownWidth: machineSelector.width + + buttons: [ + Cura.SecondaryButton + { + id: createNewPrinter + text: catalog.i18nc("@button", "Create new") + fixedWidthMode: true + width: parent.width - leftPadding * 1.5 + onClicked: + { + machineSelector.machineName = catalog.i18nc("@button", "Create new") + machineSelector.isNetworkPrinter = false + machineSelector.isConnectedCloudPrinter = false + machineSelector.isCloudRegistered = false + machineSelector.isGroup = false + + toggleContent() + manager.setResolveStrategy("machine", "new") + } + } + ] + + onSelectPrinter: function(machine) + { + toggleContent(); + manager.setResolveStrategy("machine", "override") + manager.setMachineToOverride(machine.id) + machineSelector.machineName = machine.name + } + } + } + + WorkspaceSection + { + id: profileSection + title: catalog.i18nc("@action:label", "Profile settings") + iconSource: UM.Theme.getIcon("Sliders") + content: Column + { + id: profileSettingsValuesTable + spacing: UM.Theme.getSize("default_margin").height + leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + + WorkspaceRow + { + leftLabelText: catalog.i18nc("@action:label", "Name") + rightLabelText: manager.qualityName + } + + WorkspaceRow + { + leftLabelText: catalog.i18nc("@action:label", "Intent") + rightLabelText: manager.intentName + } + + WorkspaceRow + { + leftLabelText: catalog.i18nc("@action:label", "Not in profile") + rightLabelText: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.numUserSettings).arg(manager.numUserSettings) + visible: manager.numUserSettings != 0 + } + + WorkspaceRow + { + leftLabelText: catalog.i18nc("@action:label", "Derivative from") + rightLabelText: catalog.i18ncp("@action:label", "%1, %2 override", "%1, %2 overrides", manager.numSettingsOverridenByQualityChanges).arg(manager.qualityType).arg(manager.numSettingsOverridenByQualityChanges) + visible: manager.numSettingsOverridenByQualityChanges != 0 + } + } + + comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?") + comboboxVisible: manager.qualityChangesConflict + combobox: Cura.ComboBox + { + id: qualityChangesResolveComboBox + model: resolveStrategiesModel + textRole: "label" + visible: manager.qualityChangesConflict + + // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded + currentIndex: + { + currentIndex = 0 + } + + onCurrentIndexChanged: + { + manager.setResolveStrategy("quality_changes", resolveStrategiesModel.get(currentIndex).key) + } + } + } + + WorkspaceSection + { + id: materialSection + title: catalog.i18nc("@action:label", "Material settings") + iconSource: UM.Theme.getIcon("Spool") + content: Column + { + spacing: UM.Theme.getSize("default_margin").height + leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + + Repeater + { + model: manager.materialLabels + delegate: WorkspaceRow { leftLabelText: catalog.i18nc("@action:label", "Name") - rightLabelText: manager.qualityName - } - - WorkspaceRow - { - leftLabelText: catalog.i18nc("@action:label", "Intent") - rightLabelText: manager.intentName - } - - WorkspaceRow - { - leftLabelText: catalog.i18nc("@action:label", "Not in profile") - rightLabelText: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.numUserSettings).arg(manager.numUserSettings) - visible: manager.numUserSettings != 0 - } - - WorkspaceRow - { - leftLabelText: catalog.i18nc("@action:label", "Derivative from") - rightLabelText: catalog.i18ncp("@action:label", "%1, %2 override", "%1, %2 overrides", manager.numSettingsOverridenByQualityChanges).arg(manager.qualityType).arg(manager.numSettingsOverridenByQualityChanges) - visible: manager.numSettingsOverridenByQualityChanges != 0 - } - } - - comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?") - comboboxVisible: manager.qualityChangesConflict - combobox: Cura.ComboBox - { - id: qualityChangesResolveComboBox - model: resolveStrategiesModel - textRole: "label" - visible: manager.qualityChangesConflict - - // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded - currentIndex: - { - currentIndex = 0 - } - - onCurrentIndexChanged: - { - manager.setResolveStrategy("quality_changes", resolveStrategiesModel.get(currentIndex).key) + rightLabelText: modelData } } } - WorkspaceSection - { - id: materialSection - title: catalog.i18nc("@action:label", "Material settings") - iconSource: UM.Theme.getIcon("Spool") - content: Column - { - spacing: UM.Theme.getSize("default_margin").height - leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the material be resolved?") + comboboxVisible: manager.materialConflict - Repeater - { - model: manager.materialLabels - delegate: WorkspaceRow - { - leftLabelText: catalog.i18nc("@action:label", "Name") - rightLabelText: modelData - } - } + combobox: Cura.ComboBox + { + id: materialResolveComboBox + model: resolveStrategiesModel + textRole: "label" + visible: manager.materialConflict + + // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded + currentIndex: + { + currentIndex = 0 } - comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the material be resolved?") - comboboxVisible: manager.materialConflict - - combobox: Cura.ComboBox + onCurrentIndexChanged: { - id: materialResolveComboBox - model: resolveStrategiesModel - textRole: "label" - visible: manager.materialConflict - - // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded - currentIndex: - { - currentIndex = 0 - } - - onCurrentIndexChanged: - { - manager.setResolveStrategy("material", resolveStrategiesModel.get(currentIndex).key) - } + manager.setResolveStrategy("material", resolveStrategiesModel.get(currentIndex).key) } } + } - WorkspaceSection + WorkspaceSection + { + id: visibilitySection + title: catalog.i18nc("@action:label", "Setting visibility") + iconSource: UM.Theme.getIcon("Eye") + content: Column { - id: visibilitySection - title: catalog.i18nc("@action:label", "Setting visibility") - iconSource: UM.Theme.getIcon("Eye") - content: Column + spacing: UM.Theme.getSize("default_margin").height + leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width + bottomPadding: UM.Theme.getSize("narrow_margin").height + + WorkspaceRow { - spacing: UM.Theme.getSize("default_margin").height - leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width - bottomPadding: UM.Theme.getSize("narrow_margin").height + leftLabelText: catalog.i18nc("@action:label", "Mode") + rightLabelText: manager.activeMode + } - WorkspaceRow - { - leftLabelText: catalog.i18nc("@action:label", "Mode") - rightLabelText: manager.activeMode - } - - WorkspaceRow - { - leftLabelText: catalog.i18nc("@action:label", "%1 out of %2" ).arg(manager.numVisibleSettings).arg(manager.totalNumberOfSettings) - rightLabelText: manager.activeMode - visible: manager.hasVisibleSettingsField - } + WorkspaceRow + { + leftLabelText: catalog.i18nc("@action:label", "%1 out of %2" ).arg(manager.numVisibleSettings).arg(manager.totalNumberOfSettings) + rightLabelText: manager.activeMode + visible: manager.hasVisibleSettingsField } } + } - Row + Row + { + id: clearBuildPlateWarning + width: parent.width + height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").width + visible: manager.hasObjectsOnPlate + + UM.ColorImage { - id: clearBuildPlateWarning - width: parent.width - height: childrenRect.height - spacing: UM.Theme.getSize("default_margin").width - visible: manager.hasObjectsOnPlate - - UM.ColorImage - { - width: warningLabel.height - height: width - source: UM.Theme.getIcon("Information") - color: UM.Theme.getColor("text") - } - UM.Label - { - id: warningLabel - text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the build plate.") - } + width: warningLabel.height + height: width + source: UM.Theme.getIcon("Information") + color: UM.Theme.getColor("text") + } + UM.Label + { + id: warningLabel + text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the build plate.") } } } From 79a7b1e0649b71de2dd5d41b97ad9ec7ce42541e Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 9 Nov 2022 16:56:07 +0100 Subject: [PATCH 28/48] Round width to prevent drawing text on non-integer offsets Contribution from @fieldOfView CURA-9424 --- plugins/PrepareStage/PrepareMenu.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index 59508dd102..3f24d619ac 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -75,7 +75,7 @@ Item // The maximum width of the button is half of the total space, minus the padding of the parent, the left // padding of the component and half the spacing because of the space between buttons. fixedWidthMode: true - width: parent.width / 2 - leftPadding * 1.5 + width: Math.round(parent.width / 2 - leftPadding * 1.5) onClicked: { toggleContent() From 06a28861396a46800916c9eeb45b05e45be15661 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 9 Nov 2022 17:11:31 +0100 Subject: [PATCH 29/48] Clean up section property logic CURA-9424 --- cura/Machines/Models/MachineListModel.py | 41 +++++++++++-------- .../PrinterSelector/MachineSelectorList.qml | 12 +++++- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index 04faa4d1fc..cb7c3b5998 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -130,17 +130,21 @@ class MachineListModel(ListModel): if len(abstract_machine_stacks) > 0: if self._show_cloud_printers: - self.appendItem({"componentType": "HIDE_BUTTON", - "isOnline": True, - "isAbstractMachine": False, - "machineCount": 0 - }) + self.appendItem({ + "componentType": "HIDE_BUTTON", + "isOnline": True, + "isAbstractMachine": False, + "machineCount": 0, + "catergory": "connected", + }) else: - self.appendItem({"componentType": "SHOW_BUTTON", - "isOnline": True, - "isAbstractMachine": False, - "machineCount": 0 - }) + self.appendItem({ + "componentType": "SHOW_BUTTON", + "isOnline": True, + "isAbstractMachine": False, + "machineCount": 0, + "catergory": "connected", + }) for stack in other_machine_stacks: self.addItem(stack, False) @@ -150,11 +154,12 @@ class MachineListModel(ListModel): return self.appendItem({ - "componentType": "MACHINE", - "name": container_stack.getName(), - "id": container_stack.getId(), - "metadata": container_stack.getMetaData().copy(), - "isOnline": is_online, - "isAbstractMachine": parseBool(container_stack.getMetaDataEntry("is_abstract_machine", False)), - "machineCount": machine_count, - }) + "componentType": "MACHINE", + "name": container_stack.getName(), + "id": container_stack.getId(), + "metadata": container_stack.getMetaData().copy(), + "isOnline": is_online, + "isAbstractMachine": parseBool(container_stack.getMetaDataEntry("is_abstract_machine", False)), + "machineCount": machine_count, + "catergory": "connected" if is_online else "other", + }) diff --git a/resources/qml/PrinterSelector/MachineSelectorList.qml b/resources/qml/PrinterSelector/MachineSelectorList.qml index 1b0264929d..b3a65da7da 100644 --- a/resources/qml/PrinterSelector/MachineSelectorList.qml +++ b/resources/qml/PrinterSelector/MachineSelectorList.qml @@ -10,7 +10,7 @@ import Cura 1.0 as Cura ListView { id: listView - section.property: "isOnline" + section.property: "category" property real contentHeight: childrenRect.height property var onSelectPrinter @@ -21,7 +21,15 @@ ListView section.delegate: UM.Label { - text: section == "true" ? catalog.i18nc("@label", "Connected printers") : catalog.i18nc("@label", "Other printers") + text: { + switch (section) + { + case "connected": + return catalog.i18nc("@label", "Connected printers"); + case "other": + return catalog.i18nc("@label", "Other printers"); + } + } height: UM.Theme.getSize("action_button").height width: parent.width - scrollBar.width leftPadding: UM.Theme.getSize("default_margin").width From 27267deb22dd02b7d5ce93f79f7c65d9dd61938c Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 9 Nov 2022 17:16:47 +0100 Subject: [PATCH 30/48] Fix clicking `PrepareMenu` CURA-9424 --- plugins/PrepareStage/PrepareMenu.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index 3f24d619ac..12db91635b 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -78,7 +78,7 @@ Item width: Math.round(parent.width / 2 - leftPadding * 1.5) onClicked: { - toggleContent() + machineSelection.toggleContent() Cura.Actions.addMachine.trigger() } }, @@ -94,7 +94,7 @@ Item width: parent.width / 2 - rightPadding * 1.5 onClicked: { - toggleContent() + machineSelection.toggleContent() Cura.Actions.configureMachines.trigger() } } From 0c79ec738e9eb95cd1de304dcea24ccba332bf36 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 9 Nov 2022 23:05:06 +0100 Subject: [PATCH 31/48] Fix show/hide button in WorkSpaceDialog printer selector CURA-9424 --- cura/Machines/Models/MachineListModel.py | 29 ++++++++++++------------ plugins/3MFReader/WorkspaceDialog.py | 4 ++-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index cb7c3b5998..82b889ac4b 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -29,11 +29,11 @@ class MachineListModel(ListModel): IsAbstractMachineRole = Qt.ItemDataRole.UserRole + 7 ComponentTypeRole = Qt.ItemDataRole.UserRole + 8 - def __init__(self, parent: Optional[QObject] = None, machines: List[GlobalStack] = None, listenToChanges: bool = True) -> None: + def __init__(self, parent: Optional[QObject] = None, machines_filter: Optional[List[GlobalStack]] = None) -> None: super().__init__(parent) self._show_cloud_printers = False - self._machines = machines + self._machines_filter = machines_filter self._catalog = i18nCatalog("cura") @@ -51,11 +51,10 @@ class MachineListModel(ListModel): self._change_timer.setSingleShot(True) self._change_timer.timeout.connect(self._update) - if listenToChanges: - CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerChanged) - CuraContainerRegistry.getInstance().containerMetaDataChanged.connect(self._onContainerChanged) - CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged) - self._updateDelayed() + CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerChanged) + CuraContainerRegistry.getInstance().containerMetaDataChanged.connect(self._onContainerChanged) + CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged) + self._updateDelayed() showCloudPrintersChanged = pyqtSignal(bool) @@ -80,19 +79,13 @@ class MachineListModel(ListModel): self._change_timer.start() def _getMachineStacks(self) -> List[ContainerStack]: - if self._machines is not None: - return self._machines return CuraContainerRegistry.getInstance().findContainerStacks(type="machine") def _getAbstractMachineStacks(self) -> List[ContainerStack]: - if self._machines is not None: - return list(filter(lambda machine: parseBool(machine.getMetaDataEntry("is_abstract_machine", False)), self._machines)) return CuraContainerRegistry.getInstance().findContainerStacks(is_abstract_machine = "True") - def update(self, machines: List[ContainerStack] = None) -> None: - if machines is not None: - self._machines = machines - + def set_machines_filter(self, machines_filter: Optional[List[GlobalStack]]) -> None: + self._machines_filter = machines_filter self._update() def _update(self) -> None: @@ -106,6 +99,12 @@ class MachineListModel(ListModel): abstract_machine_stacks = self._getAbstractMachineStacks() abstract_machine_stacks.sort(key = lambda machine: machine.getName().upper(), reverse = True) + + if self._machines_filter is not None: + filter_ids = [machine_filter.id for machine_filter in self._machines_filter] + other_machine_stacks = [machine for machine in other_machine_stacks if machine.id in filter_ids] + abstract_machine_stacks = [machine for machine in abstract_machine_stacks if machine.id in filter_ids] + for abstract_machine in abstract_machine_stacks: definition_id = abstract_machine.definition.getId() online_machine_stacks = machines_manager.getMachinesWithDefinition(definition_id, online_only = True) diff --git a/plugins/3MFReader/WorkspaceDialog.py b/plugins/3MFReader/WorkspaceDialog.py index 9e0c8158cd..da7b8737e3 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -62,7 +62,7 @@ class WorkspaceDialog(QObject): self._extruders = [] self._objects_on_plate = False self._is_printer_group = False - self._updatable_machines_model = MachineListModel(self, listenToChanges=False) + self._updatable_machines_model = MachineListModel(self) self._missing_package_metadata: List[Dict[str, str]] = [] self._plugin_registry: PluginRegistry = CuraApplication.getInstance().getPluginRegistry() self._install_missing_package_dialog: Optional[QObject] = None @@ -164,7 +164,7 @@ class WorkspaceDialog(QObject): return cast(MachineListModel, self._updatable_machines_model) def setUpdatableMachines(self, updatable_machines: List[GlobalStack]) -> None: - self._updatable_machines_model.update(updatable_machines) + self._updatable_machines_model.set_machines_filter(updatable_machines) self.updatableMachinesChanged.emit() @pyqtProperty(str, notify=qualityTypeChanged) From c59f5a5c00f43687b8d477b827758d1f0a2168e1 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 10 Nov 2022 14:48:38 +0100 Subject: [PATCH 32/48] Add tooltip in WorkspaceDialog over the printer selection drop down. CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 4 +- plugins/3MFReader/WorkspaceSection.qml | 98 +++++++++++++++++--------- 2 files changed, 64 insertions(+), 38 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 23f9231230..7417a58126 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -101,7 +101,7 @@ UM.Dialog } comboboxTitle: catalog.i18nc("@action:label", "Open With") - comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?") + comboboxTooltipText: catalog.i18nc("@info:tooltip", "Printer settings will be updated to match the settings saved with the project.") comboboxVisible: workspaceDialog.visible && manager.updatableMachinesModel.count > 1 combobox: Cura.MachineSelector { @@ -188,7 +188,6 @@ UM.Dialog } } - comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?") comboboxVisible: manager.qualityChangesConflict combobox: Cura.ComboBox { @@ -231,7 +230,6 @@ UM.Dialog } } - comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the material be resolved?") comboboxVisible: manager.materialConflict combobox: Cura.ComboBox diff --git a/plugins/3MFReader/WorkspaceSection.qml b/plugins/3MFReader/WorkspaceSection.qml index 211d8776f3..b11cc04cd7 100644 --- a/plugins/3MFReader/WorkspaceSection.qml +++ b/plugins/3MFReader/WorkspaceSection.qml @@ -23,41 +23,6 @@ Item height: childrenRect.height anchors.leftMargin: UM.Theme.getSize("default_margin").width - UM.TooltipArea - { - id: comboboxTooltip - width: (parent.width / 2.5) | 0 - height: visible ? UM.Theme.getSize("default_margin").height : 0 - anchors.top: parent.top - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width - - text: comboboxTooltipText - visible: comboboxVisible - - UM.Label - { - id: comboboxLabel - anchors.top: parent.top - anchors.left: parent.left - anchors.topMargin: UM.Theme.getSize("default_margin").height - visible: comboboxVisible && text != "" - text: "" - font: UM.Theme.getFont("default_bold") - } - - Loader - { - id: comboboxLoader - width: parent.width - height: UM.Theme.getSize("button").height - anchors.top: comboboxLabel.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.left: parent.left - sourceComponent: combobox - } - } - Row { id: sectionTitleRow @@ -82,6 +47,69 @@ Item } } + Item + { + id: comboboxTooltip + width: (parent.width / 2.5) | 0 + height: visible ? UM.Theme.getSize("default_margin").height : 0 + anchors.top: parent.top + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + visible: comboboxVisible + + UM.Label + { + id: comboboxLabel + anchors.top: parent.top + anchors.left: parent.left + anchors.topMargin: UM.Theme.getSize("default_margin").height + visible: comboboxVisible && text != "" + text: "" + font: UM.Theme.getFont("default_bold") + } + + Loader + { + id: comboboxLoader + width: parent.width + height: UM.Theme.getSize("button").height + anchors.top: comboboxLabel.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.left: parent.left + sourceComponent: combobox + } + + MouseArea + { + id: helpIconMouseArea + anchors.right: parent.right + anchors.verticalCenter: comboboxLabel.verticalCenter + width: childrenRect.width + height: childrenRect.height + hoverEnabled: true + + UM.ColorImage + { + width: UM.Theme.getSize("section_icon").width + height: width + + visible: comboboxTooltipText != "" + source: UM.Theme.getIcon("Help") + + UM.ToolTip + { + text: comboboxTooltipText + visible: helpIconMouseArea.containsMouse + targetPoint: Qt.point(parent.x + Math.round(parent.width / 2), parent.y) + x: 0 + y: parent.y + parent.height + UM.Theme.getSize("default_margin").height + width: UM.Theme.getSize("tooltip").width + } + } + } + } + + Loader { width: parent.width From bbadc9c8877e24ce6c1c797946e331e0577749cb Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 11 Nov 2022 13:44:37 +0100 Subject: [PATCH 33/48] Apply suggestions from code review Co-authored-by: Jelle Spijker --- cura/Machines/Models/MachineListModel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index 82b889ac4b..b9ed51ac10 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -79,7 +79,7 @@ class MachineListModel(ListModel): self._change_timer.start() def _getMachineStacks(self) -> List[ContainerStack]: - return CuraContainerRegistry.getInstance().findContainerStacks(type="machine") + return CuraContainerRegistry.getInstance().findContainerStacks(type = "machine") def _getAbstractMachineStacks(self) -> List[ContainerStack]: return CuraContainerRegistry.getInstance().findContainerStacks(is_abstract_machine = "True") From 1d34cd01c1f9c9b3e747a9819f7d843019cd0c49 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 11 Nov 2022 16:34:08 +0100 Subject: [PATCH 34/48] Removed unused UpdatableMachinesModel.py CURA-9424 --- plugins/3MFReader/UpdatableMachinesModel.py | 43 --------------------- 1 file changed, 43 deletions(-) delete mode 100644 plugins/3MFReader/UpdatableMachinesModel.py diff --git a/plugins/3MFReader/UpdatableMachinesModel.py b/plugins/3MFReader/UpdatableMachinesModel.py deleted file mode 100644 index 9d6eee6c3e..0000000000 --- a/plugins/3MFReader/UpdatableMachinesModel.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (c) 2020 Ultimaker B.V. -# Cura is released under the terms of the LGPLv3 or higher. - -from typing import Dict, List - -from PyQt6.QtCore import Qt - -from UM.Qt.ListModel import ListModel -from cura.Settings.GlobalStack import GlobalStack - -create_new_list_item = { - "id": "new", - "name": "Create new", - "displayName": "Create new", - "type": "default_option" # to make sure we are not mixing the "Create new" option with a printer with id "new" -} # type: Dict[str, str] - - -class UpdatableMachinesModel(ListModel): - """Model that holds cura packages. - - By setting the filter property the instances held by this model can be changed. - """ - - def __init__(self, parent = None) -> None: - super().__init__(parent) - - self.addRoleName(Qt.ItemDataRole.UserRole + 1, "id") - self.addRoleName(Qt.ItemDataRole.UserRole + 2, "name") - self.addRoleName(Qt.ItemDataRole.UserRole + 3, "displayName") - self.addRoleName(Qt.ItemDataRole.UserRole + 4, "type") # Either "default_option" or "machine" - - def update(self, machines: List[GlobalStack]) -> None: - items = [create_new_list_item] # type: List[Dict[str, str]] - - for machine in sorted(machines, key = lambda printer: printer.name): - items.append({ - "id": machine.id, - "name": machine.name, - "displayName": "Update " + machine.name, - "type": "machine" - }) - self.setItems(items) From 44d9df57e499eb3cb4489f06cb706c3128fa2e6c Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 11 Nov 2022 16:34:22 +0100 Subject: [PATCH 35/48] Update drop down to show correct printer icons in header CURA-9424 --- plugins/3MFReader/WorkspaceDialog.py | 22 ++++++++++++++++++++++ plugins/3MFReader/WorkspaceDialog.qml | 10 ++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.py b/plugins/3MFReader/WorkspaceDialog.py index da7b8737e3..ebf389b396 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -66,6 +66,8 @@ class WorkspaceDialog(QObject): self._missing_package_metadata: List[Dict[str, str]] = [] self._plugin_registry: PluginRegistry = CuraApplication.getInstance().getPluginRegistry() self._install_missing_package_dialog: Optional[QObject] = None + self._is_abstract_machine = False + self._is_online_machine = False machineConflictChanged = pyqtSignal() qualityChangesConflictChanged = pyqtSignal() @@ -79,6 +81,8 @@ class WorkspaceDialog(QObject): intentNameChanged = pyqtSignal() machineNameChanged = pyqtSignal() updatableMachinesChanged = pyqtSignal() + isAbstractMachineChanged = pyqtSignal() + isOnlineChanged = pyqtSignal() materialLabelsChanged = pyqtSignal() objectsOnPlateChanged = pyqtSignal() numUserSettingsChanged = pyqtSignal() @@ -167,6 +171,24 @@ class WorkspaceDialog(QObject): self._updatable_machines_model.set_machines_filter(updatable_machines) self.updatableMachinesChanged.emit() + @pyqtProperty(bool, notify = isAbstractMachineChanged) + def isAbstractMachine(self) -> bool: + return self._is_abstract_machine + + @pyqtSlot(bool) + def setIsAbstractMachine(self, is_abstract_machine: bool) -> None: + self._is_abstract_machine = is_abstract_machine + self.isAbstractMachineChanged.emit() + + @pyqtProperty(bool, notify = isOnlineChanged) + def isOnline(self) -> bool: + return self._is_online_machine + + @pyqtSlot(bool) + def setIsNetworkedMachine(self, is_online_machine: bool) -> None: + self._is_online_machine = is_online_machine + self.isOnlineChanged.emit() + @pyqtProperty(str, notify=qualityTypeChanged) def qualityType(self) -> str: return self._quality_type diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 7417a58126..3d22e18874 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -112,10 +112,10 @@ UM.Dialog machineListModel: manager.updatableMachinesModel machineName: manager.machineName - isNetworkPrinter: false isConnectedCloudPrinter: false isCloudRegistered: false - isGroup: false + isNetworkPrinter: manager.isOnline + isGroup: manager.isAbstractMachine minDropDownWidth: machineSelector.width @@ -129,10 +129,10 @@ UM.Dialog onClicked: { machineSelector.machineName = catalog.i18nc("@button", "Create new") - machineSelector.isNetworkPrinter = false + manager.setIsAbstractMachine(false) + manager.setIsNetworkedMachine(false) machineSelector.isConnectedCloudPrinter = false machineSelector.isCloudRegistered = false - machineSelector.isGroup = false toggleContent() manager.setResolveStrategy("machine", "new") @@ -145,6 +145,8 @@ UM.Dialog toggleContent(); manager.setResolveStrategy("machine", "override") manager.setMachineToOverride(machine.id) + manager.setIsAbstractMachine(machine.isAbstractMachine) + manager.setIsNetworkedMachine(machine.isOnline) machineSelector.machineName = machine.name } } From 62274c4dacd2a938cac4ef477b502776d32c4686 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 11 Nov 2022 17:04:39 +0100 Subject: [PATCH 36/48] Revert Some of "Fix show/hide button in WorkSpaceDialog printer selector" This reverts commit 0c79ec73 --- cura/Machines/Models/MachineListModel.py | 11 ++++++----- plugins/3MFReader/WorkspaceDialog.py | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index b9ed51ac10..d1aa22cfcd 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -29,7 +29,7 @@ class MachineListModel(ListModel): IsAbstractMachineRole = Qt.ItemDataRole.UserRole + 7 ComponentTypeRole = Qt.ItemDataRole.UserRole + 8 - def __init__(self, parent: Optional[QObject] = None, machines_filter: Optional[List[GlobalStack]] = None) -> None: + def __init__(self, parent: Optional[QObject] = None, machines_filter: List[GlobalStack] = None, listenToChanges: bool = True) -> None: super().__init__(parent) self._show_cloud_printers = False @@ -51,10 +51,11 @@ class MachineListModel(ListModel): self._change_timer.setSingleShot(True) self._change_timer.timeout.connect(self._update) - CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerChanged) - CuraContainerRegistry.getInstance().containerMetaDataChanged.connect(self._onContainerChanged) - CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged) - self._updateDelayed() + if listenToChanges: + CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerChanged) + CuraContainerRegistry.getInstance().containerMetaDataChanged.connect(self._onContainerChanged) + CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged) + self._updateDelayed() showCloudPrintersChanged = pyqtSignal(bool) diff --git a/plugins/3MFReader/WorkspaceDialog.py b/plugins/3MFReader/WorkspaceDialog.py index ebf389b396..1cc134b5e5 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -62,7 +62,7 @@ class WorkspaceDialog(QObject): self._extruders = [] self._objects_on_plate = False self._is_printer_group = False - self._updatable_machines_model = MachineListModel(self) + self._updatable_machines_model = MachineListModel(self, listenToChanges=False) self._missing_package_metadata: List[Dict[str, str]] = [] self._plugin_registry: PluginRegistry = CuraApplication.getInstance().getPluginRegistry() self._install_missing_package_dialog: Optional[QObject] = None @@ -168,7 +168,7 @@ class WorkspaceDialog(QObject): return cast(MachineListModel, self._updatable_machines_model) def setUpdatableMachines(self, updatable_machines: List[GlobalStack]) -> None: - self._updatable_machines_model.set_machines_filter(updatable_machines) + self._updatable_machines_model.update(updatable_machines) self.updatableMachinesChanged.emit() @pyqtProperty(bool, notify = isAbstractMachineChanged) From 57e1c7a4ce854460675a681e5b6f0eca60a065df Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 11 Nov 2022 17:08:45 +0100 Subject: [PATCH 37/48] Commit suggestion by Jelle CURA-9424 --- cura/Machines/Models/MachineListModel.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index d1aa22cfcd..03c3fbdcaa 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -129,22 +129,13 @@ class MachineListModel(ListModel): other_machine_stacks.remove(stack) if len(abstract_machine_stacks) > 0: - if self._show_cloud_printers: - self.appendItem({ - "componentType": "HIDE_BUTTON", - "isOnline": True, - "isAbstractMachine": False, - "machineCount": 0, - "catergory": "connected", - }) - else: - self.appendItem({ - "componentType": "SHOW_BUTTON", - "isOnline": True, - "isAbstractMachine": False, - "machineCount": 0, - "catergory": "connected", - }) + self.appendItem({ + "componentType": "HIDE_BUTTON" if self._show_cloud_printers else "SHOW_BUTTON", + "isOnline": True, + "isAbstractMachine": False, + "machineCount": 0, + "catergory": "connected", + }) for stack in other_machine_stacks: self.addItem(stack, False) From d6cab972c6b889b6ab55b97440cf831160b0908b Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 14 Nov 2022 12:57:38 +0100 Subject: [PATCH 38/48] Fix call to incorrect function after revert. CURA-9424 --- plugins/3MFReader/WorkspaceDialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/3MFReader/WorkspaceDialog.py b/plugins/3MFReader/WorkspaceDialog.py index 1cc134b5e5..7d5590a92c 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -168,7 +168,7 @@ class WorkspaceDialog(QObject): return cast(MachineListModel, self._updatable_machines_model) def setUpdatableMachines(self, updatable_machines: List[GlobalStack]) -> None: - self._updatable_machines_model.update(updatable_machines) + self._updatable_machines_model.set_machines_filter(updatable_machines) self.updatableMachinesChanged.emit() @pyqtProperty(bool, notify = isAbstractMachineChanged) From 959c42d96a259428fbdaaa87a612a93f7b87069f Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 14 Nov 2022 13:34:46 +0100 Subject: [PATCH 39/48] The printer to override was not being set initially, causing file loading to fail when not selecting a printer in the MachineSelector. Fix is to set it on initialization from the WorkspaceReader CURA-9424 --- plugins/3MFReader/ThreeMFWorkspaceReader.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index bec50b5660..f810ff58e5 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -600,6 +600,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): self._dialog.setActiveMode(active_mode) self._dialog.setUpdatableMachines(updatable_machines) self._dialog.setMachineName(machine_name) + self._dialog.setMachineToOverride(global_stack_id) self._dialog.setMaterialLabels(material_labels) self._dialog.setMachineType(machine_type) self._dialog.setExtruders(extruders) From 7f9c183072a3ec9246be5251787ff26f862f6b49 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 14 Nov 2022 13:35:03 +0100 Subject: [PATCH 40/48] Remove redundant assignments CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 3d22e18874..8b93b7f633 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -131,8 +131,6 @@ UM.Dialog machineSelector.machineName = catalog.i18nc("@button", "Create new") manager.setIsAbstractMachine(false) manager.setIsNetworkedMachine(false) - machineSelector.isConnectedCloudPrinter = false - machineSelector.isCloudRegistered = false toggleContent() manager.setResolveStrategy("machine", "new") From 90ce031b275b4a8e42f3851045ed8949917d8432 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 15 Nov 2022 13:49:02 +0100 Subject: [PATCH 41/48] Add default case CURA-9424 --- resources/qml/PrinterSelector/MachineSelectorList.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/qml/PrinterSelector/MachineSelectorList.qml b/resources/qml/PrinterSelector/MachineSelectorList.qml index b3a65da7da..ddf9586065 100644 --- a/resources/qml/PrinterSelector/MachineSelectorList.qml +++ b/resources/qml/PrinterSelector/MachineSelectorList.qml @@ -28,6 +28,8 @@ ListView return catalog.i18nc("@label", "Connected printers"); case "other": return catalog.i18nc("@label", "Other printers"); + default: + return catalog.i18nc("@label", "Other printers"); } } height: UM.Theme.getSize("action_button").height From cac9d67352ae0613fe3ddadad76230c46666d042 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 15 Nov 2022 13:49:55 +0100 Subject: [PATCH 42/48] Apply suggestions from code review Co-authored-by: Casper Lamboo --- plugins/3MFReader/WorkspaceRow.qml | 4 ++-- plugins/3MFReader/WorkspaceSection.qml | 2 +- plugins/PrepareStage/PrepareMenu.qml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/3MFReader/WorkspaceRow.qml b/plugins/3MFReader/WorkspaceRow.qml index 72cea7b5bd..8d9f1f25b3 100644 --- a/plugins/3MFReader/WorkspaceRow.qml +++ b/plugins/3MFReader/WorkspaceRow.qml @@ -21,14 +21,14 @@ Row { id: leftLabel text: catalog.i18nc("@action:label", "Type") - width: (parent.width / 4) | 0 + width: Math.round(parent.width / 4) wrapMode: Text.WordWrap } UM.Label { id: rightLabel text: manager.machineType - width: (parent.width / 3) | 0 + width: Math.round(parent.width / 3) wrapMode: Text.WordWrap } } \ No newline at end of file diff --git a/plugins/3MFReader/WorkspaceSection.qml b/plugins/3MFReader/WorkspaceSection.qml index b11cc04cd7..6eb8f50bdf 100644 --- a/plugins/3MFReader/WorkspaceSection.qml +++ b/plugins/3MFReader/WorkspaceSection.qml @@ -50,7 +50,7 @@ Item Item { id: comboboxTooltip - width: (parent.width / 2.5) | 0 + width: Math.round(parent.width / 2.5) height: visible ? UM.Theme.getSize("default_margin").height : 0 anchors.top: parent.top anchors.right: parent.right diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index 12db91635b..ab9b9b1b3d 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -91,7 +91,7 @@ Item fixedWidthMode: true // The maximum width of the button is half of the total space, minus the padding of the parent, the right // padding of the component and half the spacing because of the space between buttons. - width: parent.width / 2 - rightPadding * 1.5 + width: Math.round(parent.width / 2 - rightPadding * 1.5) onClicked: { machineSelection.toggleContent() From e4ad9cb48cf7418604626f820f8cbf73ae8de33f Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 15 Nov 2022 14:08:47 +0100 Subject: [PATCH 43/48] Move base hovered logic out of ComboBox.qml since base is undefined in most places the component is used. CURA-9424 --- plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml | 1 + resources/qml/Settings/SettingComboBox.qml | 1 + resources/qml/Settings/SettingExtruder.qml | 2 ++ resources/qml/Settings/SettingOptionalExtruder.qml | 1 + resources/qml/Widgets/ComboBox.qml | 3 ++- 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index 2d4b3e01e5..be7aebcf7a 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -150,6 +150,7 @@ Item width: parent.width / 2 - UM.Theme.getSize("default_margin").width height: UM.Theme.getSize("setting_control").height textRole: "text" + forceHighlight: base.hovered model: ListModel { diff --git a/resources/qml/Settings/SettingComboBox.qml b/resources/qml/Settings/SettingComboBox.qml index cbabb3ffd4..c57c0a1548 100644 --- a/resources/qml/Settings/SettingComboBox.qml +++ b/resources/qml/Settings/SettingComboBox.qml @@ -18,6 +18,7 @@ SettingItem model: definition.options textRole: "value" + forceHighlight: base.hovered anchors.fill: parent diff --git a/resources/qml/Settings/SettingExtruder.qml b/resources/qml/Settings/SettingExtruder.qml index 567161b8f6..63413aa9bd 100644 --- a/resources/qml/Settings/SettingExtruder.qml +++ b/resources/qml/Settings/SettingExtruder.qml @@ -17,6 +17,8 @@ SettingItem id: control anchors.fill: parent + forceHighlight: base.hovered + property var extrudersModel: CuraApplication.getExtrudersModel() model: extrudersModel diff --git a/resources/qml/Settings/SettingOptionalExtruder.qml b/resources/qml/Settings/SettingOptionalExtruder.qml index 22f03d44a2..a9fdc626b9 100644 --- a/resources/qml/Settings/SettingOptionalExtruder.qml +++ b/resources/qml/Settings/SettingOptionalExtruder.qml @@ -23,6 +23,7 @@ SettingItem { id: control anchors.fill: parent + forceHighlight: base.hovered model: base.extrudersWithOptionalModel diff --git a/resources/qml/Widgets/ComboBox.qml b/resources/qml/Widgets/ComboBox.qml index a7eeb33f6a..06ac2425bb 100644 --- a/resources/qml/Widgets/ComboBox.qml +++ b/resources/qml/Widgets/ComboBox.qml @@ -19,6 +19,7 @@ ComboBox property var defaultTextOnEmptyIndex: "" // Text displayed in the combobox when the model has items but no item is selected property alias textFormat: contentLabel.textFormat property alias backgroundColor: background.color + property bool forceHighlight: false enabled: delegateModel.count > 0 @@ -46,7 +47,7 @@ ComboBox State { name: "highlighted" - when: ((base != undefined && base.hovered) || control.hovered) && !control.activeFocus + when: (control.hovered && !control.activeFocus) || forceHighlight PropertyChanges { target: background From dd0411f1713fb3590dfec0d3232d2d6a314f1353 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 15 Nov 2022 14:56:25 +0100 Subject: [PATCH 44/48] isOnline was incorrectly being used instead of isNetworked. This caused offline printers not to show an Icon. Fixed CURA-9424 --- cura/Machines/Models/MachineListModel.py | 5 ++++- plugins/3MFReader/WorkspaceDialog.py | 8 ++++---- plugins/3MFReader/WorkspaceDialog.qml | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index 03c3fbdcaa..b84dc26f0a 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -5,7 +5,7 @@ # online cloud connected printers are represented within this ListModel. Additional information such as the number of # connected printers for each printer type is gathered. -from typing import Optional, List +from typing import Optional, List, cast from PyQt6.QtCore import Qt, QTimer, QObject, pyqtSlot, pyqtProperty, pyqtSignal @@ -28,6 +28,7 @@ class MachineListModel(ListModel): MachineCountRole = Qt.ItemDataRole.UserRole + 6 IsAbstractMachineRole = Qt.ItemDataRole.UserRole + 7 ComponentTypeRole = Qt.ItemDataRole.UserRole + 8 + IsNetworkedMachineRole = Qt.ItemDataRole.UserRole + 9 def __init__(self, parent: Optional[QObject] = None, machines_filter: List[GlobalStack] = None, listenToChanges: bool = True) -> None: super().__init__(parent) @@ -45,6 +46,7 @@ class MachineListModel(ListModel): self.addRoleName(self.MachineCountRole, "machineCount") self.addRoleName(self.IsAbstractMachineRole, "isAbstractMachine") self.addRoleName(self.ComponentTypeRole, "componentType") + self.addRoleName(self.IsNetworkedMachineRole, "isNetworked") self._change_timer = QTimer() self._change_timer.setInterval(200) @@ -151,6 +153,7 @@ class MachineListModel(ListModel): "metadata": container_stack.getMetaData().copy(), "isOnline": is_online, "isAbstractMachine": parseBool(container_stack.getMetaDataEntry("is_abstract_machine", False)), + "isNetworked": cast(GlobalStack, container_stack).hasNetworkedConnection() if isinstance(container_stack, GlobalStack) else False, "machineCount": machine_count, "catergory": "connected" if is_online else "other", }) diff --git a/plugins/3MFReader/WorkspaceDialog.py b/plugins/3MFReader/WorkspaceDialog.py index 7d5590a92c..15650b5164 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -82,7 +82,7 @@ class WorkspaceDialog(QObject): machineNameChanged = pyqtSignal() updatableMachinesChanged = pyqtSignal() isAbstractMachineChanged = pyqtSignal() - isOnlineChanged = pyqtSignal() + isNetworkedChanged = pyqtSignal() materialLabelsChanged = pyqtSignal() objectsOnPlateChanged = pyqtSignal() numUserSettingsChanged = pyqtSignal() @@ -180,14 +180,14 @@ class WorkspaceDialog(QObject): self._is_abstract_machine = is_abstract_machine self.isAbstractMachineChanged.emit() - @pyqtProperty(bool, notify = isOnlineChanged) - def isOnline(self) -> bool: + @pyqtProperty(bool, notify = isNetworkedChanged) + def isNetworked(self) -> bool: return self._is_online_machine @pyqtSlot(bool) def setIsNetworkedMachine(self, is_online_machine: bool) -> None: self._is_online_machine = is_online_machine - self.isOnlineChanged.emit() + self.isNetworkedChanged.emit() @pyqtProperty(str, notify=qualityTypeChanged) def qualityType(self) -> str: diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 8b93b7f633..2d9a7eba2d 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -114,7 +114,7 @@ UM.Dialog isConnectedCloudPrinter: false isCloudRegistered: false - isNetworkPrinter: manager.isOnline + isNetworkPrinter: manager.isNetworked isGroup: manager.isAbstractMachine minDropDownWidth: machineSelector.width @@ -144,7 +144,7 @@ UM.Dialog manager.setResolveStrategy("machine", "override") manager.setMachineToOverride(machine.id) manager.setIsAbstractMachine(machine.isAbstractMachine) - manager.setIsNetworkedMachine(machine.isOnline) + manager.setIsNetworkedMachine(machine.isNetworked) machineSelector.machineName = machine.name } } From cd07647b2476ae714ab6fdf2c0442adde534ee91 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 15 Nov 2022 14:57:39 +0100 Subject: [PATCH 45/48] Change misleading variable names CURA-9424 --- plugins/3MFReader/WorkspaceDialog.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.py b/plugins/3MFReader/WorkspaceDialog.py index 15650b5164..afa1deecfd 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -67,7 +67,7 @@ class WorkspaceDialog(QObject): self._plugin_registry: PluginRegistry = CuraApplication.getInstance().getPluginRegistry() self._install_missing_package_dialog: Optional[QObject] = None self._is_abstract_machine = False - self._is_online_machine = False + self._is_networked_machine = False machineConflictChanged = pyqtSignal() qualityChangesConflictChanged = pyqtSignal() @@ -182,11 +182,11 @@ class WorkspaceDialog(QObject): @pyqtProperty(bool, notify = isNetworkedChanged) def isNetworked(self) -> bool: - return self._is_online_machine + return self._is_networked_machine @pyqtSlot(bool) - def setIsNetworkedMachine(self, is_online_machine: bool) -> None: - self._is_online_machine = is_online_machine + def setIsNetworkedMachine(self, is_networked_machine: bool) -> None: + self._is_networked_machine = is_networked_machine self.isNetworkedChanged.emit() @pyqtProperty(str, notify=qualityTypeChanged) From 28862c89e58b7a45f710b5931ab8ce283ba7dfe0 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 15 Nov 2022 15:03:23 +0100 Subject: [PATCH 46/48] Show online badge and printer icon when initially loading machine selector CURA-9424 --- plugins/3MFReader/ThreeMFWorkspaceReader.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index f810ff58e5..8db6334552 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -600,6 +600,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): self._dialog.setActiveMode(active_mode) self._dialog.setUpdatableMachines(updatable_machines) self._dialog.setMachineName(machine_name) + self._dialog.setIsNetworkedMachine(existing_global_stack.hasNetworkedConnection()) self._dialog.setMachineToOverride(global_stack_id) self._dialog.setMaterialLabels(material_labels) self._dialog.setMachineType(machine_type) From a30fbf5a8f9367c10e4fe905b2c790d078fdda7f Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 15 Nov 2022 15:10:44 +0100 Subject: [PATCH 47/48] Disable connection status icon for drop down in WorkspaceDialog. It is not possible to display the correct status for LAN printers without making them the active printer anyway. CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 1 + resources/qml/PrinterSelector/MachineSelector.qml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 2d9a7eba2d..8dcf1e8454 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -116,6 +116,7 @@ UM.Dialog isCloudRegistered: false isNetworkPrinter: manager.isNetworked isGroup: manager.isAbstractMachine + connectionStatus: "" minDropDownWidth: machineSelector.width diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index b8bacc8f36..b8b27049f6 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -33,7 +33,7 @@ Cura.ExpandablePopup property list buttons - readonly property string connectionStatus: { + property string connectionStatus: { if (isNetworkPrinter) { return "printer_connected" @@ -148,7 +148,7 @@ Cura.ExpandablePopup color: connectionStatus == "printer_cloud_not_available" ? UM.Theme.getColor("cloud_unavailable") : UM.Theme.getColor("primary") - visible: isNetworkPrinter || isCloudRegistered + visible: (isNetworkPrinter || isCloudRegistered) && source != "" // Make a themable circle in the background so we can change it in other themes Rectangle From dc65e801d09217ac1b1cb485e509a9eae35587c4 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Tue, 15 Nov 2022 15:35:16 +0100 Subject: [PATCH 48/48] Set machine `isAbractMachine` in workspace dialog initialisation --- plugins/3MFReader/ThreeMFWorkspaceReader.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 8db6334552..0163877e3a 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -9,6 +9,7 @@ from typing import cast, Dict, List, Optional, Tuple, Any, Set import xml.etree.ElementTree as ET +from UM.Util import parseBool from UM.Workspace.WorkspaceReader import WorkspaceReader from UM.Application import Application @@ -601,6 +602,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): self._dialog.setUpdatableMachines(updatable_machines) self._dialog.setMachineName(machine_name) self._dialog.setIsNetworkedMachine(existing_global_stack.hasNetworkedConnection()) + self._dialog.setIsAbstractMachine(parseBool(existing_global_stack.getMetaDataEntry("is_abstract_machine", False))) self._dialog.setMachineToOverride(global_stack_id) self._dialog.setMaterialLabels(material_labels) self._dialog.setMachineType(machine_type)