Merge branch '4.0'

Conflicts:
	cura/GlobalStacksModel.py -> CuraContainerRegistry being used in stead of ContainerRegistry, but imports were reordered.
	plugins/CuraDrive/src/DrivePluginExtension.py -> Typing being solved in two ways.
This commit is contained in:
Ghostkeeper 2019-01-28 16:45:45 +01:00
commit 232498980c
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
7 changed files with 85 additions and 40 deletions

View file

@ -42,7 +42,12 @@ class GlobalStack(CuraContainerStack):
# Per thread we have our own resolving_settings, or strange things sometimes occur.
self._resolving_settings = defaultdict(set) #type: Dict[str, Set[str]] # keys are thread names
# Since the metadatachanged is defined in container stack, we can't use it here as a notifier for pyqt
# properties. So we need to tie them together like this.
self.metaDataChanged.connect(self.configuredConnectionTypesChanged)
extrudersChanged = pyqtSignal()
configuredConnectionTypesChanged = pyqtSignal()
## Get the list of extruders of this stack.
#
@ -63,6 +68,34 @@ class GlobalStack(CuraContainerStack):
def getLoadingPriority(cls) -> int:
return 2
# The configured connection types can be used to find out if the global stack is configured to be connected with
# a printer, without having to know all the details as to how this is exactly done (and without actually setting
# the stack to be active). This data can then in turn also be used when the global stack is active; If we can't
# get a network connection, but it is configured to have one, we can display a different icon to indicate the
# difference.
@pyqtProperty("QVariantList", notify=configuredConnectionTypesChanged)
def configuredConnectionTypes(self):
# Requesting it from the metadata actually gets them as strings (as that's what you get from serializing).
# But we do want them returned as a list of ints (so the rest of the code can directly compare)
connection_types = self.getMetaDataEntry("connection_type", "").split(",")
return [int(connection_type) for connection_type in connection_types if connection_type != ""]
# \sa configuredConnectionTypes
def addConfiguredConnectionType(self, connection_type):
configured_connection_types = self.configuredConnectionTypes
if connection_type not in configured_connection_types:
# Store the values as a string.
configured_connection_types.append(str(connection_type))
self.setMetaDataEntry("connection_type", ",".join(configured_connection_types))
# \sa configuredConnectionTypes
def removeConfiguredConnectionType(self, connection_type):
configured_connection_types = self.configuredConnectionTypes
if connection_type in self.configured_connection_types:
# Store the values as a string.
configured_connection_types.remove(str(connection_type))
self.setMetaDataEntry("connection_type", ",".join(configured_connection_types))
@classmethod
def getConfigurationTypeFromSerialized(cls, serialized: str) -> Optional[str]:
configuration_type = super().getConfigurationTypeFromSerialized(serialized)