CuraView.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (c) 2018 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from PyQt6.QtCore import pyqtProperty, QUrl
  4. from UM.Resources import Resources
  5. from UM.View.View import View
  6. from cura.CuraApplication import CuraApplication
  7. # Since Cura has a few pre-defined "space claims" for the locations of certain components, we've provided some structure
  8. # to indicate this.
  9. # MainComponent works in the same way the MainComponent of a stage.
  10. # the stageMenuComponent returns an item that should be used somewhere in the stage menu. It's up to the active stage
  11. # to actually do something with this.
  12. class CuraView(View):
  13. def __init__(self, parent = None, use_empty_menu_placeholder: bool = False) -> None:
  14. super().__init__(parent)
  15. self._empty_menu_placeholder_url = QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
  16. "EmptyViewMenuComponent.qml"))
  17. self._use_empty_menu_placeholder = use_empty_menu_placeholder
  18. @pyqtProperty(QUrl, constant = True)
  19. def mainComponent(self) -> QUrl:
  20. return self.getDisplayComponent("main")
  21. @pyqtProperty(QUrl, constant = True)
  22. def stageMenuComponent(self) -> QUrl:
  23. url = self.getDisplayComponent("menu")
  24. if not url.toString() and self._use_empty_menu_placeholder:
  25. url = self._empty_menu_placeholder_url
  26. return url