Add legacy 'Connect over Network' button back

This commit is contained in:
ChrisTerBeke 2019-08-12 01:19:41 +02:00
parent d703e48007
commit e977cdd431
No known key found for this signature in database
GPG key ID: A49F1AB9D7E0C263
7 changed files with 131 additions and 140 deletions

View file

@ -23,37 +23,13 @@ Cura.MachineAction
function connectToPrinter()
{
if(base.selectedDevice && base.completeProperties)
if (base.selectedDevice && base.completeProperties)
{
var printerKey = base.selectedDevice.key
var printerName = base.selectedDevice.name // TODO To change when the groups have a name
if (manager.getStoredKey() != printerKey)
{
// Check if there is another instance with the same key
if (!manager.existsKey(printerKey))
{
manager.associateActiveMachineWithPrinterDevice(base.selectedDevice)
manager.setGroupName(printerName) // TODO To change when the groups have a name
completed()
}
else
{
existingConnectionDialog.open()
}
}
manager.associateActiveMachineWithPrinterDevice(base.selectedDevice)
completed()
}
}
MessageDialog
{
id: existingConnectionDialog
title: catalog.i18nc("@window:title", "Existing Connection")
icon: StandardIcon.Information
text: catalog.i18nc("@message:text", "This printer/group is already added to Cura. Please select another printer/group.")
standardButtons: StandardButton.Ok
modality: Qt.ApplicationModal
}
Column
{
anchors.fill: parent;
@ -151,21 +127,6 @@ Cura.MachineAction
{
id: listview
model: manager.foundDevices
onModelChanged:
{
var selectedKey = manager.getLastManualEntryKey()
// If there is no last manual entry key, then we select the stored key (if any)
if (selectedKey == "")
selectedKey = manager.getStoredKey()
for(var i = 0; i < model.length; i++) {
if(model[i].key == selectedKey)
{
currentIndex = i;
return
}
}
currentIndex = -1;
}
width: parent.width
currentIndex: -1
onCurrentIndexChanged:

View file

@ -1,93 +0,0 @@
// Copyright (c) 2019 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import UM 1.2 as UM
import Cura 1.0 as Cura
Item {
id: base;
property string activeQualityDefinitionId: Cura.MachineManager.activeQualityDefinitionId;
property bool isUM3: activeQualityDefinitionId == "ultimaker3" || activeQualityDefinitionId.match("ultimaker_") != null;
property bool printerConnected: Cura.MachineManager.printerConnected;
property bool printerAcceptsCommands:
{
if (printerConnected && Cura.MachineManager.printerOutputDevices[0])
{
return Cura.MachineManager.printerOutputDevices[0].acceptsCommands
}
return false
}
property bool authenticationRequested:
{
if (printerConnected && Cura.MachineManager.printerOutputDevices[0])
{
var device = Cura.MachineManager.printerOutputDevices[0]
// AuthState.AuthenticationRequested or AuthState.AuthenticationReceived
return device.authenticationState == 2 || device.authenticationState == 5
}
return false
}
property var materialNames:
{
if (printerConnected && Cura.MachineManager.printerOutputDevices[0])
{
return Cura.MachineManager.printerOutputDevices[0].materialNames
}
return null
}
property var hotendIds:
{
if (printerConnected && Cura.MachineManager.printerOutputDevices[0])
{
return Cura.MachineManager.printerOutputDevices[0].hotendIds
}
return null
}
UM.I18nCatalog {
id: catalog;
name: "cura";
}
Row {
objectName: "networkPrinterConnectButton";
spacing: UM.Theme.getSize("default_margin").width;
visible: isUM3;
Button {
height: UM.Theme.getSize("save_button_save_to_button").height;
onClicked: Cura.MachineManager.printerOutputDevices[0].requestAuthentication();
style: UM.Theme.styles.print_setup_action_button;
text: catalog.i18nc("@action:button", "Request Access");
tooltip: catalog.i18nc("@info:tooltip", "Send access request to the printer");
visible: printerConnected && !printerAcceptsCommands && !authenticationRequested;
}
Button {
height: UM.Theme.getSize("save_button_save_to_button").height;
onClicked: connectActionDialog.show();
style: UM.Theme.styles.print_setup_action_button;
text: catalog.i18nc("@action:button", "Connect");
tooltip: catalog.i18nc("@info:tooltip", "Connect to a printer");
visible: !printerConnected;
}
}
UM.Dialog {
id: connectActionDialog;
rightButtons: Button {
iconName: "dialog-close";
onClicked: connectActionDialog.reject();
text: catalog.i18nc("@action:button", "Close");
}
Loader {
anchors.fill: parent;
source: "DiscoverUM3Action.qml";
}
}
}