mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
Simplify some checks for connection types and group size
This commit is contained in:
parent
2f92f6ef50
commit
af2061cd52
3 changed files with 31 additions and 18 deletions
|
@ -527,10 +527,15 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
|
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
|
||||||
def activeMachineHasRemoteConnection(self) -> bool:
|
def activeMachineHasRemoteConnection(self) -> bool:
|
||||||
if self._global_container_stack:
|
return self.activeMachineHasActiveNetworkConnection or self.activeMachineHasActiveCloudConnection
|
||||||
connection_type = self._global_container_stack.getMetaDataEntry("connection_type")
|
# if self._global_container_stack:
|
||||||
return connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value]
|
# connection_type = self._global_container_stack.getMetaDataEntry("connection_type")
|
||||||
return False
|
# return connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value]
|
||||||
|
# return False
|
||||||
|
|
||||||
|
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
|
||||||
|
def activeMachineIsGroup(self) -> bool:
|
||||||
|
return self._printer_output_devices and self._printer_output_devices[0].clusterSize > 1
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
|
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
|
||||||
def activeMachineHasActiveNetworkConnection(self) -> bool:
|
def activeMachineHasActiveNetworkConnection(self) -> bool:
|
||||||
|
|
|
@ -121,10 +121,11 @@ class CloudOutputDeviceManager:
|
||||||
return
|
return
|
||||||
|
|
||||||
device = next((c for c in self._remote_clusters.values() if c.matchesNetworkKey(local_network_key)), None)
|
device = next((c for c in self._remote_clusters.values() if c.matchesNetworkKey(local_network_key)), None)
|
||||||
if device:
|
if not device:
|
||||||
active_machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key)
|
return
|
||||||
device.connect()
|
|
||||||
|
|
||||||
|
active_machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key)
|
||||||
|
device.connect()
|
||||||
Logger.log("i", "Found cluster %s with network key %s", device, local_network_key)
|
Logger.log("i", "Found cluster %s with network key %s", device, local_network_key)
|
||||||
|
|
||||||
## Handles an API error received from the cloud.
|
## Handles an API error received from the cloud.
|
||||||
|
|
|
@ -11,10 +11,9 @@ Cura.ExpandablePopup
|
||||||
{
|
{
|
||||||
id: machineSelector
|
id: machineSelector
|
||||||
|
|
||||||
property var outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
|
|
||||||
property bool isPrinterConnected: Cura.MachineManager.printerConnected
|
|
||||||
property bool isNetworkPrinter: Cura.MachineManager.activeMachineHasActiveNetworkConnection
|
property bool isNetworkPrinter: Cura.MachineManager.activeMachineHasActiveNetworkConnection
|
||||||
property bool isCloudPrinter: Cura.MachineManager.activeMachineHasActiveCloudConnection
|
property bool isCloudPrinter: Cura.MachineManager.activeMachineHasActiveCloudConnection
|
||||||
|
property bool isGroup: Cura.MachineManager.activeMachineIsGroup
|
||||||
|
|
||||||
contentPadding: UM.Theme.getSize("default_lining").width
|
contentPadding: UM.Theme.getSize("default_lining").width
|
||||||
contentAlignment: Cura.ExpandablePopup.ContentAlignment.AlignLeft
|
contentAlignment: Cura.ExpandablePopup.ContentAlignment.AlignLeft
|
||||||
|
@ -30,15 +29,13 @@ Cura.ExpandablePopup
|
||||||
text: isNetworkPrinter ? Cura.MachineManager.activeMachineNetworkGroupName : Cura.MachineManager.activeMachineName
|
text: isNetworkPrinter ? Cura.MachineManager.activeMachineNetworkGroupName : Cura.MachineManager.activeMachineName
|
||||||
source:
|
source:
|
||||||
{
|
{
|
||||||
if (isNetworkPrinter)
|
if (isGroup) {
|
||||||
{
|
return UM.Theme.getIcon("printer_group")
|
||||||
if (machineSelector.outputDevice != null && machineSelector.outputDevice.clusterSize > 1)
|
} else if (isNetworkPrinter || isCloudPrinter) {
|
||||||
{
|
|
||||||
return UM.Theme.getIcon("printer_group")
|
|
||||||
}
|
|
||||||
return UM.Theme.getIcon("printer_single")
|
return UM.Theme.getIcon("printer_single")
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
font: UM.Theme.getFont("medium")
|
font: UM.Theme.getFont("medium")
|
||||||
iconColor: UM.Theme.getColor("machine_selector_printer_icon")
|
iconColor: UM.Theme.getColor("machine_selector_printer_icon")
|
||||||
|
@ -53,12 +50,22 @@ Cura.ExpandablePopup
|
||||||
leftMargin: UM.Theme.getSize("thick_margin").width
|
leftMargin: UM.Theme.getSize("thick_margin").width
|
||||||
}
|
}
|
||||||
|
|
||||||
source: machineSelector.isCloudPrinter ? UM.Theme.getIcon("printer_cloud_connected") : UM.Theme.getIcon("printer_connected")
|
source:
|
||||||
|
{
|
||||||
|
if (isNetworkPrinter) {
|
||||||
|
return UM.Theme.getIcon("printer_connected")
|
||||||
|
} else if (isCloudPrinter) {
|
||||||
|
return UM.Theme.getIcon("printer_cloud_connected")
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
width: UM.Theme.getSize("printer_status_icon").width
|
width: UM.Theme.getSize("printer_status_icon").width
|
||||||
height: UM.Theme.getSize("printer_status_icon").height
|
height: UM.Theme.getSize("printer_status_icon").height
|
||||||
|
|
||||||
color: UM.Theme.getColor("primary")
|
color: UM.Theme.getColor("primary")
|
||||||
visible: isNetworkPrinter && isPrinterConnected
|
visible: isNetworkPrinter || isCloudPrinter
|
||||||
|
|
||||||
// Make a themable circle in the background so we can change it in other themes
|
// Make a themable circle in the background so we can change it in other themes
|
||||||
Rectangle
|
Rectangle
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue