Browse Source

Fix manual printer device not up-to-date

CURA-6483
Lipu Fei 5 years ago
parent
commit
0575fd283e
1 changed files with 23 additions and 0 deletions
  1. 23 0
      resources/qml/WelcomePages/AddPrinterByIpContent.qml

+ 23 - 0
resources/qml/WelcomePages/AddPrinterByIpContent.qml

@@ -22,6 +22,7 @@ Item
     property bool hasRequestInProgress: CuraApplication.getDiscoveredPrintersModel().hasManualDeviceRequestInProgress
     // Indicates if a request has finished.
     property bool hasRequestFinished: false
+    property string currentRequestAddress: ""
 
     property var discoveredPrinter: null
     property bool isPrinterDiscovered: discoveredPrinter != null
@@ -31,6 +32,26 @@ Item
     // For validating IP address
     property var networkingUtil: Cura.NetworkingUtil {}
 
+    // CURA-6483
+    // For a manually added UM printer, the UM3OutputDevicePlugin will first create a LegacyUM device for it. Later,
+    // when it gets more info from the printer, it will first REMOVE the LegacyUM device and then add a ClusterUM device.
+    // The Add-by-IP page needs to make sure that the user do not add an unknown printer or a printer that's not the
+    // host of a group. Because of the device list change, this page needs to react upon DiscoveredPrintersChanged so
+    // it has the correct information.
+    Connections
+    {
+        target: CuraApplication.getDiscoveredPrintersModel()
+        onDiscoveredPrintersChanged:
+        {
+            if (hasRequestFinished && currentRequestAddress)
+            {
+                var printer = CuraApplication.getDiscoveredPrintersModel().discoveredPrintersByAddress[currentRequestAddress]
+                printer = printer ? printer : null
+                discoveredPrinter = printer
+            }
+        }
+    }
+
     // Make sure to cancel the current request when this page closes.
     onVisibleChanged:
     {
@@ -149,9 +170,11 @@ Item
                         if (CuraApplication.getDiscoveredPrintersModel().discoveredPrintersByAddress[address])
                         {
                             addPrinterByIpScreen.discoveredPrinter = CuraApplication.getDiscoveredPrintersModel().discoveredPrintersByAddress[address]
+                            addPrinterByIpScreen.hasRequestFinished = true
                             return
                         }
 
+                        addPrinterByIpScreen.currentRequestAddress = address
                         CuraApplication.getDiscoveredPrintersModel().checkManualDevice(address)
                     }
                     busy: addPrinterByIpScreen.hasRequestInProgress