Merge pull request #4975 from Ultimaker/CURA-6011_connection_types

[4.0] Every output device should define its connection type
This commit is contained in:
Lipu Fei 2018-12-18 13:23:02 +01:00 committed by GitHub
commit 71e71e0a4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 183 additions and 104 deletions

View file

@ -136,7 +136,7 @@ Cura.ExpandablePopup
onVisibleChanged:
{
is_connected = Cura.MachineManager.activeMachineNetworkKey !== "" && Cura.MachineManager.printerConnected // Re-evaluate.
is_connected = Cura.MachineManager.activeMachineHasRemoteConnection && Cura.MachineManager.printerConnected //Re-evaluate.
// If the printer is not connected, we switch always to the custom mode. If is connected instead, the auto mode
// or the previous state is selected

View file

@ -11,7 +11,7 @@ Cura.ExpandablePopup
{
id: machineSelector
property bool isNetworkPrinter: Cura.MachineManager.activeMachineNetworkKey != ""
property bool isNetworkPrinter: Cura.MachineManager.activeMachineHasRemoteConnection
property bool isPrinterConnected: Cura.MachineManager.printerConnected
property var outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
@ -98,6 +98,12 @@ Cura.ExpandablePopup
scroll.height = Math.min(height, maximumHeight)
popup.height = scroll.height + buttonRow.height
}
Component.onCompleted:
{
scroll.height = Math.min(height, maximumHeight)
popup.height = scroll.height + buttonRow.height
}
}
}

View file

@ -7,78 +7,40 @@ import QtQuick.Controls 2.3
import UM 1.2 as UM
import Cura 1.0 as Cura
Column
ListView
{
id: machineSelectorList
id: listView
height: childrenRect.height
model: Cura.PrintersModel {}
section.property: "hasRemoteConnection"
Label
section.delegate: Label
{
text: catalog.i18nc("@label", "Connected printers")
visible: networkedPrintersModel.items.length > 0
leftPadding: UM.Theme.getSize("default_margin").width
text: section == "true" ? catalog.i18nc("@label", "Connected printers") : catalog.i18nc("@label", "Preset printers")
width: parent.width
height: visible ? contentHeight + 2 * UM.Theme.getSize("default_margin").height : 0
leftPadding: UM.Theme.getSize("default_margin").width
renderType: Text.NativeRendering
font: UM.Theme.getFont("medium")
color: UM.Theme.getColor("text_medium")
verticalAlignment: Text.AlignVCenter
}
Repeater
delegate: MachineSelectorButton
{
id: networkedPrinters
text: model.name
width: listView.width
outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
model: UM.ContainerStacksModel
checked:
{
id: networkedPrintersModel
filter:
// If the machine has a remote connection
var result = Cura.MachineManager.activeMachineId == model.id
if (Cura.MachineManager.activeMachineHasRemoteConnection)
{
"type": "machine", "um_network_key": "*", "hidden": "False"
result |= Cura.MachineManager.activeMachineNetworkGroupName == model.metadata["connect_group_name"]
}
}
delegate: MachineSelectorButton
{
text: model.metadata["connect_group_name"]
checked: Cura.MachineManager.activeMachineNetworkGroupName == model.metadata["connect_group_name"]
outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
Connections
{
target: Cura.MachineManager
onActiveMachineNetworkGroupNameChanged: checked = Cura.MachineManager.activeMachineNetworkGroupName == model.metadata["connect_group_name"]
}
}
}
Label
{
text: catalog.i18nc("@label", "Preset printers")
visible: virtualPrintersModel.items.length > 0
leftPadding: UM.Theme.getSize("default_margin").width
height: visible ? contentHeight + 2 * UM.Theme.getSize("default_margin").height : 0
renderType: Text.NativeRendering
font: UM.Theme.getFont("medium")
color: UM.Theme.getColor("text_medium")
verticalAlignment: Text.AlignVCenter
}
Repeater
{
id: virtualPrinters
model: UM.ContainerStacksModel
{
id: virtualPrintersModel
filter:
{
"type": "machine", "um_network_key": null
}
}
delegate: MachineSelectorButton
{
text: model.name
checked: Cura.MachineManager.activeMachineId == model.id
return result
}
}
}