Просмотр исходного кода

Hide "Request Access" buttons when access request is active

CURA-2277 & CURA-2276
fieldOfView 8 лет назад
Родитель
Сommit
20f76b62fe
2 измененных файлов с 24 добавлено и 18 удалено
  1. 9 1
      NetworkPrinterOutputDevice.py
  2. 15 17
      UM3InfoComponents.qml

+ 9 - 1
NetworkPrinterOutputDevice.py

@@ -242,7 +242,15 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
             self._authentication_timer.stop()
             self._authentication_counter = 0
 
-        self._authentication_state = auth_state
+        if auth_state != self._authentication_state:
+            self._authentication_state = auth_state
+            self.authenticationStateChanged.emit()
+
+    authenticationStateChanged = pyqtSignal()
+
+    @pyqtProperty(int, notify = authenticationStateChanged)
+    def authenticationState(self):
+        return self._authentication_state
 
     @pyqtSlot()
     def requestAuthentication(self, message_id = None, action_id = "Retry"):

+ 15 - 17
UM3InfoComponents.qml

@@ -13,6 +13,7 @@ Item
     property bool isUM3: Cura.MachineManager.activeDefinitionId == "ultimaker3"
     property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
     property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
+    property bool authenticationRequested: printerConnected && Cura.MachineManager.printerOutputDevices[0].authenticationState == 2 // AuthState.AuthenticationRequested
 
     Row
     {
@@ -27,7 +28,7 @@ Item
             text: catalog.i18nc("@action:button", "Request Access")
             style: UM.Theme.styles.sidebar_action_button
             onClicked: Cura.MachineManager.printerOutputDevices[0].requestAuthentication()
-            visible: base.printerConnected && !base.printerAcceptsCommands
+            visible: !base.printerAcceptsCommands && !base.authenticationRequested
         }
 
         Button
@@ -66,6 +67,14 @@ Item
         spacing: UM.Theme.getSize("default_margin").width
         anchors.fill: parent
 
+        Button
+        {
+            tooltip: catalog.i18nc("@info:tooltip", "Send access request to the printer")
+            text: catalog.i18nc("@action:button", "Request Access")
+            onClicked: Cura.MachineManager.printerOutputDevices[0].requestAuthentication()
+            visible: !base.printerAcceptsCommands && !base.authenticationRequested
+        }
+
         Row
         {
             visible: base.printerConnected
@@ -103,23 +112,12 @@ Item
             }
         }
 
-        Row
+        Button
         {
-            Button
-            {
-                tooltip: catalog.i18nc("@info:tooltip", "Load the configuration of the printer into Cura")
-                text: catalog.i18nc("@action:button", "Activate Configuration")
-                visible: base.printerConnected
-                onClicked: manager.loadConfigurationFromPrinter()
-            }
-
-            Button
-            {
-                tooltip: catalog.i18nc("@info:tooltip", "Send access request to the printer")
-                text: catalog.i18nc("@action:button", "Request Access")
-                onClicked: Cura.MachineManager.printerOutputDevices[0].requestAuthentication()
-                visible: base.printerConnected && !base.printerAcceptsCommands
-            }
+            tooltip: catalog.i18nc("@info:tooltip", "Load the configuration of the printer into Cura")
+            text: catalog.i18nc("@action:button", "Activate Configuration")
+            visible: base.printerConnected
+            onClicked: manager.loadConfigurationFromPrinter()
         }
     }