Cura/resources/qml/Menus/OpenFilesMenu.qml
Kostas Karmas 71994eaaf9 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
2020-12-23 17:13:14 +01:00

45 lines
1.1 KiB
QML

// Copyright (c) 2016 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 1.1
import UM 1.6 as UM
import Cura 1.0 as Cura
import "../Dialogs"
Menu
{
id: openFilesMenu
title: catalog.i18nc("@title:menu menubar:file", "Open File(s)...")
iconName: "document-open-recent";
Instantiator
{
id: fileProviders
model: CuraApplication.getFileProviderModel()
MenuItem
{
text:
{
return model.displayText;
}
onTriggered:
{
if (model.index == 0) // The 0th element is the "From Disk" option, which should activate the open local file dialog
{
Cura.Actions.open.trigger()
}
else
{
CuraApplication.getFileProviderModel().trigger(model.name);
}
}
shortcut: model.shortcut
}
onObjectAdded: openFilesMenu.insertItem(index, object)
onObjectRemoved: openFilesMenu.removeItem(object)
}
}