mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
Refactor removal warning message to CloudOutputDeviceManager
CURA-7436
This commit is contained in:
parent
c61f5a162e
commit
252b993169
3 changed files with 21 additions and 11 deletions
|
@ -19,9 +19,9 @@ class GlobalStacksModel(ListModel):
|
|||
ConnectionTypeRole = Qt.UserRole + 4
|
||||
MetaDataRole = Qt.UserRole + 5
|
||||
DiscoverySourceRole = Qt.UserRole + 6 # For separating local and remote printers in the machine management page
|
||||
HasCloudConnectionRole = Qt.UserRole + 7
|
||||
RemovalWarningRole = Qt.UserRole + 7
|
||||
|
||||
def __init__(self, parent = None) -> None:
|
||||
def __init__(self, parent=None) -> None:
|
||||
super().__init__(parent)
|
||||
|
||||
self._catalog = i18nCatalog("cura")
|
||||
|
@ -55,7 +55,7 @@ class GlobalStacksModel(ListModel):
|
|||
def _update(self) -> None:
|
||||
items = []
|
||||
|
||||
container_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type = "machine")
|
||||
container_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type="machine")
|
||||
for container_stack in container_stacks:
|
||||
has_remote_connection = False
|
||||
has_cloud_connection = False
|
||||
|
@ -68,14 +68,22 @@ class GlobalStacksModel(ListModel):
|
|||
if parseBool(container_stack.getMetaDataEntry("hidden", False)):
|
||||
continue
|
||||
|
||||
device_name = container_stack.getMetaDataEntry("group_name", container_stack.getName())
|
||||
section_name = "Connected printers" if has_remote_connection else "Preset printers"
|
||||
section_name = self._catalog.i18nc("@info:title", section_name)
|
||||
|
||||
items.append({"name": container_stack.getMetaDataEntry("group_name", container_stack.getName()),
|
||||
default_removal_warning = self._catalog.i18nc(
|
||||
"@label ({} is object name)",
|
||||
"Are you sure you wish to remove {}? This cannot be undone!", device_name
|
||||
)
|
||||
removal_warning = container_stack.getMetaDataEntry("removal_warning", default_removal_warning)
|
||||
|
||||
items.append({"name": device_name,
|
||||
"id": container_stack.getId(),
|
||||
"hasRemoteConnection": has_remote_connection,
|
||||
"hasCloudConnection": has_cloud_connection,
|
||||
"metadata": container_stack.getMetaData().copy(),
|
||||
"discoverySource": section_name})
|
||||
items.sort(key = lambda i: (not i["hasRemoteConnection"], i["name"]))
|
||||
"discoverySource": section_name,
|
||||
"removalWarning": removal_warning})
|
||||
items.sort(key=lambda i: (not i["hasRemoteConnection"], i["name"]))
|
||||
self.setItems(items)
|
||||
|
|
|
@ -265,6 +265,12 @@ class CloudOutputDeviceManager:
|
|||
machine.setName(device.name)
|
||||
machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key)
|
||||
machine.setMetaDataEntry("group_name", device.name)
|
||||
machine.setMetaDataEntry("removal_warning", self.I18N_CATALOG.i18nc(
|
||||
"@label ({} is printer name)",
|
||||
"{} will be removed but will be added again in the next sync. To remove the printer permanently, "
|
||||
"visit <a href='https://mycloud.ultimaker.com/'>Ultimaker Digital Factory</a>",
|
||||
device.name
|
||||
))
|
||||
machine.addConfiguredConnectionType(device.connectionType.value)
|
||||
|
||||
def _connectToOutputDevice(self, device: CloudOutputDevice, machine: GlobalStack) -> None:
|
||||
|
|
|
@ -136,11 +136,7 @@ UM.ManagementPage
|
|||
{
|
||||
id: confirmDialog
|
||||
object: base.currentItem && base.currentItem.name ? base.currentItem.name : ""
|
||||
text: base.currentItem && base.currentItem.hasCloudConnection?
|
||||
catalog.i18nc("@label (%1 is object name)", "%1 will be removed but will be added again in the next sync. To remove the printer permanently, visit <a href='https://mycloud.ultimaker.com/'>Ultimaker Digital Factory</a>").arg(base.currentItem.name)
|
||||
:
|
||||
catalog.i18nc("@label (%1 is object name)", "Are you sure you wish to remove %1? This cannot be undone!").arg(base.currentItem.name)
|
||||
;
|
||||
text: base.currentItem ? base.currentItem.removalWarning : "";
|
||||
onYes:
|
||||
{
|
||||
Cura.MachineManager.removeMachine(base.currentItem.id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue