CuraView.py 1.6 KB

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