mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 10:17:52 -06:00
WIP: Complete add network and local printer flow
This commit is contained in:
parent
cc35eb0195
commit
5fa2c72b0d
5 changed files with 51 additions and 13 deletions
|
@ -16,7 +16,9 @@ ScrollView
|
||||||
{
|
{
|
||||||
id: base
|
id: base
|
||||||
|
|
||||||
property var currentItem: null
|
property var currentItem: (machineList.currentIndex >= 0)
|
||||||
|
? machineList.model.getItem(machineList.currentIndex)
|
||||||
|
: null
|
||||||
property string currentSection: preferredCategory
|
property string currentSection: preferredCategory
|
||||||
property string preferredCategory: "Ultimaker"
|
property string preferredCategory: "Ultimaker"
|
||||||
|
|
||||||
|
@ -36,7 +38,6 @@ ScrollView
|
||||||
var item = machineList.model.getItem(i)
|
var item = machineList.model.getItem(i)
|
||||||
if (item.section == base.currentSection)
|
if (item.section == base.currentSection)
|
||||||
{
|
{
|
||||||
base.currentItem = item
|
|
||||||
machineList.currentIndex = i
|
machineList.currentIndex = i
|
||||||
break
|
break
|
||||||
}
|
}
|
|
@ -21,7 +21,9 @@ Item
|
||||||
height: networkPrinterScrollView.height + controlsRectangle.height
|
height: networkPrinterScrollView.height + controlsRectangle.height
|
||||||
|
|
||||||
property alias maxItemCountAtOnce: networkPrinterScrollView.maxItemCountAtOnce
|
property alias maxItemCountAtOnce: networkPrinterScrollView.maxItemCountAtOnce
|
||||||
property var selectedItem: networkPrinterListView.model[networkPrinterListView.currentIndex]
|
property var currentItem: (networkPrinterListView.currentIndex >= 0)
|
||||||
|
? networkPrinterListView.model[networkPrinterListView.currentIndex]
|
||||||
|
: null
|
||||||
|
|
||||||
signal refreshButtonClicked()
|
signal refreshButtonClicked()
|
||||||
signal addByIpButtonClicked()
|
signal addByIpButtonClicked()
|
||||||
|
|
|
@ -38,6 +38,7 @@ Item
|
||||||
anchors.margins: 20
|
anchors.margins: 20
|
||||||
|
|
||||||
title: catalog.i18nc("@label", "Add a network printer")
|
title: catalog.i18nc("@label", "Add a network printer")
|
||||||
|
contentShown: true // by default expand the network printer list
|
||||||
|
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
|
@ -97,7 +98,7 @@ Item
|
||||||
{
|
{
|
||||||
id: localPrinterListComponent
|
id: localPrinterListComponent
|
||||||
|
|
||||||
AddPrinterScrollView
|
AddLocalPrinterScrollView
|
||||||
{
|
{
|
||||||
id: localPrinterView
|
id: localPrinterView
|
||||||
|
|
||||||
|
@ -112,10 +113,42 @@ Item
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.margins: 40
|
anchors.margins: 40
|
||||||
enabled: true // TODO
|
enabled:
|
||||||
|
{
|
||||||
|
// If the network printer dropdown is expanded, make sure that there is a selected item
|
||||||
|
if (addNetworkPrinterDropDown.contentShown)
|
||||||
|
{
|
||||||
|
return addNetworkPrinterDropDown.contentItem.currentItem != null
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return addLocalPrinterDropDown.contentItem.currentItem != null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
text: catalog.i18nc("@button", "Next")
|
text: catalog.i18nc("@button", "Next")
|
||||||
width: 140
|
width: 140
|
||||||
fixedWidthMode: true
|
fixedWidthMode: true
|
||||||
onClicked: base.showNextPage()
|
onClicked:
|
||||||
|
{
|
||||||
|
// Create a network printer or a local printer according to the selection
|
||||||
|
if (addNetworkPrinterDropDown.contentShown)
|
||||||
|
{
|
||||||
|
// Create a network printer
|
||||||
|
const networkPrinterItem = addNetworkPrinterDropDown.contentItem.currentItem
|
||||||
|
CuraApplication.getDiscoveredPrinterModel().createMachineFromDiscoveredPrinter(networkPrinterItem)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create a local printer
|
||||||
|
const localPrinterItem = addLocalPrinterDropDown.contentItem.currentItem
|
||||||
|
Cura.MachineManager.addMachine(localPrinterItem.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: implement machine actions
|
||||||
|
|
||||||
|
// If we have created a machine, go to the last page, which is the "cloud" page.
|
||||||
|
base.gotoPage("cloud")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,7 @@ Cura.RoundedRectangle
|
||||||
onEntered: base.hovered = true
|
onEntered: base.hovered = true
|
||||||
onExited: base.hovered = false
|
onExited: base.hovered = false
|
||||||
|
|
||||||
onClicked: {
|
onClicked: base.clicked()
|
||||||
base.contentShown = !base.contentShown
|
|
||||||
base.clicked()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Label
|
Label
|
||||||
|
|
|
@ -25,16 +25,21 @@ Item
|
||||||
height: header.contentShown ? (header.height + contentRectangle.height + 30) : header.height
|
height: header.contentShown ? (header.height + contentRectangle.height + 30) : header.height
|
||||||
|
|
||||||
property var contentComponent: null
|
property var contentComponent: null
|
||||||
|
property alias contentItem: contentLoader.item
|
||||||
|
|
||||||
property alias title: header.title
|
property alias title: header.title
|
||||||
property alias contentShown: header.contentShown
|
property bool contentShown: false
|
||||||
|
|
||||||
signal clicked()
|
signal clicked()
|
||||||
|
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
target: header
|
target: header
|
||||||
onClicked: base.clicked()
|
onClicked:
|
||||||
|
{
|
||||||
|
base.contentShown = !base.contentShown
|
||||||
|
clicked()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DropDownHeader
|
DropDownHeader
|
||||||
|
@ -45,7 +50,7 @@ Item
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
height: UM.Theme.getSize("expandable_component_content_header").height
|
height: UM.Theme.getSize("expandable_component_content_header").height
|
||||||
rightIconSource: contentShown ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_right")
|
rightIconSource: contentShown ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_right")
|
||||||
|
contentShown: base.contentShown
|
||||||
}
|
}
|
||||||
|
|
||||||
Cura.RoundedRectangle
|
Cura.RoundedRectangle
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue