Change the Open File(s) option according to the file providers count

When there is only one file provider (i.e. the local file provider), the Open File(s) will be a
simple item in the File menu.
When there are more than one file providers, the Open File(s) will become a submenu in the File
menu, which will contain all the file providers as submenu items.

CURA-7868
This commit is contained in:
Kostas Karmas 2020-12-23 17:13:14 +01:00
parent 43615a57b6
commit 71994eaaf9
3 changed files with 31 additions and 9 deletions

View file

@ -11,15 +11,14 @@ import "../Dialogs"
Menu
{
id: menu
id: openFilesMenu
title: catalog.i18nc("@title:menu menubar:file", "Open File(s)...")
iconName: "document-open-recent";
Instantiator
{
id: fileProviders
model: UM.FileProviderModel { }
model: CuraApplication.getFileProviderModel()
MenuItem
{
text:
@ -34,12 +33,12 @@ Menu
}
else
{
fileProviders.model.trigger(model.name);
CuraApplication.getFileProviderModel().trigger(model.name);
}
}
shortcut: model.shortcut
}
onObjectAdded: menu.insertItem(index, object)
onObjectRemoved: menu.removeItem(object)
onObjectAdded: openFilesMenu.insertItem(index, object)
onObjectRemoved: openFilesMenu.removeItem(object)
}
}