Browse Source

Merge branch 'master' into WIP_improve_initialization

Lipu Fei 6 years ago
parent
commit
f395f1eebc

+ 6 - 2
cura/CuraPackageManager.py

@@ -89,7 +89,6 @@ class CuraPackageManager(QObject):
                              "installed": self._installed_package_dict,
                              "to_remove": list(self._to_remove_package_set),
                              "to_install": self._to_install_package_dict}
-                data_dict["to_remove"] = list(data_dict["to_remove"])
                 json.dump(data_dict, f, sort_keys = True, indent = 4)
                 Logger.log("i", "Package management file %s was saved", self._user_package_management_file_path)
 
@@ -103,7 +102,6 @@ class CuraPackageManager(QObject):
 
     # (for initialize) Installs all packages that have been scheduled to be installed.
     def _installAllScheduledPackages(self) -> None:
-
         while self._to_install_package_dict:
             package_id, package_info = list(self._to_install_package_dict.items())[0]
             self._installPackage(package_info)
@@ -111,6 +109,12 @@ class CuraPackageManager(QObject):
             del self._to_install_package_dict[package_id]
             self._saveManagementData()
 
+    def getBundledPackageInfo(self, package_id: str) -> Optional[dict]:
+        package_info = None
+        if package_id in self._bundled_package_dict:
+            package_info = self._bundled_package_dict[package_id]["package_info"]
+        return package_info
+
     # Checks the given package is installed. If so, return a dictionary that contains the package's information.
     def getInstalledPackageInfo(self, package_id: str) -> Optional[dict]:
         if package_id in self._to_remove_package_set:

+ 19 - 11
cura/PrintInformation.py

@@ -66,6 +66,7 @@ class PrintInformation(QObject):
             self._backend.printDurationMessage.connect(self._onPrintDurationMessage)
         self._application.getController().getScene().sceneChanged.connect(self._onSceneChanged)
 
+        self._is_user_specified_job_name = False
         self._base_name = ""
         self._abbr_machine = ""
         self._job_name = ""
@@ -281,10 +282,13 @@ class PrintInformation(QObject):
 
     # Manual override of job name should also set the base name so that when the printer prefix is updated, it the
     # prefix can be added to the manually added name, not the old base name
-    @pyqtSlot(str)
-    def setJobName(self, name):
+    @pyqtSlot(str, bool)
+    def setJobName(self, name, is_user_specified_job_name = False):
+        self._is_user_specified_job_name = is_user_specified_job_name
         self._job_name = name
         self._base_name = name.replace(self._abbr_machine + "_", "")
+        if name == "":
+            self._is_user_specified_job_name = False
         self.jobNameChanged.emit()
 
     jobNameChanged = pyqtSignal()
@@ -296,21 +300,25 @@ class PrintInformation(QObject):
     def _updateJobName(self):
         if self._base_name == "":
             self._job_name = ""
+            self._is_user_specified_job_name = False
             self.jobNameChanged.emit()
             return
 
         base_name = self._stripAccents(self._base_name)
         self._setAbbreviatedMachineName()
-        if self._pre_sliced:
-            self._job_name = catalog.i18nc("@label", "Pre-sliced file {0}", base_name)
-        elif self._application.getInstance().getPreferences().getValue("cura/jobname_prefix"):
-            # Don't add abbreviation if it already has the exact same abbreviation.
-            if base_name.startswith(self._abbr_machine + "_"):
-                self._job_name = base_name
+
+        # Only update the job name when it's not user-specified.
+        if not self._is_user_specified_job_name:
+            if self._pre_sliced:
+                self._job_name = catalog.i18nc("@label", "Pre-sliced file {0}", base_name)
+            elif self._application.getInstance().getPreferences().getValue("cura/jobname_prefix"):
+                # Don't add abbreviation if it already has the exact same abbreviation.
+                if base_name.startswith(self._abbr_machine + "_"):
+                    self._job_name = base_name
+                else:
+                    self._job_name = self._abbr_machine + "_" + base_name
             else:
-                self._job_name = self._abbr_machine + "_" + base_name
-        else:
-            self._job_name = base_name
+                self._job_name = base_name
 
         self.jobNameChanged.emit()
 

+ 7 - 7
plugins/Toolbox/src/Toolbox.py

@@ -250,8 +250,6 @@ class Toolbox(QObject, Extension):
             if remote_package:
                 download_url = remote_package["download_url"]
                 Logger.log("d", "Updating package [%s]..." % plugin_id)
