CURA-5158 Create a custom signal that is emitted when global container

changes and output devices change.
This commit is contained in:
Diego Prado Gesto 2018-03-28 11:07:48 +02:00
parent 35cd4eb572
commit 79daf3706b
9 changed files with 20 additions and 11 deletions

View file

@ -131,6 +131,10 @@ class MachineManager(QObject):
self._material_manager.materialsUpdated.connect(self._updateUponMaterialMetadataChange)
self.rootMaterialChanged.connect(self._onRootMaterialChanged)
# Emit the printerConnectedStatusChanged when either globalContainerChanged or outputDevicesChanged are emitted
self.globalContainerChanged.connect(self.printerConnectedStatusChanged)
self.outputDevicesChanged.connect(self.printerConnectedStatusChanged)
activeQualityGroupChanged = pyqtSignal()
activeQualityChangesGroupChanged = pyqtSignal()
@ -151,6 +155,7 @@ class MachineManager(QObject):
outputDevicesChanged = pyqtSignal()
currentConfigurationChanged = pyqtSignal() # Emitted every time the current configurations of the machine changes
printerConnectedStatusChanged = pyqtSignal() # Emitted every time the active machine change or the outputdevices change
rootMaterialChanged = pyqtSignal()
@ -466,13 +471,17 @@ class MachineManager(QObject):
return self._global_container_stack.getId()
return ""
@pyqtProperty(str, notify = outputDevicesChanged)
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
def printerConnected(self):
return bool(self._printer_output_devices)
@pyqtProperty(str, notify = printerConnectedStatusChanged)
def activeMachineNetworkKey(self) -> str:
if self._global_container_stack:
return self._global_container_stack.getMetaDataEntry("um_network_key", "")
return ""
@pyqtProperty(str, notify = outputDevicesChanged)
@pyqtProperty(str, notify = printerConnectedStatusChanged)
def activeMachineNetworkGroupName(self) -> str:
if self._global_container_stack:
return self._global_container_stack.getMetaDataEntry("connect_group_name", "")

View file

@ -12,7 +12,7 @@ Item
property string activeQualityDefinitionId: Cura.MachineManager.activeQualityDefinitionId
property bool isUM3: activeQualityDefinitionId == "ultimaker3" || activeQualityDefinitionId.match("ultimaker_") != null
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property bool printerConnected: Cura.MachineManager.printerConnected
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property bool authenticationRequested: printerConnected && (Cura.MachineManager.printerOutputDevices[0].authenticationState == 2 || Cura.MachineManager.printerOutputDevices[0].authenticationState == 5) // AuthState.AuthenticationRequested or AuthenticationReceived.

View file

@ -14,7 +14,7 @@ import Cura 1.0 as Cura
Cura.MachineAction
{
anchors.fill: parent;
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property bool printerConnected: Cura.MachineManager.printerConnected
property var activeOutputDevice: printerConnected ? Cura.MachineManager.printerOutputDevices[0] : null
Item

View file

@ -14,8 +14,8 @@ ToolButton
{
id: base
property bool isNetworkPrinter: Cura.MachineManager.activeMachineNetworkKey != ""
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property var printerStatus: Cura.MachineManager.printerOutputDevices.length != 0 ? "connected" : "disconnected"
property bool printerConnected: Cura.MachineManager.printerConnected
property var printerStatus: Cura.MachineManager.printerConnected ? "connected" : "disconnected"
text: isNetworkPrinter ? Cura.MachineManager.activeMachineNetworkGroupName : Cura.MachineManager.activeMachineName
tooltip: Cura.MachineManager.activeMachineName

View file

@ -15,7 +15,7 @@ Item
id: base;
UM.I18nCatalog { id: catalog; name:"cura"}
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property bool printerConnected: Cura.MachineManager.printerConnected
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property var activePrinter: printerConnected ? Cura.MachineManager.printerOutputDevices[0].activePrinter : null
property var activePrintJob: activePrinter ? activePrinter.activePrintJob: null

View file

@ -138,7 +138,7 @@ UM.ManagementPage
visible: base.currentItem
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property bool printerConnected: Cura.MachineManager.printerConnected
property var connectedPrinter: printerConnected ? Cura.MachineManager.printerOutputDevices[0] : null
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property var printJob: connectedPrinter != null ? connectedPrinter.activePrintJob: null

View file

@ -20,7 +20,7 @@ Rectangle
// Is there an output device for this printer?
property bool isNetworkPrinter: Cura.MachineManager.activeMachineNetworkKey != ""
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property bool printerConnected: Cura.MachineManager.printerConnected
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null

View file

@ -16,7 +16,7 @@ Column
property int currentExtruderIndex: Cura.ExtruderManager.activeExtruderIndex;
property bool currentExtruderVisible: extrudersList.visible;
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property bool printerConnected: Cura.MachineManager.printerConnected
property bool hasManyPrinterTypes: printerConnected ? Cura.MachineManager.printerOutputDevices[0].connectedPrintersTypeCount.length > 1 : false
spacing: Math.round(UM.Theme.getSize("sidebar_margin").width * 0.9)

View file

@ -18,7 +18,7 @@ Rectangle
height: UM.Theme.getSize("sidebar_header").height
color: UM.Controller.activeStage.stageId == "MonitorStage" ? UM.Theme.getColor("topbar_background_color_monitoring") : UM.Theme.getColor("topbar_background_color")
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property bool printerConnected: Cura.MachineManager.printerConnected
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property int rightMargin: UM.Theme.getSize("sidebar").width + UM.Theme.getSize("default_margin").width;