Show either openFileButton or openFileMenu, depending on provider count

If there's just 1 provider, show the button. If there are multiple, show the menu. If there are 0, also show the button but disable the button.
The behaviour is not yet implemented though. It doesn't actually look at which providers are available and what they do.

Contributes to issue CURA-8008.
This commit is contained in:
Ghostkeeper 2021-07-09 15:33:57 +02:00
parent c100ba88d0
commit 5bc3848301
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -13,6 +13,8 @@ Item
{ {
id: prepareMenu id: prepareMenu
property var fileProviderModel: CuraApplication.getFileProviderModel()
UM.I18nCatalog UM.I18nCatalog
{ {
id: catalog id: catalog
@ -78,6 +80,8 @@ Item
Cura.ExpandablePopup Cura.ExpandablePopup
{ {
id: openFileMenu id: openFileMenu
visible: prepareMenu.fileProviderModel.count > 1
contentAlignment: Cura.ExpandablePopup.ContentAlignment.AlignLeft contentAlignment: Cura.ExpandablePopup.ContentAlignment.AlignLeft
headerCornerSide: Cura.RoundedRectangle.Direction.All headerCornerSide: Cura.RoundedRectangle.Direction.All
headerPadding: Math.round((parent.height - UM.Theme.getSize("button_icon").height) / 2) headerPadding: Math.round((parent.height - UM.Theme.getSize("button_icon").height) / 2)
@ -107,11 +111,12 @@ Item
Button Button
{ {
id: openFileButton id: openFileButton
visible: prepareMenu.fileProviderModel.count <= 1
height: parent.height height: parent.height
width: height //Square button. width: visible ? height : 0 //Square button (and don't take up space if invisible).
onClicked: Cura.Actions.open.trigger() onClicked: Cura.Actions.open.trigger()
enabled: visible enabled: visible && prepareMenu.fileProviderModel.count > 0
hoverEnabled: true hoverEnabled: true
contentItem: Item contentItem: Item