From 113c37f555a40ab42f90c2fae644e33f9fd09561 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Fri, 1 Mar 2019 13:17:15 +0100 Subject: [PATCH 1/2] Start work on 'AddPrinterByIp' for WelcomePages. [CURA-6057] --- cura/UI/WelcomePagesModel.py | 8 +- .../resources/qml/DiscoverUM3Action.qml | 2 +- .../WelcomePages/AddPrinterByIpContent.qml | 169 ++++++++++++++++++ 3 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 resources/qml/WelcomePages/AddPrinterByIpContent.qml diff --git a/cura/UI/WelcomePagesModel.py b/cura/UI/WelcomePagesModel.py index e85cb53a4a..a1b5c6b602 100644 --- a/cura/UI/WelcomePagesModel.py +++ b/cura/UI/WelcomePagesModel.py @@ -11,7 +11,6 @@ from UM.Resources import Resources if TYPE_CHECKING: from PyQt5.QtCore import QObject - class WelcomePagesModel(ListModel): IdRole = Qt.UserRole + 1 # Page ID @@ -50,16 +49,19 @@ class WelcomePagesModel(ListModel): os.path.join("WelcomePages", "DataCollectionsContent.qml"))), }) + self._pages.append({"id": "add_printer_by_ip", + "page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, + os.path.join("WelcomePages", + "AddPrinterByIpContent.qml"))), + }) self._pages.append({"id": "cloud", "page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, os.path.join("WelcomePages", "CloudContent.qml"))), }) - self.setItems(self._pages) def addPage(self): pass - __all__ = ["WelcomePagesModel"] diff --git a/plugins/UM3NetworkPrinting/resources/qml/DiscoverUM3Action.qml b/plugins/UM3NetworkPrinting/resources/qml/DiscoverUM3Action.qml index 3883a7e285..2788a35173 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/DiscoverUM3Action.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/DiscoverUM3Action.qml @@ -371,7 +371,7 @@ Cura.MachineAction Label { - text: catalog.i18nc("@alabel", "Enter the IP address or hostname of your printer on the network.") + text: catalog.i18nc("@label", "Enter the IP address or hostname of your printer on the network.") width: parent.width wrapMode: Text.WordWrap renderType: Text.NativeRendering diff --git a/resources/qml/WelcomePages/AddPrinterByIpContent.qml b/resources/qml/WelcomePages/AddPrinterByIpContent.qml new file mode 100644 index 0000000000..7cb98c5dde --- /dev/null +++ b/resources/qml/WelcomePages/AddPrinterByIpContent.qml @@ -0,0 +1,169 @@ +// Copyright (c) 2019 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 +import QtQuick.Controls 2.3 + +import UM 1.3 as UM +import Cura 1.1 as Cura + + +// +// This component contains the content for the 'by IP' page of the "Add New Printer" flow of the on-boarding process. +// +Item +{ + UM.I18nCatalog { id: catalog; name: "cura" } + + Label + { + id: titleLabel + anchors.top: parent.top + anchors.topMargin: 40 + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + text: catalog.i18nc("@label", "Add printer by IP adress") + color: UM.Theme.getColor("primary_button") + font: UM.Theme.getFont("large_bold") + renderType: Text.NativeRendering + } + + Rectangle + { + anchors.top: titleLabel.bottom + anchors.bottom: connectButton.top + anchors.topMargin: 40 + anchors.bottomMargin: 40 + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width * 3 / 4 + + border.color: "#dfdfdf" + border.width: 1 + + Item + { + width: parent.width + //anchors.top: parent.top + //anchors.topMargin: 20 + //anchors.bottomMargin: 20 + + Label + { + id: explainLabel + height: contentHeight + width: parent.width + anchors.top: parent.top + anchors.margins: 20 + //anchors.bottomMargin: 20 + + text: catalog.i18nc("@label", "Enter the IP address or hostname of your printer on the network.") + } + + Item + { + id: userInputFields + height: childrenRect.height + width: parent.width + anchors.top: explainLabel.bottom + + TextField + { + id: hostnameField + anchors.top: parent.top + anchors.left: parent.left + //anchors.bottom: parent.bottom + anchors.right: addPrinterButton.left + anchors.margins: 20 + //width: parent.width / 2 + //horizontalAlignment: Text.AlignLeft + + //editable: true + text: "" + + //validator: RegExpValidator + //{ + // regExp: /[a-zA-Z0-9\.\-\_]*/ + //} + + onAccepted: addPrinterButton.clicked() + } + + Cura.PrimaryButton + { + id: addPrinterButton + anchors.top: parent.top + anchors.right: parent.right + //anchors.bottom: parent.bottom + anchors.margins: 20 + width: 140 + fixedWidthMode: true + + text: catalog.i18nc("@button", "Add") + onClicked: + { + // fire off method, then wait for event + + + // manager.setManualDevice(manualPrinterDialog.printerKey, manualPrinterDialog.addressText) // manager not defined + // manualPrinterDialog.hide() + } + //enabled: hostnameField.trim() != "" + } + } + + Rectangle + { + width: parent.width + anchors.top: userInputFields.bottom + + Label + { + id: visTestA + anchors.top: parent.top + anchors.margins: 20 + + visible: false + text: catalog.i18nc("@label", "The printer at this address has not responded yet.") + } + + Label + { + id: visTestB + anchors.top: parent.top + anchors.margins: 20 + + visible: true + text: "PLACEHOLDER" + } + } + } + } + + Cura.PrimaryButton + { + id: backButton + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.margins: 40 + text: catalog.i18nc("@button", "Back") + width: 140 + fixedWidthMode: true + onClicked: base.showPreviousPage() // TODO? + + enabled: true // TODO + } + + Cura.PrimaryButton + { + id: connectButton + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.margins: 40 + text: catalog.i18nc("@button", "Connect") + width: 140 + fixedWidthMode: true + onClicked: base.showNextPage() + + enabled: false // TODO + } +} From 3c0583bef08e8bf91dd0664dd89502498e76f23b Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Wed, 6 Mar 2019 14:05:42 +0100 Subject: [PATCH 2/2] [AddPrinterByIp] Finish GUI as a facade first for review. [CURA-6057] --- cura/UI/WelcomePagesModel.py | 6 +- .../WelcomePages/AddPrinterByIpContent.qml | 135 ++++++++++++++---- 2 files changed, 109 insertions(+), 32 deletions(-) diff --git a/cura/UI/WelcomePagesModel.py b/cura/UI/WelcomePagesModel.py index a1b5c6b602..b22fc31408 100644 --- a/cura/UI/WelcomePagesModel.py +++ b/cura/UI/WelcomePagesModel.py @@ -1,5 +1,5 @@ - - +# Copyright (c) 2019 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. import os from typing import TYPE_CHECKING, Optional @@ -60,6 +60,8 @@ class WelcomePagesModel(ListModel): "CloudContent.qml"))), }) + self.setItems(self._pages) + def addPage(self): pass diff --git a/resources/qml/WelcomePages/AddPrinterByIpContent.qml b/resources/qml/WelcomePages/AddPrinterByIpContent.qml index 7cb98c5dde..25a6d532ce 100644 --- a/resources/qml/WelcomePages/AddPrinterByIpContent.qml +++ b/resources/qml/WelcomePages/AddPrinterByIpContent.qml @@ -3,6 +3,7 @@ import QtQuick 2.10 import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 import UM 1.3 as UM import Cura 1.1 as Cura @@ -15,6 +16,53 @@ Item { UM.I18nCatalog { id: catalog; name: "cura" } + id: addPrinterByIpScreen + + property bool hasPushedAdd: false + property bool hasSentRequest: false + property bool haveConnection: false + + Timer + { + id: tempTimerButton + + interval: 1200 + running: false + repeat: false + onTriggered: + { + hasPushedAdd = true + tempTimerRequest.running = true + } + } + // TODO: Remove timers after review interface! + + Timer + { + id: tempTimerRequest + + interval: 1200 + running: false + repeat: false + onTriggered: + { + hasSentRequest = true + tempTimerConnection.running = true + } + } + // TODO: Remove timers after review interface! + + Timer + { + id: tempTimerConnection + + interval: 1200 + running: false + repeat: false + onTriggered: haveConnection = true + } + // TODO: Remove timers after review interface! + Label { id: titleLabel @@ -37,15 +85,9 @@ Item anchors.horizontalCenter: parent.horizontalCenter width: parent.width * 3 / 4 - border.color: "#dfdfdf" - border.width: 1 - Item { width: parent.width - //anchors.top: parent.top - //anchors.topMargin: 20 - //anchors.bottomMargin: 20 Label { @@ -55,6 +97,7 @@ Item anchors.top: parent.top anchors.margins: 20 //anchors.bottomMargin: 20 + font: UM.Theme.getFont("default") text: catalog.i18nc("@label", "Enter the IP address or hostname of your printer on the network.") } @@ -69,21 +112,19 @@ Item TextField { id: hostnameField - anchors.top: parent.top + anchors.verticalCenter: addPrinterButton.verticalCenter anchors.left: parent.left - //anchors.bottom: parent.bottom + height: addPrinterButton.height anchors.right: addPrinterButton.left anchors.margins: 20 - //width: parent.width / 2 - //horizontalAlignment: Text.AlignLeft + font: UM.Theme.getFont("default") - //editable: true text: "" - //validator: RegExpValidator - //{ - // regExp: /[a-zA-Z0-9\.\-\_]*/ - //} + validator: RegExpValidator + { + regExp: /[a-zA-Z0-9\.\-\_]*/ + } onAccepted: addPrinterButton.clicked() } @@ -93,7 +134,6 @@ Item id: addPrinterButton anchors.top: parent.top anchors.right: parent.right - //anchors.bottom: parent.bottom anchors.margins: 20 width: 140 fixedWidthMode: true @@ -101,13 +141,22 @@ Item text: catalog.i18nc("@button", "Add") onClicked: { - // fire off method, then wait for event + // TEMP: Simulate successfull connection to printer with 127.0.0.1 or unsuccessful with anything else + // TODO, alter after review interface, now it just starts the timers. - - // manager.setManualDevice(manualPrinterDialog.printerKey, manualPrinterDialog.addressText) // manager not defined - // manualPrinterDialog.hide() + if (hostnameField.text.trim() != "") + { + addPrinterByIpScreen.hasPushedAdd = true + tempTimerRequest.running = true + } + } + + enabled: ! addPrinterByIpScreen.hasPushedAdd + BusyIndicator + { + anchors.fill: parent + running: { ! parent.enabled && ! addPrinterByIpScreen.hasSentRequest } } - //enabled: hostnameField.trim() != "" } } @@ -115,25 +164,51 @@ Item { width: parent.width anchors.top: userInputFields.bottom + anchors.margins: 20 Label { - id: visTestA + id: waitResponseLabel anchors.top: parent.top anchors.margins: 20 + font: UM.Theme.getFont("default") - visible: false + visible: { addPrinterByIpScreen.hasSentRequest && ! addPrinterByIpScreen.haveConnection } text: catalog.i18nc("@label", "The printer at this address has not responded yet.") } - Label + Rectangle { - id: visTestB + id: printerInfoLabels anchors.top: parent.top anchors.margins: 20 - visible: true - text: "PLACEHOLDER" + visible: addPrinterByIpScreen.haveConnection + + Label + { + id: printerNameLabel + anchors.top: parent.top + font: UM.Theme.getFont("large") + + text: "Davids-desktop" // TODO: placeholder, alter after interface review. + } + + GridLayout + { + anchors.top: printerNameLabel.bottom + columns: 2 + columnSpacing: 20 + + Text { font: UM.Theme.getFont("default"); text: "Type" } + Text { font: UM.Theme.getFont("default"); text: "Ultimaker S5" } // TODO: placeholder, alter after interface review. + + Text { font: UM.Theme.getFont("default"); text: "Firmware version" } + Text { font: UM.Theme.getFont("default"); text: "4.3.3.20180529" } // TODO: placeholder, alter after interface review. + + Text { font: UM.Theme.getFont("default"); text: "Address" } + Text { font: UM.Theme.getFont("default"); text: "10.183.1.115" } // TODO: placeholder, alter after interface review. + } } } } @@ -148,9 +223,9 @@ Item text: catalog.i18nc("@button", "Back") width: 140 fixedWidthMode: true - onClicked: base.showPreviousPage() // TODO? + onClicked: base.showPreviousPage() - enabled: true // TODO + enabled: true } Cura.PrimaryButton @@ -164,6 +239,6 @@ Item fixedWidthMode: true onClicked: base.showNextPage() - enabled: false // TODO + enabled: addPrinterByIpScreen.haveConnection } }