diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index 01e378c2d4..719c598469 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -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 diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index ef9112eead..a395ea3913 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -18,6 +18,8 @@ Cura.ExpandablePopup property alias machineListModel: machineSelectorList.model + property list 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() - } - } - - 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: buttonRow.width / 2 - rightPadding * 1.5 - onClicked: - { - toggleContent() - Cura.Actions.configureMachines.trigger() - } - } + children: buttons } + + states: [ + State { + name: "noButtons" + when: !buttons || buttons.length == 0 + PropertyChanges + { + target: buttonRow + height: 0 + padding: 0 + } + PropertyChanges + { + target: separator + height: 0 + } + } + ] } }