RecentFilesMenu.qml 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2016 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  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:
  25. {
  26. CuraApplication.readLocalFile(modelData);
  27. var meshName = backgroundItem.getMeshName(modelData.toString())
  28. backgroundItem.hasMesh(decodeURIComponent(meshName))
  29. }
  30. }
  31. onObjectAdded: menu.insertItem(index, object)
  32. onObjectRemoved: menu.removeItem(object)
  33. }
  34. Cura.AskOpenAsProjectOrModelsDialog
  35. {
  36. id: askOpenAsProjectOrModelsDialog
  37. }
  38. }