OpenFilesMenu.qml 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (c) 2022 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.1
  5. import UM 1.6 as UM
  6. import Cura 1.0 as Cura
  7. import "../Dialogs"
  8. Cura.Menu
  9. {
  10. id: openFilesMenu
  11. title: catalog.i18nc("@title:menu menubar:file", "Open File(s)...")
  12. Instantiator
  13. {
  14. id: fileProviders
  15. model: CuraApplication.getFileProviderModel()
  16. Cura.MenuItem
  17. {
  18. text: model.displayText
  19. onTriggered:
  20. {
  21. if (model.index == 0) // The 0th element is the "From Disk" option, which should activate the open local file dialog
  22. {
  23. Cura.Actions.open.trigger()
  24. }
  25. else
  26. {
  27. CuraApplication.getFileProviderModel().trigger(model.name);
  28. }
  29. }
  30. shortcut: model.shortcut
  31. }
  32. onObjectAdded: function(index, object) { openFilesMenu.insertItem(index, object)}
  33. onObjectRemoved: function(index, object) { openFilesMenu.removeItem(object) }
  34. }
  35. }