Lipu Fei 6 лет назад
Родитель
Сommit
ec0b197b6e

+ 10 - 10
plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py

@@ -259,22 +259,26 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
     def _onNetworkRequestFinished(self, reply: "QNetworkReply") -> None:
         reply_url = reply.url().toString()
 
-        address = ""
+        address = reply.url().host()
         device = None
         properties = {}  # type: Dict[bytes, bytes]
 
-        if "system" in reply_url:
-            if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200:
-                # Something went wrong with checking the firmware version!
-                return
+        if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200:
+            # Either:
+            #  - Something went wrong with checking the firmware version!
+            #  - Something went wrong with checking the amount of printers the cluster has!
+            #  - Couldn't find printer at the address when trying to add it manually.
+            if address in self._manual_instances:
+                self.removeManualDeviceSignal.emit(self.getPluginId(), "", address)
+            return
 
+        if "system" in reply_url:
             try:
                 system_info = json.loads(bytes(reply.readAll()).decode("utf-8"))
             except:
                 Logger.log("e", "Something went wrong converting the JSON.")
                 return
 
-            address = reply.url().host()
             has_cluster_capable_firmware = Version(system_info["firmware"]) > self._min_cluster_version
             instance_name = "manual:%s" % address
             properties = {
@@ -302,16 +306,12 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
                 self._network_manager.get(cluster_request)
 
         elif "printers" in reply_url:
-            if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200:
-                # Something went wrong with checking the amount of printers the cluster has!
-                return
             # So we confirmed that the device is in fact a cluster printer, and we should now know how big it is.
             try:
                 cluster_printers_list = json.loads(bytes(reply.readAll()).decode("utf-8"))
             except:
                 Logger.log("e", "Something went wrong converting the JSON.")
                 return
-            address = reply.url().host()
             instance_name = "manual:%s" % address
             if instance_name in self._discovered_devices:
                 device = self._discovered_devices[instance_name]

+ 51 - 8
resources/qml/WelcomePages/AddPrinterByIpContent.qml

@@ -22,6 +22,8 @@ Item
     property bool hasSentRequest: false
     // Whether the IP address user entered can be resolved as a recognizable printer.
     property bool haveConnection: false
+    // True when a request comes back, but the device hasn't responded.
+    property bool deviceUnresponsive: false
 
     Label
     {
@@ -77,12 +79,14 @@ Item
                     anchors.right: addPrinterButton.left
                     anchors.margins: UM.Theme.getSize("default_margin").width
                     font: UM.Theme.getFont("default")
+                    selectByMouse: true
 
                     validator: RegExpValidator
                     {
                         regExp: /[a-fA-F0-9\.\:]*/
                     }
 
+                    enabled: { ! (addPrinterByIpScreen.hasSentRequest || addPrinterByIpScreen.haveConnection) }
                     onAccepted: addPrinterButton.clicked()
                 }
 
@@ -101,6 +105,7 @@ Item
                         if (hostnameField.text.trim() != "")
                         {
                             enabled = false;
+                            addPrinterByIpScreen.deviceUnresponsive = false;
                             UM.OutputDeviceManager.addManualDevice(hostnameField.text, hostnameField.text);
                         }
                     }
@@ -115,6 +120,12 @@ Item
                             ! addPrinterByIpScreen.haveConnection
                         }
                     }
+
+                    Connections
+                    {
+                        target: UM.OutputDeviceManager
+                        onManualDeviceChanged: { addPrinterButton.enabled = ! UM.OutputDeviceManager.hasManualDevice }
+                    }
                 }
             }
 
@@ -131,8 +142,22 @@ Item
                     anchors.margins: UM.Theme.getSize("default_margin").width
                     font: UM.Theme.getFont("default")
 
-                    visible: { addPrinterByIpScreen.hasSentRequest && ! addPrinterByIpScreen.haveConnection }
-                    text: catalog.i18nc("@label", "The printer at this address has not responded yet.")
+                    visible:
+                    {
+                        (addPrinterByIpScreen.hasSentRequest && ! addPrinterByIpScreen.haveConnection)
+                            || addPrinterByIpScreen.deviceUnresponsive
+                    }
+                    text:
+                    {
+                        if (addPrinterByIpScreen.deviceUnresponsive)
+                        {
+                            catalog.i18nc("@label", "Could not connect to device.")
+                        }
+                        else
+                        {
+                            catalog.i18nc("@label", "The printer at this address has not responded yet.")
+                        }
+                    }
                 }
 
                 Item
