RecentFilesMenu.qml 915 B

1234567891011121314151617181920212223242526272829303132333435
  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.3 as UM
  6. import Cura 1.0 as Cura
  7. import "../Dialogs"
  8. Cura.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. Cura.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: (index, object) => menu.insertItem(index, object)
  27. onObjectRemoved: (object) => menu.removeItem(object)
  28. }
  29. }