From 2b5d78a01af1ffb0c0ff58efdf81cbb39c1990d6 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 1 May 2019 14:24:58 +0200 Subject: [PATCH] Do not add unknown or non-host printers in add-by-ip CURA-6483 --- .../WelcomePages/AddPrinterByIpContent.qml | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/resources/qml/WelcomePages/AddPrinterByIpContent.qml b/resources/qml/WelcomePages/AddPrinterByIpContent.qml index 663cd83de8..13c87eccd8 100644 --- a/resources/qml/WelcomePages/AddPrinterByIpContent.qml +++ b/resources/qml/WelcomePages/AddPrinterByIpContent.qml @@ -24,7 +24,9 @@ Item property bool hasRequestFinished: false property var discoveredPrinter: null - property var isPrinterDiscovered: discoveredPrinter != null + property bool isPrinterDiscovered: discoveredPrinter != null + // A printer can only be added if it doesn't have an unknown type and it's the host of a group. + property bool canAddPrinter: isPrinterDiscovered && !discoveredPrinter.isUnknownMachineType && discoveredPrinter.isHostOfGroup // For validating IP address property var networkingUtil: Cura.NetworkingUtil {} @@ -188,6 +190,8 @@ Item Item { id: printerInfoLabels + anchors.left: parent.left + anchors.right: parent.right anchors.top: parent.top anchors.margins: UM.Theme.getSize("default_margin").width @@ -204,10 +208,24 @@ Item text: !addPrinterByIpScreen.isPrinterDiscovered ? "???" : addPrinterByIpScreen.discoveredPrinter.name } + Label + { + id: printerCannotBeAddedLabel + width: parent.width + anchors.top: printerNameLabel.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + text: catalog.i18nc("@label", "This printer cannot be added because it's an unknown printer or it's not the host of a group.") + visible: addPrinterByIpScreen.hasRequestFinished && !addPrinterByIpScreen.canAddPrinter + font: UM.Theme.getFont("default_bold") + color: UM.Theme.getColor("text") + renderType: Text.NativeRendering + wrapMode: Text.WordWrap + } + GridLayout { id: printerInfoGrid - anchors.top: printerNameLabel.bottom + anchors.top: printerCannotBeAddedLabel ? printerCannotBeAddedLabel.bottom : printerNameLabel.bottom anchors.margins: UM.Theme.getSize("default_margin").width columns: 2 columnSpacing: UM.Theme.getSize("default_margin").width @@ -305,6 +323,6 @@ Item base.showNextPage() } - enabled: addPrinterByIpScreen.isPrinterDiscovered + enabled: addPrinterByIpScreen.canAddPrinter } }