@@ -141,7 +166,7 @@ Item
                     anchors.top: parent.top
                     anchors.margins: UM.Theme.getSize("default_margin").width
 
-                    visible: addPrinterByIpScreen.haveConnection
+                    visible: addPrinterByIpScreen.haveConnection && ! addPrinterByIpScreen.deviceUnresponsive
 
                     Label
                     {
@@ -174,9 +199,18 @@ Item
                             target: UM.OutputDeviceManager
                             onManualDeviceChanged:
                             {
-                                typeText.text = UM.OutputDeviceManager.manualDeviceProperty("printer_type")
-                                firmwareText.text = UM.OutputDeviceManager.manualDeviceProperty("firmware_version")
-                                addressText.text = UM.OutputDeviceManager.manualDeviceProperty("address")
+                                if (UM.OutputDeviceManager.hasManualDevice)
+                                {
+                                    typeText.text = UM.OutputDeviceManager.manualDeviceProperty("printer_type")
+                                    firmwareText.text = UM.OutputDeviceManager.manualDeviceProperty("firmware_version")
+                                    addressText.text = UM.OutputDeviceManager.manualDeviceProperty("address")
+                                }
+                                else
+                                {
+                                    typeText.text = ""
+                                    firmwareText.text = ""
+                                    addressText.text = ""
+                                }
                             }
                         }
                     }
@@ -186,8 +220,17 @@ Item
                         target: UM.OutputDeviceManager
                         onManualDeviceChanged:
                         {
-                            printerNameLabel.text = UM.OutputDeviceManager.manualDeviceProperty("name")
-                            addPrinterByIpScreen.haveConnection = true
+                            if (UM.OutputDeviceManager.hasManualDevice)
+                            {
+                                printerNameLabel.text = UM.OutputDeviceManager.manualDeviceProperty("name")
+                                addPrinterByIpScreen.haveConnection = true
+                            }
+                            else
+                            {
+                                addPrinterByIpScreen.hasSentRequest = false
+                                addPrinterByIpScreen.haveConnection = false
+                                addPrinterByIpScreen.deviceUnresponsive = true
+                            }
                         }
                     }
                 }

+ 14 - 8
resources/qml/WelcomePages/CloudContent.qml

@@ -120,18 +120,24 @@ Item
         onClicked: Qt.openUrlExternally(CuraApplication.ultimakerCloudAccountRootUrl + "/app/create")
     }
 
-    Cura.SecondaryButton
+    Label
     {
         id: signInButton
         anchors.left: createAccountButton.right
         anchors.verticalCenter: finishButton.verticalCenter
+        anchors.margins: UM.Theme.getSize("welcome_pages_default_margin").width
         text: catalog.i18nc("@button", "Sign in")
-        width: UM.Theme.getSize("welcome_pages_button").width
-        shadowEnabled: false
-        color: "transparent"
-        hoverColor: "transparent"
-        textHoverColor: UM.Theme.getColor("primary")
-        fixedWidthMode: true
-        onClicked: Cura.API.account.login()
+        color: UM.Theme.getColor("secondary_button_text")
+        font: UM.Theme.getFont("medium")
+        renderType: Text.NativeRendering
+
+        MouseArea
+        {
+            anchors.fill: parent
+            hoverEnabled: true
+            onClicked: Cura.API.account.login()
+            onEntered: parent.font.underline = true
+            onExited: parent.font.underline = false
+        }
     }
 }

+ 28 - 19
resources/qml/WelcomePages/DataCollectionsContent.qml

@@ -28,30 +28,39 @@ Item
         renderType: Text.NativeRendering
     }
 
