mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
Pass application
This commit is contained in:
parent
3ad79a5888
commit
f4d0e39788
3 changed files with 19 additions and 14 deletions
|
@ -1,12 +1,15 @@
|
|||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from typing import Optional, Dict, Any
|
||||
from typing import Optional, Dict, Any, TYPE_CHECKING
|
||||
|
||||
from PyQt5.QtCore import QObject, Qt, pyqtProperty, pyqtSignal, pyqtSlot
|
||||
|
||||
from UM.Qt.ListModel import ListModel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from cura.CuraApplication import CuraApplication
|
||||
|
||||
|
||||
#
|
||||
# This model holds all first-start machine actions for the currently active machine. It has 2 roles:
|
||||
|
@ -20,7 +23,7 @@ class FirstStartMachineActionsModel(ListModel):
|
|||
ContentRole = Qt.UserRole + 2
|
||||
ActionRole = Qt.UserRole + 3
|
||||
|
||||
def __init__(self, parent: Optional[QObject] = None) -> None:
|
||||
def __init__(self, application: "CuraApplication", parent: Optional[QObject] = None) -> None:
|
||||
super().__init__(parent)
|
||||
|
||||
self.addRoleName(self.TitleRole, "title")
|
||||
|
@ -29,9 +32,7 @@ class FirstStartMachineActionsModel(ListModel):
|
|||
|
||||
self._current_action_index = 0
|
||||
|
||||
from cura.CuraApplication import CuraApplication
|
||||
self._application = CuraApplication.getInstance()
|
||||
|
||||
self._application = application
|
||||
self._application.initializationFinished.connect(self._initialize)
|
||||
|
||||
def _initialize(self) -> None:
|
||||
|
|
|
@ -1,24 +1,26 @@
|
|||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from typing import Optional
|
||||
from typing import Optional, TYPE_CHECKING
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtSlot
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from cura.CuraApplication import CuraApplication
|
||||
|
||||
|
||||
#
|
||||
# This manager provides (convenience) functions to the Machine Settings Dialog QML to update certain machine settings.
|
||||
#
|
||||
class MachineSettingsManager(QObject):
|
||||
|
||||
def __init__(self, parent: Optional["QObject"] = None) -> None:
|
||||
def __init__(self, application: "CuraApplication", parent: Optional["QObject"] = None) -> None:
|
||||
super().__init__(parent)
|
||||
self._i18n_catalog = i18nCatalog("cura")
|
||||
|
||||
from cura.CuraApplication import CuraApplication
|
||||
self._application = CuraApplication.getInstance()
|
||||
self._application = application
|
||||
|
||||
# Force rebuilding the build volume by reloading the global container stack. This is a bit of a hack, but it seems
|
||||
# quite enough.
|
||||
|
|
|
@ -12,6 +12,8 @@ from UM.Resources import Resources
|
|||
|
||||
if TYPE_CHECKING:
|
||||
from PyQt5.QtCore import QObject
|
||||
from cura.CuraApplication import CuraApplication
|
||||
|
||||
|
||||
#
|
||||
# This is the Qt ListModel that contains all welcome pages data. Each page is a page that can be shown as a step in the
|
||||
|
@ -33,13 +35,15 @@ class WelcomePagesModel(ListModel):
|
|||
PageUrlRole = Qt.UserRole + 2 # URL to the page's QML file
|
||||
NextPageIdRole = Qt.UserRole + 3 # The next page ID it should go to
|
||||
|
||||
def __init__(self, parent: Optional["QObject"] = None) -> None:
|
||||
def __init__(self, application: "CuraApplication", parent: Optional["QObject"] = None) -> None:
|
||||
super().__init__(parent)
|
||||
|
||||
self.addRoleName(self.IdRole, "id")
|
||||
self.addRoleName(self.PageUrlRole, "page_url")
|
||||
self.addRoleName(self.NextPageIdRole, "next_page_id")
|
||||
|
||||
self._application = application
|
||||
|
||||
self._pages = [] # type: List[Dict[str, Any]]
|
||||
|
||||
self._current_page_index = 0
|
||||
|
@ -206,14 +210,12 @@ class WelcomePagesModel(ListModel):
|
|||
# Indicates if the machine action panel should be shown by checking if there's any first start machine actions
|
||||
# available.
|
||||
def shouldShowMachineActions(self) -> bool:
|
||||
from cura.CuraApplication import CuraApplication
|
||||
application = CuraApplication.getInstance()
|
||||
global_stack = application.getMachineManager().activeMachine
|
||||
global_stack = self._application.getMachineManager().activeMachine
|
||||
if global_stack is None:
|
||||
return False
|
||||
|
||||
definition_id = global_stack.definition.getId()
|
||||
first_start_actions = application.getMachineActionManager().getFirstStartActions(definition_id)
|
||||
first_start_actions = self._application.getMachineActionManager().getFirstStartActions(definition_id)
|
||||
return len(first_start_actions) > 0
|
||||
|
||||
def addPage(self) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue