diff --git a/cura/UI/MachineModels/DiscoveredPrintersModel.py b/cura/UI/MachineModels/DiscoveredPrintersModel.py index 15d002298c..e127ba48af 100644 --- a/cura/UI/MachineModels/DiscoveredPrintersModel.py +++ b/cura/UI/MachineModels/DiscoveredPrintersModel.py @@ -88,7 +88,7 @@ class DiscoveredPrintersModel(QObject): discoveredPrintersChanged = pyqtSignal() @pyqtProperty(list, notify = discoveredPrintersChanged) - def discovered_printers(self) -> "List[DiscoveredPrinter]": + def discovered_printers(self) -> List["DiscoveredPrinter"]: item_list = list(x for x in self._discovered_printer_by_ip_dict.values()) item_list.sort(key = lambda x: x.name) return item_list @@ -125,6 +125,8 @@ class DiscoveredPrintersModel(QObject): del self._discovered_printer_by_ip_dict[ip_address] self.discoveredPrintersChanged.emit() + # A convenience function for QML to create a machine (GlobalStack) out of the given discovered printer. + # This function invokes the given discovered printer's "create_callback" to do this. @pyqtSlot("QVariant") def createMachineFromDiscoveredPrinter(self, discovered_printer: "DiscoveredPrinter") -> None: discovered_printer.create_callback(discovered_printer.getKey()) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index 3217e3be9d..60ffe477bc 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -1,24 +1,25 @@ # Copyright (c) 2019 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import json +import os from queue import Queue from threading import Event, Thread from time import time -import os -from typing import Optional, TYPE_CHECKING +from typing import Optional, TYPE_CHECKING, Dict from zeroconf import Zeroconf, ServiceBrowser, ServiceStateChange, ServiceInfo + from PyQt5.QtNetwork import QNetworkRequest, QNetworkAccessManager from PyQt5.QtCore import QUrl from PyQt5.QtGui import QDesktopServices from cura.CuraApplication import CuraApplication from cura.PrinterOutput.PrinterOutputDevice import ConnectionType -from UM.OutputDevice.OutputDeviceManager import ManualDeviceAdditionAttempt from UM.i18n import i18nCatalog from UM.Logger import Logger from UM.Message import Message +from UM.OutputDevice.OutputDeviceManager import ManualDeviceAdditionAttempt from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin from UM.PluginRegistry import PluginRegistry from UM.Signal import Signal, signalemitter @@ -28,6 +29,7 @@ from . import ClusterUM3OutputDevice, LegacyUM3OutputDevice from .Cloud.CloudOutputDeviceManager import CloudOutputDeviceManager if TYPE_CHECKING: + from PyQt5.QtNetwork import QNetworkReply from cura.Settings.GlobalStack import GlobalStack from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin @@ -254,7 +256,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): name_request = QNetworkRequest(url) self._network_manager.get(name_request) - def _onNetworkRequestFinished(self, reply): + def _onNetworkRequestFinished(self, reply: "QNetworkReply") -> None: reply_url = reply.url().toString() address = "" @@ -324,7 +326,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): self.getOutputDeviceManager().addOutputDevice(device) self.addManualDeviceSignal.emit(self.getPluginId(), device.getId(), address, properties) - def _onRemoveDevice(self, device_id): + def _onRemoveDevice(self, device_id: str) -> None: device = self._discovered_devices.pop(device_id, None) if device: if device.isConnected(): diff --git a/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml b/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml index 7ad0f5c96c..f8db8b297e 100644 --- a/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml +++ b/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml @@ -16,10 +16,13 @@ ScrollView { id: base + // The currently selected machine item in the local machine list. property var currentItem: (machineList.currentIndex >= 0) ? machineList.model.getItem(machineList.currentIndex) : null + // The currently active (expanded) section/category, where section/category is the grouping of local machine items. property string currentSection: preferredCategory + // By default (when this list shows up) we always expand the "Ultimaker" section. property string preferredCategory: "Ultimaker" ScrollBar.horizontal.policy: ScrollBar.AlwaysOff diff --git a/resources/qml/WelcomePages/AddNetworkPrinterScrollView.qml b/resources/qml/WelcomePages/AddNetworkPrinterScrollView.qml index b27e4db1fe..575ec9c126 100644 --- a/resources/qml/WelcomePages/AddNetworkPrinterScrollView.qml +++ b/resources/qml/WelcomePages/AddNetworkPrinterScrollView.qml @@ -91,7 +91,7 @@ Item anchors.left: parent.left anchors.right: parent.right - anchors.rightMargin: 10 + anchors.rightMargin: UM.Theme.getSize("default_margin").width outputDevice: modelData.device enabled: !modelData.is_unknown_machine_type