From ae2b3124721c9c74730073d178c0ac1927819b1c Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 14 Nov 2018 13:41:23 +0100 Subject: [PATCH 01/43] Add typing for all version upgrade plug-ins Hopefully we'll take this typing along when we next copy-paste the stuffs. Contributes to issue CURA-5936. --- .../VersionUpgrade21to22/MachineInstance.py | 17 ++--- .../VersionUpgrade21to22/Preferences.py | 9 +-- .../VersionUpgrade21to22/Profile.py | 11 ++- .../VersionUpgrade21to22.py | 69 ++++++++++--------- .../VersionUpgrade21to22/__init__.py | 11 ++- .../VersionUpgrade22to24/VersionUpgrade.py | 20 +++--- .../VersionUpgrade22to24/__init__.py | 11 ++- .../VersionUpgrade25to26.py | 26 +++---- .../VersionUpgrade25to26/__init__.py | 11 ++- .../VersionUpgrade26to27.py | 13 ++-- .../VersionUpgrade26to27/__init__.py | 11 ++- .../VersionUpgrade27to30.py | 21 +++--- .../VersionUpgrade27to30/__init__.py | 11 ++- .../VersionUpgrade30to31.py | 19 ++--- .../VersionUpgrade30to31/__init__.py | 11 ++- .../VersionUpgrade32to33.py | 21 +++--- .../VersionUpgrade32to33/__init__.py | 9 ++- .../VersionUpgrade33to34.py | 8 +-- .../VersionUpgrade33to34/__init__.py | 9 ++- .../VersionUpgrade34to35.py | 23 +++---- .../VersionUpgrade34to35/__init__.py | 9 ++- 21 files changed, 200 insertions(+), 150 deletions(-) diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py index 37b6989add..a947114595 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py @@ -1,15 +1,16 @@ -# Copyright (c) 2016 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -import UM.VersionUpgrade #To indicate that a file is of incorrect format. -import UM.VersionUpgradeManager #To schedule more files to be upgraded. -from UM.Resources import Resources #To get the config storage path. - import configparser #To read config files. import io #To write config files to strings as if they were files. import os.path #To get the path to write new user profiles to. +from typing import List, Optional, Tuple import urllib #To serialise the user container file name properly. +import UM.VersionUpgrade #To indicate that a file is of incorrect format. +import UM.VersionUpgradeManager #To schedule more files to be upgraded. +from UM.Resources import Resources #To get the config storage path. + ## Creates a new machine instance instance by parsing a serialised machine # instance in version 1 of the file format. # @@ -18,7 +19,7 @@ import urllib #To serialise the user container file name properly. # extension. # \return A machine instance instance, or None if the file format is # incorrect. -def importFrom(serialised, filename): +def importFrom(serialised: str, filename: str) -> Optional["MachineInstance"]: try: return MachineInstance(serialised, filename) except (configparser.Error, UM.VersionUpgrade.FormatException, UM.VersionUpgrade.InvalidVersionException): @@ -32,7 +33,7 @@ class MachineInstance: # \param serialised A string with the contents of a machine instance file, # without extension. # \param filename The supposed file name of this machine instance. - def __init__(self, serialised, filename): + def __init__(self, serialised: str, filename: str) -> str: self._filename = filename config = configparser.ConfigParser(interpolation = None) @@ -67,7 +68,7 @@ class MachineInstance: # # \return A tuple containing the new filename and a serialised form of # this machine instance, serialised in version 2 of the file format. - def export(self): + def export(self) -> Tuple[List[str], List[str]]: config = configparser.ConfigParser(interpolation = None) # Build a config file in the form of version 2. config.add_section("general") diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py b/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py index 842499da86..51e4b617e8 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py @@ -1,8 +1,9 @@ -# Copyright (c) 2016 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import configparser #To read config files. import io #To output config files to string. +from typing import List, Optional, Tuple import UM.VersionUpgrade #To indicate that a file is of the wrong format. @@ -14,7 +15,7 @@ import UM.VersionUpgrade #To indicate that a file is of the wrong format. # extension. # \return A representation of those preferences, or None if the file format is # incorrect. -def importFrom(serialised, filename): +def importFrom(serialised: str, filename: str) -> Optional["Preferences"]: try: return Preferences(serialised, filename) except (configparser.Error, UM.VersionUpgrade.FormatException, UM.VersionUpgrade.InvalidVersionException): @@ -28,7 +29,7 @@ class Preferences: # \param serialised A serialised version 2 preferences file. # \param filename The supposed filename of the preferences file, without # extension. - def __init__(self, serialised, filename): + def __init__(self, serialised: str, filename: str) -> None: self._filename = filename self._config = configparser.ConfigParser(interpolation = None) @@ -50,7 +51,7 @@ class Preferences: # # \return A tuple containing the new filename and a serialised version of # a preferences file in version 3. - def export(self): + def export(self) -> Tuple[List[str], List[str]]: #Reset the cura/categories_expanded property since it works differently now. if self._config.has_section("cura") and self._config.has_option("cura", "categories_expanded"): self._config.remove_option("cura", "categories_expanded") diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py b/plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py index 161edcb67c..af9635d384 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py @@ -1,10 +1,9 @@ -# Copyright (c) 2016 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import configparser #To read config files. import io #To write config files to strings as if they were files. -from typing import Dict -from typing import List +from typing import Dict, List, Optional, Tuple import UM.VersionUpgrade from UM.Logger import Logger @@ -15,7 +14,7 @@ from UM.Logger import Logger # \param serialised The serialised form of a profile in version 1. # \param filename The supposed filename of the profile, without extension. # \return A profile instance, or None if the file format is incorrect. -def importFrom(serialised, filename): +def importFrom(serialised: str, filename: str) -> Optional["Profile"]: try: return Profile(serialised, filename) except (configparser.Error, UM.VersionUpgrade.FormatException, UM.VersionUpgrade.InvalidVersionException): @@ -77,11 +76,11 @@ class Profile: # # \return A tuple containing the new filename and a serialised form of # this profile, serialised in version 2 of the file format. - def export(self): + def export(self) -> Optional[Tuple[List[str], List[str]]]: import VersionUpgrade21to22 # Import here to prevent circular dependencies. if self._name == "Current settings": - return None, None #Can't upgrade these, because the new current profile needs to specify the definition ID and the old file only had the machine instance, not the definition. + return None #Can't upgrade these, because the new current profile needs to specify the definition ID and the old file only had the machine instance, not the definition. config = configparser.ConfigParser(interpolation = None) diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py b/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py index d8036491bf..89c847e606 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py @@ -1,7 +1,8 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import configparser #To get version numbers from config files. +from typing import Dict, Iterable, List, Optional, Set, Tuple from UM.VersionUpgrade import VersionUpgrade # Superclass of the plugin. @@ -30,7 +31,7 @@ _machines_with_machine_quality = { "materials": { "generic_abs", "generic_cpe", "generic_pla", "generic_pva", "generic_cpe_plus", "generic_nylon", "generic_pc", "generic_tpu" }, "variants": { "0.25 mm", "0.4 mm", "0.6 mm", "0.8 mm" } } -} +} # type: Dict[str, Dict[str, Set[str]]] ## How to translate material names from the old version to the new. _material_translations = { @@ -41,7 +42,7 @@ _material_translations = { "Nylon": "generic_nylon", "PC": "generic_pc", "TPU": "generic_tpu", -} +} # type: Dict[str, str] ## How to translate material names for in the profile names. _material_translations_profiles = { @@ -52,17 +53,17 @@ _material_translations_profiles = { "Nylon": "nylon", "PC": "pc", "TPU": "tpu", -} +} # type: Dict[str, str] ## How to translate printer names from the old version to the new. _printer_translations = { "ultimaker2plus": "ultimaker2_plus" -} +} # type: Dict[str, str] _printer_translations_profiles = { "ultimaker2plus": "um2p", #Does NOT get included in PLA profiles! "ultimaker2_extended_plus": "um2ep" #Has no profiles for CPE+, Nylon, PC and TPU! -} +} # type: Dict[str, str] ## How to translate profile names from the old version to the new. # @@ -116,13 +117,13 @@ _profile_translations = { "tpu_0.25_high": "um2p_tpu_0.25_high", "tpu_0.4_normal": "um2p_tpu_0.4_normal", "tpu_0.6_fast": "um2p_tpu_0.6_fast" -} +} # type: Dict[str, str] ## Settings that are no longer in the new version. _removed_settings = { "fill_perimeter_gaps", "support_area_smoothing" -} +} # type: Set[str] ## How to translate setting names from the old version to the new. _setting_name_translations = { @@ -142,7 +143,7 @@ _setting_name_translations = { "support_roof_line_distance": "support_interface_line_distance", "support_roof_line_width": "support_interface_line_width", "support_roof_pattern": "support_interface_pattern" -} +} # type: Dict[str, str] ## Custom profiles become quality_changes. This dictates which quality to base # the quality_changes profile on. @@ -190,7 +191,7 @@ _quality_fallbacks = { #No TPU. } } -} +} # type: Dict[str, Dict[str, Dict[str, str]]] ## How to translate variants of specific machines from the old version to the # new. @@ -207,7 +208,7 @@ _variant_translations = { "0.6 mm": "ultimaker2_extended_plus_0.6", "0.8 mm": "ultimaker2_extended_plus_0.8" } -} +} # type: Dict[str, Dict[str, str]] ## How to translate variant names for in the profile names. _variant_translations_profiles = { @@ -215,7 +216,7 @@ _variant_translations_profiles = { "0.4 mm": "0.4", "0.6 mm": "0.6", "0.8 mm": "0.8" -} +} # type: Dict[str, str] ## Cura 2.2's material profiles use a different naming scheme for variants. # @@ -233,7 +234,7 @@ _variant_translations_materials = { "0.6 mm": "ultimaker2_plus_0.6_mm", "0.8 mm": "ultimaker2_plus_0.8_mm" } -} +} # type: Dict[str, Dict[str, str]] ## Converts configuration from Cura 2.1's file formats to Cura 2.2's. # @@ -245,8 +246,8 @@ class VersionUpgrade21to22(VersionUpgrade): # number is stored in general/version, so get the data from that key. # # \param serialised The contents of a config file. - # \return \type{int} The version number of that config file. - def getCfgVersion(self, serialised): + # \return The version number of that config file. + def getCfgVersion(self, serialised: str) -> int: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. @@ -263,7 +264,7 @@ class VersionUpgrade21to22(VersionUpgrade): # \param variant The variant ID of the user's configuration in 2.2. # \param material The material ID of the user's configuration in 2.2. @staticmethod - def getQualityFallback(machine, variant, material): + def getQualityFallback(machine: str, variant: str, material: str) -> str: if machine not in _quality_fallbacks: return "normal" if variant not in _quality_fallbacks[machine]: @@ -277,14 +278,14 @@ class VersionUpgrade21to22(VersionUpgrade): # This is required to test if profiles should be converted to a quality # profile or a quality-changes profile. @staticmethod - def builtInProfiles(): + def builtInProfiles() -> Iterable[str]: return _profile_translations.keys() ## Gets a set of the machines which now have per-material quality profiles. # # \return A set of machine identifiers. @staticmethod - def machinesWithMachineQuality(): + def machinesWithMachineQuality() -> Dict[str, Dict[str, Set[str]]]: return _machines_with_machine_quality ## Converts machine instances from format version 1 to version 2. @@ -295,10 +296,10 @@ class VersionUpgrade21to22(VersionUpgrade): # \return A tuple containing the new filename and the serialised machine # instance in version 2, or None if the input was not of the correct # format. - def upgradeMachineInstance(self, serialised, filename): + def upgradeMachineInstance(self, serialised: str, filename: str) -> Optional[Tuple[List[str], List[str]]]: machine_instance = MachineInstance.importFrom(serialised, filename) if not machine_instance: #Invalid file format. - return filename, None + return None return machine_instance.export() ## Converts preferences from format version 2 to version 3. @@ -309,10 +310,10 @@ class VersionUpgrade21to22(VersionUpgrade): # \return A tuple containing the new filename and the serialised # preferences in version 3, or None if the input was not of the correct # format. - def upgradePreferences(self, serialised, filename): + def upgradePreferences(self, serialised: str, filename: str) -> Optional[Tuple[List[str], List[str]]]: preferences = Preferences.importFrom(serialised, filename) if not preferences: #Invalid file format. - return filename, None + return None return preferences.export() ## Converts profiles from format version 1 to version 2. @@ -322,10 +323,10 @@ class VersionUpgrade21to22(VersionUpgrade): # extension. # \return A tuple containing the new filename and the serialised profile # in version 2, or None if the input was not of the correct format. - def upgradeProfile(self, serialised, filename): + def upgradeProfile(self, serialised: str, filename: str) -> Optional[Tuple[List[str], List[str]]]: profile = Profile.importFrom(serialised, filename) if not profile: # Invalid file format. - return filename, None + return None return profile.export() ## Translates a material name for the change from Cura 2.1 to 2.2. @@ -333,7 +334,7 @@ class VersionUpgrade21to22(VersionUpgrade): # \param material A material name in Cura 2.1. # \return The name of the corresponding material in Cura 2.2. @staticmethod - def translateMaterial(material): + def translateMaterial(material: str) -> str: if material in _material_translations: return _material_translations[material] return material @@ -345,7 +346,7 @@ class VersionUpgrade21to22(VersionUpgrade): # \return The name of the corresponding material in the quality profiles # in Cura 2.2. @staticmethod - def translateMaterialForProfiles(material): + def translateMaterialForProfiles(material: str) -> str: if material in _material_translations_profiles: return _material_translations_profiles[material] return material @@ -356,7 +357,7 @@ class VersionUpgrade21to22(VersionUpgrade): # \param printer A printer name in Cura 2.1. # \return The name of the corresponding printer in Cura 2.2. @staticmethod - def translatePrinter(printer): + def translatePrinter(printer: str) -> str: if printer in _printer_translations: return _printer_translations[printer] return printer #Doesn't need to be translated. @@ -367,7 +368,7 @@ class VersionUpgrade21to22(VersionUpgrade): # \param printer A printer name in 2.1. # \return The name of the corresponding printer in Cura 2.2. @staticmethod - def translatePrinterForProfile(printer): + def translatePrinterForProfile(printer: str) -> str: if printer in _printer_translations_profiles: return _printer_translations_profiles[printer] return printer @@ -378,7 +379,7 @@ class VersionUpgrade21to22(VersionUpgrade): # \param profile A profile name in the old version. # \return The corresponding profile name in the new version. @staticmethod - def translateProfile(profile): + def translateProfile(profile: str) -> str: if profile in _profile_translations: return _profile_translations[profile] return profile #Doesn't need to be translated. @@ -392,7 +393,7 @@ class VersionUpgrade21to22(VersionUpgrade): # \param settings A dictionary of settings (as key-value pairs) to update. # \return The same dictionary. @staticmethod - def translateSettings(settings): + def translateSettings(settings: Dict[str, str]) -> Dict[str, str]: new_settings = {} for key, value in settings.items(): if key in _removed_settings: @@ -414,7 +415,7 @@ class VersionUpgrade21to22(VersionUpgrade): # \param setting The name of a setting in Cura 2.1. # \return The name of the corresponding setting in Cura 2.2. @staticmethod - def translateSettingName(setting): + def translateSettingName(setting: str) -> str: if setting in _setting_name_translations: return _setting_name_translations[setting] return setting #Doesn't need to be translated. @@ -426,7 +427,7 @@ class VersionUpgrade21to22(VersionUpgrade): # 2.2's naming. # \return The name of the corresponding variant in Cura 2.2. @staticmethod - def translateVariant(variant, machine): + def translateVariant(variant: str, machine: str) -> str: if machine in _variant_translations and variant in _variant_translations[machine]: return _variant_translations[machine][variant] return variant @@ -440,7 +441,7 @@ class VersionUpgrade21to22(VersionUpgrade): # \return The name of the corresponding variant for in material profiles # in Cura 2.2. @staticmethod - def translateVariantForMaterials(variant, machine): + def translateVariantForMaterials(variant: str, machine: str) -> str: if machine in _variant_translations_materials and variant in _variant_translations_materials[machine]: return _variant_translations_materials[machine][variant] return variant @@ -452,7 +453,7 @@ class VersionUpgrade21to22(VersionUpgrade): # \return The name of the corresponding variant for in quality profiles in # Cura 2.2. @staticmethod - def translateVariantForProfiles(variant): + def translateVariantForProfiles(variant: str) -> str: if variant in _variant_translations_profiles: return _variant_translations_profiles[variant] return variant \ No newline at end of file diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/__init__.py b/plugins/VersionUpgrade/VersionUpgrade21to22/__init__.py index 609781ebfe..67530b9d45 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/__init__.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/__init__.py @@ -1,11 +1,16 @@ -# Copyright (c) 2016 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from typing import Any, Dict, TYPE_CHECKING + from . import VersionUpgrade21to22 +if TYPE_CHECKING: + from UM.Application import Application + upgrade = VersionUpgrade21to22.VersionUpgrade21to22() -def getMetaData(): +def getMetaData() -> Dict[str, Any]: return { "version_upgrade": { # From To Upgrade function @@ -33,5 +38,5 @@ def getMetaData(): } } -def register(app): +def register(app: "Application") -> Dict[str, Any]: return { "version_upgrade": upgrade } diff --git a/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py b/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py index a56f1f807b..48af365877 100644 --- a/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py +++ b/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py @@ -1,18 +1,18 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import configparser #To get version numbers from config files. +import io import os import os.path -import io +from typing import Dict, List, Optional, Tuple from UM.Resources import Resources from UM.VersionUpgrade import VersionUpgrade # Superclass of the plugin. import UM.VersionUpgrade class VersionUpgrade22to24(VersionUpgrade): - - def upgradeMachineInstance(self, serialised, filename): + def upgradeMachineInstance(self, serialised: str, filename: str) -> Optional[Tuple[List[str], List[str]]]: # All of this is needed to upgrade custom variant machines from old Cura to 2.4 where # `definition_changes` instance container has been introduced. Variant files which # look like the the handy work of the old machine settings plugin are converted directly @@ -71,7 +71,7 @@ class VersionUpgrade22to24(VersionUpgrade): config.write(output) return [filename], [output.getvalue()] - def __convertVariant(self, variant_path): + def __convertVariant(self, variant_path: str) -> str: # Copy the variant to the machine_instances/*_settings.inst.cfg variant_config = configparser.ConfigParser(interpolation = None) with open(variant_path, "r", encoding = "utf-8") as fhandle: @@ -99,7 +99,7 @@ class VersionUpgrade22to24(VersionUpgrade): return config_name - def __getUserVariants(self): + def __getUserVariants(self) -> List[Dict[str, str]]: resource_path = Resources.getDataStoragePath() variants_dir = os.path.join(resource_path, "variants") @@ -113,7 +113,7 @@ class VersionUpgrade22to24(VersionUpgrade): result.append( { "path": entry.path, "name": config.get("general", "name") } ) return result - def upgradeExtruderTrain(self, serialised, filename): + def upgradeExtruderTrain(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: config = configparser.ConfigParser(interpolation = None) config.read_string(serialised) # Read the input string as config file. config.set("general", "version", "3") # Just bump the version number. That is all we need for now. @@ -122,7 +122,7 @@ class VersionUpgrade22to24(VersionUpgrade): config.write(output) return [filename], [output.getvalue()] - def upgradePreferences(self, serialised, filename): + def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: config = configparser.ConfigParser(interpolation = None) config.read_string(serialised) @@ -142,7 +142,7 @@ class VersionUpgrade22to24(VersionUpgrade): config.write(output) return [filename], [output.getvalue()] - def upgradeQuality(self, serialised, filename): + def upgradeQuality(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: config = configparser.ConfigParser(interpolation = None) config.read_string(serialised) # Read the input string as config file. config.set("metadata", "type", "quality_changes") # Update metadata/type to quality_changes @@ -152,7 +152,7 @@ class VersionUpgrade22to24(VersionUpgrade): config.write(output) return [filename], [output.getvalue()] - def getCfgVersion(self, serialised): + def getCfgVersion(self, serialised: str) -> int: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. diff --git a/plugins/VersionUpgrade/VersionUpgrade22to24/__init__.py b/plugins/VersionUpgrade/VersionUpgrade22to24/__init__.py index 278b660ec1..fe79333544 100644 --- a/plugins/VersionUpgrade/VersionUpgrade22to24/__init__.py +++ b/plugins/VersionUpgrade/VersionUpgrade22to24/__init__.py @@ -1,11 +1,16 @@ -# Copyright (c) 2016 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from typing import Any, Dict, TYPE_CHECKING + from . import VersionUpgrade +if TYPE_CHECKING: + from UM.Application import Application + upgrade = VersionUpgrade.VersionUpgrade22to24() -def getMetaData(): +def getMetaData() -> Dict[str, Any]: return { "version_upgrade": { # From To Upgrade function @@ -26,5 +31,5 @@ def getMetaData(): } } -def register(app): +def register(app: "Application"): return { "version_upgrade": upgrade } diff --git a/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py b/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py index 6643edb765..5c9b94cca3 100644 --- a/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py +++ b/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py @@ -4,6 +4,7 @@ import configparser #To parse the files we need to upgrade and write the new files. import io #To serialise configparser output to a string. import os +from typing import Dict, List, Set, Tuple from urllib.parse import quote_plus from UM.Resources import Resources @@ -12,19 +13,18 @@ from UM.VersionUpgrade import VersionUpgrade _removed_settings = { #Settings that were removed in 2.5. "start_layers_at_same_position", "sub_div_rad_mult" -} +} # type: Set[str] _split_settings = { #These settings should be copied to all settings it was split into. "support_interface_line_distance": {"support_roof_line_distance", "support_bottom_line_distance"} -} +} # type: Dict[str, Set[str]] ## A collection of functions that convert the configuration of the user in Cura # 2.5 to a configuration for Cura 2.6. # # All of these methods are essentially stateless. class VersionUpgrade25to26(VersionUpgrade): - - def __init__(self): + def __init__(self) -> None: super().__init__() self._current_fdm_printer_count = 2 @@ -39,7 +39,7 @@ class VersionUpgrade25to26(VersionUpgrade): # \raises ValueError The format of the version number in the file is # incorrect. # \raises KeyError The format of the file is incorrect. - def getCfgVersion(self, serialised): + def getCfgVersion(self, serialised: str) -> int: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. @@ -50,7 +50,7 @@ class VersionUpgrade25to26(VersionUpgrade): # # \param serialised The serialised form of a preferences file. # \param filename The name of the file to upgrade. - def upgradePreferences(self, serialised, filename): + def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) @@ -86,7 +86,7 @@ class VersionUpgrade25to26(VersionUpgrade): # # \param serialised The serialised form of a quality profile. # \param filename The name of the file to upgrade. - def upgradeInstanceContainer(self, serialised, filename): + def upgradeInstanceContainer(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) @@ -116,7 +116,7 @@ class VersionUpgrade25to26(VersionUpgrade): # # \param serialised The serialised form of a quality profile. # \param filename The name of the file to upgrade. - def upgradeMachineStack(self, serialised, filename): + def upgradeMachineStack(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) @@ -149,7 +149,7 @@ class VersionUpgrade25to26(VersionUpgrade): return [filename], [output.getvalue()] ## Acquires the next unique extruder stack index number for the Custom FDM Printer. - def _acquireNextUniqueCustomFdmPrinterExtruderStackIdIndex(self): + def _acquireNextUniqueCustomFdmPrinterExtruderStackIdIndex(self) -> int: extruder_stack_dir = os.path.join(Resources.getDataStoragePath(), "extruders") file_name_list = os.listdir(extruder_stack_dir) file_name_list = [os.path.basename(file_name) for file_name in file_name_list] @@ -169,7 +169,7 @@ class VersionUpgrade25to26(VersionUpgrade): return self._current_fdm_printer_count - def _checkCustomFdmPrinterHasExtruderStack(self, machine_id): + def _checkCustomFdmPrinterHasExtruderStack(self, machine_id: str) -> bool: # go through all extruders and make sure that this custom FDM printer has extruder stacks. extruder_stack_dir = os.path.join(Resources.getDataStoragePath(), "extruders") has_extruders = False @@ -197,7 +197,7 @@ class VersionUpgrade25to26(VersionUpgrade): return has_extruders - def _createCustomFdmPrinterExtruderStack(self, machine_id: str, position: int, quality_id: str, material_id: str): + def _createCustomFdmPrinterExtruderStack(self, machine_id: str, position: int, quality_id: str, material_id: str) -> None: stack_id = "custom_extruder_%s" % (position + 1) if self._current_fdm_printer_count > 1: stack_id += " #%s" % self._current_fdm_printer_count @@ -256,7 +256,7 @@ class VersionUpgrade25to26(VersionUpgrade): ## Creates a definition changes container which doesn't contain anything for the Custom FDM Printers. # The container ID will be automatically generated according to the given stack name. - def _getCustomFdmPrinterDefinitionChanges(self, stack_id: str): + def _getCustomFdmPrinterDefinitionChanges(self, stack_id: str) -> configparser.ConfigParser: # In 2.5, there is no definition_changes container for the Custom FDM printer, so it should be safe to use the # default name unless some one names the printer as something like "Custom FDM Printer_settings". definition_changes_id = stack_id + "_settings" @@ -277,7 +277,7 @@ class VersionUpgrade25to26(VersionUpgrade): ## Creates a user settings container which doesn't contain anything for the Custom FDM Printers. # The container ID will be automatically generated according to the given stack name. - def _getCustomFdmPrinterUserSettings(self, stack_id: str): + def _getCustomFdmPrinterUserSettings(self, stack_id: str) -> configparser.ConfigParser: # For the extruder stacks created in the upgrade, also create user_settings containers so the user changes # will be saved. user_settings_id = stack_id + "_user" diff --git a/plugins/VersionUpgrade/VersionUpgrade25to26/__init__.py b/plugins/VersionUpgrade/VersionUpgrade25to26/__init__.py index 67aa73233f..c74b3218b6 100644 --- a/plugins/VersionUpgrade/VersionUpgrade25to26/__init__.py +++ b/plugins/VersionUpgrade/VersionUpgrade25to26/__init__.py @@ -1,11 +1,16 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from typing import Any, Dict, TYPE_CHECKING + from . import VersionUpgrade25to26 +if TYPE_CHECKING: + from UM.Application import Application + upgrade = VersionUpgrade25to26.VersionUpgrade25to26() -def getMetaData(): +def getMetaData() -> Dict[str, Any]: return { "version_upgrade": { # From To Upgrade function @@ -41,5 +46,5 @@ def getMetaData(): } } -def register(app): +def register(app: "Application") -> Dict[str, Any]: return { "version_upgrade": upgrade } diff --git a/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py b/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py index dfa436e5bd..96307ca43c 100644 --- a/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py +++ b/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py @@ -3,6 +3,7 @@ import configparser #To parse the files we need to upgrade and write the new files. import io #To serialise configparser output to a string. +from typing import Dict, List, Tuple from UM.VersionUpgrade import VersionUpgrade @@ -61,7 +62,7 @@ _renamed_quality_profiles = { "um3_bb0.8_TPU_Not_Supported_Quality": "um3_bb0.8_TPU_Fast_print", "um3_bb0.8_TPU_Not_Supported_Superdraft_Quality": "um3_bb0.8_TPU_Superdraft_Print", -} +} # type: Dict[str, str] ## A collection of functions that convert the configuration of the user in Cura # 2.6 to a configuration for Cura 2.7. @@ -79,7 +80,7 @@ class VersionUpgrade26to27(VersionUpgrade): # \raises ValueError The format of the version number in the file is # incorrect. # \raises KeyError The format of the file is incorrect. - def getCfgVersion(self, serialised): + def getCfgVersion(self, serialised: str) -> int: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. @@ -90,7 +91,7 @@ class VersionUpgrade26to27(VersionUpgrade): # # \param serialised The serialised form of a preferences file. # \param filename The name of the file to upgrade. - def upgradePreferences(self, serialised, filename): + def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation=None) parser.read_string(serialised) @@ -117,8 +118,8 @@ class VersionUpgrade26to27(VersionUpgrade): # # \param serialised The serialised form of a container file. # \param filename The name of the file to upgrade. - def upgradeOtherContainer(self, serialised, filename): - parser = configparser.ConfigParser(interpolation=None) + def upgradeOtherContainer(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: + parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) # Update version numbers @@ -139,7 +140,7 @@ class VersionUpgrade26to27(VersionUpgrade): # # \param serialised The serialised form of a container stack. # \param filename The name of the file to upgrade. - def upgradeStack(self, serialised, filename): + def upgradeStack(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) diff --git a/plugins/VersionUpgrade/VersionUpgrade26to27/__init__.py b/plugins/VersionUpgrade/VersionUpgrade26to27/__init__.py index 0e26ca8bbf..1952c9ceff 100644 --- a/plugins/VersionUpgrade/VersionUpgrade26to27/__init__.py +++ b/plugins/VersionUpgrade/VersionUpgrade26to27/__init__.py @@ -1,11 +1,16 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from typing import Any, Dict, TYPE_CHECKING + from . import VersionUpgrade26to27 +if TYPE_CHECKING: + from UM.Application import Application + upgrade = VersionUpgrade26to27.VersionUpgrade26to27() -def getMetaData(): +def getMetaData() -> Dict[str, Any]: return { "version_upgrade": { # From To Upgrade function @@ -59,5 +64,5 @@ def getMetaData(): } } -def register(app): +def register(app: "Application") -> Dict[str, Any]: return { "version_upgrade": upgrade } diff --git a/plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py b/plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py index 5a141f1558..c9e9e41f7e 100644 --- a/plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py +++ b/plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py @@ -1,9 +1,10 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import configparser #To parse preference files. import io #To serialise the preference files afterwards. import os +from typing import Dict, List, Tuple import urllib.parse import re @@ -11,7 +12,7 @@ from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this. _renamed_themes = { "cura": "cura-light" -} +} # type: Dict[str, str] _renamed_i18n = { "7s": "en_7S", "de": "de_DE", @@ -28,7 +29,7 @@ _renamed_i18n = { "ptbr": "pt_BR", "ru": "ru_RU", "tr": "tr_TR" -} +} # type: Dict[str, str] class VersionUpgrade27to30(VersionUpgrade): @@ -43,7 +44,7 @@ class VersionUpgrade27to30(VersionUpgrade): # \raises ValueError The format of the version number in the file is # incorrect. # \raises KeyError The format of the file is incorrect. - def getCfgVersion(self, serialised): + def getCfgVersion(self, serialised: str) -> int: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. @@ -54,8 +55,8 @@ class VersionUpgrade27to30(VersionUpgrade): # # \param serialised The serialised form of a preferences file. # \param filename The name of the file to upgrade. - def upgradePreferences(self, serialised, filename): - parser = configparser.ConfigParser(interpolation=None) + def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: + parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) # Update version numbers @@ -100,8 +101,8 @@ class VersionUpgrade27to30(VersionUpgrade): # # \param serialised The serialised form of the container file. # \param filename The name of the file to upgrade. - def upgradeQualityChangesContainer(self, serialised, filename): - parser = configparser.ConfigParser(interpolation=None) + def upgradeQualityChangesContainer(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: + parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) # Update the skin pre-shrink settings: @@ -156,7 +157,7 @@ class VersionUpgrade27to30(VersionUpgrade): # # \param serialised The serialised form of the container file. # \param filename The name of the file to upgrade. - def upgradeOtherContainer(self, serialised, filename): + def upgradeOtherContainer(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation=None) parser.read_string(serialised) @@ -185,7 +186,7 @@ class VersionUpgrade27to30(VersionUpgrade): # # \param serialised The serialised form of a container stack. # \param filename The name of the file to upgrade. - def upgradeStack(self, serialised, filename): + def upgradeStack(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation=None) parser.read_string(serialised) diff --git a/plugins/VersionUpgrade/VersionUpgrade27to30/__init__.py b/plugins/VersionUpgrade/VersionUpgrade27to30/__init__.py index 4da7257b1c..bddc71a1e0 100644 --- a/plugins/VersionUpgrade/VersionUpgrade27to30/__init__.py +++ b/plugins/VersionUpgrade/VersionUpgrade27to30/__init__.py @@ -1,11 +1,16 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from typing import Any, Dict, TYPE_CHECKING + from . import VersionUpgrade27to30 +if TYPE_CHECKING: + from UM.Application import Application + upgrade = VersionUpgrade27to30.VersionUpgrade27to30() -def getMetaData(): +def getMetaData() -> Dict[str, Any]: return { "version_upgrade": { # From To Upgrade function @@ -51,5 +56,5 @@ def getMetaData(): } } -def register(app): +def register(app: "Application") -> Dict[str, Any]: return { "version_upgrade": upgrade } diff --git a/plugins/VersionUpgrade/VersionUpgrade30to31/VersionUpgrade30to31.py b/plugins/VersionUpgrade/VersionUpgrade30to31/VersionUpgrade30to31.py index 399eb18b5d..74467d67c6 100644 --- a/plugins/VersionUpgrade/VersionUpgrade30to31/VersionUpgrade30to31.py +++ b/plugins/VersionUpgrade/VersionUpgrade30to31/VersionUpgrade30to31.py @@ -1,14 +1,15 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import configparser #To parse preference files. import io #To serialise the preference files afterwards. +from typing import Dict, List, Set, Tuple from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this. # a list of all legacy "Not Supported" quality profiles -_OLD_NOT_SUPPORTED_PROFILES = [ +_OLD_NOT_SUPPORTED_PROFILES = { "um2p_pp_0.25_normal", "um2p_tpu_0.8_normal", "um3_bb0.4_ABS_Fast_Print", @@ -42,7 +43,7 @@ _OLD_NOT_SUPPORTED_PROFILES = [ "um3_bb0.8_PP_Superdraft_Print", "um3_bb0.8_TPU_Fast_print", "um3_bb0.8_TPU_Superdraft_Print", -] +} # type: Set[str] # Some containers have their specific empty containers, those need to be set correctly. @@ -51,13 +52,13 @@ _EMPTY_CONTAINER_DICT = { "2": "empty_quality", "3": "empty_material", "4": "empty_variant", -} +} # type: Dict[str, str] # Renamed definition files _RENAMED_DEFINITION_DICT = { "jellybox": "imade3d_jellybox", -} +} # type: Dict[str, str] class VersionUpgrade30to31(VersionUpgrade): @@ -72,7 +73,7 @@ class VersionUpgrade30to31(VersionUpgrade): # \raises ValueError The format of the version number in the file is # incorrect. # \raises KeyError The format of the file is incorrect. - def getCfgVersion(self, serialised): + def getCfgVersion(self, serialised: str) -> int: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. @@ -83,7 +84,7 @@ class VersionUpgrade30to31(VersionUpgrade): # # \param serialised The serialised form of a preferences file. # \param filename The name of the file to upgrade. - def upgradePreferences(self, serialised, filename): + def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) @@ -104,7 +105,7 @@ class VersionUpgrade30to31(VersionUpgrade): # # \param serialised The serialised form of the container file. # \param filename The name of the file to upgrade. - def upgradeInstanceContainer(self, serialised, filename): + def upgradeInstanceContainer(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) @@ -129,7 +130,7 @@ class VersionUpgrade30to31(VersionUpgrade): # # \param serialised The serialised form of a container stack. # \param filename The name of the file to upgrade. - def upgradeStack(self, serialised, filename): + def upgradeStack(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) diff --git a/plugins/VersionUpgrade/VersionUpgrade30to31/__init__.py b/plugins/VersionUpgrade/VersionUpgrade30to31/__init__.py index 7b2c213a31..c5cc851d6a 100644 --- a/plugins/VersionUpgrade/VersionUpgrade30to31/__init__.py +++ b/plugins/VersionUpgrade/VersionUpgrade30to31/__init__.py @@ -1,11 +1,16 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from typing import Any, Dict, TYPE_CHECKING + from . import VersionUpgrade30to31 +if TYPE_CHECKING: + from UM.Application import Application + upgrade = VersionUpgrade30to31.VersionUpgrade30to31() -def getMetaData(): +def getMetaData() -> Dict[str, Any]: return { "version_upgrade": { # From To Upgrade function @@ -55,5 +60,5 @@ def getMetaData(): } } -def register(app): +def register(app: "Application") -> Dict[str, Any]: return { "version_upgrade": upgrade } diff --git a/plugins/VersionUpgrade/VersionUpgrade32to33/VersionUpgrade32to33.py b/plugins/VersionUpgrade/VersionUpgrade32to33/VersionUpgrade32to33.py index 18851b82c7..5be58eab3b 100644 --- a/plugins/VersionUpgrade/VersionUpgrade32to33/VersionUpgrade32to33.py +++ b/plugins/VersionUpgrade/VersionUpgrade32to33/VersionUpgrade32to33.py @@ -3,6 +3,7 @@ import configparser #To parse preference files. import io #To serialise the preference files afterwards. +from typing import Dict, List, Tuple from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this. @@ -51,22 +52,22 @@ _EXTRUDER_TO_POSITION = { "ultimaker_original_dual_2nd": 1, "vertex_k8400_dual_1st": 0, "vertex_k8400_dual_2nd": 1 -} +} # type: Dict[str, int] _RENAMED_QUALITY_PROFILES = { "low": "fast", "um2_low": "um2_fast" -} +} # type: Dict[str, str] _RENAMED_QUALITY_TYPES = { "low": "fast" -} +} # type: Dict[str, str] ## Upgrades configurations from the state they were in at version 3.2 to the # state they should be in at version 3.3. class VersionUpgrade32to33(VersionUpgrade): - temporary_group_name_counter = 1 + ## Gets the version number from a CFG file in Uranium's 3.2 format. # # Since the format may change, this is implemented for the 3.2 format only @@ -78,7 +79,7 @@ class VersionUpgrade32to33(VersionUpgrade): # \raises ValueError The format of the version number in the file is # incorrect. # \raises KeyError The format of the file is incorrect. - def getCfgVersion(self, serialised): + def getCfgVersion(self, serialised: str) -> int: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. @@ -89,7 +90,7 @@ class VersionUpgrade32to33(VersionUpgrade): # # \param serialised The serialised form of a preferences file. # \param filename The name of the file to upgrade. - def upgradePreferences(self, serialised, filename): + def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) @@ -117,7 +118,7 @@ class VersionUpgrade32to33(VersionUpgrade): # # \param serialised The serialised form of a container stack. # \param filename The name of the file to upgrade. - def upgradeStack(self, serialized, filename): + def upgradeStack(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialized) @@ -141,7 +142,7 @@ class VersionUpgrade32to33(VersionUpgrade): ## Upgrades non-quality-changes instance containers to have the new version # number. - def upgradeInstanceContainer(self, serialized, filename): + def upgradeInstanceContainer(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialized) @@ -153,7 +154,7 @@ class VersionUpgrade32to33(VersionUpgrade): return [filename], [result.getvalue()] ## Upgrades a quality changes container to the new format. - def upgradeQualityChanges(self, serialized, filename): + def upgradeQualityChanges(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialized) @@ -182,7 +183,7 @@ class VersionUpgrade32to33(VersionUpgrade): return [filename], [result.getvalue()] ## Upgrades a variant container to the new format. - def upgradeVariants(self, serialized, filename): + def upgradeVariants(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialized) diff --git a/plugins/VersionUpgrade/VersionUpgrade32to33/__init__.py b/plugins/VersionUpgrade/VersionUpgrade32to33/__init__.py index 5073be772d..006b21bc48 100644 --- a/plugins/VersionUpgrade/VersionUpgrade32to33/__init__.py +++ b/plugins/VersionUpgrade/VersionUpgrade32to33/__init__.py @@ -1,11 +1,16 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from typing import Any, Dict, TYPE_CHECKING + from . import VersionUpgrade32to33 +if TYPE_CHECKING: + from UM.Application import Application + upgrade = VersionUpgrade32to33.VersionUpgrade32to33() -def getMetaData(): +def getMetaData() -> Dict[str, Any]: return { "version_upgrade": { # From To Upgrade function @@ -51,5 +56,5 @@ def getMetaData(): } } -def register(app): +def register(app: "Application") -> Dict[str, Any]: return { "version_upgrade": upgrade } \ No newline at end of file diff --git a/plugins/VersionUpgrade/VersionUpgrade33to34/VersionUpgrade33to34.py b/plugins/VersionUpgrade/VersionUpgrade33to34/VersionUpgrade33to34.py index e2241fd195..5077dda8ad 100644 --- a/plugins/VersionUpgrade/VersionUpgrade33to34/VersionUpgrade33to34.py +++ b/plugins/VersionUpgrade/VersionUpgrade33to34/VersionUpgrade33to34.py @@ -3,17 +3,17 @@ import configparser #To parse preference files. import io #To serialise the preference files afterwards. +from typing import Dict, List, Tuple from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this. _renamed_settings = { "infill_hollow": "infill_support_enabled" -} +} # type: Dict[str, str] ## Upgrades configurations from the state they were in at version 3.3 to the # state they should be in at version 3.4. class VersionUpgrade33to34(VersionUpgrade): - ## Gets the version number from a CFG file in Uranium's 3.3 format. # # Since the format may change, this is implemented for the 3.3 format only @@ -25,7 +25,7 @@ class VersionUpgrade33to34(VersionUpgrade): # \raises ValueError The format of the version number in the file is # incorrect. # \raises KeyError The format of the file is incorrect. - def getCfgVersion(self, serialised): + def getCfgVersion(self, serialised: str) -> int: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. @@ -34,7 +34,7 @@ class VersionUpgrade33to34(VersionUpgrade): ## Upgrades instance containers to have the new version # number. - def upgradeInstanceContainer(self, serialized, filename): + def upgradeInstanceContainer(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialized) diff --git a/plugins/VersionUpgrade/VersionUpgrade33to34/__init__.py b/plugins/VersionUpgrade/VersionUpgrade33to34/__init__.py index 1130c1e9e2..5fd757f843 100644 --- a/plugins/VersionUpgrade/VersionUpgrade33to34/__init__.py +++ b/plugins/VersionUpgrade/VersionUpgrade33to34/__init__.py @@ -1,11 +1,16 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from typing import Any, Dict, TYPE_CHECKING + from . import VersionUpgrade33to34 +if TYPE_CHECKING: + from UM.Application import Application + upgrade = VersionUpgrade33to34.VersionUpgrade33to34() -def getMetaData(): +def getMetaData() -> Dict[str, Any]: return { "version_upgrade": { # From To Upgrade function @@ -35,5 +40,5 @@ def getMetaData(): } -def register(app): +def register(app: "Application") -> Dict[str, Any]: return { "version_upgrade": upgrade } diff --git a/plugins/VersionUpgrade/VersionUpgrade34to35/VersionUpgrade34to35.py b/plugins/VersionUpgrade/VersionUpgrade34to35/VersionUpgrade34to35.py index 9d59133036..88cc3ca420 100644 --- a/plugins/VersionUpgrade/VersionUpgrade34to35/VersionUpgrade34to35.py +++ b/plugins/VersionUpgrade/VersionUpgrade34to35/VersionUpgrade34to35.py @@ -3,13 +3,14 @@ import configparser import io +from typing import Dict, List, Set, Tuple from UM.VersionUpgrade import VersionUpgrade -deleted_settings = {"prime_tower_wall_thickness", "dual_pre_wipe", "prime_tower_purge_volume"} +deleted_settings = {"prime_tower_wall_thickness", "dual_pre_wipe", "prime_tower_purge_volume"} # type: Set[str] -changed_settings = {'retraction_combing': 'noskin'} -updated_settings = {'retraction_combing': 'infill'} +changed_settings = {"retraction_combing": "noskin"} # type: Dict[str, str] +updated_settings = {"retraction_combing": "infill"} # type: Dict[str, str] _RENAMED_MATERIAL_PROFILES = { "dsm_arnitel2045_175_cartesio_0.25_mm": "dsm_arnitel2045_175_cartesio_0.25mm_thermoplastic_extruder", @@ -57,12 +58,11 @@ _RENAMED_MATERIAL_PROFILES = { "ultimaker_pva_cartesio_0.25_mm": "ultimaker_pva_cartesio_0.25mm_thermoplastic_extruder", "ultimaker_pva_cartesio_0.4_mm": "ultimaker_pva_cartesio_0.4mm_thermoplastic_extruder", "ultimaker_pva_cartesio_0.8_mm": "ultimaker_pva_cartesio_0.8mm_thermoplastic_extruder" -} +} # type: Dict[str, str] ## Upgrades configurations from the state they were in at version 3.4 to the # state they should be in at version 3.5. class VersionUpgrade34to35(VersionUpgrade): - ## Gets the version number from a CFG file in Uranium's 3.3 format. # # Since the format may change, this is implemented for the 3.3 format only @@ -74,7 +74,7 @@ class VersionUpgrade34to35(VersionUpgrade): # \raises ValueError The format of the version number in the file is # incorrect. # \raises KeyError The format of the file is incorrect. - def getCfgVersion(self, serialised): + def getCfgVersion(self, serialised: str) -> int: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. @@ -82,7 +82,7 @@ class VersionUpgrade34to35(VersionUpgrade): return format_version * 1000000 + setting_version ## Upgrades Preferences to have the new version number. - def upgradePreferences(self, serialized, filename): + def upgradePreferences(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialized) @@ -103,7 +103,7 @@ class VersionUpgrade34to35(VersionUpgrade): return [filename], [result.getvalue()] ## Upgrades stacks to have the new version number. - def upgradeStack(self, serialized, filename): + def upgradeStack(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialized) @@ -121,7 +121,7 @@ class VersionUpgrade34to35(VersionUpgrade): ## Upgrades instance containers to have the new version # number. - def upgradeInstanceContainer(self, serialized, filename): + def upgradeInstanceContainer(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialized) @@ -147,7 +147,7 @@ class VersionUpgrade34to35(VersionUpgrade): parser.write(result) return [filename], [result.getvalue()] - def _resetConcentric3DInfillPattern(self, parser): + def _resetConcentric3DInfillPattern(self, parser: configparser.ConfigParser) -> None: if "values" not in parser: return @@ -161,5 +161,4 @@ class VersionUpgrade34to35(VersionUpgrade): if key not in parser["values"]: continue if parser["values"][key] == "concentric_3d": - del parser["values"][key] - + del parser["values"][key] \ No newline at end of file diff --git a/plugins/VersionUpgrade/VersionUpgrade34to35/__init__.py b/plugins/VersionUpgrade/VersionUpgrade34to35/__init__.py index 2ea74f6194..332bc827b9 100644 --- a/plugins/VersionUpgrade/VersionUpgrade34to35/__init__.py +++ b/plugins/VersionUpgrade/VersionUpgrade34to35/__init__.py @@ -1,11 +1,16 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from typing import Any, Dict, TYPE_CHECKING + from . import VersionUpgrade34to35 +if TYPE_CHECKING: + from UM.Application import Application + upgrade = VersionUpgrade34to35.VersionUpgrade34to35() -def getMetaData(): +def getMetaData() -> Dict[str, Any]: return { "version_upgrade": { # From To Upgrade function @@ -52,5 +57,5 @@ def getMetaData(): } -def register(app): +def register(app: "Application") -> Dict[str, Any]: return { "version_upgrade": upgrade } From b67d8d410343490b96357def995adb3a8f0d198f Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 14 Nov 2018 13:46:13 +0100 Subject: [PATCH 02/43] Fix type of fallback variable These have to be strings because the configparser getter can only return strings. Contributes to issue CURA-5936. --- .../VersionUpgrade21to22/VersionUpgrade21to22.py | 2 +- plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py | 2 +- .../VersionUpgrade25to26/VersionUpgrade25to26.py | 2 +- .../VersionUpgrade26to27/VersionUpgrade26to27.py | 4 ++-- .../VersionUpgrade27to30/VersionUpgrade27to30.py | 4 ++-- .../VersionUpgrade30to31/VersionUpgrade30to31.py | 2 +- .../VersionUpgrade32to33/VersionUpgrade32to33.py | 2 +- .../VersionUpgrade33to34/VersionUpgrade33to34.py | 2 +- .../VersionUpgrade34to35/VersionUpgrade34to35.py | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py b/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py index 89c847e606..536385b19d 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py @@ -251,7 +251,7 @@ class VersionUpgrade21to22(VersionUpgrade): parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. - setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) + setting_version = int(parser.get("metadata", "setting_version", fallback = "0")) return format_version * 1000000 + setting_version ## Gets the fallback quality to use for a specific machine-variant-material diff --git a/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py b/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py index 48af365877..dac73683bb 100644 --- a/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py +++ b/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py @@ -156,5 +156,5 @@ class VersionUpgrade22to24(VersionUpgrade): parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. - setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) + setting_version = int(parser.get("metadata", "setting_version", fallback = "0")) return format_version * 1000000 + setting_version diff --git a/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py b/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py index 5c9b94cca3..6dbcfebc46 100644 --- a/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py +++ b/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py @@ -43,7 +43,7 @@ class VersionUpgrade25to26(VersionUpgrade): parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. - setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) + setting_version = int(parser.get("metadata", "setting_version", fallback = "0")) return format_version * 1000000 + setting_version ## Upgrades the preferences file from version 2.5 to 2.6. diff --git a/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py b/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py index 96307ca43c..39e3dea4ed 100644 --- a/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py +++ b/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py @@ -84,7 +84,7 @@ class VersionUpgrade26to27(VersionUpgrade): parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. - setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) + setting_version = int(parser.get("metadata", "setting_version", fallback = "0")) return format_version * 1000000 + setting_version ## Upgrades a preferences file from version 2.6 to 2.7. @@ -92,7 +92,7 @@ class VersionUpgrade26to27(VersionUpgrade): # \param serialised The serialised form of a preferences file. # \param filename The name of the file to upgrade. def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: - parser = configparser.ConfigParser(interpolation=None) + parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) # Update version numbers diff --git a/plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py b/plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py index c9e9e41f7e..b594c3c6c4 100644 --- a/plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py +++ b/plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py @@ -48,7 +48,7 @@ class VersionUpgrade27to30(VersionUpgrade): parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. - setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) + setting_version = int(parser.get("metadata", "setting_version", fallback = "0")) return format_version * 1000000 + setting_version ## Upgrades a preferences file from version 2.7 to 3.0. @@ -158,7 +158,7 @@ class VersionUpgrade27to30(VersionUpgrade): # \param serialised The serialised form of the container file. # \param filename The name of the file to upgrade. def upgradeOtherContainer(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]: - parser = configparser.ConfigParser(interpolation=None) + parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) # Update the skin pre-shrink settings: diff --git a/plugins/VersionUpgrade/VersionUpgrade30to31/VersionUpgrade30to31.py b/plugins/VersionUpgrade/VersionUpgrade30to31/VersionUpgrade30to31.py index 74467d67c6..f0b2e939b9 100644 --- a/plugins/VersionUpgrade/VersionUpgrade30to31/VersionUpgrade30to31.py +++ b/plugins/VersionUpgrade/VersionUpgrade30to31/VersionUpgrade30to31.py @@ -77,7 +77,7 @@ class VersionUpgrade30to31(VersionUpgrade): parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. - setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) + setting_version = int(parser.get("metadata", "setting_version", fallback = "0")) return format_version * 1000000 + setting_version ## Upgrades a preferences file from version 3.0 to 3.1. diff --git a/plugins/VersionUpgrade/VersionUpgrade32to33/VersionUpgrade32to33.py b/plugins/VersionUpgrade/VersionUpgrade32to33/VersionUpgrade32to33.py index 5be58eab3b..83cb15c864 100644 --- a/plugins/VersionUpgrade/VersionUpgrade32to33/VersionUpgrade32to33.py +++ b/plugins/VersionUpgrade/VersionUpgrade32to33/VersionUpgrade32to33.py @@ -83,7 +83,7 @@ class VersionUpgrade32to33(VersionUpgrade): parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. - setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) + setting_version = int(parser.get("metadata", "setting_version", fallback = "0")) return format_version * 1000000 + setting_version ## Upgrades a preferences file from version 3.2 to 3.3. diff --git a/plugins/VersionUpgrade/VersionUpgrade33to34/VersionUpgrade33to34.py b/plugins/VersionUpgrade/VersionUpgrade33to34/VersionUpgrade33to34.py index 5077dda8ad..704ede02d6 100644 --- a/plugins/VersionUpgrade/VersionUpgrade33to34/VersionUpgrade33to34.py +++ b/plugins/VersionUpgrade/VersionUpgrade33to34/VersionUpgrade33to34.py @@ -29,7 +29,7 @@ class VersionUpgrade33to34(VersionUpgrade): parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. - setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) + setting_version = int(parser.get("metadata", "setting_version", fallback = "0")) return format_version * 1000000 + setting_version ## Upgrades instance containers to have the new version diff --git a/plugins/VersionUpgrade/VersionUpgrade34to35/VersionUpgrade34to35.py b/plugins/VersionUpgrade/VersionUpgrade34to35/VersionUpgrade34to35.py index 88cc3ca420..d930b6e217 100644 --- a/plugins/VersionUpgrade/VersionUpgrade34to35/VersionUpgrade34to35.py +++ b/plugins/VersionUpgrade/VersionUpgrade34to35/VersionUpgrade34to35.py @@ -78,7 +78,7 @@ class VersionUpgrade34to35(VersionUpgrade): parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. - setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) + setting_version = int(parser.get("metadata", "setting_version", fallback = "0")) return format_version * 1000000 + setting_version ## Upgrades Preferences to have the new version number. From 8ec7d6dba3b79dc88c9496185c6e49000740018a Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 14 Nov 2018 13:56:46 +0100 Subject: [PATCH 03/43] Fix type issues in old version upgrade plug-ins The one actual change was this: To give a KeyError when stuff can't be found in a dictionary, rather than returning None there and then getting a TypeError later. Contributes to issue CURA-5936. --- .../VersionUpgrade21to22/MachineInstance.py | 10 +++++----- .../VersionUpgrade21to22/Preferences.py | 8 ++++---- .../VersionUpgrade22to24/VersionUpgrade.py | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py index a947114595..478f955e49 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py @@ -4,7 +4,7 @@ import configparser #To read config files. import io #To write config files to strings as if they were files. import os.path #To get the path to write new user profiles to. -from typing import List, Optional, Tuple +from typing import Dict, List, Optional, Set, Tuple import urllib #To serialise the user container file name properly. import UM.VersionUpgrade #To indicate that a file is of incorrect format. @@ -33,7 +33,7 @@ class MachineInstance: # \param serialised A string with the contents of a machine instance file, # without extension. # \param filename The supposed file name of this machine instance. - def __init__(self, serialised: str, filename: str) -> str: + def __init__(self, serialised: str, filename: str) -> None: self._filename = filename config = configparser.ConfigParser(interpolation = None) @@ -54,11 +54,11 @@ class MachineInstance: self._type_name = config.get("general", "type") self._variant_name = config.get("general", "variant", fallback = "empty_variant") self._name = config.get("general", "name", fallback = "") - self._key = config.get("general", "key", fallback = None) + self._key = config.get("general", "key", fallback = "") self._active_profile_name = config.get("general", "active_profile", fallback = "empty_quality") self._active_material_name = config.get("general", "material", fallback = "empty_material") - self._machine_setting_overrides = {} + self._machine_setting_overrides = {} # type: Dict[str, str] for key, value in config["machine_settings"].items(): self._machine_setting_overrides[key] = value @@ -109,7 +109,7 @@ class MachineInstance: version_upgrade_manager = UM.VersionUpgradeManager.VersionUpgradeManager.getInstance() user_version_to_paths_dict = version_upgrade_manager.getStoragePaths("user") - paths_set = set() + paths_set = set() # type: Set[str] for paths in user_version_to_paths_dict.values(): paths_set |= paths diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py b/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py index 51e4b617e8..953837b863 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py @@ -59,11 +59,11 @@ class Preferences: #Translate the setting names in the visible settings. if self._config.has_section("machines") and self._config.has_option("machines", "setting_visibility"): visible_settings = self._config.get("machines", "setting_visibility") - visible_settings = visible_settings.split(",") + visible_settings_list = visible_settings.split(",") import VersionUpgrade21to22 #Import here to prevent a circular dependency. - visible_settings = [VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateSettingName(setting_name) - for setting_name in visible_settings] - visible_settings = ",".join(visible_settings) + visible_settings_list = [VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateSettingName(setting_name) + for setting_name in visible_settings_list] + visible_settings = ",".join(visible_settings_list) self._config.set("machines", "setting_visibility", value = visible_settings) #Translate the active_instance key. diff --git a/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py b/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py index dac73683bb..ded892d137 100644 --- a/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py +++ b/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py @@ -22,11 +22,11 @@ class VersionUpgrade22to24(VersionUpgrade): config.read_string(serialised) # Read the input string as config file. if config.get("metadata", "type") == "definition_changes": # This is not a container stack, don't upgrade it here - return + return None config.set("general", "version", "3") - container_list = [] + container_list = [] # type: List[str] if config.has_section("containers"): for index, container_id in config.items("containers"): container_list.append(container_id) @@ -37,14 +37,14 @@ class VersionUpgrade22to24(VersionUpgrade): user_variants = self.__getUserVariants() name_path_dict = {} for variant in user_variants: - name_path_dict[variant.get("name")] = variant.get("path") + name_path_dict[variant["name"]] = variant["path"] user_variant_names = set(container_list).intersection(name_path_dict.keys()) if len(user_variant_names): # One of the user defined variants appears in the list of containers in the stack. for variant_name in user_variant_names: # really there should just be one variant to convert. - config_name = self.__convertVariant(name_path_dict.get(variant_name)) + config_name = self.__convertVariant(name_path_dict[variant_name]) # Change the name of variant and insert empty_variant into the stack. new_container_list = [] @@ -64,8 +64,8 @@ class VersionUpgrade22to24(VersionUpgrade): config.remove_option("general", "containers") - for index in range(len(container_list)): - config.set("containers", str(index), container_list[index]) + for idx in range(len(container_list)): + config.set("containers", str(idx), container_list[idx]) output = io.StringIO() config.write(output) From 66c3cc9204fdc309c993ec4b40983cdd150dc00a Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 14 Nov 2018 14:20:42 +0100 Subject: [PATCH 04/43] Prevent an error during start up --- cura/BuildVolume.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py index 547c3dae71..1589f16afc 100755 --- a/cura/BuildVolume.py +++ b/cura/BuildVolume.py @@ -489,7 +489,9 @@ class BuildVolume(SceneNode): def _updateRaftThickness(self): old_raft_thickness = self._raft_thickness - self._adhesion_type = self._global_container_stack.getProperty("adhesion_type", "value") + if self._global_container_stack.extruders: + # This might be called before the extruder stacks have initialised, in which case getting the adhesion_type fails + self._adhesion_type = self._global_container_stack.getProperty("adhesion_type", "value") self._raft_thickness = 0.0 if self._adhesion_type == "raft": self._raft_thickness = ( From b671a3153a0f7f7ab9745f73c300d34c6bf7a06b Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 14 Nov 2018 14:21:39 +0100 Subject: [PATCH 05/43] Catch an error getting an extruder value before extruders are added to the global stack --- cura/Settings/CuraFormulaFunctions.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cura/Settings/CuraFormulaFunctions.py b/cura/Settings/CuraFormulaFunctions.py index 1db01857f8..9ef80bd3d4 100644 --- a/cura/Settings/CuraFormulaFunctions.py +++ b/cura/Settings/CuraFormulaFunctions.py @@ -5,6 +5,7 @@ from typing import Any, List, Optional, TYPE_CHECKING from UM.Settings.PropertyEvaluationContext import PropertyEvaluationContext from UM.Settings.SettingFunction import SettingFunction +from UM.Logger import Logger if TYPE_CHECKING: from cura.CuraApplication import CuraApplication @@ -38,7 +39,11 @@ class CuraFormulaFunctions: extruder_position = int(machine_manager.defaultExtruderPosition) global_stack = machine_manager.activeMachine - extruder_stack = global_stack.extruders[str(extruder_position)] + try: + extruder_stack = global_stack.extruders[str(extruder_position)] + except KeyError: + Logger.log("w", "Value for %s of extruder %s was requested, but that extruder is not available" % (property_key, extruder_position)) + return None value = extruder_stack.getRawProperty(property_key, "value", context = context) if isinstance(value, SettingFunction): From 2bf4354fed244e47ab00da8528f1db7b6a906a15 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Thu, 15 Nov 2018 15:57:34 +0100 Subject: [PATCH 06/43] Removed minimum_value for the setting support_roof_offset and support_bottom_offset CURA-5880 --- resources/definitions/fdmprinter.def.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index 325e4b6c79..7cb6720f27 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -4456,7 +4456,6 @@ "description": "Amount of offset applied to the roofs of the support.", "unit": "mm", "type": "float", - "minimum_value": "0", "default_value": 0.0, "value": "extruderValue(support_roof_extruder_nr, 'support_interface_offset')", "maximum_value": "extruderValue(support_extruder_nr, 'support_offset')", @@ -4471,7 +4470,6 @@ "description": "Amount of offset applied to the floors of the support.", "unit": "mm", "type": "float", - "minimum_value": "0", "default_value": 0.0, "value": "extruderValue(support_bottom_extruder_nr, 'support_interface_offset')", "maximum_value": "extruderValue(support_extruder_nr, 'support_offset')", From 240ac1f06b6458d154d84ce326a3dd8e16777aa1 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 16 Nov 2018 13:03:45 +0100 Subject: [PATCH 07/43] Clarify some setting descriptions --- resources/definitions/fdmextruder.def.json | 2 +- resources/definitions/fdmprinter.def.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/definitions/fdmextruder.def.json b/resources/definitions/fdmextruder.def.json index 19c9e92d18..55556f5764 100644 --- a/resources/definitions/fdmextruder.def.json +++ b/resources/definitions/fdmextruder.def.json @@ -78,7 +78,7 @@ "machine_extruder_start_code": { "label": "Extruder Start G-Code", - "description": "Start g-code to execute whenever turning the extruder on.", + "description": "Start g-code to execute whenever this extruder is switched to.", "type": "str", "default_value": "", "settable_per_mesh": false, diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index 7cb6720f27..b1812ae705 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -2406,7 +2406,7 @@ "switch_extruder_retraction_amount": { "label": "Nozzle Switch Retraction Distance", - "description": "The amount of retraction: Set at 0 for no retraction at all. This should generally be the same as the length of the heat zone.", + "description": "The amount of retraction when switching extruder. Set to 0 for no retraction at all. This should generally be the same as the length of the heat zone.", "type": "float", "unit": "mm", "enabled": "retraction_enable", From 93bd5fee5387e45ea880ee1fc6125790546e465a Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 16 Nov 2018 13:44:46 +0100 Subject: [PATCH 08/43] Fix wrong push free shadow for one at a time. It was applying the size twice. CURA-5822 --- cura/Scene/ConvexHullDecorator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/Scene/ConvexHullDecorator.py b/cura/Scene/ConvexHullDecorator.py index 39124c5ba3..0c03ae615b 100644 --- a/cura/Scene/ConvexHullDecorator.py +++ b/cura/Scene/ConvexHullDecorator.py @@ -272,7 +272,7 @@ class ConvexHullDecorator(SceneNodeDecorator): head_and_fans = self._getHeadAndFans().intersectionConvexHulls(mirrored) # Min head hull is used for the push free - convex_hull = self._compute2DConvexHeadFull() + convex_hull = self._compute2DConvexHull() if convex_hull: return convex_hull.getMinkowskiHull(head_and_fans) return None From f10bd28c4ae8084f9b8f8f343b3b8471a764a2a4 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 16 Nov 2018 17:25:32 +0100 Subject: [PATCH 09/43] Improve grammar and do similar fix for extruder end g-code Contributes to issue CURA-5906. --- resources/definitions/fdmextruder.def.json | 4 ++-- resources/definitions/fdmprinter.def.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/definitions/fdmextruder.def.json b/resources/definitions/fdmextruder.def.json index 55556f5764..cb49b1e128 100644 --- a/resources/definitions/fdmextruder.def.json +++ b/resources/definitions/fdmextruder.def.json @@ -78,7 +78,7 @@ "machine_extruder_start_code": { "label": "Extruder Start G-Code", - "description": "Start g-code to execute whenever this extruder is switched to.", + "description": "Start g-code to execute when switching to this extruder.", "type": "str", "default_value": "", "settable_per_mesh": false, @@ -124,7 +124,7 @@ "machine_extruder_end_code": { "label": "Extruder End G-Code", - "description": "End g-code to execute whenever turning the extruder off.", + "description": "End g-code to execute when switching away from this extruder.", "type": "str", "default_value": "", "settable_per_mesh": false, diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index b1812ae705..c015ab8ccb 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -2406,7 +2406,7 @@ "switch_extruder_retraction_amount": { "label": "Nozzle Switch Retraction Distance", - "description": "The amount of retraction when switching extruder. Set to 0 for no retraction at all. This should generally be the same as the length of the heat zone.", + "description": "The amount of retraction when switching extruders. Set to 0 for no retraction at all. This should generally be the same as the length of the heat zone.", "type": "float", "unit": "mm", "enabled": "retraction_enable", From b0f3fedc94354d30a8677bc93f02e67a9ec3d0f0 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 19 Nov 2018 13:42:19 +0100 Subject: [PATCH 10/43] Fix import QtQuick versions to suit Qt 5.10 CURA-5785 --- plugins/PreviewStage/PreviewMenu.qml | 3 +-- resources/qml/MachineSelector.qml | 2 +- .../qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/PreviewStage/PreviewMenu.qml b/plugins/PreviewStage/PreviewMenu.qml index b331ff69c5..1a744aeb65 100644 --- a/plugins/PreviewStage/PreviewMenu.qml +++ b/plugins/PreviewStage/PreviewMenu.qml @@ -2,8 +2,7 @@ // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 - -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.3 import UM 1.3 as UM import Cura 1.1 as Cura diff --git a/resources/qml/MachineSelector.qml b/resources/qml/MachineSelector.qml index a464949192..c9756d93ba 100644 --- a/resources/qml/MachineSelector.qml +++ b/resources/qml/MachineSelector.qml @@ -2,7 +2,7 @@ // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.2 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.3 import QtQuick.Controls.Styles 1.1 import QtQuick.Layouts 1.1 diff --git a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml index 33610135fe..d428a05463 100644 --- a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml +++ b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml @@ -4,7 +4,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Controls.Styles 1.4 -import QtQuick.Layouts 1.11 +import QtQuick.Layouts 1.3 import QtQuick.Controls 1.1 as OldControls From 8683a1e07e5adc60e0be272eb4b6871d92f8c1ef Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 19 Nov 2018 16:16:41 +0100 Subject: [PATCH 11/43] Add previewStage to bundled cura package list CURA-5785 --- resources/bundled_packages/cura.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/resources/bundled_packages/cura.json b/resources/bundled_packages/cura.json index ee82b17a75..678ea0a697 100644 --- a/resources/bundled_packages/cura.json +++ b/resources/bundled_packages/cura.json @@ -356,6 +356,23 @@ } } }, + "PreviewStage": { + "package_info": { + "package_id": "PreviewStage", + "package_type": "plugin", + "display_name": "Preview Stage", + "description": "Provides a preview stage in Cura.", + "package_version": "1.0.0", + "sdk_version": 5, + "website": "https://ultimaker.com", + "author": { + "author_id": "UltimakerPackages", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, "RemovableDriveOutputDevice": { "package_info": { "package_id": "RemovableDriveOutputDevice", From 421a64c7b0ff712ed8c5103641bda03c257df3da Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 19 Nov 2018 16:42:36 +0100 Subject: [PATCH 12/43] Replace queued print job cards with new design Contributes to CL-1148 --- .../resources/qml/ClusterMonitorItem.qml | 52 +++------ .../resources/qml/ExpandableCard.qml | 81 +++++++++++++ .../resources/qml/MonitorPrintJobCard.qml | 109 ++++++++++++++++++ .../resources/qml/MonitorPrintJobPreview.qml | 67 +++++++++++ 4 files changed, 272 insertions(+), 37 deletions(-) create mode 100644 plugins/UM3NetworkPrinting/resources/qml/ExpandableCard.qml create mode 100644 plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml create mode 100644 plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobPreview.qml diff --git a/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml index d210ab40f3..ff4bc72218 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml @@ -6,13 +6,15 @@ import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import UM 1.3 as UM import Cura 1.0 as Cura +import QtGraphicalEffects 1.0 Component { + Rectangle { id: monitorFrame; property var emphasisColor: UM.Theme.getColor("setting_control_border_highlight"); property var cornerRadius: UM.Theme.getSize("monitor_corner_radius").width; - color: UM.Theme.getColor("viewport_background"); + color: transparent height: maximumHeight; onVisibleChanged: { if (monitorFrame != null && !monitorFrame.visible) { @@ -21,6 +23,14 @@ Component { } width: maximumWidth; + LinearGradient { + anchors.fill: parent + gradient: Gradient { + GradientStop { position: 0.0; color: "#f6f6f6" } + GradientStop { position: 1.0; color: "#ffffff" } + } + } + UM.I18nCatalog { id: catalog; name: "cura"; @@ -60,39 +70,6 @@ Component { text: catalog.i18nc("@label", "Queued"); } - Column { - id: skeletonLoader; - anchors { - bottom: parent.bottom; - bottomMargin: UM.Theme.getSize("default_margin").height; - horizontalCenter: parent.horizontalCenter; - top: queuedLabel.bottom; - topMargin: UM.Theme.getSize("default_margin").height; - } - visible: !queuedPrintJobs.visible; - width: Math.min(800 * screenScaleFactor, maximumWidth); - - PrintJobInfoBlock { - anchors { - left: parent.left; - leftMargin: UM.Theme.getSize("default_margin").width; - right: parent.right; - rightMargin: UM.Theme.getSize("default_margin").width; - } - printJob: null; // Use as skeleton - } - - PrintJobInfoBlock { - anchors { - left: parent.left; - leftMargin: UM.Theme.getSize("default_margin").width; - right: parent.right; - rightMargin: UM.Theme.getSize("default_margin").width; - } - printJob: null; // Use as skeleton - } - } - ScrollView { id: queuedPrintJobs; anchors { @@ -104,12 +81,12 @@ Component { } style: UM.Theme.styles.scrollview; visible: OutputDevice.receivedPrintJobs; - width: Math.min(800 * screenScaleFactor, maximumWidth); + width: Math.min(834 * screenScaleFactor, maximumWidth); ListView { id: printJobList; anchors.fill: parent; - delegate: PrintJobInfoBlock { + delegate: MonitorPrintJobCard { anchors { left: parent.left; leftMargin: UM.Theme.getSize("default_margin").width; @@ -119,7 +96,7 @@ Component { printJob: modelData; } model: OutputDevice.queuedPrintJobs; - spacing: UM.Theme.getSize("default_margin").height - 2 * UM.Theme.getSize("monitor_shadow_radius").width; + spacing: 6; } } @@ -129,4 +106,5 @@ Component { visible: OutputDevice.activeCameraUrl != ""; } } + } diff --git a/plugins/UM3NetworkPrinting/resources/qml/ExpandableCard.qml b/plugins/UM3NetworkPrinting/resources/qml/ExpandableCard.qml new file mode 100644 index 0000000000..89d88d671a --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/qml/ExpandableCard.qml @@ -0,0 +1,81 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 2.0 +import UM 1.3 as UM +import Cura 1.0 as Cura + +// The expandable component has 3 major sub components: +// * The headerItem Always visible and should hold some info about what happens if the component is expanded +// * The popupItem The content that needs to be shown if the component is expanded. +Item +{ + id: base + + property var expanded: false + property var borderWidth: 1 + property color borderColor: "#EAEAEC" + property color headerBackgroundColor: "white" + property color headerHoverColor: "#f5f5f5" + property color drawerBackgroundColor: "white" + property alias headerItem: header.children + property alias drawerItem: drawer.children + + width: parent.width + height: childrenRect.height + + Rectangle + { + id: header + border + { + color: borderColor + width: borderWidth + } + color: headerMouseArea.containsMouse ? headerHoverColor : headerBackgroundColor + height: childrenRect.height + width: parent.width + Behavior on color + { + ColorAnimation + { + duration: 100 + } + } + } + + MouseArea + { + id: headerMouseArea + anchors.fill: header + onClicked: base.expanded = !base.expanded + hoverEnabled: true + } + + Rectangle + { + id: drawer + anchors + { + top: header.bottom + topMargin: -1 + } + border + { + color: borderColor + width: borderWidth + } + clip: true + color: headerBackgroundColor + height: base.expanded ? childrenRect.height : 0 + width: parent.width + Behavior on height + { + NumberAnimation + { + duration: 100 + } + } + } +} \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml new file mode 100644 index 0000000000..307a4f908f --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml @@ -0,0 +1,109 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 2.0 +import UM 1.3 as UM +import Cura 1.0 as Cura + +// A Print Job Card is essentially just a filled-in Expandable Card item. +Item +{ + id: base + property var printJob: null + + width: parent.width + height: childrenRect.height + + ExpandableCard + { + headerItem: Row + { + height: 48 + anchors.left: parent.left + anchors.leftMargin: 24 + spacing: 18 + + MonitorPrintJobPreview + { + printJob: base.printJob + size: 32 + anchors.verticalCenter: parent.verticalCenter + } + + Label + { + text: printJob && printJob.name ? printJob.name : "" + color: "#374355" + elide: Text.ElideRight + font: UM.Theme.getFont("default_bold") + anchors.verticalCenter: parent.verticalCenter + width: 216 + height: 18 + } + + Label + { + text: printJob ? OutputDevice.formatDuration(printJob.timeTotal) : "" + color: "#374355" + elide: Text.ElideRight + font: UM.Theme.getFont("default_bold") + anchors.verticalCenter: parent.verticalCenter + width: 216 + height: 18 + } + + Label + { + color: "#374355" + height: 18 + elide: Text.ElideRight + font: UM.Theme.getFont("default_bold") + text: { + if (printJob !== null) { + if (printJob.assignedPrinter == null) + { + if (printJob.state == "error") + { + return catalog.i18nc("@label", "Waiting for: Unavailable printer") + } + return catalog.i18nc("@label", "Waiting for: First available") + } + else + { + return catalog.i18nc("@label", "Waiting for: ") + printJob.assignedPrinter.name + } + } + return "" + } + visible: printJob + anchors.verticalCenter: parent.verticalCenter + width: 216 + } + } + drawerItem: Row + { + height: 96 + anchors.left: parent.left + anchors.leftMargin: 74 + spacing: 18 + + Rectangle + { + id: printerConfiguration + width: 450 + height: 72 + color: "blue" + anchors.verticalCenter: parent.verticalCenter + } + Label { + height: 18 + text: printJob && printJob.owner ? printJob.owner : "" + color: "#374355" + elide: Text.ElideRight + font: UM.Theme.getFont("default_bold") + anchors.top: printerConfiguration.top + } + } + } +} \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobPreview.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobPreview.qml new file mode 100644 index 0000000000..7322193451 --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobPreview.qml @@ -0,0 +1,67 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Dialogs 1.1 +import QtQuick.Controls 2.0 +import QtQuick.Controls.Styles 1.4 +import QtGraphicalEffects 1.0 +import QtQuick.Layouts 1.1 +import QtQuick.Dialogs 1.1 +import UM 1.3 as UM + +Item +{ + id: printJobPreview + + property var printJob: null + property var size: 256 + + width: size + height: size + + // Actual content + Image + { + id: previewImage + anchors.fill: parent + opacity: printJob && printJob.state == "error" ? 0.5 : 1.0 + source: printJob ? printJob.previewImageUrl : "" + visible: printJob + } + + UM.RecolorImage + { + id: ultiBotImage + + anchors.centerIn: printJobPreview + color: UM.Theme.getColor("monitor_placeholder_image") + height: printJobPreview.height + source: "../svg/ultibot.svg" + sourceSize + { + height: height + width: width + } + /* Since print jobs ALWAYS have an image url, we have to check if that image URL errors or + not in order to determine if we show the placeholder (ultibot) image instead. */ + visible: printJob && previewImage.status == Image.Error + width: printJobPreview.width + } + + UM.RecolorImage + { + id: statusImage + anchors.centerIn: printJobPreview + color: UM.Theme.getColor("monitor_image_overlay") + height: 0.5 * printJobPreview.height + source: printJob && printJob.state == "error" ? "../svg/aborted-icon.svg" : "" + sourceSize + { + height: height + width: width + } + visible: source != "" + width: 0.5 * printJobPreview.width + } +} \ No newline at end of file From 2b88e82a2a520761ede661ba0843a77b5269b1c1 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 19 Nov 2018 16:52:02 +0100 Subject: [PATCH 13/43] Add option test-verbose build option to CuraTests --- cmake/CuraTests.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/CuraTests.cmake b/cmake/CuraTests.cmake index f2ee92d65b..b6d04de036 100644 --- a/cmake/CuraTests.cmake +++ b/cmake/CuraTests.cmake @@ -6,6 +6,8 @@ include(CMakeParseArguments) find_package(PythonInterp 3.5.0 REQUIRED) +add_custom_target(test-verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose) + function(cura_add_test) set(_single_args NAME DIRECTORY PYTHONPATH) cmake_parse_arguments("" "" "${_single_args}" "" ${ARGN}) From e6d9ad31ab0e432a7357dfa702332cae25aead88 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 20 Nov 2018 09:20:45 +0100 Subject: [PATCH 14/43] Use generated Makefiles to run tests --- Jenkinsfile | 43 ++----------------------------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f9a3a9864a..a345ebbd05 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,20 +38,9 @@ parallel_nodes(['linux && cura', 'windows && cura']) { if (isUnix()) { - // For Linux to show everything - def branch = env.BRANCH_NAME - if(!fileExists("${env.CURA_ENVIRONMENT_PATH}/${branch}")) - { - branch = "master" - } - def uranium_dir = get_workspace_dir("Ultimaker/Uranium/${branch}") - + // For Linux try { - sh """ - cd .. - export PYTHONPATH=.:"${uranium_dir}" - ${env.CURA_ENVIRONMENT_PATH}/${branch}/bin/pytest -x --verbose --full-trace --capture=no ./tests - """ + sh 'make CTEST_OUTPUT_ON_FAILURE=TRUE test' } catch(e) { currentBuild.result = "UNSTABLE" @@ -70,34 +59,6 @@ parallel_nodes(['linux && cura', 'windows && cura']) } } } - - stage('Code Style') - { - if (isUnix()) - { - // For Linux to show everything. - // CMake also runs this test, but if it fails then the test just shows "failed" without details of what exactly failed. - def branch = env.BRANCH_NAME - if(!fileExists("${env.CURA_ENVIRONMENT_PATH}/${branch}")) - { - branch = "master" - } - def uranium_dir = get_workspace_dir("Ultimaker/Uranium/${branch}") - - try - { - sh """ - cd .. - export PYTHONPATH=.:"${uranium_dir}" - ${env.CURA_ENVIRONMENT_PATH}/${branch}/bin/python3 run_mypy.py - """ - } - catch(e) - { - currentBuild.result = "UNSTABLE" - } - } - } } } From 76f2aeb43c8ab19a638ade5016229a5f542664cb Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Tue, 20 Nov 2018 11:27:45 +0100 Subject: [PATCH 15/43] Fix the title's top margin size in the add machine dialog. --- resources/qml/AddMachineDialog.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/AddMachineDialog.qml b/resources/qml/AddMachineDialog.qml index 0df8b891d9..aa160acd4d 100644 --- a/resources/qml/AddMachineDialog.qml +++ b/resources/qml/AddMachineDialog.qml @@ -73,7 +73,7 @@ UM.Dialog { top: parent.top left: parent.left - topMargin: UM.Theme.getSize("default_margin") + topMargin: UM.Theme.getSize("default_margin").height } text: catalog.i18nc("@title:tab", "Add a printer to Cura") From fab0d5a4b7f1e3b5dd9bfc6ccecba5cc73c0a799 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Tue, 20 Nov 2018 13:25:15 +0100 Subject: [PATCH 16/43] Rename the color of the sidebar to main_background, since it was deleted but not updated in the usages. Contributes to CURA-5785. --- plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml | 2 +- plugins/UM3NetworkPrinting/resources/qml/ClusterControlItem.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml b/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml index a48cb2ee3f..62e1e3ab86 100644 --- a/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml +++ b/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml @@ -83,7 +83,7 @@ Item model: packageData.supported_configs headerDelegate: Rectangle { - color: UM.Theme.getColor("sidebar") + color: UM.Theme.getColor("main_background") height: UM.Theme.getSize("toolbox_chart_row").height Label { diff --git a/plugins/UM3NetworkPrinting/resources/qml/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/resources/qml/ClusterControlItem.qml index 068c369a3f..94e75a6de0 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/ClusterControlItem.qml @@ -13,7 +13,7 @@ Component { property var shadowRadius: UM.Theme.getSize("monitor_shadow_radius").width; property var cornerRadius: UM.Theme.getSize("monitor_corner_radius").width; anchors.fill: parent; - color: UM.Theme.getColor("sidebar"); + color: UM.Theme.getColor("main_background"); visible: OutputDevice != null; UM.I18nCatalog { From fb3cb67da05115779cd6964d0d24e0760180ec99 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Tue, 20 Nov 2018 13:46:41 +0100 Subject: [PATCH 17/43] Add printer configuration components Contributes to CL-1148 --- .../qml/MonitorBuildplateConfiguration.qml | 63 +++++++++++++++ .../qml/MonitorExtruderConfiguration.qml | 76 +++++++++++++++++++ .../resources/qml/MonitorIconExtruder.qml | 60 +++++++++++++++ .../resources/qml/MonitorPrintJobCard.qml | 74 +++++++++++------- .../resources/qml/MonitorPrintJobPreview.qml | 6 +- .../qml/MonitorPrinterConfiguration.qml | 56 ++++++++++++++ .../resources/svg/icons/buildplate.svg | 5 ++ .../resources/svg/icons/extruder.svg | 5 ++ 8 files changed, 314 insertions(+), 31 deletions(-) create mode 100644 plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml create mode 100644 plugins/UM3NetworkPrinting/resources/qml/MonitorExtruderConfiguration.qml create mode 100644 plugins/UM3NetworkPrinting/resources/qml/MonitorIconExtruder.qml create mode 100644 plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterConfiguration.qml create mode 100644 plugins/UM3NetworkPrinting/resources/svg/icons/buildplate.svg create mode 100644 plugins/UM3NetworkPrinting/resources/svg/icons/extruder.svg diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml new file mode 100644 index 0000000000..d14277a1ff --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml @@ -0,0 +1,63 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 2.0 +import UM 1.3 as UM + +/** + * This component comprises a buildplate icon and the buildplate name. It is + * used by the MonitorPrinterConfiguration component along with two instances + * of MonitorExtruderConfiguration. + * + * NOTE: For most labels, a fixed height with vertical alignment is used to make + * layouts more deterministic (like the fixed-size textboxes used in original + * mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted + * with '// FIXED-LINE-HEIGHT:'. + */ +Item +{ + // The buildplate name + property alias buildplate: buildplateLabel.text + + // Height is one 18px label/icon + height: 18 * screenScaleFactor // TODO: Theme! + width: childrenRect.width + + Row + { + height: parent.height + spacing: 12 * screenScaleFactor // TODO: Theme! (Should be same as extruder spacing) + + // This wrapper ensures that the buildplate icon is located centered + // below an extruder icon. + Item + { + height: parent.height + width: 32 * screenScaleFactor // TODO: Theme! (Should be same as extruder icon width) + + UM.RecolorImage + { + id: buildplateIcon + anchors.centerIn: parent + color: "#0a0850" // TODO: Theme! (Standard purple) + elide: Text.ElideRight + height: parent.height + source: "../svg/icons/buildplate.svg" + width: height + } + } + + Label + { + id: buildplateLabel + color: "#191919" // TODO: Theme! + font: UM.Theme.getFont("very_small") // 12pt, regular + text: "" + + // FIXED-LINE-HEIGHT: + height: 18 * screenScaleFactor // TODO: Theme! + verticalAlignment: Text.AlignVCenter + } + } +} \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorExtruderConfiguration.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorExtruderConfiguration.qml new file mode 100644 index 0000000000..afbd4c3641 --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorExtruderConfiguration.qml @@ -0,0 +1,76 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 2.0 +import UM 1.3 as UM + +/** + * This component comprises a colored extruder icon, the material name, and the + * print core name. It is used by the MonitorPrinterConfiguration component with + * a sibling instance as well as a MonitorBuildplateConfiguration instance. + * + * NOTE: For most labels, a fixed height with vertical alignment is used to make + * layouts more deterministic (like the fixed-size textboxes used in original + * mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted + * with '// FIXED-LINE-HEIGHT:'. + */ +Item +{ + // The material color + property alias color: extruderIcon.color + + // The extruder position; NOTE: Decent human beings count from 0 + property alias position: extruderIcon.position + + // The material name + property alias material: materialLabel.text + + // The print core name (referred to as hotendID in Python) + property alias printCore: printCoreLabel.text + + // Height is 2 x 18px labels, plus 4px spacing between them + height: 40 * screenScaleFactor // TODO: Theme! + width: childrenRect.width + + MonitorIconExtruder + { + id: extruderIcon + color: "#eeeeee" // TODO: Theme! + position: 0 + } + Label + { + id: materialLabel + anchors + { + left: extruderIcon.right + leftMargin: 12 * screenScaleFactor // TODO: Theme! + } + color: "#191919" // TODO: Theme! + elide: Text.ElideRight + font: UM.Theme.getFont("very_small") // 12pt, regular + text: "" + + // FIXED-LINE-HEIGHT: + height: 18 * screenScaleFactor // TODO: Theme! + verticalAlignment: Text.AlignVCenter + } + Label + { + id: printCoreLabel + anchors + { + left: materialLabel.left + bottom: parent.bottom + } + color: "#191919" // TODO: Theme! + elide: Text.ElideRight + font: UM.Theme.getFont("small") // 12pt, bold + text: "" + + // FIXED-LINE-HEIGHT: + height: 18 * screenScaleFactor // TODO: Theme! + verticalAlignment: Text.AlignVCenter + } +} \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorIconExtruder.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorIconExtruder.qml new file mode 100644 index 0000000000..971c6b2251 --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorIconExtruder.qml @@ -0,0 +1,60 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 2.0 +import UM 1.3 as UM + +/** + * This component is a sort of "super icon" which includes a colored SVG image + * as well as the extruder position number. It is used in the the + * MonitorExtruderConfiguration component. + */ +Item +{ + // The material color + property alias color: icon.color + + // The extruder position; NOTE: Decent human beings count from 0 + property int position: 0 + + // The extruder icon size; NOTE: This shouldn't need to be changed + property int size: 32 // TODO: Theme! + + // THe extruder icon source; NOTE: This shouldn't need to be changed + property string iconSource: "../svg/icons/extruder.svg" + + height: size + width: size + + UM.RecolorImage + { + id: icon + anchors.fill: parent + source: iconSource + width: size + } + + /* + * The label uses some "fancy" math to ensure that if you change the overall + * icon size, the number scales with it. That is to say, the font properties + * are linked to the icon size, NOT the theme. And that's intentional. + */ + Label + { + id: positionLabel + font + { + pointSize: Math.round(size * 0.3125) + weight: Font.Bold + } + height: Math.round(size / 2) * screenScaleFactor + horizontalAlignment: Text.AlignHCenter + text: position + 1 + verticalAlignment: Text.AlignVCenter + width: Math.round(size / 2) * screenScaleFactor + x: Math.round(size * 0.25) * screenScaleFactor + y: Math.round(size * 0.15625) * screenScaleFactor + // TODO: Once 'size' is themed, screenScaleFactor won't be needed + } +} \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml index 307a4f908f..6d02c40776 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml @@ -4,12 +4,21 @@ import QtQuick 2.2 import QtQuick.Controls 2.0 import UM 1.3 as UM -import Cura 1.0 as Cura -// A Print Job Card is essentially just a filled-in Expandable Card item. +/** + * A Print Job Card is essentially just a filled-in Expandable Card item. All + * data within it is derived from being passed a printJob property. + * + * NOTE: For most labels, a fixed height with vertical alignment is used to make + * layouts more deterministic (like the fixed-size textboxes used in original + * mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted + * with '// FIXED-LINE-HEIGHT:'. + */ Item { id: base + + // The print job which all other data is derived from property var printJob: null width: parent.width @@ -19,15 +28,15 @@ Item { headerItem: Row { - height: 48 + height: 48 * screenScaleFactor // TODO: Theme! anchors.left: parent.left - anchors.leftMargin: 24 - spacing: 18 + anchors.leftMargin: 24 * screenScaleFactor // TODO: Theme! + spacing: 18 * screenScaleFactor // TODO: Theme! MonitorPrintJobPreview { printJob: base.printJob - size: 32 + size: 32 * screenScaleFactor // TODO: Theme! anchors.verticalCenter: parent.verticalCenter } @@ -36,10 +45,13 @@ Item text: printJob && printJob.name ? printJob.name : "" color: "#374355" elide: Text.ElideRight - font: UM.Theme.getFont("default_bold") + font: UM.Theme.getFont("medium") // 14pt, regular anchors.verticalCenter: parent.verticalCenter - width: 216 - height: 18 + width: 216 * screenScaleFactor // TODO: Theme! + + // FIXED-LINE-HEIGHT: + height: 18 * screenScaleFactor // TODO: Theme! + verticalAlignment: Text.AlignVCenter } Label @@ -47,18 +59,20 @@ Item text: printJob ? OutputDevice.formatDuration(printJob.timeTotal) : "" color: "#374355" elide: Text.ElideRight - font: UM.Theme.getFont("default_bold") + font: UM.Theme.getFont("medium") // 14pt, regular anchors.verticalCenter: parent.verticalCenter - width: 216 - height: 18 + width: 216 * screenScaleFactor // TODO: Theme! + + // FIXED-LINE-HEIGHT: + height: 18 * screenScaleFactor // TODO: Theme! + verticalAlignment: Text.AlignVCenter } Label { color: "#374355" - height: 18 elide: Text.ElideRight - font: UM.Theme.getFont("default_bold") + font: UM.Theme.getFont("medium") // 14pt, regular text: { if (printJob !== null) { if (printJob.assignedPrinter == null) @@ -78,31 +92,39 @@ Item } visible: printJob anchors.verticalCenter: parent.verticalCenter - width: 216 + width: 216 * screenScaleFactor // TODO: Theme! + + // FIXED-LINE-HEIGHT: + height: 18 * screenScaleFactor // TODO: Theme! + verticalAlignment: Text.AlignVCenter } } drawerItem: Row { - height: 96 - anchors.left: parent.left - anchors.leftMargin: 74 - spacing: 18 + anchors + { + left: parent.left + leftMargin: 74 * screenScaleFactor // TODO: Theme! + } + height: 96 * screenScaleFactor // TODO: Theme! + spacing: 18 * screenScaleFactor // TODO: Theme! - Rectangle + MonitorPrinterConfiguration { id: printerConfiguration - width: 450 - height: 72 - color: "blue" anchors.verticalCenter: parent.verticalCenter + printJob: base.printJob } Label { - height: 18 text: printJob && printJob.owner ? printJob.owner : "" - color: "#374355" + color: "#374355" // TODO: Theme! elide: Text.ElideRight - font: UM.Theme.getFont("default_bold") + font: UM.Theme.getFont("medium") // 14pt, regular anchors.top: printerConfiguration.top + + // FIXED-LINE-HEIGHT: + height: 18 * screenScaleFactor // TODO: Theme! + verticalAlignment: Text.AlignVCenter } } } diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobPreview.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobPreview.qml index 7322193451..1a69d2dc12 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobPreview.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobPreview.qml @@ -2,14 +2,10 @@ // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.2 -import QtQuick.Dialogs 1.1 import QtQuick.Controls 2.0 -import QtQuick.Controls.Styles 1.4 -import QtGraphicalEffects 1.0 -import QtQuick.Layouts 1.1 -import QtQuick.Dialogs 1.1 import UM 1.3 as UM +// TODO: Documentation! Item { id: printJobPreview diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterConfiguration.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterConfiguration.qml new file mode 100644 index 0000000000..5d4d408b8e --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterConfiguration.qml @@ -0,0 +1,56 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 2.0 +import UM 1.3 as UM + +/** + * + */ +Item +{ + id: base + + property var printJob: null + property var config0: printJob ? printJob.configuration.extruderConfigurations[0] : null + property var config1: printJob ? printJob.configuration.extruderConfigurations[1] : null + + height: 72 * screenScaleFactor // TODO: Theme! + width: 450 * screenScaleFactor // TODO: Theme! + + Row + { + spacing: 18 * screenScaleFactor // TODO: Theme! + + MonitorExtruderConfiguration + { + color: config0 ? config0.activeMaterial.color : "#eeeeee" // TODO: Theme! + material: config0 ? config0.activeMaterial.name : "" + position: config0.position + printCore: config0 ? config0.hotendID : "" + visible: config0 + + // Keep things responsive! + width: Math.floor((base.width - parent.spacing) / 2) + } + + MonitorExtruderConfiguration + { + color: config1 ? config1.activeMaterial.color : "#eeeeee" // TODO: Theme! + material: config1 ? config1.activeMaterial.name : "" + position: config1.position + printCore: config1 ? config1.hotendID : "" + visible: config1 + + // Keep things responsive! + width: Math.floor((base.width - parent.spacing) / 2) + } + } + + MonitorBuildplateConfiguration + { + anchors.bottom: parent.bottom + buildplate: "Glass" + } +} \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/resources/svg/icons/buildplate.svg b/plugins/UM3NetworkPrinting/resources/svg/icons/buildplate.svg new file mode 100644 index 0000000000..bcb278a8ca --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/svg/icons/buildplate.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/resources/svg/icons/extruder.svg b/plugins/UM3NetworkPrinting/resources/svg/icons/extruder.svg new file mode 100644 index 0000000000..235cb432e9 --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/svg/icons/extruder.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From 895590c3d0a445d4e114766348cdc5de676442e5 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Tue, 20 Nov 2018 14:28:54 +0100 Subject: [PATCH 18/43] Change the size of the progress bar control. Also add the rounded rectangle. Contributes to the new Cura UI-Flow. --- resources/themes/cura-light/styles.qml | 1 + resources/themes/cura-light/theme.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/themes/cura-light/styles.qml b/resources/themes/cura-light/styles.qml index 6f099bf1c5..58035ae3bd 100755 --- a/resources/themes/cura-light/styles.qml +++ b/resources/themes/cura-light/styles.qml @@ -515,6 +515,7 @@ QtObject implicitWidth: Theme.getSize("message").width - (Theme.getSize("default_margin").width * 2) implicitHeight: Theme.getSize("progressbar").height color: control.hasOwnProperty("backgroundColor") ? control.backgroundColor : Theme.getColor("progressbar_background") + radius: Theme.getSize("progressbar_radius").width } progress: Rectangle { diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index a33ff87042..f4d50e4c79 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -448,7 +448,7 @@ "progressbar": [26.0, 0.75], "progressbar_radius": [0.15, 0.15], - "progressbar_control": [8.0, 0.4], + "progressbar_control": [8.0, 0.75], "scrollbar": [0.75, 0.5], From 3b4d728d6a134237c708b0093bc6925122859056 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 20 Nov 2018 14:35:13 +0100 Subject: [PATCH 19/43] Fix Simulation view popup not sizing down I have no idea why implictHeight does work and childrenRect.height doesn't (eg; childrenRect.height only scales up for some reason, never down) CURA-5785 --- plugins/SimulationView/SimulationViewMenuComponent.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/SimulationView/SimulationViewMenuComponent.qml b/plugins/SimulationView/SimulationViewMenuComponent.qml index 89615f43a4..caf47508e3 100644 --- a/plugins/SimulationView/SimulationViewMenuComponent.qml +++ b/plugins/SimulationView/SimulationViewMenuComponent.qml @@ -65,7 +65,7 @@ Cura.ExpandableComponent property int top_layer_count: UM.Preferences.getValue("view/top_layer_count") width: UM.Theme.getSize("layerview_menu_size").width - 2 * UM.Theme.getSize("default_margin").width - height: childrenRect.height + height: implicitHeight spacing: UM.Theme.getSize("layerview_row_spacing").height From 2f84339f5cb51be69098c0a9c6e33cc535f508ad Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Tue, 20 Nov 2018 15:58:09 +0100 Subject: [PATCH 20/43] Finalize queue Contributes to CL-1148 --- .../resources/qml/ClusterMonitorItem.qml | 269 ++++++++++++------ .../resources/qml/ExpandableCard.qml | 1 + .../qml/MonitorBuildplateConfiguration.qml | 2 +- .../resources/qml/MonitorPrintJobCard.qml | 108 +++++-- .../qml/MonitorPrinterConfiguration.qml | 30 +- .../resources/qml/MonitorPrinterPill.qml | 34 +++ .../resources/svg/icons/external_link.svg | 8 + 7 files changed, 327 insertions(+), 125 deletions(-) create mode 100644 plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterPill.qml create mode 100644 plugins/UM3NetworkPrinting/resources/svg/icons/external_link.svg diff --git a/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml index ff4bc72218..d055071521 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml @@ -8,102 +8,203 @@ import UM 1.3 as UM import Cura 1.0 as Cura import QtGraphicalEffects 1.0 -Component { - - Rectangle { - id: monitorFrame; - property var emphasisColor: UM.Theme.getColor("setting_control_border_highlight"); - property var cornerRadius: UM.Theme.getSize("monitor_corner_radius").width; +Component +{ + Rectangle + { + id: monitorFrame + + property var emphasisColor: UM.Theme.getColor("setting_control_border_highlight") + property var cornerRadius: UM.Theme.getSize("monitor_corner_radius").width + color: transparent - height: maximumHeight; - onVisibleChanged: { - if (monitorFrame != null && !monitorFrame.visible) { - OutputDevice.setActiveCameraUrl(""); + height: maximumHeight + onVisibleChanged: + { + if (monitorFrame != null && !monitorFrame.visible) + { + OutputDevice.setActiveCameraUrl("") } } - width: maximumWidth; + width: maximumWidth + + UM.I18nCatalog + { + id: catalog + name: "cura" + } LinearGradient { anchors.fill: parent gradient: Gradient { - GradientStop { position: 0.0; color: "#f6f6f6" } - GradientStop { position: 1.0; color: "#ffffff" } - } - } - - UM.I18nCatalog { - id: catalog; - name: "cura"; - } - - Label { - id: manageQueueLabel; - anchors { - bottom: queuedLabel.bottom; - right: queuedPrintJobs.right; - rightMargin: 3 * UM.Theme.getSize("default_margin").width; - } - color: UM.Theme.getColor("primary"); - font: UM.Theme.getFont("default"); - linkColor: UM.Theme.getColor("primary"); - text: catalog.i18nc("@label link to connect manager", "Manage queue"); - } - - MouseArea { - anchors.fill: manageQueueLabel; - hoverEnabled: true; - onClicked: Cura.MachineManager.printerOutputDevices[0].openPrintJobControlPanel(); - onEntered: manageQueueLabel.font.underline = true; - onExited: manageQueueLabel.font.underline = false; - } - - Label { - id: queuedLabel; - anchors { - left: queuedPrintJobs.left; - leftMargin: 3 * UM.Theme.getSize("default_margin").width + 5 * screenScaleFactor; - top: parent.top; - topMargin: 2 * UM.Theme.getSize("default_margin").height; - } - color: UM.Theme.getColor("text"); - font: UM.Theme.getFont("large"); - text: catalog.i18nc("@label", "Queued"); - } - - ScrollView { - id: queuedPrintJobs; - anchors { - top: queuedLabel.bottom; - topMargin: UM.Theme.getSize("default_margin").height; - horizontalCenter: parent.horizontalCenter; - bottomMargin: UM.Theme.getSize("default_margin").height; - bottom: parent.bottom; - } - style: UM.Theme.styles.scrollview; - visible: OutputDevice.receivedPrintJobs; - width: Math.min(834 * screenScaleFactor, maximumWidth); - - ListView { - id: printJobList; - anchors.fill: parent; - delegate: MonitorPrintJobCard { - anchors { - left: parent.left; - leftMargin: UM.Theme.getSize("default_margin").width; - right: parent.right; - rightMargin: UM.Theme.getSize("default_margin").width; - } - printJob: modelData; + GradientStop { + position: 0.0 + color: "#f6f6f6" + } + GradientStop { + position: 1.0 + color: "#ffffff" + } + } + } + + Item + { + id: queue + + anchors.fill: parent + anchors.top: parent.top + anchors.topMargin: 400 * screenScaleFactor // TODO: Insert carousel here + + Label + { + id: queuedLabel + anchors + { + left: queuedPrintJobs.left + top: parent.top + } + color: UM.Theme.getColor("text") + font: UM.Theme.getFont("large_nonbold") + text: catalog.i18nc("@label", "Queued") + } + + Item + { + id: manageQueueLabel + anchors + { + right: queuedPrintJobs.right + verticalCenter: queuedLabel.verticalCenter + } + height: 18 * screenScaleFactor // TODO: Theme! + width: childrenRect.width + + UM.RecolorImage + { + id: externalLinkIcon + anchors.verticalCenter: externalLinkIcon.verticalCenter + color: UM.Theme.getColor("primary") + source: "../svg/icons/external_link.svg" + width: 16 * screenScaleFactor // TODO: Theme! (Y U NO USE 18 LIKE ALL OTHER ICONS?!) + height: 16 * screenScaleFactor // TODO: Theme! (Y U NO USE 18 LIKE ALL OTHER ICONS?!) + } + Label + { + anchors + { + left: externalLinkIcon.right + leftMargin: 6 * screenScaleFactor // TODO: Theme! + verticalCenter: externalLinkIcon.verticalCenter + } + color: UM.Theme.getColor("primary") + font: UM.Theme.getFont("default") + linkColor: UM.Theme.getColor("primary") + text: catalog.i18nc("@label link to connect manager", "Manage queue in Cura Connect") + } + } + + + MouseArea + { + anchors.fill: manageQueueLabel + hoverEnabled: true + onClicked: Cura.MachineManager.printerOutputDevices[0].openPrintJobControlPanel() + onEntered: manageQueueLabel.font.underline = true + onExited: manageQueueLabel.font.underline = false + } + + Row + { + id: printJobQueueHeadings + anchors + { + left: queuedPrintJobs.left + leftMargin: 6 * screenScaleFactor // TODO: Theme! + top: queuedLabel.bottom + topMargin: 24 * screenScaleFactor // TODO: Theme! + } + spacing: 18 * screenScaleFactor // TODO: Theme! + + Label + { + text: catalog.i18nc("@label", "Print jobs") + color: "#666666" + elide: Text.ElideRight + font: UM.Theme.getFont("medium") // 14pt, regular + anchors.verticalCenter: parent.verticalCenter + width: 284 * screenScaleFactor // TODO: Theme! (Should match column size) + + // FIXED-LINE-HEIGHT: + height: 18 * screenScaleFactor // TODO: Theme! + verticalAlignment: Text.AlignVCenter + } + + Label + { + text: catalog.i18nc("@label", "Total print time") + color: "#666666" + elide: Text.ElideRight + font: UM.Theme.getFont("medium") // 14pt, regular + anchors.verticalCenter: parent.verticalCenter + width: 216 * screenScaleFactor // TODO: Theme! (Should match column size) + + // FIXED-LINE-HEIGHT: + height: 18 * screenScaleFactor // TODO: Theme! + verticalAlignment: Text.AlignVCenter + } + + Label + { + text: catalog.i18nc("@label", "Waiting for") + color: "#666666" + elide: Text.ElideRight + font: UM.Theme.getFont("medium") // 14pt, regular + anchors.verticalCenter: parent.verticalCenter + width: 216 * screenScaleFactor // TODO: Theme! (Should match column size) + + // FIXED-LINE-HEIGHT: + height: 18 * screenScaleFactor // TODO: Theme! + verticalAlignment: Text.AlignVCenter + } + } + + ScrollView + { + id: queuedPrintJobs + anchors { + bottom: parent.bottom + horizontalCenter: parent.horizontalCenter + top: printJobQueueHeadings.bottom + topMargin: 12 * screenScaleFactor // TODO: Theme! + } + style: UM.Theme.styles.scrollview + visible: OutputDevice.receivedPrintJobs + width: Math.min(834 * screenScaleFactor, maximumWidth) + + ListView + { + id: printJobList + anchors.fill: parent + delegate: MonitorPrintJobCard + { + anchors + { + left: parent.left + right: parent.right + } + printJob: modelData + } + model: OutputDevice.queuedPrintJobs + spacing: 6 } - model: OutputDevice.queuedPrintJobs; - spacing: 6; } } PrinterVideoStream { - anchors.fill: parent; - cameraUrl: OutputDevice.activeCameraUrl; - visible: OutputDevice.activeCameraUrl != ""; + anchors.fill: parent + cameraUrl: OutputDevice.activeCameraUrl + visible: OutputDevice.activeCameraUrl != "" } } diff --git a/plugins/UM3NetworkPrinting/resources/qml/ExpandableCard.qml b/plugins/UM3NetworkPrinting/resources/qml/ExpandableCard.qml index 89d88d671a..4922aea853 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/ExpandableCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/ExpandableCard.qml @@ -6,6 +6,7 @@ import QtQuick.Controls 2.0 import UM 1.3 as UM import Cura 1.0 as Cura +// TODO: Theme & documentation! // The expandable component has 3 major sub components: // * The headerItem Always visible and should hold some info about what happens if the component is expanded // * The popupItem The content that needs to be shown if the component is expanded. diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml index d14277a1ff..9ffb1eabb4 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml @@ -41,7 +41,6 @@ Item id: buildplateIcon anchors.centerIn: parent color: "#0a0850" // TODO: Theme! (Standard purple) - elide: Text.ElideRight height: parent.height source: "../svg/icons/buildplate.svg" width: height @@ -52,6 +51,7 @@ Item { id: buildplateLabel color: "#191919" // TODO: Theme! + elide: Text.ElideRight font: UM.Theme.getFont("very_small") // 12pt, regular text: "" diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml index 6d02c40776..ada6f8a644 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml @@ -47,7 +47,7 @@ Item elide: Text.ElideRight font: UM.Theme.getFont("medium") // 14pt, regular anchors.verticalCenter: parent.verticalCenter - width: 216 * screenScaleFactor // TODO: Theme! + width: 216 * screenScaleFactor // TODO: Theme! (Should match column size) // FIXED-LINE-HEIGHT: height: 18 * screenScaleFactor // TODO: Theme! @@ -61,42 +61,72 @@ Item elide: Text.ElideRight font: UM.Theme.getFont("medium") // 14pt, regular anchors.verticalCenter: parent.verticalCenter - width: 216 * screenScaleFactor // TODO: Theme! + width: 216 * screenScaleFactor // TODO: Theme! (Should match column size) // FIXED-LINE-HEIGHT: height: 18 * screenScaleFactor // TODO: Theme! verticalAlignment: Text.AlignVCenter } - Label + Item { - color: "#374355" - elide: Text.ElideRight - font: UM.Theme.getFont("medium") // 14pt, regular - text: { - if (printJob !== null) { - if (printJob.assignedPrinter == null) - { - if (printJob.state == "error") - { - return catalog.i18nc("@label", "Waiting for: Unavailable printer") - } - return catalog.i18nc("@label", "Waiting for: First available") - } - else - { - return catalog.i18nc("@label", "Waiting for: ") + printJob.assignedPrinter.name - } - } - return "" - } - visible: printJob anchors.verticalCenter: parent.verticalCenter - width: 216 * screenScaleFactor // TODO: Theme! + height: childrenRect.height + width: childrenRect.width - // FIXED-LINE-HEIGHT: - height: 18 * screenScaleFactor // TODO: Theme! - verticalAlignment: Text.AlignVCenter + Label + { + id: printerAssignmentLabel + anchors.verticalCenter: parent.verticalCenter + color: "#374355" + elide: Text.ElideRight + font: UM.Theme.getFont("medium") // 14pt, regular + text: { + if (printJob !== null) { + if (printJob.assignedPrinter == null) + { + if (printJob.state == "error") + { + return catalog.i18nc("@label", "Unavailable printer") + } + return catalog.i18nc("@label", "First available") + } + else + { + return printJob.assignedPrinter.name + } + } + return "" + } + visible: printJob + + // FIXED-LINE-HEIGHT: + height: 18 * screenScaleFactor // TODO: Theme! + verticalAlignment: Text.AlignVCenter + } + + Row + { + id: printerFamilyPills + anchors + { + left: printerAssignmentLabel.right; + leftMargin: 12 // TODO: Theme! + verticalCenter: parent.verticalCenter + } + height: childrenRect.height + spacing: 6 // TODO: Theme! + + Repeater + { + id: compatiblePills + delegate: MonitorPrinterPill + { + text: modelData + } + model: printJob ? printJob.compatibleMachineFamilies : [] + } + } } } drawerItem: Row @@ -106,14 +136,17 @@ Item left: parent.left leftMargin: 74 * screenScaleFactor // TODO: Theme! } - height: 96 * screenScaleFactor // TODO: Theme! + height: 108 * screenScaleFactor // TODO: Theme! spacing: 18 * screenScaleFactor // TODO: Theme! MonitorPrinterConfiguration { id: printerConfiguration anchors.verticalCenter: parent.verticalCenter - printJob: base.printJob + buildplate: "Glass" + config0: base.printJob.configuration.extruderConfigurations[0] + config1: base.printJob.configuration.extruderConfigurations[1] + height: 72 * screenScaleFactor // TODO: Theme! } Label { text: printJob && printJob.owner ? printJob.owner : "" @@ -128,4 +161,19 @@ Item } } } + + PrintJobContextMenu + { + id: contextButton + anchors + { + right: parent.right; + rightMargin: 8 * screenScaleFactor // TODO: Theme! + top: parent.top + topMargin: 8 * screenScaleFactor // TODO: Theme! + } + printJob: base.printJob + width: 32 * screenScaleFactor // TODO: Theme! + height: 32 * screenScaleFactor // TODO: Theme! + } } \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterConfiguration.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterConfiguration.qml index 5d4d408b8e..a31c8bbd99 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterConfiguration.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterConfiguration.qml @@ -6,17 +6,26 @@ import QtQuick.Controls 2.0 import UM 1.3 as UM /** - * + * The MonitorPrinterConfiguration accepts 2 configuration objects as input and + * applies them to a MonitorBuildplateConfiguration instance and two instances + * of MonitorExtruderConfiguration. It's used in both the MonitorPrintJobCard + * component as well as the MonitorPrinterCard component. */ Item { id: base - property var printJob: null - property var config0: printJob ? printJob.configuration.extruderConfigurations[0] : null - property var config1: printJob ? printJob.configuration.extruderConfigurations[1] : null + // Extracted buildplate configuration + property alias buildplate: buildplateConfig.buildplate - height: 72 * screenScaleFactor // TODO: Theme! + // Extracted extruder configuration for position 0 + property var config0: null + + // Extracted extruder configuration for position 1 + property var config1: null + + // Default size, but should be stretched to fill parent + height: 72 * parent.height width: 450 * screenScaleFactor // TODO: Theme! Row @@ -25,8 +34,8 @@ Item MonitorExtruderConfiguration { - color: config0 ? config0.activeMaterial.color : "#eeeeee" // TODO: Theme! - material: config0 ? config0.activeMaterial.name : "" + color: config0 && config0.activeMaterial ? config0.activeMaterial.color : "#eeeeee" // TODO: Theme! + material: config0 && config0.activeMaterial ? config0.activeMaterial.name : "" position: config0.position printCore: config0 ? config0.hotendID : "" visible: config0 @@ -37,8 +46,8 @@ Item MonitorExtruderConfiguration { - color: config1 ? config1.activeMaterial.color : "#eeeeee" // TODO: Theme! - material: config1 ? config1.activeMaterial.name : "" + color: config1 && config1.activeMaterial ? config1.activeMaterial.color : "#eeeeee" // TODO: Theme! + material: config1 && config1.activeMaterial ? config1.activeMaterial.name : "" position: config1.position printCore: config1 ? config1.hotendID : "" visible: config1 @@ -50,7 +59,8 @@ Item MonitorBuildplateConfiguration { + id: buildplateConfig anchors.bottom: parent.bottom - buildplate: "Glass" + buildplate: "Glass" // 'Glass' as a default } } \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterPill.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterPill.qml new file mode 100644 index 0000000000..cd78f1b11f --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterPill.qml @@ -0,0 +1,34 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 1.4 +import UM 1.2 as UM + +/** + * A MonitorPrinterPill is a blue-colored tag indicating which printers a print + * job is compatible with. It is used by the MonitorPrintJobCard component. + */ +Item +{ + // The printer name + property alias text: printerNameLabel.text; + + implicitHeight: 18 * screenScaleFactor // TODO: Theme! + implicitWidth: printerNameLabel.contentWidth + 12 // TODO: Theme! + + Rectangle { + id: background + anchors.fill: parent + color: "#e4e4f2" // TODO: Theme! + radius: 2 * screenScaleFactor // TODO: Theme! + } + + Label { + id: printerNameLabel + anchors.centerIn: parent + color: "#535369" // TODO: Theme! + text: "" + font.pointSize: 10 + } +} \ No newline at end of file diff --git a/plugins/UM3NetworkPrinting/resources/svg/icons/external_link.svg b/plugins/UM3NetworkPrinting/resources/svg/icons/external_link.svg new file mode 100644 index 0000000000..a2130fb97b --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/svg/icons/external_link.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file From 669648d3e11a969ec75b83c5d5b763cef9705f71 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Tue, 20 Nov 2018 16:28:21 +0100 Subject: [PATCH 21/43] Improve the toolbar style by modifying the rectangles and the behavior to get a rounded rectangle on the right-top and right-bottom. Contributes to CURA-5962. --- resources/qml/ExtruderButton.qml | 16 ++---- resources/qml/Toolbar.qml | 36 ++++++++---- resources/themes/cura-light/styles.qml | 80 ++++++++++++++++++++------ resources/themes/cura-light/theme.json | 6 +- 4 files changed, 92 insertions(+), 46 deletions(-) diff --git a/resources/qml/ExtruderButton.qml b/resources/qml/ExtruderButton.qml index 7923521658..cdd0386d30 100644 --- a/resources/qml/ExtruderButton.qml +++ b/resources/qml/ExtruderButton.qml @@ -21,6 +21,9 @@ Button checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1 enabled: UM.Selection.hasSelection && extruder.stack.isEnabled + property bool isFirstElement: extrudersModel.getItem(0).name == model.name + property bool isLastElement: extrudersModel.getItem(extrudersModel.rowCount() - 1).name == model.name + Item { anchors.centerIn: parent @@ -32,18 +35,7 @@ Button { anchors.centerIn: parent text: index + 1 - color: - { - if (base.checked) - { - return UM.Theme.getColor("toolbar_button_text_active") - } - else if(base.hovered) - { - return UM.Theme.getColor("toolbar_button_text_hover") - } - return UM.Theme.getColor("toolbar_button_text") - } + color: UM.Theme.getColor("toolbar_button_text") font: UM.Theme.getFont("default_bold") } } diff --git a/resources/qml/Toolbar.qml b/resources/qml/Toolbar.qml index 9955ceeba7..81896f1a75 100644 --- a/resources/qml/Toolbar.qml +++ b/resources/qml/Toolbar.qml @@ -28,12 +28,16 @@ Item // Used to create a rounded rectangle behind the toolButtons Rectangle { - anchors.fill: toolButtons - anchors.leftMargin: -radius + anchors + { + fill: toolButtons + leftMargin: -radius - border.width + rightMargin: -border.width + topMargin: -border.width + bottomMargin: -border.width + } radius: UM.Theme.getSize("default_radius").width - border.width: UM.Theme.getSize("default_lining").width - border.color: UM.Theme.getColor("lining") - color: UM.Theme.getColor("toolbar_background") + color: UM.Theme.getColor("lining") } Column @@ -42,13 +46,13 @@ Item anchors.top: parent.top anchors.right: parent.right - spacing: UM.Theme.getSize("button_lining").width + spacing: UM.Theme.getSize("default_lining").height Repeater { id: repeat - model: UM.ToolModel { } + model: UM.ToolModel { id: toolsModel } width: childrenRect.width height: childrenRect.height Button @@ -60,6 +64,9 @@ Item enabled: model.enabled && UM.Selection.hasSelection && UM.Controller.toolsEnabled style: UM.Theme.styles.toolbar_button + property bool isFirstElement: toolsModel.getItem(0).id == model.id + property bool isLastElement: toolsModel.getItem(toolsModel.rowCount() - 1).id == model.id + onCheckedChanged: { if (checked) @@ -93,12 +100,16 @@ Item // Used to create a rounded rectangle behind the extruderButtons Rectangle { - anchors.fill: extruderButtons - anchors.leftMargin: -radius + anchors + { + fill: extruderButtons + leftMargin: -radius - border.width + rightMargin: -border.width + topMargin: -border.width + bottomMargin: -border.width + } radius: UM.Theme.getSize("default_radius").width - border.width: UM.Theme.getSize("default_lining").width - border.color: UM.Theme.getColor("lining") - color: UM.Theme.getColor("toolbar_background") + color: UM.Theme.getColor("lining") } Column @@ -108,6 +119,7 @@ Item anchors.topMargin: UM.Theme.getSize("default_margin").height anchors.top: toolButtons.bottom anchors.right: parent.right + spacing: UM.Theme.getSize("default_lining").height Repeater { diff --git a/resources/themes/cura-light/styles.qml b/resources/themes/cura-light/styles.qml index 58035ae3bd..723b393efa 100755 --- a/resources/themes/cura-light/styles.qml +++ b/resources/themes/cura-light/styles.qml @@ -175,11 +175,68 @@ QtObject { ButtonStyle { - background: Item + background: Rectangle { - implicitWidth: Theme.getSize("button").width; - implicitHeight: Theme.getSize("button").height; + implicitWidth: Theme.getSize("button").width + implicitHeight: Theme.getSize("button").height + color: + { + if (control.checked && control.hovered) + { + return Theme.getColor("toolbar_button_active_hover") + } + else if (control.checked) + { + return Theme.getColor("toolbar_button_active") + } + else if(control.hovered) + { + return Theme.getColor("toolbar_button_hover") + } + return Theme.getColor("toolbar_background") + } + radius: UM.Theme.getSize("default_radius").width + Rectangle + { + id: topSquare + anchors + { + left: parent.left + right: parent.right + top: parent.top + } + height: parent.radius + color: control.isFirstElement ? "transparent" : parent.color + } + + Rectangle + { + id: bottomSquare + anchors + { + left: parent.left + right: parent.right + bottom: parent.bottom + } + height: parent.radius + color: control.isLastElement ? "transparent" : parent.color + } + + Rectangle + { + id: leftSquare + anchors + { + left: parent.left + top: parent.top + bottom: parent.bottom + } + width: parent.radius + color: parent.color + } + + // This is the tooltip UM.PointingRectangle { id: button_tooltip @@ -223,22 +280,7 @@ QtObject source: control.iconSource; width: Theme.getSize("button_icon").width; height: Theme.getSize("button_icon").height; - color: - { - if (control.checked && control.hovered) - { - return Theme.getColor("toolbar_button_text_active_hover"); - } - else if (control.checked) - { - return Theme.getColor("toolbar_button_text_active"); - } - else if(control.hovered) - { - return Theme.getColor("toolbar_button_text_hover"); - } - return Theme.getColor("toolbar_button_text"); - } + color: Theme.getColor("toolbar_button_text"); sourceSize: Theme.getSize("button_icon") } diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index f4d50e4c79..d00e998cc8 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -123,9 +123,9 @@ "warning": [255, 190, 35, 255], "toolbar_button_text": [10, 8, 80, 255], - "toolbar_button_text_hover": [50, 130, 255, 255], - "toolbar_button_text_active": [50, 130, 255, 255], - "toolbar_button_text_active_hover": [50, 130, 255, 255], + "toolbar_button_hover": [232, 242, 252, 255], + "toolbar_button_active": [232, 242, 252, 255], + "toolbar_button_active_hover": [232, 242, 252, 255], "button": [31, 36, 39, 255], "button_hover": [68, 72, 75, 255], From 4e8979334e0d794b2cd8cae72ce9c351890577c8 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Tue, 20 Nov 2018 19:18:48 +0100 Subject: [PATCH 22/43] Switch Ultimaker Account OAuth2 client The new client has access to more permissions and is labeled as "Ultimaker Cura" instead of "Cura Backups Plugin". Also removes `self._cloud_api_root` as that's not used anymore now that `self._oauth_root` is used for the redirect URLs. --- cura/API/Account.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cura/API/Account.py b/cura/API/Account.py index 397e220478..64d63c7025 100644 --- a/cura/API/Account.py +++ b/cura/API/Account.py @@ -38,13 +38,12 @@ class Account(QObject): self._callback_port = 32118 self._oauth_root = "https://account.ultimaker.com" - self._cloud_api_root = "https://api.ultimaker.com" self._oauth_settings = OAuth2Settings( OAUTH_SERVER_URL= self._oauth_root, CALLBACK_PORT=self._callback_port, CALLBACK_URL="http://localhost:{}/callback".format(self._callback_port), - CLIENT_ID="um---------------ultimaker_cura_drive_plugin", + CLIENT_ID="um----------------------------ultimaker_cura", CLIENT_SCOPES="account.user.read drive.backup.read drive.backup.write packages.download packages.rating.read packages.rating.write", AUTH_DATA_PREFERENCE_KEY="general/ultimaker_auth_data", AUTH_SUCCESS_REDIRECT="{}/app/auth-success".format(self._oauth_root), From 8b085aa877194c45a3122ccbafa5460d57f9e28d Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Tue, 20 Nov 2018 23:47:25 +0100 Subject: [PATCH 23/43] Revert "Switch Ultimaker Account OAuth2 client" This reverts commit 4e8979334e0d794b2cd8cae72ce9c351890577c8. --- cura/API/Account.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cura/API/Account.py b/cura/API/Account.py index 64d63c7025..397e220478 100644 --- a/cura/API/Account.py +++ b/cura/API/Account.py @@ -38,12 +38,13 @@ class Account(QObject): self._callback_port = 32118 self._oauth_root = "https://account.ultimaker.com" + self._cloud_api_root = "https://api.ultimaker.com" self._oauth_settings = OAuth2Settings( OAUTH_SERVER_URL= self._oauth_root, CALLBACK_PORT=self._callback_port, CALLBACK_URL="http://localhost:{}/callback".format(self._callback_port), - CLIENT_ID="um----------------------------ultimaker_cura", + CLIENT_ID="um---------------ultimaker_cura_drive_plugin", CLIENT_SCOPES="account.user.read drive.backup.read drive.backup.write packages.download packages.rating.read packages.rating.write", AUTH_DATA_PREFERENCE_KEY="general/ultimaker_auth_data", AUTH_SUCCESS_REDIRECT="{}/app/auth-success".format(self._oauth_root), From 791929d6897942e971a112a26839c0fa6f94f847 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Tue, 20 Nov 2018 23:47:46 +0100 Subject: [PATCH 24/43] Revert "Merge branch 'fix-oauth2-client' into CURA-5785-Restyle_stage_menu" This reverts commit 4caf770a62f07b71a646b7f09a08623485b89582, reversing changes made to 0cdcd61ff2dfe2677e636cc2f1ee993cbd9d641d. --- resources/qml/Dialogs/AddMachineDialog.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Dialogs/AddMachineDialog.qml b/resources/qml/Dialogs/AddMachineDialog.qml index aa160acd4d..0df8b891d9 100644 --- a/resources/qml/Dialogs/AddMachineDialog.qml +++ b/resources/qml/Dialogs/AddMachineDialog.qml @@ -73,7 +73,7 @@ UM.Dialog { top: parent.top left: parent.left - topMargin: UM.Theme.getSize("default_margin").height + topMargin: UM.Theme.getSize("default_margin") } text: catalog.i18nc("@title:tab", "Add a printer to Cura") From 60ed0ddc2493f357417922529f25ce242d8daba7 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Tue, 20 Nov 2018 23:49:33 +0100 Subject: [PATCH 25/43] Revert "Revert "Merge branch 'fix-oauth2-client' into CURA-5785-Restyle_stage_menu"" This reverts commit 791929d6897942e971a112a26839c0fa6f94f847. --- resources/qml/Dialogs/AddMachineDialog.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Dialogs/AddMachineDialog.qml b/resources/qml/Dialogs/AddMachineDialog.qml index 0df8b891d9..aa160acd4d 100644 --- a/resources/qml/Dialogs/AddMachineDialog.qml +++ b/resources/qml/Dialogs/AddMachineDialog.qml @@ -73,7 +73,7 @@ UM.Dialog { top: parent.top left: parent.left - topMargin: UM.Theme.getSize("default_margin") + topMargin: UM.Theme.getSize("default_margin").height } text: catalog.i18nc("@title:tab", "Add a printer to Cura") From d74393498b18805de9453e05bded2e9c09a3d928 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 21 Nov 2018 09:35:35 +0100 Subject: [PATCH 26/43] Fixed view selector header not updating correctly CURA-5785 --- plugins/PreviewStage/PreviewMenu.qml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/plugins/PreviewStage/PreviewMenu.qml b/plugins/PreviewStage/PreviewMenu.qml index 1a744aeb65..fa1b6aae0f 100644 --- a/plugins/PreviewStage/PreviewMenu.qml +++ b/plugins/PreviewStage/PreviewMenu.qml @@ -54,22 +54,27 @@ Item { for (var i = 0; i < viewModel.rowCount(); i++) { - if (viewModel.getItem(i).active) + if (viewModel.items[i].active) { - return viewModel.getItem(i) + return viewModel.items[i] } } - // Nothing was active, so just return the first one (the list is sorted by priority, so the most - // important one should be returned) - return viewModel.getItem(0) + return null } - // Ensure that the controller is synced with whatever happend here. - onActiveViewChanged: UM.Controller.setActiveView(activeView.id) + Component.onCompleted: + { + // Nothing was active, so just return the first one (the list is sorted by priority, so the most + // important one should be returned) + if(activeView == null) + { + UM.Controller.setActiveView(viewModel.getItem(0).id) + } + } headerItem: Label { - text: viewSelector.activeView.name + text: viewSelector.activeView ? viewSelector.activeView.name : "" verticalAlignment: Text.AlignVCenter height: parent.height elide: Text.ElideRight @@ -98,7 +103,7 @@ Item text: name radius: UM.Theme.getSize("default_radius").width checkable: true - checked: active + checked: viewSelector.activeView != null ? viewSelector.activeView.id == id : false onClicked: { viewSelector.togglePopup() From b826a420265051cefd6483eb228e3716182b1380 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 21 Nov 2018 11:37:58 +0100 Subject: [PATCH 27/43] Add the RoundedRectangle as background to the ExpandableComponent This way the expandable components can have rounded corners only on one side, thus preventing the need to do add backgrounds to the rows that they are in. CURA-5785 --- plugins/PrepareStage/PrepareMenu.qml | 99 ++++++------- plugins/PreviewStage/PreviewMenu.qml | 191 ++++++++++++-------------- resources/qml/Cura.qml | 1 + resources/qml/ExpandableComponent.qml | 9 +- resources/qml/RoundedRectangle.qml | 39 ++++++ 5 files changed, 181 insertions(+), 158 deletions(-) create mode 100644 resources/qml/RoundedRectangle.qml diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index ef01625a22..22f93aa5f2 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -24,77 +24,66 @@ Item Item { anchors.horizontalCenter: parent.horizontalCenter - width: openFileButtonBackground.width + itemRowBackground.width + width: openFileButtonBackground.width + itemRow.width + UM.Theme.getSize("default_margin").width height: parent.height - Rectangle + RowLayout { - id: itemRowBackground - radius: UM.Theme.getSize("default_radius").width - - color: UM.Theme.getColor("toolbar_background") - - width: itemRow.width + UM.Theme.getSize("default_margin").width - height: parent.height + id: itemRow anchors.left: openFileButtonBackground.right anchors.leftMargin: UM.Theme.getSize("default_margin").width - RowLayout + width: 0.9 * prepareMenu.width + height: parent.height + spacing: 0 + + Cura.MachineSelector { - id: itemRow + id: machineSelection + z: openFileButtonBackground.z - 1 //Ensure that the tooltip of the open file button stays above the item row. + headerCornerSide: 2 // Show corners on the left. + Layout.minimumWidth: UM.Theme.getSize("machine_selector_widget").width + Layout.maximumWidth: UM.Theme.getSize("machine_selector_widget").width + Layout.fillWidth: true + Layout.fillHeight: true + } - anchors.centerIn: parent - - width: 0.9 * prepareMenu.width + // Separator line + Rectangle + { height: parent.height - spacing: 0 + width: UM.Theme.getSize("default_lining").width + color: UM.Theme.getColor("lining") + } - Cura.MachineSelector - { - id: machineSelection - z: openFileButtonBackground.z - 1 //Ensure that the tooltip of the open file button stays above the item row. - Layout.minimumWidth: UM.Theme.getSize("machine_selector_widget").width - Layout.maximumWidth: UM.Theme.getSize("machine_selector_widget").width - Layout.fillWidth: true - Layout.fillHeight: true - } + Cura.QuickConfigurationSelector + { + Layout.fillHeight: true + Layout.fillWidth: true + Layout.preferredWidth: itemRow.width - machineSelection.width - printSetupSelectorItem.width - 2 * UM.Theme.getSize("default_lining").width + } - // Separator line - Rectangle - { - height: parent.height - width: UM.Theme.getSize("default_lining").width - color: UM.Theme.getColor("lining") - } + // Separator line + Rectangle + { + height: parent.height + width: UM.Theme.getSize("default_lining").width + color: UM.Theme.getColor("lining") + } - Cura.QuickConfigurationSelector - { - Layout.fillHeight: true - Layout.fillWidth: true - Layout.preferredWidth: itemRow.width - machineSelection.width - printSetupSelectorItem.width - 2 * UM.Theme.getSize("default_lining").width - } - - // Separator line - Rectangle - { - height: parent.height - width: UM.Theme.getSize("default_lining").width - color: UM.Theme.getColor("lining") - } - - Item - { - id: printSetupSelectorItem - // This is a work around to prevent the printSetupSelector from having to be re-loaded every time - // a stage switch is done. - children: [printSetupSelector] - height: childrenRect.height - width: childrenRect.width - } + Item + { + id: printSetupSelectorItem + // This is a work around to prevent the printSetupSelector from having to be re-loaded every time + // a stage switch is done. + children: [printSetupSelector] + height: childrenRect.height + width: childrenRect.width } } + Rectangle { id: openFileButtonBackground diff --git a/plugins/PreviewStage/PreviewMenu.qml b/plugins/PreviewStage/PreviewMenu.qml index fa1b6aae0f..d6033d6272 100644 --- a/plugins/PreviewStage/PreviewMenu.qml +++ b/plugins/PreviewStage/PreviewMenu.qml @@ -22,135 +22,122 @@ Item name: "cura" } - Rectangle - { - anchors.fill: stageMenu - anchors.leftMargin: -radius - radius: UM.Theme.getSize("default_radius").width - color: UM.Theme.getColor("toolbar_background") - } - Item + Row { - id: stageMenu + id: stageMenuRow + anchors.centerIn: parent height: parent.height - width: stageMenuRow.width + UM.Theme.getSize("default_margin").width - anchors.horizontalCenter: parent.horizontalCenter - Row + + Cura.ExpandableComponent { - id: stageMenuRow - anchors.centerIn: parent + id: viewSelector + iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") height: parent.height + headerCornerSide: 2 // Show corners on the left side - Cura.ExpandableComponent + property var viewModel: UM.ViewModel { } + + property var activeView: { - id: viewSelector - iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") - height: parent.height - - property var viewModel: UM.ViewModel { } - - property var activeView: + for (var i = 0; i < viewModel.rowCount(); i++) { - for (var i = 0; i < viewModel.rowCount(); i++) + if (viewModel.items[i].active) { - if (viewModel.items[i].active) - { - return viewModel.items[i] - } + return viewModel.items[i] } - return null } + return null + } + Component.onCompleted: + { + // Nothing was active, so just return the first one (the list is sorted by priority, so the most + // important one should be returned) + if(activeView == null) + { + UM.Controller.setActiveView(viewModel.getItem(0).id) + } + } + + headerItem: Label + { + text: viewSelector.activeView ? viewSelector.activeView.name : "" + verticalAlignment: Text.AlignVCenter + height: parent.height + elide: Text.ElideRight + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + } + + popupItem: Column + { + id: viewSelectorPopup + width: viewSelector.width - 2 * UM.Theme.getSize("default_margin").width + + // For some reason the height/width of the column gets set to 0 if this is not set... Component.onCompleted: { - // Nothing was active, so just return the first one (the list is sorted by priority, so the most - // important one should be returned) - if(activeView == null) - { - UM.Controller.setActiveView(viewModel.getItem(0).id) - } + height = implicitHeight + width = viewSelector.width - 2 * UM.Theme.getSize("default_margin").width } - headerItem: Label + Repeater { - text: viewSelector.activeView ? viewSelector.activeView.name : "" - verticalAlignment: Text.AlignVCenter - height: parent.height - elide: Text.ElideRight - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text") - } - - popupItem: Column - { - id: viewSelectorPopup - width: viewSelector.width - 2 * UM.Theme.getSize("default_margin").width - - // For some reason the height/width of the column gets set to 0 if this is not set... - Component.onCompleted: + id: viewsList + model: viewSelector.viewModel + RoundButton { - height = implicitHeight - width = viewSelector.width - 2 * UM.Theme.getSize("default_margin").width - } - - Repeater - { - id: viewsList - model: viewSelector.viewModel - RoundButton + text: name + radius: UM.Theme.getSize("default_radius").width + checkable: true + checked: viewSelector.activeView != null ? viewSelector.activeView.id == id : false + onClicked: { - text: name - radius: UM.Theme.getSize("default_radius").width - checkable: true - checked: viewSelector.activeView != null ? viewSelector.activeView.id == id : false - onClicked: - { - viewSelector.togglePopup() - UM.Controller.setActiveView(id) - } + viewSelector.togglePopup() + UM.Controller.setActiveView(id) } } - } - } - // Separator line - Rectangle - { - height: parent.height - // If there is no viewPanel, we only need a single spacer, so hide this one. - visible: viewPanel.source != "" - width: visible ? UM.Theme.getSize("default_lining").width : 0 - - color: UM.Theme.getColor("lining") } + } - Loader - { - id: viewPanel - height: parent.height - width: childrenRect.width - source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : "" - } + // Separator line + Rectangle + { + height: parent.height + // If there is no viewPanel, we only need a single spacer, so hide this one. + visible: viewPanel.source != "" + width: visible ? UM.Theme.getSize("default_lining").width : 0 - // Separator line - Rectangle - { - height: parent.height - width: UM.Theme.getSize("default_lining").width - color: UM.Theme.getColor("lining") - } + color: UM.Theme.getColor("lining") + } - Item - { - id: printSetupSelectorItem - // This is a work around to prevent the printSetupSelector from having to be re-loaded every time - // a stage switch is done. - children: [printSetupSelector] - height: childrenRect.height - width: childrenRect.width - } + Loader + { + id: viewPanel + height: parent.height + width: childrenRect.width + source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : "" + } + + // Separator line + Rectangle + { + height: parent.height + width: UM.Theme.getSize("default_lining").width + color: UM.Theme.getColor("lining") + } + + Item + { + id: printSetupSelectorItem + // This is a work around to prevent the printSetupSelector from having to be re-loaded every time + // a stage switch is done. + children: [printSetupSelector] + height: childrenRect.height + width: childrenRect.width } } } diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index c239dc8d6f..711c05c64c 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -259,6 +259,7 @@ UM.MainWindow onHideTooltip: base.hideTooltip() width: UM.Theme.getSize("print_setup_widget").width height: UM.Theme.getSize("stage_menu").height + headerCornerSide: 4 // Show corners on the right side } } diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index 8ed6dc5674..262c6bfd3f 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -40,6 +40,12 @@ Item property alias expandedHighlightColor: expandedHighlight.color + // What should the radius of the header be. This is also influenced by the headerCornerSide + property alias headerRadius: background.radius + + // On what side should the header corners be shown? 1 is down, 2 is left, 3 is up and 4 is right. + property alias headerCornerSide: background.cornerSide + function togglePopup() { if(popup.visible) @@ -71,7 +77,8 @@ Item implicitHeight: 100 * screenScaleFactor implicitWidth: 400 * screenScaleFactor - Rectangle + + RoundedRectangle { id: background property real padding: UM.Theme.getSize("default_margin").width diff --git a/resources/qml/RoundedRectangle.qml b/resources/qml/RoundedRectangle.qml new file mode 100644 index 0000000000..d7ba7d6d13 --- /dev/null +++ b/resources/qml/RoundedRectangle.qml @@ -0,0 +1,39 @@ +import QtQuick 2.0 + +import UM 1.2 as UM + +// The rounded rectangle works mostly like a regular rectangle, but provides the option to have rounded corners on only one side of the rectangle. +Item +{ + // As per the regular rectangle + property color color: "transparent" + + // As per regular rectangle + property int radius: UM.Theme.getSize("default_radius").width + + // On what side should the corners be shown 0 can be used if no radius is needed. + // 1 is down, 2 is left, 3 is up and 4 is right. + property int cornerSide: 0 + + Rectangle + { + id: background + anchors.fill: parent + radius: cornerSide != 0 ? parent.radius : 0 + color: parent.color + } + + // The item that covers 2 of the corners to make them not rounded. + Rectangle + { + visible: cornerSide != 0 + height: cornerSide % 2 ? parent.radius: parent.height + width: cornerSide % 2 ? parent.width : parent.radius + color: parent.color + anchors + { + right: cornerSide == 2 ? parent.right: undefined + bottom: cornerSide == 3 ? parent.bottom: undefined + } + } +} From eef6ad662d816ac8266faaa391342accab36f07d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 21 Nov 2018 11:50:39 +0100 Subject: [PATCH 28/43] Added enum for the roundedCorner property This makes it a whole lot easier to read what is being set. CURA-5785 --- plugins/PrepareStage/PrepareMenu.qml | 2 +- plugins/PreviewStage/PreviewMenu.qml | 2 +- resources/qml/Cura.qml | 2 +- resources/qml/RoundedRectangle.qml | 24 +++++++++++++++++------- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index 22f93aa5f2..bf2a0e1283 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -42,7 +42,7 @@ Item { id: machineSelection z: openFileButtonBackground.z - 1 //Ensure that the tooltip of the open file button stays above the item row. - headerCornerSide: 2 // Show corners on the left. + headerCornerSide: Cura.RoundedRectangle.Direction.Left Layout.minimumWidth: UM.Theme.getSize("machine_selector_widget").width Layout.maximumWidth: UM.Theme.getSize("machine_selector_widget").width Layout.fillWidth: true diff --git a/plugins/PreviewStage/PreviewMenu.qml b/plugins/PreviewStage/PreviewMenu.qml index d6033d6272..29632e5f00 100644 --- a/plugins/PreviewStage/PreviewMenu.qml +++ b/plugins/PreviewStage/PreviewMenu.qml @@ -34,7 +34,7 @@ Item id: viewSelector iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") height: parent.height - headerCornerSide: 2 // Show corners on the left side + headerCornerSide: Cura.RoundedRectangle.Direction.Left property var viewModel: UM.ViewModel { } diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 711c05c64c..2814bb9eb2 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -259,7 +259,7 @@ UM.MainWindow onHideTooltip: base.hideTooltip() width: UM.Theme.getSize("print_setup_widget").width height: UM.Theme.getSize("stage_menu").height - headerCornerSide: 4 // Show corners on the right side + headerCornerSide: RoundedRectangle.Direction.Right } } diff --git a/resources/qml/RoundedRectangle.qml b/resources/qml/RoundedRectangle.qml index d7ba7d6d13..9ad2230be5 100644 --- a/resources/qml/RoundedRectangle.qml +++ b/resources/qml/RoundedRectangle.qml @@ -1,4 +1,4 @@ -import QtQuick 2.0 +import QtQuick 2.7 import UM 1.2 as UM @@ -11,29 +11,39 @@ Item // As per regular rectangle property int radius: UM.Theme.getSize("default_radius").width - // On what side should the corners be shown 0 can be used if no radius is needed. + // On what side should the corners be shown 5 can be used if no radius is needed. // 1 is down, 2 is left, 3 is up and 4 is right. - property int cornerSide: 0 + property int cornerSide: RoundedRectangle.Direction.None + + enum Direction + { + None = 0, + Down = 1, + Left = 2, + Up = 3, + Right = 4, + All = 5 + } Rectangle { id: background anchors.fill: parent - radius: cornerSide != 0 ? parent.radius : 0 + radius: cornerSide != RoundedRectangle.Direction.None ? parent.radius : 0 color: parent.color } // The item that covers 2 of the corners to make them not rounded. Rectangle { - visible: cornerSide != 0 + visible: cornerSide != RoundedRectangle.Direction.None && cornerSide != RoundedRectangle.Direction.All height: cornerSide % 2 ? parent.radius: parent.height width: cornerSide % 2 ? parent.width : parent.radius color: parent.color anchors { - right: cornerSide == 2 ? parent.right: undefined - bottom: cornerSide == 3 ? parent.bottom: undefined + right: cornerSide == RoundedRectangle.Direction.Left ? parent.right: undefined + bottom: cornerSide == RoundedRectangle.Direction.Up ? parent.bottom: undefined } } } From bd636e61a0577b8f5f7eac160fa0af05757240c6 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 21 Nov 2018 13:17:36 +0100 Subject: [PATCH 29/43] Minor changes suggested in review CURA-5785 --- plugins/PrepareStage/PrepareMenu.qml | 2 +- plugins/PreviewStage/PreviewMenu.qml | 3 ++- plugins/SimulationView/SimulationViewMenuComponent.qml | 7 +++++-- resources/qml/ExtruderIcon.qml | 1 + resources/qml/MachineSelector.qml | 3 +++ resources/qml/PrintSetupSelector.qml | 1 + 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index bf2a0e1283..963908cea6 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -34,7 +34,7 @@ Item anchors.left: openFileButtonBackground.right anchors.leftMargin: UM.Theme.getSize("default_margin").width - width: 0.9 * prepareMenu.width + width: Math.round(0.9 * prepareMenu.width) height: parent.height spacing: 0 diff --git a/plugins/PreviewStage/PreviewMenu.qml b/plugins/PreviewStage/PreviewMenu.qml index 29632e5f00..656cf185d5 100644 --- a/plugins/PreviewStage/PreviewMenu.qml +++ b/plugins/PreviewStage/PreviewMenu.qml @@ -54,7 +54,7 @@ Item { // Nothing was active, so just return the first one (the list is sorted by priority, so the most // important one should be returned) - if(activeView == null) + if (activeView == null) { UM.Controller.setActiveView(viewModel.getItem(0).id) } @@ -68,6 +68,7 @@ Item elide: Text.ElideRight font: UM.Theme.getFont("default") color: UM.Theme.getColor("text") + renderType: Text.NativeRendering } popupItem: Column diff --git a/plugins/SimulationView/SimulationViewMenuComponent.qml b/plugins/SimulationView/SimulationViewMenuComponent.qml index caf47508e3..110cd1c109 100644 --- a/plugins/SimulationView/SimulationViewMenuComponent.qml +++ b/plugins/SimulationView/SimulationViewMenuComponent.qml @@ -132,6 +132,7 @@ Cura.ExpandableComponent visible: UM.SimulationView.compatibilityMode height: UM.Theme.getSize("layerview_row").height width: parent.width + renderType: Text.NativeRendering } Item // Spacer @@ -188,7 +189,7 @@ Cura.ExpandableComponent leftMargin: UM.Theme.getSize("checkbox").width + Math.round(UM.Theme.getSize("default_margin").width / 2) rightMargin: UM.Theme.getSize("default_margin").width * 2 } - + renderType: Text.NativeRendering } } } @@ -254,6 +255,7 @@ Cura.ExpandableComponent text: label font: UM.Theme.getFont("default") elide: Text.ElideRight + renderType: Text.NativeRendering color: UM.Theme.getColor("setting_control_text") anchors.verticalCenter: parent.verticalCenter anchors.left: legendModelCheckBox.left @@ -310,7 +312,7 @@ Cura.ExpandableComponent width: parent.width color: UM.Theme.getColor("setting_control_text") font: UM.Theme.getFont("default") - + renderType: Text.NativeRendering Rectangle { anchors.verticalCenter: parent.verticalCenter @@ -357,6 +359,7 @@ Cura.ExpandableComponent anchors.left: parent.left color: UM.Theme.getColor("setting_control_text") font: UM.Theme.getFont("default") + renderType: Text.NativeRendering } Label diff --git a/resources/qml/ExtruderIcon.qml b/resources/qml/ExtruderIcon.qml index 87e210e75a..79106bdd3a 100644 --- a/resources/qml/ExtruderIcon.qml +++ b/resources/qml/ExtruderIcon.qml @@ -53,6 +53,7 @@ Item width: contentWidth height: contentHeight visible: extruderEnabled + renderType: Text.NativeRendering } UM.RecolorImage diff --git a/resources/qml/MachineSelector.qml b/resources/qml/MachineSelector.qml index c9756d93ba..750ac7f620 100644 --- a/resources/qml/MachineSelector.qml +++ b/resources/qml/MachineSelector.qml @@ -33,6 +33,7 @@ Cura.ExpandableComponent elide: Text.ElideRight font: UM.Theme.getFont("default") color: UM.Theme.getColor("text") + renderType: Text.NativeRendering } popupItem: Item @@ -60,6 +61,7 @@ Cura.ExpandableComponent height: visible ? contentHeight + 2 * UM.Theme.getSize("default_margin").height : 0 font: UM.Theme.getFont("medium_bold") color: UM.Theme.getColor("text") + renderType: Text.NativeRendering verticalAlignment: Text.AlignVCenter } @@ -103,6 +105,7 @@ Cura.ExpandableComponent font: UM.Theme.getFont("medium_bold") color: UM.Theme.getColor("text") verticalAlignment: Text.AlignVCenter + renderType: Text.NativeRendering } Repeater diff --git a/resources/qml/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector.qml index b843244147..2ecdc9e546 100644 --- a/resources/qml/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector.qml @@ -182,6 +182,7 @@ Cura.ExpandableComponent verticalAlignment: Text.AlignVCenter renderType: Text.NativeRendering elide: Text.ElideRight + color: { if(control.pressed) From c7dbaa3a001fbca621e94134e15ce0d0c5ae4fae Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 21 Nov 2018 13:22:03 +0100 Subject: [PATCH 30/43] Add rendertype for labels in quickConfigurationSelector CURA-5785 --- .../qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml index d428a05463..ef7a425a87 100644 --- a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml +++ b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml @@ -152,6 +152,7 @@ Cura.ExpandableComponent color: UM.Theme.getColor("text") height: parent.height width: tabControl.textWidth + renderType: Text.NativeRendering } OldControls.CheckBox @@ -174,6 +175,7 @@ Cura.ExpandableComponent color: UM.Theme.getColor("text") height: parent.height width: tabControl.textWidth + renderType: Text.NativeRendering } OldControls.ToolButton @@ -217,6 +219,7 @@ Cura.ExpandableComponent color: UM.Theme.getColor("text") height: parent.height width: tabControl.textWidth + renderType: Text.NativeRendering } OldControls.ToolButton From a9672458fd31ffb7c64273b88a779a9f262b19d6 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 21 Nov 2018 13:46:50 +0100 Subject: [PATCH 31/43] Update extruderIcon to be more in line with the design CURA-5785 --- resources/qml/ExtruderIcon.qml | 10 ++++++---- .../ConfigurationMenu/QuickConfigurationSelector.qml | 3 +-- resources/themes/cura-light/theme.json | 9 +++++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/resources/qml/ExtruderIcon.qml b/resources/qml/ExtruderIcon.qml index 79106bdd3a..1e51835d60 100644 --- a/resources/qml/ExtruderIcon.qml +++ b/resources/qml/ExtruderIcon.qml @@ -9,8 +9,8 @@ Item { id: extruderIconItem - implicitWidth: UM.Theme.getSize("button").width - implicitHeight: implicitWidth + implicitWidth: UM.Theme.getSize("extruder_icon").width + implicitHeight: UM.Theme.getSize("extruder_icon").height property bool checked: true property color materialColor @@ -22,7 +22,7 @@ Item anchors.fill: parent sourceSize.width: parent.width - sourceSize.height: parent.width + sourceSize.height: parent.height source: UM.Theme.getIcon("extruder_button") color: extruderEnabled ? materialColor: "gray" } @@ -49,11 +49,13 @@ Item id: extruderNumberText anchors.centerIn: parent text: index + 1 - font: UM.Theme.getFont("default") + font: UM.Theme.getFont("extruder_icon") width: contentWidth height: contentHeight visible: extruderEnabled renderType: Text.NativeRendering + horizontalAlignment: Text.alignHCenter + verticalAlignment: Text.alignVCenter } UM.RecolorImage diff --git a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml index ef7a425a87..eb6800cb36 100644 --- a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml +++ b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml @@ -50,8 +50,7 @@ Cura.ExpandableComponent id: extruderIcon materialColor: model.color extruderEnabled: model.enabled - height: parent.height - width: height + anchors.verticalCenter: parent.verticalCenter } // Label for the brand of the material diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index d28611529b..b09370ccdb 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -64,6 +64,12 @@ "size": 1.15, "weight": 50, "family": "Noto Sans" + }, + "extruder_icon": + { + "size": 0.7, + "weight": 50, + "family": "Noto Sans" } }, @@ -406,8 +412,7 @@ "thin_margin": [0.71, 0.71], "narrow_margin": [0.5, 0.5], - "extruder_button_material_margin": [0.70, 0.9], - "extruder_button_material": [0.75, 0.75], + "extruder_icon": [1.8, 1.8], "simple_mode_infill_caption": [0.0, 5.0], "simple_mode_infill_height": [0.0, 8.0], From a1f3ebc25b97f555362a1dead86d7cc6081f718a Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Wed, 21 Nov 2018 13:58:21 +0100 Subject: [PATCH 32/43] Fix typo. Contributes to CURA-5785. --- resources/qml/ExtruderIcon.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/ExtruderIcon.qml b/resources/qml/ExtruderIcon.qml index 1e51835d60..c103ee245c 100644 --- a/resources/qml/ExtruderIcon.qml +++ b/resources/qml/ExtruderIcon.qml @@ -54,8 +54,8 @@ Item height: contentHeight visible: extruderEnabled renderType: Text.NativeRendering - horizontalAlignment: Text.alignHCenter - verticalAlignment: Text.alignVCenter + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter } UM.RecolorImage From f866390c7bb0cc9ac4af65d78a30c6b7995f6201 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Wed, 21 Nov 2018 16:56:25 +0100 Subject: [PATCH 33/43] Fix an issue in the action panel. When the panel is created while the user is in the preview stage, the row has no width. Contributes to CURA-5786. --- resources/qml/ActionPanel/OutputProcessWidget.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/qml/ActionPanel/OutputProcessWidget.qml b/resources/qml/ActionPanel/OutputProcessWidget.qml index f4e014b1ec..3c4386f079 100644 --- a/resources/qml/ActionPanel/OutputProcessWidget.qml +++ b/resources/qml/ActionPanel/OutputProcessWidget.qml @@ -99,6 +99,7 @@ Column { id: buttonRow spacing: UM.Theme.getSize("default_margin").width + width: parent.width Cura.ActionButton { From a9f0402f636b652585c23c5ea7299f0256ba195d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 22 Nov 2018 09:37:36 +0100 Subject: [PATCH 34/43] Made size of viewselector themable CURA-5785 --- plugins/PreviewStage/PreviewMenu.qml | 1 + resources/themes/cura-light/theme.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/PreviewStage/PreviewMenu.qml b/plugins/PreviewStage/PreviewMenu.qml index 656cf185d5..d660db549b 100644 --- a/plugins/PreviewStage/PreviewMenu.qml +++ b/plugins/PreviewStage/PreviewMenu.qml @@ -34,6 +34,7 @@ Item id: viewSelector iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") height: parent.height + width: UM.Theme.getSize("views_selector").width headerCornerSide: Cura.RoundedRectangle.Direction.Left property var viewModel: UM.ViewModel { } diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index b09370ccdb..0df1c8eb31 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -395,7 +395,7 @@ "machine_selector_widget": [16.0, 4.5], - "views_selector": [0.0, 4.0], + "views_selector": [16.0, 4.5], "default_radius": [0.25, 0.25], From d4e4e507411dbc6e63c26737c0ae6931847ceba3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 22 Nov 2018 10:55:53 +0100 Subject: [PATCH 35/43] Fix typo --- resources/definitions/fdmextruder.def.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/definitions/fdmextruder.def.json b/resources/definitions/fdmextruder.def.json index cb49b1e128..0af1e68075 100644 --- a/resources/definitions/fdmextruder.def.json +++ b/resources/definitions/fdmextruder.def.json @@ -189,7 +189,7 @@ "settable_per_mesh": false, "settable_per_extruder": true, "settable_per_meshgroup": false, - "setttable_globally": false + "settable_globally": false } } }, From bf8a04fa4049b4a7bf99c4903b437109ec415b73 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 22 Nov 2018 11:08:46 +0100 Subject: [PATCH 36/43] Fix some minor display issues for simulation view CURA-5785 --- plugins/SimulationView/SimulationViewMenuComponent.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/SimulationView/SimulationViewMenuComponent.qml b/plugins/SimulationView/SimulationViewMenuComponent.qml index 110cd1c109..53b64afb47 100644 --- a/plugins/SimulationView/SimulationViewMenuComponent.qml +++ b/plugins/SimulationView/SimulationViewMenuComponent.qml @@ -40,7 +40,6 @@ Cura.ExpandableComponent id: layerViewTypesLabel text: catalog.i18nc("@label", "Color scheme") font: UM.Theme.getFont("default") - visible: !UM.SimulationView.compatibilityMode color: UM.Theme.getColor("setting_control_text") height: base.height verticalAlignment: Text.AlignVCenter @@ -273,6 +272,7 @@ Cura.ExpandableComponent text: catalog.i18nc("@label", "Only Show Top Layers") visible: UM.SimulationView.compatibilityMode style: UM.Theme.styles.checkbox + width: parent.width } CheckBox @@ -280,6 +280,7 @@ Cura.ExpandableComponent checked: viewSettings.top_layer_count == 5 onClicked: UM.Preferences.setValue("view/top_layer_count", checked ? 5 : 1) text: catalog.i18nc("@label", "Show 5 Detailed Layers On Top") + width: parent.width visible: UM.SimulationView.compatibilityMode style: UM.Theme.styles.checkbox } From ba7863c9d9640ce30f01cf47fff8d1ec9564d06f Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 22 Nov 2018 11:09:35 +0100 Subject: [PATCH 37/43] Fix type error for hovering manage queue link Contributes to CL-1148 --- .../resources/qml/ClusterMonitorItem.qml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml index d055071521..328f82dec5 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml @@ -91,6 +91,7 @@ Component } Label { + id: manageQueueText anchors { left: externalLinkIcon.right @@ -110,8 +111,14 @@ Component anchors.fill: manageQueueLabel hoverEnabled: true onClicked: Cura.MachineManager.printerOutputDevices[0].openPrintJobControlPanel() - onEntered: manageQueueLabel.font.underline = true - onExited: manageQueueLabel.font.underline = false + onEntered: + { + manageQueueText.font.underline = true + } + onExited: + { + manageQueueText.font.underline = false + } } Row From 088b2f6f2808d3aca074e68e47e05d0d0b46808c Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Thu, 22 Nov 2018 11:36:32 +0100 Subject: [PATCH 38/43] Added an extra import module, did not pass coding style test CURA-5936 --- plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py index 478f955e49..ff5c33517d 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py @@ -6,6 +6,7 @@ import io #To write config files to strings as if they were files. import os.path #To get the path to write new user profiles to. from typing import Dict, List, Optional, Set, Tuple import urllib #To serialise the user container file name properly. +import urllib.parse import UM.VersionUpgrade #To indicate that a file is of incorrect format. import UM.VersionUpgradeManager #To schedule more files to be upgraded. From 3c3343a4073f7cf574ee3aa45eaeb17a0d25f166 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 22 Nov 2018 13:11:59 +0100 Subject: [PATCH 39/43] Use bool for expanded or collapsed state Contributes to CL-1148 --- plugins/UM3NetworkPrinting/resources/qml/ExpandableCard.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/ExpandableCard.qml b/plugins/UM3NetworkPrinting/resources/qml/ExpandableCard.qml index 4922aea853..0877a15f00 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/ExpandableCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/ExpandableCard.qml @@ -14,7 +14,7 @@ Item { id: base - property var expanded: false + property bool expanded: false property var borderWidth: 1 property color borderColor: "#EAEAEC" property color headerBackgroundColor: "white" From 1de21c1d94a5be627c125694118edf39ea5a2f9b Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 22 Nov 2018 13:13:06 +0100 Subject: [PATCH 40/43] Remove unnecessary "else" Contributes to CL-1148 --- .../UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml index ada6f8a644..913e684827 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml @@ -91,10 +91,7 @@ Item } return catalog.i18nc("@label", "First available") } - else - { - return printJob.assignedPrinter.name - } + return printJob.assignedPrinter.name } return "" } From da834d6a1fdf4ef7123e737015acdc10b555bece Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 22 Nov 2018 13:55:22 +0100 Subject: [PATCH 41/43] Silence binding loop Contributes to CL-1148 --- .../UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml index 913e684827..0f2ae67442 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml @@ -71,7 +71,7 @@ Item Item { anchors.verticalCenter: parent.verticalCenter - height: childrenRect.height + height: 18 * screenScaleFactor // TODO: This should be childrenRect.height but QML throws warnings width: childrenRect.width Label From 55554c62a9a4d8995ae6358b9d29cb2a4b6861d3 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 22 Nov 2018 13:55:43 +0100 Subject: [PATCH 42/43] Use array for extruder configurations Contributes to CL-1148 --- .../resources/qml/MonitorPrintJobCard.qml | 7 +++- .../qml/MonitorPrinterConfiguration.qml | 38 ++++++++----------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml index 0f2ae67442..8231870c21 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml @@ -141,8 +141,11 @@ Item id: printerConfiguration anchors.verticalCenter: parent.verticalCenter buildplate: "Glass" - config0: base.printJob.configuration.extruderConfigurations[0] - config1: base.printJob.configuration.extruderConfigurations[1] + configurations: + [ + base.printJob.configuration.extruderConfigurations[0], + base.printJob.configuration.extruderConfigurations[1] + ] height: 72 * screenScaleFactor // TODO: Theme! } Label { diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterConfiguration.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterConfiguration.qml index a31c8bbd99..6aa11528de 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterConfiguration.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterConfiguration.qml @@ -18,11 +18,8 @@ Item // Extracted buildplate configuration property alias buildplate: buildplateConfig.buildplate - // Extracted extruder configuration for position 0 - property var config0: null - - // Extracted extruder configuration for position 1 - property var config1: null + // Array of extracted extruder configurations + property var configurations: null // Default size, but should be stretched to fill parent height: 72 * parent.height @@ -30,30 +27,25 @@ Item Row { + id: extruderConfigurationRow spacing: 18 * screenScaleFactor // TODO: Theme! - MonitorExtruderConfiguration + Repeater { - color: config0 && config0.activeMaterial ? config0.activeMaterial.color : "#eeeeee" // TODO: Theme! - material: config0 && config0.activeMaterial ? config0.activeMaterial.name : "" - position: config0.position - printCore: config0 ? config0.hotendID : "" - visible: config0 + id: extruderConfigurationRepeater + model: configurations - // Keep things responsive! - width: Math.floor((base.width - parent.spacing) / 2) - } + MonitorExtruderConfiguration + { + color: modelData.activeMaterial ? modelData.activeMaterial.color : "#eeeeee" // TODO: Theme! + material: modelData.activeMaterial ? modelData.activeMaterial.name : "" + position: modelData.position + printCore: modelData.hotendID - MonitorExtruderConfiguration - { - color: config1 && config1.activeMaterial ? config1.activeMaterial.color : "#eeeeee" // TODO: Theme! - material: config1 && config1.activeMaterial ? config1.activeMaterial.name : "" - position: config1.position - printCore: config1 ? config1.hotendID : "" - visible: config1 + // Keep things responsive! + width: Math.floor((base.width - (configurations.length - 1) * extruderConfigurationRow.spacing) / configurations.length) + } - // Keep things responsive! - width: Math.floor((base.width - parent.spacing) / 2) } } From 963b8aa97487bc839ec051473eb79f1839767316 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 22 Nov 2018 13:56:01 +0100 Subject: [PATCH 43/43] Fix QML warnings Contributes to CL-1148 --- .../UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml index 328f82dec5..19a152e6eb 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/ClusterMonitorItem.qml @@ -17,7 +17,7 @@ Component property var emphasisColor: UM.Theme.getColor("setting_control_border_highlight") property var cornerRadius: UM.Theme.getSize("monitor_corner_radius").width - color: transparent + color: "transparent" height: maximumHeight onVisibleChanged: { @@ -83,7 +83,7 @@ Component UM.RecolorImage { id: externalLinkIcon - anchors.verticalCenter: externalLinkIcon.verticalCenter + anchors.verticalCenter: manageQueueLabel.verticalCenter color: UM.Theme.getColor("primary") source: "../svg/icons/external_link.svg" width: 16 * screenScaleFactor // TODO: Theme! (Y U NO USE 18 LIKE ALL OTHER ICONS?!)