Browse Source

Merge branch 'ui_rework_4_0' into CURA-5876-Configuration_dropdown

Conflicts:
	plugins/PrepareStage/PrepareMenu.qml: Git was wrong, this was not really a conflict.
	resources/qml/ActionButton.qml: With iconSource being modified on ui_rework_4_0 and me modifying the icon to be able to display it on the left hand side.
	resources/qml/ActionPanel/OutputProcessWidget.qml: Git was wrong, not really a conflict.
	resources/qml/ActionPanel/SliceProcessWidget.qml: Git was wrong, not really a conflict.
	resources/qml/ExpandableComponent.qml: Both ui_rework_4_0 and me implemented a border around popups.
	resources/qml/MainWindow/MainWindowHeader.qml: Git was wrong, not really a conflict.
	resources/themes/cura-light/theme.json: Theme item was added in a place where I added whitespace.
Ghostkeeper 6 years ago
parent
commit
289399825b

+ 2 - 1
README.md

@@ -20,8 +20,9 @@ Dependencies
 ------------
 * [Uranium](https://github.com/Ultimaker/Uranium) Cura is built on top of the Uranium framework.
 * [CuraEngine](https://github.com/Ultimaker/CuraEngine) This will be needed at runtime to perform the actual slicing.
+* [fdm_materials](https://github.com/Ultimaker/fdm_materials) Required to load a printer that has swappable material profiles.
 * [PySerial](https://github.com/pyserial/pyserial) Only required for USB printing support.
-* [python-zeroconf](https://github.com/jstasiak/python-zeroconf) Only required to detect mDNS-enabled printers
+* [python-zeroconf](https://github.com/jstasiak/python-zeroconf) Only required to detect mDNS-enabled printers.
 
 Build scripts
 -------------

+ 1 - 1
cura.desktop.in

@@ -13,6 +13,6 @@ TryExec=@CMAKE_INSTALL_FULL_BINDIR@/cura
 Icon=cura-icon
 Terminal=false
 Type=Application
-MimeType=model/stl;application/vnd.ms-3mfdocument;application/prs.wavefront-obj;image/bmp;image/gif;image/jpeg;image/png;model/x3d+xml;
+MimeType=model/stl;application/vnd.ms-3mfdocument;application/prs.wavefront-obj;image/bmp;image/gif;image/jpeg;image/png;model/x3d+xml;text/x-gcode;
 Categories=Graphics;
 Keywords=3D;Printing;Slicer;

+ 8 - 0
cura.sharedmimeinfo

@@ -19,4 +19,12 @@
         <glob-deleteall/>
         <glob pattern="*.obj"/>
     </mime-type>
+    <mime-type type="text/x-gcode">
+        <sub-class-of type="text/plain"/>
+        <comment>Gcode file</comment>
+        <icon name="unknown"/>
+        <glob-deleteall/>
+        <glob pattern="*.gcode"/>
+        <glob pattern="*.g"/>
+    </mime-type>
 </mime-info>

+ 4 - 3
cura/Backups/Backup.py

@@ -46,12 +46,13 @@ class Backup:
 
         # We copy the preferences file to the user data directory in Linux as it's in a different location there.
         # When restoring a backup on Linux, we move it back.
-        if Platform.isLinux():
+        if Platform.isLinux(): #TODO: This should check for the config directory not being the same as the data directory, rather than hard-coding that to Linux systems.
             preferences_file_name = self._application.getApplicationName()
             preferences_file = Resources.getPath(Resources.Preferences, "{}.cfg".format(preferences_file_name))
             backup_preferences_file = os.path.join(version_data_dir, "{}.cfg".format(preferences_file_name))
-            Logger.log("d", "Copying preferences file from %s to %s", preferences_file, backup_preferences_file)
-            shutil.copyfile(preferences_file, backup_preferences_file)
+            if os.path.exists(preferences_file) and (not os.path.exists(backup_preferences_file) or not os.path.samefile(preferences_file, backup_preferences_file)):
+                Logger.log("d", "Copying preferences file from %s to %s", preferences_file, backup_preferences_file)
+                shutil.copyfile(preferences_file, backup_preferences_file)
 
         # Create an empty buffer and write the archive to it.
         buffer = io.BytesIO()

+ 1 - 15
cura/PrintInformation.py

@@ -395,21 +395,7 @@ class PrintInformation(QObject):
             return
         active_machine_type_name = global_container_stack.definition.getName()
 
-        abbr_machine = ""
-        for word in re.findall(r"[\w']+", active_machine_type_name):
-            if word.lower() == "ultimaker":
-                abbr_machine += "UM"
-            elif word.isdigit():
-                abbr_machine += word
-            else:
-                stripped_word = self._stripAccents(word.upper())
-                # - use only the first character if the word is too long (> 3 characters)
-                # - use the whole word if it's not too long (<= 3 characters)
-                if len(stripped_word) > 3:
-                    stripped_word = stripped_word[0]
-                abbr_machine += stripped_word
-
-        self._abbr_machine = abbr_machine
+        self._abbr_machine = self._application.getMachineManager().getAbbreviatedMachineName(active_machine_type_name)
 
     ##  Utility method that strips accents from characters (eg: â -> a)
     def _stripAccents(self, to_strip: str) -> str:

+ 3 - 0
cura/PrinterOutput/NetworkedPrinterOutputDevice.py

@@ -147,6 +147,9 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
         request.setHeader(QNetworkRequest.UserAgentHeader, self._user_agent)
         return request
 
+    def createFormPart(self, content_header: str, data: bytes, content_type: Optional[str] = None) -> QHttpPart:
+        return self._createFormPart(content_header, data, content_type)
+
     def _createFormPart(self, content_header: str, data: bytes, content_type: Optional[str] = None) -> QHttpPart:
         part = QHttpPart()
 

+ 6 - 1
cura/PrinterOutputDevice.py

@@ -211,6 +211,11 @@ class PrinterOutputDevice(QObject, OutputDevice):
         self._unique_configurations.sort(key = lambda k: k.printerType)
         self.uniqueConfigurationsChanged.emit()
 
+    # Returns the unique configurations of the printers within this output device
+    @pyqtProperty("QStringList", notify = uniqueConfigurationsChanged)
+    def uniquePrinterTypes(self) -> List[str]:
+        return list(set([configuration.printerType for configuration in self._unique_configurations]))
+
     def _onPrintersChanged(self) -> None:
         for printer in self._printers:
             printer.configurationChanged.connect(self._updateUniqueConfigurations)
@@ -238,4 +243,4 @@ class PrinterOutputDevice(QObject, OutputDevice):
         if not self._firmware_updater:
             return
 
-        self._firmware_updater.updateFirmware(firmware_file)
+        self._firmware_updater.updateFirmware(firmware_file)

+ 23 - 8
cura/Settings/MachineManager.py

@@ -3,6 +3,8 @@
 
 import collections
 import time
+import re
+import unicodedata
 from typing import Any, Callable, List, Dict, TYPE_CHECKING, Optional, cast
 
 from UM.ConfigurationErrorMessage import ConfigurationErrorMessage
@@ -909,20 +911,14 @@ class MachineManager(QObject):
         # After CURA-4482 this should not be the case anymore, but we still want to support older project files.
         global_user_container = self._global_container_stack.userChanges
 
-        # Make sure extruder_stacks exists
-        extruder_stacks = [] #type: List[ExtruderStack]
-
-        if previous_extruder_count == 1:
-            extruder_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
-            global_user_container = self._global_container_stack.userChanges
-
         for setting_instance in global_user_container.findInstances():
             setting_key = setting_instance.definition.key
             settable_per_extruder = self._global_container_stack.getProperty(setting_key, "settable_per_extruder")
 
             if settable_per_extruder:
                 limit_to_extruder = int(self._global_container_stack.getProperty(setting_key, "limit_to_extruder"))
-                extruder_stack = extruder_stacks[max(0, limit_to_extruder)]
+                extruder_position = str(max(0, limit_to_extruder))
+                extruder_stack = self._global_container_stack.extruders[extruder_position]
                 extruder_stack.userChanges.setProperty(setting_key, "value", global_user_container.getProperty(setting_key, "value"))
                 global_user_container.removeInstance(setting_key)
 
@@ -1537,3 +1533,22 @@ class MachineManager(QObject):
         with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue):
             self.updateMaterialWithVariant(None)
             self._updateQualityWithMaterial()
+
+    ##  This function will translate any printer type name to an abbreviated printer type name
+    @pyqtSlot(str, result = str)
+    def getAbbreviatedMachineName(self, machine_type_name: str) -> str:
+        abbr_machine = ""
+        for word in re.findall(r"[\w']+", machine_type_name):
+            if word.lower() == "ultimaker":
+                abbr_machine += "UM"
+            elif word.isdigit():
+                abbr_machine += word
+            else:
+                stripped_word = ''.join(char for char in unicodedata.normalize('NFD', word.upper()) if unicodedata.category(char) != 'Mn')
+                # - use only the first character if the word is too long (> 3 characters)
+                # - use the whole word if it's not too long (<= 3 characters)
+                if len(stripped_word) > 3:
+                    stripped_word = stripped_word[0]
+                abbr_machine += stripped_word
+
+        return abbr_machine

+ 12 - 4
plugins/CuraEngineBackend/StartSliceJob.py

@@ -66,11 +66,19 @@ class GcodeStartEndFormatter(Formatter):
             return "{" + key + "}"
 
         key = key_fragments[0]
-        try:
-            return kwargs[str(extruder_nr)][key]
-        except KeyError:
+
+        default_value_str = "{" + key + "}"
+        value = default_value_str
+        # "-1" is global stack, and if the setting value exists in the global stack, use it as the fallback value.
+        if key in kwargs["-1"]:
+            value = kwargs["-1"]
+        if key in kwargs[str(extruder_nr)]:
+            value = kwargs[str(extruder_nr)][key]
+
+        if value == default_value_str:
             Logger.log("w", "Unable to replace '%s' placeholder in start/end g-code", key)
-            return "{" + key + "}"
+
+        return value
 
 
 ##  Job class that builds up the message of scene data to send to CuraEngine.

+ 5 - 0
plugins/FirmwareUpdateChecker/FirmwareUpdateCheckerJob.py

@@ -93,6 +93,11 @@ class FirmwareUpdateCheckerJob(Job):
 
                 current_version = self.getCurrentVersion()
 
+                # This case indicates that was an error checking the version.
+                # It happens for instance when not connected to internet.
+                if current_version == self.ZERO_VERSION:
+                    return
+
                 # If it is the first time the version is checked, the checked_version is ""
                 setting_key_str = getSettingsKeyForMachine(machine_id)
                 checked_version = Version(Application.getInstance().getPreferences().getValue(setting_key_str))

Some files were not shown because too many files changed in this diff