diff --git a/cura/MachineManagerModel.py b/cura/MachineManagerModel.py index 275ede0518..bef949b483 100644 --- a/cura/MachineManagerModel.py +++ b/cura/MachineManagerModel.py @@ -8,6 +8,8 @@ from UM.Preferences import Preferences import UM.Settings from UM.Settings.Validator import ValidatorState from UM.Settings.InstanceContainer import InstanceContainer + +from cura.PrinterOutputDevice import PrinterOutputDevice from UM.Settings.ContainerStack import ContainerStack from . import ExtruderManager from UM.i18n import i18nCatalog @@ -49,6 +51,8 @@ class MachineManagerModel(QObject): active_machine_id = Preferences.getInstance().getValue("cura/active_machine") + Application.getInstance().getOutputDeviceManager().outputDevicesChanged.connect(self._onOutputDevicesChanged) + if active_machine_id != "": # An active machine was saved, so restore it. self.setActiveMachine(active_machine_id) @@ -65,6 +69,11 @@ class MachineManagerModel(QObject): blurSettings = pyqtSignal() # Emitted to force fields in the advanced sidebar to un-focus, so they update properly + outputDevicesChanged = pyqtSignal() + + def _onOutputDevicesChanged(self): + self.outputDevicesChanged.emit() + @pyqtProperty("QVariantMap", notify = globalContainerChanged) def extrudersIds(self): ## Find all extruders that reference the new stack @@ -164,6 +173,10 @@ class MachineManagerModel(QObject): Application.getInstance().setGlobalContainerStack(new_global_stack) + @pyqtProperty("QVariantList", notify = outputDevicesChanged) + def printerOutputDevices(self): + return [printer_output_device for printer_output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices() if isinstance(printer_output_device, PrinterOutputDevice)] + ## Create a name that is not empty and unique # \param container_type \type{string} Type of the container (machine, quality, ...) # \param current_name \type{} Current name of the container, which may be an acceptable option diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index b7ff0743de..4c8d671a7f 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -7,6 +7,7 @@ import QtQuick.Controls.Styles 1.1 import QtQuick.Layouts 1.1 import UM 1.1 as UM +import Cura 1.0 as Cura Rectangle { @@ -14,6 +15,9 @@ Rectangle property int currentModeIndex; + // Is there an output device for this printer? + property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0 + color: UM.Theme.getColor("sidebar"); UM.I18nCatalog { id: catalog; name:"cura"}