Просмотр исходного кода

Merge branch 'master' into ui_rework_4_0

Diego Prado Gesto 6 лет назад
Родитель
Сommit
7a12cc53cc

+ 4 - 1
cura/Machines/MaterialManager.py

@@ -644,8 +644,11 @@ class MaterialManager(QObject):
         machine_manager = self._application.getMachineManager()
         machine_manager = self._application.getMachineManager()
         extruder_stack = machine_manager.activeStack
         extruder_stack = machine_manager.activeStack
 
 
+        machine_definition = self._application.getGlobalContainerStack().definition
+        preferred_material = machine_definition.getMetaDataEntry("preferred_material")
+
         approximate_diameter = str(extruder_stack.approximateMaterialDiameter)
         approximate_diameter = str(extruder_stack.approximateMaterialDiameter)
-        root_material_id = "generic_pla"
+        root_material_id = preferred_material if preferred_material else "generic_pla"
         root_material_id = self.getRootMaterialIDForDiameter(root_material_id, approximate_diameter)
         root_material_id = self.getRootMaterialIDForDiameter(root_material_id, approximate_diameter)
         material_group = self.getMaterialGroup(root_material_id)
         material_group = self.getMaterialGroup(root_material_id)
 
 

+ 6 - 1
cura/PrintInformation.py

@@ -371,9 +371,14 @@ class PrintInformation(QObject):
 
 
             # Strip the old "curaproject" extension from the name
             # Strip the old "curaproject" extension from the name
             OLD_CURA_PROJECT_EXT = ".curaproject"
             OLD_CURA_PROJECT_EXT = ".curaproject"
-            if self._base_name.endswith(OLD_CURA_PROJECT_EXT):
+            if self._base_name.lower().endswith(OLD_CURA_PROJECT_EXT):
                 self._base_name = self._base_name[:len(self._base_name) - len(OLD_CURA_PROJECT_EXT)]
                 self._base_name = self._base_name[:len(self._base_name) - len(OLD_CURA_PROJECT_EXT)]
 
 
+            # CURA-5896 Try to strip extra extensions with an infinite amount of ".curaproject.3mf".
+            OLD_CURA_PROJECT_3MF_EXT = ".curaproject.3mf"
+            while self._base_name.lower().endswith(OLD_CURA_PROJECT_3MF_EXT):
+                self._base_name = self._base_name[:len(self._base_name) - len(OLD_CURA_PROJECT_3MF_EXT)]
+
             self._updateJobName()
             self._updateJobName()
 
 
     @pyqtProperty(str, fset = setBaseName, notify = baseNameChanged)
     @pyqtProperty(str, fset = setBaseName, notify = baseNameChanged)

+ 1 - 1
cura/PrinterOutput/NetworkedPrinterOutputDevice.py

@@ -213,7 +213,7 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
         request = self._createEmptyRequest(target)
         request = self._createEmptyRequest(target)
         self._last_request_time = time()
         self._last_request_time = time()
         if self._manager is not None:
         if self._manager is not None:
-            reply = self._manager.post(request, data)
+            reply = self._manager.post(request, data.encode())
             if on_progress is not None:
             if on_progress is not None:
                 reply.uploadProgress.connect(on_progress)
                 reply.uploadProgress.connect(on_progress)
             self._registerOnFinishedCallback(reply, on_finished)
             self._registerOnFinishedCallback(reply, on_finished)

+ 2 - 2
plugins/ChangeLogPlugin/ChangeLog.txt

@@ -11,8 +11,8 @@ It is now possible to specify the cooling fan to use if your printer has multipl
 *Settings refactor
 *Settings refactor
 The CuraEngine has been refactored to create a more testable, future-proof way of storing and representing settings. This makes slicing faster, and future development easier.
 The CuraEngine has been refactored to create a more testable, future-proof way of storing and representing settings. This makes slicing faster, and future development easier.
 
 
-*Print core CC Red 0.6
-The new print core CC Red 0.6 is selectable when the Ultimaker S5 profile is active. This print core is optimized for use with abrasive materials and composites.
+*Print core CC 0.6
+The new print core CC 0.6 is selectable when the Ultimaker S5 profile is active. This print core is optimized for use with abrasive materials and composites.
 
 
 *File name and layer display
 *File name and layer display
 Added M117 commands to GCODE to give real-time information about the print job file name and layer number shown on the printer’s display when printing via USB. Contributed by adecastilho.
 Added M117 commands to GCODE to give real-time information about the print job file name and layer number shown on the printer’s display when printing via USB. Contributed by adecastilho.

