mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-10-01 05:03:12 +08:00
Fix connect via network dialog
CURA-6483 - Do not add printers that have already been discovered - Add IP address validation check
This commit is contained in:
parent
99ec1761e9
commit
3578482ea5
@ -1,8 +1,8 @@
|
|||||||
// Copyright (c) 2018 Ultimaker B.V.
|
// Copyright (c) 2019 Ultimaker B.V.
|
||||||
// Cura is released under the terms of the LGPLv3 or higher.
|
// Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import UM 1.2 as UM
|
import UM 1.2 as UM
|
||||||
import Cura 1.0 as Cura
|
import Cura 1.5 as Cura
|
||||||
|
|
||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
import QtQuick.Controls 1.1
|
import QtQuick.Controls 1.1
|
||||||
@ -14,9 +14,13 @@ Cura.MachineAction
|
|||||||
{
|
{
|
||||||
id: base
|
id: base
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
|
property alias currentItemIndex: listview.currentIndex
|
||||||
property var selectedDevice: null
|
property var selectedDevice: null
|
||||||
property bool completeProperties: true
|
property bool completeProperties: true
|
||||||
|
|
||||||
|
// For validating IP addresses
|
||||||
|
property var networkingUtil: Cura.NetworkingUtil {}
|
||||||
|
|
||||||
function connectToPrinter()
|
function connectToPrinter()
|
||||||
{
|
{
|
||||||
if(base.selectedDevice && base.completeProperties)
|
if(base.selectedDevice && base.completeProperties)
|
||||||
@ -342,6 +346,17 @@ Cura.MachineAction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageDialog
|
||||||
|
{
|
||||||
|
id: invalidIPAddressMessageDialog
|
||||||
|
x: ((parent.width - width) / 2) | 0
|
||||||
|
y: ((parent.height - height) / 2) | 0
|
||||||
|
title: catalog.i18nc("@title:window", "Invalid IP address")
|
||||||
|
text: catalog.i18nc("@text", "Please enter a valid IP address.")
|
||||||
|
icon: StandardIcon.Warning
|
||||||
|
standardButtons: StandardButton.Ok
|
||||||
|
}
|
||||||
|
|
||||||
UM.Dialog
|
UM.Dialog
|
||||||
{
|
{
|
||||||
id: manualPrinterDialog
|
id: manualPrinterDialog
|
||||||
@ -404,6 +419,26 @@ Cura.MachineAction
|
|||||||
text: catalog.i18nc("@action:button", "OK")
|
text: catalog.i18nc("@action:button", "OK")
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
|
// Validate the input first
|
||||||
|
if (!networkingUtil.isValidIP(manualPrinterDialog.addressText))
|
||||||
|
{
|
||||||
|
invalidIPAddressMessageDialog.open()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the entered IP address has already been discovered, switch the current item to that item
|
||||||
|
// and do nothing else.
|
||||||
|
for (var i = 0; i < manager.foundDevices.length; i++)
|
||||||
|
{
|
||||||
|
var device = manager.foundDevices[i]
|
||||||
|
if (device.address == manualPrinterDialog.addressText)
|
||||||
|
{
|
||||||
|
currentItemIndex = i
|
||||||
|
manualPrinterDialog.hide()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
manager.setManualDevice(manualPrinterDialog.printerKey, manualPrinterDialog.addressText)
|
manager.setManualDevice(manualPrinterDialog.printerKey, manualPrinterDialog.addressText)
|
||||||
manualPrinterDialog.hide()
|
manualPrinterDialog.hide()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user