From 5bc384830114fb4144709784441f0c5900900bb9 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 9 Jul 2021 15:33:57 +0200 Subject: [PATCH] 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. --- plugins/PrepareStage/PrepareMenu.qml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index 576cd3cd95..219979407b 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -13,6 +13,8 @@ Item { id: prepareMenu + property var fileProviderModel: CuraApplication.getFileProviderModel() + UM.I18nCatalog { id: catalog @@ -78,6 +80,8 @@ Item Cura.ExpandablePopup { id: openFileMenu + visible: prepareMenu.fileProviderModel.count > 1 + contentAlignment: Cura.ExpandablePopup.ContentAlignment.AlignLeft headerCornerSide: Cura.RoundedRectangle.Direction.All headerPadding: Math.round((parent.height - UM.Theme.getSize("button_icon").height) / 2) @@ -107,11 +111,12 @@ Item Button { id: openFileButton + visible: prepareMenu.fileProviderModel.count <= 1 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() - enabled: visible + enabled: visible && prepareMenu.fileProviderModel.count > 0 hoverEnabled: true contentItem: Item