+ 1 - 1
plugins/SimulationView/SimulationSliderLabel.qml

@@ -48,7 +48,7 @@ UM.PointingRectangle {
             horizontalCenter: parent.horizontalCenter
             horizontalCenter: parent.horizontalCenter
         }
         }
 
 
-        width: (maximumValue.toString().length + 1) * 10 * screenScaleFactor
+        width: ((maximumValue + 1).toString().length + 1) * 10 * screenScaleFactor
         text: sliderLabelRoot.value + startFrom // the current handle value, add 1 because layers is an array
         text: sliderLabelRoot.value + startFrom // the current handle value, add 1 because layers is an array
         horizontalAlignment: TextInput.AlignRight
         horizontalAlignment: TextInput.AlignRight
 
 

+ 22 - 16
plugins/Toolbox/src/Toolbox.py

@@ -265,21 +265,25 @@ class Toolbox(QObject, Extension):
             raise Exception("Failed to create Marketplace dialog")
             raise Exception("Failed to create Marketplace dialog")
         return dialog
         return dialog
 
 
-    def _convertPluginMetadata(self, plugin: Dict[str, Any]) -> Dict[str, Any]:
-        formatted = {
-            "package_id": plugin["id"],
-            "package_type": "plugin",
-            "display_name": plugin["plugin"]["name"],
-            "package_version": plugin["plugin"]["version"],
-            "sdk_version": plugin["plugin"]["api"],
-            "author": {
-                "author_id": plugin["plugin"]["author"],
-                "display_name": plugin["plugin"]["author"]
-            },
-            "is_installed": True,
-            "description": plugin["plugin"]["description"]
-        }
-        return formatted
+    def _convertPluginMetadata(self, plugin_data: Dict[str, Any]) -> Optional[Dict[str, Any]]:
+        try:
+            formatted = {
+                "package_id": plugin_data["id"],
+                "package_type": "plugin",
+                "display_name": plugin_data["plugin"]["name"],
+                "package_version": plugin_data["plugin"]["version"],
+                "sdk_version": plugin_data["plugin"]["api"],
+                "author": {
+                    "author_id": plugin_data["plugin"]["author"],
+                    "display_name": plugin_data["plugin"]["author"]
+                },
+                "is_installed": True,
+                "description": plugin_data["plugin"]["description"]
+            }
+            return formatted
+        except:
+            Logger.log("w", "Unable to convert plugin meta data %s", str(plugin_data))
+            return None
 
 
     @pyqtSlot()
     @pyqtSlot()
     def _updateInstalledModels(self) -> None:
     def _updateInstalledModels(self) -> None:
@@ -299,7 +303,9 @@ class Toolbox(QObject, Extension):
 
 
                 old_metadata = self._plugin_registry.getMetaData(plugin_id)
                 old_metadata = self._plugin_registry.getMetaData(plugin_id)
                 new_metadata = self._convertPluginMetadata(old_metadata)
                 new_metadata = self._convertPluginMetadata(old_metadata)
-
+                if new_metadata is None:
+                    # Something went wrong converting it.
+                    continue
                 self._old_plugin_ids.add(plugin_id)
                 self._old_plugin_ids.add(plugin_id)
                 self._old_plugin_metadata[new_metadata["package_id"]] = new_metadata
                 self._old_plugin_metadata[new_metadata["package_id"]] = new_metadata
 
 

+ 70 - 17
plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml

