mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 08:17:49 -06:00
Add availableConfiguration property to the output model
CURA-6732
This commit is contained in:
parent
9f16973215
commit
d2e9715409
1 changed files with 27 additions and 2 deletions
|
@ -7,6 +7,7 @@ from UM.Math.Vector import Vector
|
||||||
from cura.PrinterOutput.Peripheral import Peripheral
|
from cura.PrinterOutput.Peripheral import Peripheral
|
||||||
from cura.PrinterOutput.Models.PrinterConfigurationModel import PrinterConfigurationModel
|
from cura.PrinterOutput.Models.PrinterConfigurationModel import PrinterConfigurationModel
|
||||||
from cura.PrinterOutput.Models.ExtruderOutputModel import ExtruderOutputModel
|
from cura.PrinterOutput.Models.ExtruderOutputModel import ExtruderOutputModel
|
||||||
|
from UM.Logger import Logger
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel
|
from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel
|
||||||
|
@ -50,6 +51,8 @@ class PrinterOutputModel(QObject):
|
||||||
self._printer_configuration.extruderConfigurations = [extruder.extruderConfiguration for extruder in
|
self._printer_configuration.extruderConfigurations = [extruder.extruderConfiguration for extruder in
|
||||||
self._extruders]
|
self._extruders]
|
||||||
|
|
||||||
|
self._available_printer_configurations = [] # type: List[PrinterConfigurationModel]
|
||||||
|
|
||||||
self._camera_url = QUrl() # type: QUrl
|
self._camera_url = QUrl() # type: QUrl
|
||||||
|
|
||||||
@pyqtProperty(str, constant = True)
|
@pyqtProperty(str, constant = True)
|
||||||
|
@ -290,7 +293,7 @@ class PrinterOutputModel(QObject):
|
||||||
def _onControllerCanUpdateFirmwareChanged(self) -> None:
|
def _onControllerCanUpdateFirmwareChanged(self) -> None:
|
||||||
self.canUpdateFirmwareChanged.emit()
|
self.canUpdateFirmwareChanged.emit()
|
||||||
|
|
||||||
# Returns the configuration (material, variant and buildplate) of the current printer
|
# Returns the active configuration (material, variant and buildplate) of the current printer
|
||||||
@pyqtProperty(QObject, notify = configurationChanged)
|
@pyqtProperty(QObject, notify = configurationChanged)
|
||||||
def printerConfiguration(self) -> Optional[PrinterConfigurationModel]:
|
def printerConfiguration(self) -> Optional[PrinterConfigurationModel]:
|
||||||
if self._printer_configuration.isValid():
|
if self._printer_configuration.isValid():
|
||||||
|
@ -309,4 +312,26 @@ class PrinterOutputModel(QObject):
|
||||||
|
|
||||||
def removePeripheral(self, peripheral: Peripheral) -> None:
|
def removePeripheral(self, peripheral: Peripheral) -> None:
|
||||||
self._peripherals.remove(peripheral)
|
self._peripherals.remove(peripheral)
|
||||||
self.peripheralsChanged.emit()
|
self.peripheralsChanged.emit()
|
||||||
|
|
||||||
|
availableConfigurationsChanged = pyqtSignal()
|
||||||
|
|
||||||
|
@pyqtProperty("QVariantList", notify = availableConfigurationsChanged)
|
||||||
|
def availableConfigurations(self) -> List[PrinterConfigurationModel]:
|
||||||
|
return self._available_printer_configurations
|
||||||
|
|
||||||
|
def addAvailableConfiguration(self, new_configuration: PrinterConfigurationModel) -> None:
|
||||||
|
self._available_printer_configurations.append(new_configuration)
|
||||||
|
self.availableConfigurationsChanged.emit()
|
||||||
|
|
||||||
|
def removeAvailableConfiguration(self, config_to_remove: PrinterConfigurationModel) -> None:
|
||||||
|
try:
|
||||||
|
self._available_printer_configurations.remove(config_to_remove)
|
||||||
|
except ValueError:
|
||||||
|
Logger.log("w", "Unable to remove configuration that isn't in the list of available configurations")
|
||||||
|
else:
|
||||||
|
self.availableConfigurationsChanged.emit()
|
||||||
|
|
||||||
|
def setAvailableConfigurations(self, new_configurations: List[PrinterConfigurationModel]) -> None:
|
||||||
|
self._available_printer_configurations = new_configurations
|
||||||
|
self.availableConfigurationsChanged.emit()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue