Add a new file menu option when there are multiple file providers

CURA-7868
This commit is contained in:
Kostas Karmas 2020-12-15 18:31:15 +01:00
parent b49d5ab9e9
commit 430550452f
2 changed files with 50 additions and 0 deletions

View File

@ -22,6 +22,11 @@ Menu
{
id: openMenu
action: Cura.Actions.open
visible: CuraApplication.fileProviders.length > 0 // DEBUG: It's > 0 so that both options are visible for debugging purposes
}
OpenFilesMenu {
visible: CuraApplication.fileProviders.length > 0 // DEBUG: It's > 0 so that both options are visible for debugging purposes
}
RecentFilesMenu { }

View File

@ -0,0 +1,45 @@
// 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: menu
title: catalog.i18nc("@title:menu menubar:file", "Open File(s)...")
iconName: "document-open-recent";
Instantiator
{
id: fileProviders
model: UM.FileProviderModel { }
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
{
fileProviders.model.trigger(model.name);
}
}
shortcut: model.shortcut
}
onObjectAdded: menu.insertItem(index, object)
onObjectRemoved: menu.removeItem(object)
}
}