-                if self._package_manager.isUserInstalledPackage(plugin_id):
-                    self.uninstall(plugin_id)
                 self.startDownload(download_url)
             else:
                 Logger.log("e", "Could not update package [%s] because there is no remote package info available.", plugin_id)
@@ -318,19 +316,21 @@ class Toolbox(QObject, Extension):
         remote_version = Version(remote_package["package_version"])
         return remote_version > local_version
 
-    @pyqtSlot(str, result=bool)
+    @pyqtSlot(str, result = bool)
     def canDowngrade(self, package_id: str) -> bool:
+        # If the currently installed version is higher than the bundled version (if present), the we can downgrade
+        # this package.
         local_package = self._package_manager.getInstalledPackageInfo(package_id)
         if local_package is None:
             return False
 
-        remote_package = self.getRemotePackage(package_id)
-        if remote_package is None:
+        bundled_package = self._package_manager.getBundledPackageInfo(package_id)
+        if bundled_package is None:
             return False
 
         local_version = Version(local_package["package_version"])
-        remote_version = Version(remote_package["package_version"])
-        return remote_version < local_version
+        bundled_version = Version(bundled_package["package_version"])
+        return bundled_version < local_version
 
     @pyqtSlot(str, result = bool)
     def isInstalled(self, package_id: str) -> bool:

+ 2 - 1
plugins/USBPrinting/USBPrinterOutputDevice.py

@@ -379,13 +379,14 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
 
     def resumePrint(self):
         self._paused = False
+        self._sendNextGcodeLine() #Send one line of g-code next so that we'll trigger an "ok" response loop even if we're not polling temperatures.
 
     def cancelPrint(self):
         self._gcode_position = 0
         self._gcode.clear()
         self._printers[0].updateActivePrintJob(None)
         self._is_printing = False
-        self._is_paused = False
+        self._paused = False
 
         # Turn off temperatures, fan and steppers
         self._sendCommand("M140 S0")

+ 1 - 1
plugins/VersionUpgrade/VersionUpgrade33to34/__init__.py

@@ -21,7 +21,7 @@ def getMetaData():
             },
             "quality_changes": {
                 "get_version": upgrade.getCfgVersion,
-                "location": {"./quality"}
+                "location": {"./quality_changes"}
             },
             "user": {
                 "get_version": upgrade.getCfgVersion,

+ 5 - 3
plugins/XmlMaterialProfile/XmlMaterialProfile.py

@@ -1,4 +1,4 @@
-# Copyright (c) 2017 Ultimaker B.V.
+# Copyright (c) 2018 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 import copy
@@ -12,10 +12,10 @@ import xml.etree.ElementTree as ET
 from UM.Resources import Resources
 from UM.Logger import Logger
 from cura.CuraApplication import CuraApplication
-
 import UM.Dictionary
 from UM.Settings.InstanceContainer import InstanceContainer
 from UM.Settings.ContainerRegistry import ContainerRegistry
+from UM.ConfigurationErrorMessage import ConfigurationErrorMessage
 
 from .XmlMaterialValidator import XmlMaterialValidator
 
@@ -540,7 +540,9 @@ class XmlMaterialProfile(InstanceContainer):
 
         validation_message = XmlMaterialValidator.validateMaterialMetaData(meta_data)
         if validation_message is not None:
-            raise Exception("Not valid material profile: %s" % (validation_message))
+            ConfigurationErrorMessage.getInstance().addFaultyContainers(self.getId())
+            Logger.log("e", "Not a valid material profile: {message}".format(message = validation_message))
+            return
 
         property_values = {}
         properties = data.iterfind("./um:properties/*", self.__namespaces)

+ 1 - 0
resources/definitions/malyan_m180.def.json

@@ -7,6 +7,7 @@
         "visible": true,
         "author": "Ruben Dulek",
         "manufacturer": "Malyan",
+        "machine_x3g_variant": "r1d",
         "file_formats": "application/x3g"
     },
 

+ 1 - 1
resources/qml/JobSpecs.qml

@@ -81,7 +81,7 @@ Item {
                 text: PrintInformation.jobName
                 horizontalAlignment: TextInput.AlignRight
                 onTextChanged: {
-                    PrintInformation.setJobName(text);
+                    PrintInformation.setJobName(text, true);
                 }
                 onEditingFinished: {
                     if (printJobTextfield.text != ''){