-    Column
+    // Area where the cloud contents can be put. Pictures, texts and such.
+    Item
     {
+        id: contentsArea
         anchors.top: titleLabel.bottom
-        anchors.topMargin: 80
-        anchors.horizontalCenter: parent.horizontalCenter
-
-        spacing: 60
+        anchors.bottom: getStartedButton.top
+        anchors.left: parent.left
+        anchors.right: parent.right
+        anchors.margins: UM.Theme.getSize("default_margin").width
 
-        Image
+        Column
         {
-            id: curaImage
-            anchors.horizontalCenter: parent.horizontalCenter
-            source: UM.Theme.getImage("first_run_share_data")
-        }
+            anchors.centerIn: parent
 
-        Label
-        {
-            id: textLabel
-            anchors.horizontalCenter: parent.horizontalCenter
-            horizontalAlignment: Text.AlignHCenter
-            text: catalog.i18nc("@text", "Ultimaker Cura collects anonymous data to improve print quality<br/>and user experience. <a href=\"TODO\">More information</a>")
-            textFormat: Text.RichText
-            font: UM.Theme.getFont("medium")
-            renderType: Text.NativeRendering
+            spacing: UM.Theme.getSize("welcome_pages_default_margin").height
+
+            Image
+            {
+                id: curaImage
+                anchors.horizontalCenter: parent.horizontalCenter
+                source: UM.Theme.getImage("first_run_share_data")
+            }
+
+            Label
+            {
+                id: textLabel
+                anchors.horizontalCenter: parent.horizontalCenter
+                horizontalAlignment: Text.AlignHCenter
+                text: catalog.i18nc("@text", "Ultimaker Cura collects anonymous data to improve print quality<br/>and user experience. <a href=\"TODO\">More information</a>")
+                textFormat: Text.RichText
+                font: UM.Theme.getFont("medium")
+                renderType: Text.NativeRendering
+            }
         }
     }
 

+ 3 - 1
resources/qml/WelcomePages/DropDownWidget.qml

@@ -74,7 +74,9 @@ Item
             anchors.top: parent.top
             anchors.left: parent.left
             anchors.right: parent.right
-            anchors.margins: 1
+            // Keep a small margin with the Rectangle container so its content will not overlap with the Rectangle
+            // border.
+            anchors.margins: UM.Theme.getSize("default_lining").width
             sourceComponent: base.contentComponent != null ? base.contentComponent : emptyComponent
         }
 

+ 2 - 5
resources/qml/WelcomePages/StepPanel.qml

@@ -39,7 +39,8 @@ Item
         {
             currentStep++
         }
-        else {
+        else
+        {
             passLastPage()
         }
     }
@@ -69,10 +70,6 @@ Item
         {
             currentStep = page_index
         }
-        else
-        {
-            console.log("Error: cannot find page with page_id = [", page_id, "]")
-        }
     }
 
     onVisibleChanged:

+ 23 - 22
resources/qml/WelcomePages/UserAgreementContent.qml

