mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
Complete interface for selecting cloud printer.
CURA-9278
This commit is contained in:
parent
d955a05d55
commit
6adf05bbf0
4 changed files with 83 additions and 32 deletions
|
@ -1,24 +1,18 @@
|
|||
# Copyright (c) 2022 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
# TODO?: documentation
|
||||
|
||||
from typing import Optional, Dict, cast
|
||||
from typing import Optional
|
||||
|
||||
from PyQt6.QtCore import Qt, QObject, pyqtSlot, pyqtProperty, pyqtSignal
|
||||
|
||||
from UM.Logger import Logger
|
||||
from UM.Qt.ListModel import ListModel
|
||||
from UM.Settings.ContainerStack import ContainerStack
|
||||
from UM.i18n import i18nCatalog
|
||||
from UM.Util import parseBool
|
||||
|
||||
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry
|
||||
from cura.Settings.ExtruderStack import ExtruderStack
|
||||
|
||||
|
||||
class CompatibleMachineModel(ListModel):
|
||||
NameRole = Qt.ItemDataRole.UserRole + 1
|
||||
IdRole = Qt.ItemDataRole.UserRole + 2
|
||||
UniqueIdRole = Qt.ItemDataRole.UserRole + 2
|
||||
ExtrudersRole = Qt.ItemDataRole.UserRole + 3
|
||||
|
||||
def __init__(self, parent: Optional[QObject] = None) -> None:
|
||||
|
@ -27,7 +21,7 @@ class CompatibleMachineModel(ListModel):
|
|||
self._catalog = i18nCatalog("cura")
|
||||
|
||||
self.addRoleName(self.NameRole, "name")
|
||||
self.addRoleName(self.IdRole, "id")
|
||||
self.addRoleName(self.UniqueIdRole, "unique_id")
|
||||
self.addRoleName(self.ExtrudersRole, "extruders")
|
||||
|
||||
self._update()
|
||||
|
@ -62,11 +56,10 @@ class CompatibleMachineModel(ListModel):
|
|||
|
||||
# add currently inactive, but possible materials:
|
||||
for configuration in printer.availableConfigurations:
|
||||
print(" CONFIG !")
|
||||
for extruder in configuration.extruderConfigurations:
|
||||
|
||||
if not extruder.position in extruder_configs:
|
||||
# TODO: log -- all extruders should be present in the init round, regardless of if a material was active
|
||||
Logger.log("w", f"No active extruder for position {extruder.position}.")
|
||||
continue
|
||||
|
||||
extruder_configs[extruder.position]["materials"].append({
|
||||
|
@ -77,8 +70,6 @@ class CompatibleMachineModel(ListModel):
|
|||
|
||||
self.appendItem({
|
||||
"name": printer.name,
|
||||
"id": printer.uniqueName,
|
||||
"unique_id": printer.uniqueName,
|
||||
"extruders": [extruder for extruder in extruder_configs.values()]
|
||||
})
|
||||
|
||||
# TODO: Handle 0 compatible machines -> option to close window? Message in card? (remember the design has a refresh button!)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue