Allow buttons to be passed in for drop down.

The change also remove the "Add Printer" and "Manage Printer" buttons from the monitor page drop down.

CURA-9424
This commit is contained in:
Joey de l'Arago 2022-11-04 15:37:57 +01:00
parent 2019d8f3af
commit ccb4d181e6
2 changed files with 56 additions and 33 deletions

View file

@ -57,6 +57,41 @@ Item
Layout.fillHeight: true
machineListModel: Cura.MachineListModel {}
buttons: [
Cura.SecondaryButton
{
id: addPrinterButton
leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width
text: catalog.i18nc("@button", "Add printer")
// The maximum width of the button is half of the total space, minus the padding of the parent, the left
// padding of the component and half the spacing because of the space between buttons.
fixedWidthMode: true
width: parent.width / 2 - leftPadding * 1.5
onClicked:
{
toggleContent()
Cura.Actions.addMachine.trigger()
}
},
Cura.SecondaryButton
{
id: managePrinterButton
leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width
text: catalog.i18nc("@button", "Manage printers")
fixedWidthMode: true
// The maximum width of the button is half of the total space, minus the padding of the parent, the right
// padding of the component and half the spacing because of the space between buttons.
width: parent.width / 2 - rightPadding * 1.5
onClicked:
{
toggleContent()
Cura.Actions.configureMachines.trigger()
}
}
]
}
Cura.ConfigurationMenu

View file

@ -18,6 +18,8 @@ Cura.ExpandablePopup
property alias machineListModel: machineSelectorList.model
property list<Item> buttons
readonly property string connectionStatus: {
if (isNetworkPrinter)
{
@ -232,39 +234,25 @@ Cura.ExpandablePopup
padding: UM.Theme.getSize("default_margin").width
spacing: UM.Theme.getSize("default_margin").width
Cura.SecondaryButton
{
id: addPrinterButton
leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width
text: catalog.i18nc("@button", "Add printer")
// The maximum width of the button is half of the total space, minus the padding of the parent, the left
// padding of the component and half the spacing because of the space between buttons.
fixedWidthMode: true
width: buttonRow.width / 2 - leftPadding * 1.5
onClicked:
{
toggleContent()
Cura.Actions.addMachine.trigger()
}
children: buttons
}
Cura.SecondaryButton
states: [
State {
name: "noButtons"
when: !buttons || buttons.length == 0
PropertyChanges
{
id: managePrinterButton
leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width
text: catalog.i18nc("@button", "Manage printers")
fixedWidthMode: true
// The maximum width of the button is half of the total space, minus the padding of the parent, the right
// padding of the component and half the spacing because of the space between buttons.
width: buttonRow.width / 2 - rightPadding * 1.5
onClicked:
target: buttonRow
height: 0
padding: 0
}
PropertyChanges
{
toggleContent()
Cura.Actions.configureMachines.trigger()
}
target: separator
height: 0
}
}
]
}
}