@@ -11,7 +11,7 @@ import UM 1.3 as UM
 Item {
 Item {
     id: root;
     id: root;
     property var printJob: null;
     property var printJob: null;
-    property var running: isRunning(printJob);
+    property var started: isStarted(printJob);
     property var assigned: isAssigned(printJob);
     property var assigned: isAssigned(printJob);
 
 
     Button {
     Button {
@@ -34,7 +34,13 @@ Item {
         hoverEnabled: true;
         hoverEnabled: true;
         onClicked: parent.switchPopupState();
         onClicked: parent.switchPopupState();
         text: "\u22EE"; //Unicode; Three stacked points.
         text: "\u22EE"; //Unicode; Three stacked points.
-        visible: printJob.state == "queued" || running ? true : false;
+        visible: {
+            if (!printJob) {
+                return false;
+            }
+            var states = ["queued", "sent_to_printer", "pre_print", "printing", "pausing", "paused", "resuming"];
+            return states.indexOf(printJob.state) !== -1;
+        }
         width: 35 * screenScaleFactor; // TODO: Theme!
         width: 35 * screenScaleFactor; // TODO: Theme!
     }
     }
 
 
@@ -102,7 +108,12 @@ Item {
             width: parent.width;
             width: parent.width;
 
 
             PrintJobContextMenuItem {
             PrintJobContextMenuItem {
-                enabled: {
+                onClicked: {
+                    sendToTopConfirmationDialog.visible = true;
+                    popup.close();
+                }
+                text: catalog.i18nc("@label", "Move to top");
+                visible: {
                     if (printJob && printJob.state == "queued" && !assigned) {
                     if (printJob && printJob.state == "queued" && !assigned) {
                         if (OutputDevice && OutputDevice.queuedPrintJobs[0]) {
                         if (OutputDevice && OutputDevice.queuedPrintJobs[0]) {
                             return OutputDevice.queuedPrintJobs[0].key != printJob.key;
                             return OutputDevice.queuedPrintJobs[0].key != printJob.key;
@@ -110,42 +121,75 @@ Item {
                     }
                     }
                     return false;
                     return false;
                 }
                 }
-                onClicked: {
-                    sendToTopConfirmationDialog.visible = true;
-                    popup.close();
-                }
-                text: catalog.i18nc("@label", "Move to top");
             }
             }
 
 
             PrintJobContextMenuItem {
             PrintJobContextMenuItem {
-                enabled: printJob && !running;
                 onClicked: {
                 onClicked: {
                     deleteConfirmationDialog.visible = true;
                     deleteConfirmationDialog.visible = true;
                     popup.close();
                     popup.close();
                 }
                 }
                 text: catalog.i18nc("@label", "Delete");
                 text: catalog.i18nc("@label", "Delete");
+                visible: {
+                    if (!printJob) {
+                        return false;
+                    }
+                    var states = ["queued", "sent_to_printer"];
+                    return states.indexOf(printJob.state) !== -1;
+                }
             }
             }
 
 
             PrintJobContextMenuItem {
             PrintJobContextMenuItem {
-                enabled: printJob && running;
+                enabled: visible && !(printJob.state == "pausing" || printJob.state == "resuming");
                 onClicked: {
                 onClicked: {
                     if (printJob.state == "paused") {
                     if (printJob.state == "paused") {
                         printJob.setState("print");
                         printJob.setState("print");
-                    } else if(printJob.state == "printing") {
+                        popup.close();
+                        return;
+                    }
+                    if (printJob.state == "printing") {
                         printJob.setState("pause");
                         printJob.setState("pause");
+                        popup.close();
+                        return;
                     }
                     }
-                    popup.close();
                 }
                 }
-                text: printJob && printJob.state == "paused" ? catalog.i18nc("@label", "Resume") : catalog.i18nc("@label", "Pause");
+                text: {
+                    if (!printJob) {
+                        return "";
+                    }
+                    switch(printJob.state) {
+                        case "paused":
+                            return catalog.i18nc("@label", "Resume");
+                        case "pausing":
+                            return catalog.i18nc("@label", "Pausing...");
+                        case "resuming":
+                            return catalog.i18nc("@label", "Resuming...");
+                        default:
+                            catalog.i18nc("@label", "Pause");
+                    }
+                }
+                visible: {
+                    if (!printJob) {
+                        return false;
+                    }
+                    var states = ["printing", "pausing", "paused", "resuming"];
+                    return states.indexOf(printJob.state) !== -1;
+                }
             }
             }
 
 
             PrintJobContextMenuItem {
             PrintJobContextMenuItem {
-                enabled: printJob && running;
+                enabled: visible && printJob.state !== "aborting";
                 onClicked: {
                 onClicked: {
                     abortConfirmationDialog.visible = true;
                     abortConfirmationDialog.visible = true;
                     popup.close();
                     popup.close();
                 }
                 }
-                text: catalog.i18nc("@label", "Abort");
+                text: printJob.state == "aborting" ? catalog.i18nc("@label", "Aborting...") : catalog.i18nc("@label", "Abort");
+                visible: {
+                    if (!printJob) {
+                        return false;
+                    }
+                    var states = ["pre_print", "printing", "pausing", "paused", "resuming"];
+                    return states.indexOf(printJob.state) !== -1;
+                }
             }
             }
         }
         }
         enter: Transition {
         enter: Transition {
@@ -205,11 +249,11 @@ Item {
     function switchPopupState() {
     function switchPopupState() {
         popup.visible ? popup.close() : popup.open();
         popup.visible ? popup.close() : popup.open();
     }
     }
-    function isRunning(job) {
+    function isStarted(job) {
         if (!job) {
         if (!job) {
             return false;
             return false;
         }
         }
-        return ["paused", "printing", "pre_print"].indexOf(job.state) !== -1;
+        return ["pre_print", "printing", "pausing", "paused", "resuming", "aborting"].indexOf(job.state) !== -1;
     }
     }
     function isAssigned(job) {
     function isAssigned(job) {
         if (!job) {
         if (!job) {
@@ -217,4 +261,13 @@ Item {
         }
         }
         return job.assignedPrinter ? true : false;
         return job.assignedPrinter ? true : false;
     }
     }
+    function getMenuLength() {
+        var visible = 0;
+        for (var i = 0; i < popupOptions.children.length; i++) {
+            if (popupOptions.children[i].visible) {
+                visible++;
+            }
+        }
+        return visible;
+    }
 }
 }

+ 2 - 3
plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenuItem.qml

@@ -12,13 +12,12 @@ Button {
         color: UM.Theme.getColor("monitor_context_menu_highlight");
         color: UM.Theme.getColor("monitor_context_menu_highlight");
     }
     }
     contentItem: Label {
     contentItem: Label {
-        color: UM.Theme.getColor("text");
+        color: enabled ? UM.Theme.getColor("text") : UM.Theme.getColor("text_inactive");
         text: parent.text
         text: parent.text
         horizontalAlignment: Text.AlignLeft;
         horizontalAlignment: Text.AlignLeft;
         verticalAlignment: Text.AlignVCenter;
         verticalAlignment: Text.AlignVCenter;
     }
     }
-    height: 39 * screenScaleFactor; // TODO: Theme!
+    height: visible ? 39 * screenScaleFactor : 0; // TODO: Theme!
     hoverEnabled: true;
     hoverEnabled: true;
-    visible: enabled;
     width: parent.width;
     width: parent.width;
 }
 }

+ 12 - 0
plugins/UM3NetworkPrinting/resources/qml/PrintJobInfoBlock.qml

@@ -168,6 +168,18 @@ Item {
                             width: 0.5 * printJobPreview.width;
                             width: 0.5 * printJobPreview.width;
                         }
                         }
                     }
                     }
+
+                    Label {
+                        id: totalTimeLabel;
+                        anchors {
+                            bottom: parent.bottom;
+                            right: parent.right;
+                        }
+                        color: UM.Theme.getColor("text");
+                        elide: Text.ElideRight;
+                        font: UM.Theme.getFont("default");
+                        text: printJob ? OutputDevice.formatDuration(printJob.timeTotal) : "";
+                    }
                 }
                 }
 
 
                 // Divider
                 // Divider