@@ -12,36 +12,37 @@ import Cura 1.1 as Cura
 //
 Item
 {
-    Column
+    UM.I18nCatalog { id: catalog; name: "cura" }
+
+    Label
     {
+        id: titleLabel
         anchors.top: parent.top
+        anchors.topMargin: UM.Theme.getSize("welcome_pages_default_margin").height
+        anchors.horizontalCenter: parent.horizontalCenter
+        horizontalAlignment: Text.AlignHCenter
+        text: catalog.i18nc("@label", "User Agreement")
+        color: UM.Theme.getColor("primary_button")
+        font: UM.Theme.getFont("large_bold")
+        renderType: Text.NativeRendering
+    }
+
+    Item  // Area for pictures and texts
+    {
+        anchors.top: titleLabel.bottom
+        anchors.bottom: agreeButton.top
         anchors.left: parent.left
         anchors.right: parent.right
-        anchors.margins: 20
-
-        UM.I18nCatalog { id: catalog; name: "cura" }
-
-        spacing: 40
-
-        // Placeholder
-        Label { text: " " }
-
-        Label
-        {
-            id: titleLabel
-            anchors.horizontalCenter: parent.horizontalCenter
-            horizontalAlignment: Text.AlignHCenter
-            text: catalog.i18nc("@label", "User Agreement")
-            color: UM.Theme.getColor("primary_button")
-            font: UM.Theme.getFont("large_bold")
-            renderType: Text.NativeRendering
-        }
+        anchors.margins: UM.Theme.getSize("welcome_pages_default_margin").width
 
         Label
         {
-            width: parent.width * 2 / 3
             id: disclaimerLineLabel
-            anchors.horizontalCenter: parent.horizontalCenter
+            anchors.centerIn: parent
+            anchors.margins: UM.Theme.getSize("welcome_pages_default_margin").width
+
+            width: (parent.width * 2 / 3) | 0
+
             text: "<p><b>Disclaimer by Ultimaker</b></p>"
                 + "<p>Please read this disclaimer carefully.</p>"
                 + "<p>Except when otherwise stated in writing, Ultimaker provides any Ultimaker software or third party software \"As is\" without warranty of any kind. The entire risk as to the quality and perfoemance of Ultimaker software is with you.</p>"

+ 26 - 27
resources/qml/WelcomePages/WelcomeContent.qml

@@ -11,30 +11,28 @@ import Cura 1.1 as Cura
 //
 // This component contains the content for the "Welcome" page of the welcome on-boarding process.
 //
-Column
+Item
 {
     UM.I18nCatalog { id: catalog; name: "cura" }
 
-    spacing: 60
+    anchors.margins: UM.Theme.getSize("welcome_pages_default_margin").width
 
-    // Placeholder
-    Label { text: " " }
-
-    Label
+    Column  // Arrange the items vertically and put everything in the center
     {
-        id: titleLabel
-        anchors.horizontalCenter: parent.horizontalCenter
-        horizontalAlignment: Text.AlignHCenter
-        text: catalog.i18nc("@label", "Welcome to Ultimaker Cura")
-        color: UM.Theme.getColor("primary_button")
-        font: UM.Theme.getFont("large_bold")
-        renderType: Text.NativeRendering
-    }
+        anchors.centerIn: parent
+        width: parent.width
+        spacing: UM.Theme.getSize("welcome_pages_default_margin").height
 
-    Column
-    {
-        anchors.horizontalCenter: parent.horizontalCenter
-        spacing: 40
+        Label
+        {
+            id: titleLabel
+            anchors.horizontalCenter: parent.horizontalCenter
+            horizontalAlignment: Text.AlignHCenter
+            text: catalog.i18nc("@label", "Welcome to Ultimaker Cura")
+            color: UM.Theme.getColor("primary_button")
+            font: UM.Theme.getFont("large_bold")
+            renderType: Text.NativeRendering
+        }
 
         Image
         {
@@ -52,15 +50,16 @@ Column
             font: UM.Theme.getFont("medium")
             renderType: Text.NativeRendering
         }
-    }
 
-    Cura.PrimaryButton
-    {
-        id: getStartedButton
-        anchors.horizontalCenter: parent.horizontalCenter
-        text: catalog.i18nc("@button", "Get started")
-        width: UM.Theme.getSize("welcome_pages_button").width
-        fixedWidthMode: true
-        onClicked: base.showNextPage()
+        Cura.PrimaryButton
+        {
+            id: getStartedButton
+            anchors.horizontalCenter: parent.horizontalCenter
+            anchors.margins: UM.Theme.getSize("welcome_pages_default_margin").width
+            text: catalog.i18nc("@button", "Get started")
+            width: UM.Theme.getSize("welcome_pages_button").width
+            fixedWidthMode: true
+            onClicked: base.showNextPage()
+        }
     }
 }

+ 2 - 2
resources/qml/WelcomePages/WhatsNewContent.qml

@@ -32,8 +32,8 @@ Item
     {
         anchors.top: titleLabel.bottom
         anchors.bottom: getStartedButton.top
-        anchors.topMargin: 40
-        anchors.bottomMargin: 40
+        anchors.topMargin: UM.Theme.getSize("welcome_pages_default_margin").height
+        anchors.bottomMargin: UM.Theme.getSize("welcome_pages_default_margin").height
         anchors.horizontalCenter: parent.horizontalCenter
         width: parent.width * 3 / 4