mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-28 23:04:34 +08:00
Add a new file menu option when there are multiple file providers
CURA-7868
This commit is contained in:
parent
b49d5ab9e9
commit
430550452f
@ -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 { }
|
||||
|
45
resources/qml/Menus/OpenFilesMenu.qml
Normal file
45
resources/qml/Menus/OpenFilesMenu.qml
Normal 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)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user