OpenFilesMenu.qml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2020 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 2.2
  5. import UM 1.6 as UM
  6. import Cura 1.0 as Cura
  7. import "../Dialogs"
  8. Menu
  9. {
  10. id: openFilesMenu
  11. title: catalog.i18nc("@title:menu menubar:file", "Open File(s)...")
  12. iconName: "document-open-recent";
  13. Instantiator
  14. {
  15. id: fileProviders
  16. model: CuraApplication.getFileProviderModel()
  17. MenuItem
  18. {
  19. text:
  20. {
  21. return model.displayText;
  22. }
  23. onTriggered:
  24. {
  25. if (model.index == 0) // The 0th element is the "From Disk" option, which should activate the open local file dialog
  26. {
  27. Cura.Actions.open.trigger()
  28. }
  29. else
  30. {
  31. CuraApplication.getFileProviderModel().trigger(model.name);
  32. }
  33. }
  34. // Unassign the shortcuts when the submenu is invisible (i.e. when there is only one file provider) to avoid ambiguous shortcuts.
  35. // When there is a single file provider, the openAction is assigned with the Ctrl+O shortcut instead.
  36. shortcut: openFilesMenu.visible ? model.shortcut : ""
  37. }
  38. onObjectAdded: openFilesMenu.insertItem(index, object)
  39. onObjectRemoved: openFilesMenu.removeItem(object)
  40. }
  41. }