+ 21 - 7
plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py

@@ -590,13 +590,27 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
                                                    origin_name=change["origin_name"]))
                                                    origin_name=change["origin_name"]))
         return result
         return result
 
 
-    def _createMaterialOutputModel(self, material_data) -> MaterialOutputModel:
-        containers = ContainerRegistry.getInstance().findInstanceContainers(type="material", GUID=material_data["guid"])
-        if containers:
-            color = containers[0].getMetaDataEntry("color_code")
-            brand = containers[0].getMetaDataEntry("brand")
-            material_type = containers[0].getMetaDataEntry("material")
-            name = containers[0].getName()
+    def _createMaterialOutputModel(self, material_data: Dict[str, Any]) -> "MaterialOutputModel":
+        material_manager = CuraApplication.getInstance().getMaterialManager()
+        material_group_list = material_manager.getMaterialGroupListByGUID(material_data["guid"])
+
+        # Sort the material groups by "is_read_only = True" first, and then the name alphabetically.
+        read_only_material_group_list = list(filter(lambda x: x.is_read_only, material_group_list))
+        non_read_only_material_group_list = list(filter(lambda x: not x.is_read_only, material_group_list))
+        material_group = None
+        if read_only_material_group_list:
+            read_only_material_group_list = sorted(read_only_material_group_list, key = lambda x: x.name)
+            material_group = read_only_material_group_list[0]
+        elif non_read_only_material_group_list:
+            non_read_only_material_group_list = sorted(non_read_only_material_group_list, key = lambda x: x.name)
+            material_group = non_read_only_material_group_list[0]
+
+        if material_group:
+            container = material_group.root_material_node.getContainer()
+            color = container.getMetaDataEntry("color_code")
+            brand = container.getMetaDataEntry("brand")
+            material_type = container.getMetaDataEntry("material")
+            name = container.getName()
         else:
         else:
             Logger.log("w",
             Logger.log("w",
                        "Unable to find material with guid {guid}. Using data as provided by cluster".format(
                        "Unable to find material with guid {guid}. Using data as provided by cluster".format(

Некоторые файлы не были показаны из-за большого количества измененных файлов