mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-07 14:04:03 -06: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 changed files with 37 additions and 2 deletions
|
@ -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.
|
||||
|
||||
import UM 1.2 as UM
|
||||
import Cura 1.0 as Cura
|
||||
import Cura 1.5 as Cura
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.1
|
||||
|
@ -14,9 +14,13 @@ Cura.MachineAction
|
|||
{
|
||||
id: base
|
||||
anchors.fill: parent;
|
||||
property alias currentItemIndex: listview.currentIndex
|
||||
property var selectedDevice: null
|
||||
property bool completeProperties: true
|
||||
|
||||
// For validating IP addresses
|
||||
property var networkingUtil: Cura.NetworkingUtil {}
|
||||
|
||||
function connectToPrinter()
|
||||
{
|
||||
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
|
||||
{
|
||||
id: manualPrinterDialog
|
||||
|
@ -404,6 +419,26 @@ Cura.MachineAction
|
|||
text: catalog.i18nc("@action:button", "OK")
|
||||
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)
|
||||
manualPrinterDialog.hide()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue