RecentFilesMenu.qml 968 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) 2021 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.3 as UM
  6. import Cura 1.0 as Cura
  7. import "../Dialogs"
  8. Menu
  9. {
  10. id: menu
  11. title: catalog.i18nc("@title:menu menubar:file", "Open &Recent")
  12. iconName: "document-open-recent";
  13. enabled: CuraApplication.recentFiles.length > 0;
  14. Instantiator
  15. {
  16. model: CuraApplication.recentFiles
  17. MenuItem
  18. {
  19. text:
  20. {
  21. var path = decodeURIComponent(modelData.toString())
  22. return (index + 1) + ". " + path.slice(path.lastIndexOf("/") + 1);
  23. }
  24. onTriggered: CuraApplication.readLocalFile(modelData)
  25. }
  26. onObjectAdded: menu.insertItem(index, object)
  27. onObjectRemoved: menu.removeItem(object)
  28. }
  29. Cura.AskOpenAsProjectOrModelsDialog
  30. {
  31. id: askOpenAsProjectOrModelsDialog
  32. }
  33. }