WIP: Add label for no discovered network printer

This commit is contained in:
Lipu Fei 2019-03-13 14:12:02 +01:00
parent 764f7281c2
commit 20933e8bef
2 changed files with 67 additions and 42 deletions

View file

@ -18,7 +18,7 @@ import "../PrinterSelector"
Item Item
{ {
id: base id: base
height: networkPrinterScrollView.height + controlsRectangle.height height: networkPrinterInfo.height + controlsRectangle.height
property alias maxItemCountAtOnce: networkPrinterScrollView.maxItemCountAtOnce property alias maxItemCountAtOnce: networkPrinterScrollView.maxItemCountAtOnce
property var currentItem: (networkPrinterListView.currentIndex >= 0) property var currentItem: (networkPrinterListView.currentIndex >= 0)
@ -28,51 +28,76 @@ Item
signal refreshButtonClicked() signal refreshButtonClicked()
signal addByIpButtonClicked() signal addByIpButtonClicked()
ScrollView Item
{ {
id: networkPrinterScrollView id: networkPrinterInfo
anchors.fill: parent height: networkPrinterScrollView.visible ? networkPrinterScrollView.height : noPrinterLabel.height
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
ScrollBar.horizontal.policy: ScrollBar.AsNeeded Label
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
property int maxItemCountAtOnce: 8 // show at max 8 items at once, otherwise you need to scroll.
height: maxItemCountAtOnce * UM.Theme.getSize("action_button").height
clip: true
ListView
{ {
id: networkPrinterListView id: noPrinterLabel
anchors.fill: parent height: UM.Theme.getSize("setting_control").height + UM.Theme.getSize("default_margin").height
model: CuraApplication.getDiscoveredPrinterModel().discovered_printers anchors.left: parent.left
visible: model.length > 0 anchors.leftMargin: UM.Theme.getSize("default_margin").width
text: catalog.i18nc("@label", "There is no printer found over your network.")
renderType: Text.NativeRendering
verticalAlignment: Text.AlignVCenter
visible: !networkPrinterScrollView.visible
}
delegate: MachineSelectorButton ScrollView
{
id: networkPrinterScrollView
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
ScrollBar.horizontal.policy: ScrollBar.AsNeeded
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
property int maxItemCountAtOnce: 8 // show at max 8 items at once, otherwise you need to scroll.
height: maxItemCountAtOnce * UM.Theme.getSize("action_button").height
visible: networkPrinterListView.model.length > 0
clip: true
ListView
{ {
text: modelData.device.name id: networkPrinterListView
anchors.fill: parent
model: CuraApplication.getDiscoveredPrinterModel().discovered_printers
//visible: base.visible && model.length > 0
anchors.left: parent.left delegate: MachineSelectorButton
anchors.right: parent.right
anchors.rightMargin: 10
outputDevice: modelData.device
printerTypeLabelAutoFit: true
updatePrinterTypesFunction: updateMachineTypes
// show printer type as it is
printerTypeLabelConversionFunction: function(value) { return value }
function updateMachineTypes()
{ {
printerTypesList = [ modelData.readable_machine_type ] text: modelData.device.name
}
checkable: false anchors.left: parent.left
selected: ListView.view.currentIndex == model.index anchors.right: parent.right
onClicked: anchors.rightMargin: 10
{ outputDevice: modelData.device
ListView.view.currentIndex = index
printerTypeLabelAutoFit: true
updatePrinterTypesFunction: updateMachineTypes
// show printer type as it is
printerTypeLabelConversionFunction: function(value) { return value }
function updateMachineTypes()
{
printerTypesList = [ modelData.readable_machine_type ]
}
checkable: false
selected: ListView.view.currentIndex == model.index
onClicked:
{
ListView.view.currentIndex = index
}
} }
} }
} }
@ -83,7 +108,7 @@ Item
id: controlsRectangle id: controlsRectangle
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: networkPrinterScrollView.bottom anchors.top: networkPrinterInfo.bottom
// Make sure that the left, right, and bottom borders do not show up, otherwise you see double // Make sure that the left, right, and bottom borders do not show up, otherwise you see double
// borders. // borders.
anchors.bottomMargin: -border.width anchors.bottomMargin: -border.width
@ -159,7 +184,7 @@ Item
hoverEnabled: true hoverEnabled: true
onClicked: onClicked:
{ {
// open the material URL with web browser // open the throubleshooting URL with web browser
var url = "https://ultimaker.com/incoming-links/cura/material-compatibilty" // TODO var url = "https://ultimaker.com/incoming-links/cura/material-compatibilty" // TODO
Qt.openUrlExternally(url) Qt.openUrlExternally(url)
} }

View file

@ -37,7 +37,7 @@ Item
anchors.right: parent.right anchors.right: parent.right
anchors.margins: 20 anchors.margins: 20
title: catalog.i18nc("@label", "Add a network printer") title: catalog.i18nc("@label", "Add a networked printer")
contentShown: true // by default expand the network printer list contentShown: true // by default expand the network printer list
onClicked: onClicked:
@ -82,7 +82,7 @@ Item
anchors.right: parent.right anchors.right: parent.right
anchors.margins: 20 anchors.margins: 20
title: catalog.i18nc("@label", "Add a non-network printer") title: catalog.i18nc("@label", "Add a non-networked printer")
onClicked: onClicked:
{ {