mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 09:47:50 -06:00
WIP: Add FirstStartMachineActionsModel
This commit is contained in:
parent
58062cb4de
commit
d4c0104bc2
3 changed files with 62 additions and 1 deletions
|
@ -78,6 +78,7 @@ from cura.Machines.Models.GenericMaterialsModel import GenericMaterialsModel
|
||||||
from cura.Machines.Models.MaterialBrandsModel import MaterialBrandsModel
|
from cura.Machines.Models.MaterialBrandsModel import MaterialBrandsModel
|
||||||
from cura.Machines.Models.QualityManagementModel import QualityManagementModel
|
from cura.Machines.Models.QualityManagementModel import QualityManagementModel
|
||||||
from cura.Machines.Models.QualitySettingsModel import QualitySettingsModel
|
from cura.Machines.Models.QualitySettingsModel import QualitySettingsModel
|
||||||
|
from cura.Machines.Models.FirstStartMachineActionsModel import FirstStartMachineActionsModel
|
||||||
|
|
||||||
from cura.Machines.Models.SettingVisibilityPresetsModel import SettingVisibilityPresetsModel
|
from cura.Machines.Models.SettingVisibilityPresetsModel import SettingVisibilityPresetsModel
|
||||||
|
|
||||||
|
@ -215,6 +216,7 @@ class CuraApplication(QtApplication):
|
||||||
self._machine_settings_manager = MachineSettingsManager(self)
|
self._machine_settings_manager = MachineSettingsManager(self)
|
||||||
|
|
||||||
self._discovered_printer_model = DiscoveredPrintersModel(self)
|
self._discovered_printer_model = DiscoveredPrintersModel(self)
|
||||||
|
self._first_start_machine_actions_model = FirstStartMachineActionsModel(self)
|
||||||
self._welcome_pages_model = WelcomePagesModel(self)
|
self._welcome_pages_model = WelcomePagesModel(self)
|
||||||
|
|
||||||
self._quality_profile_drop_down_menu_model = None
|
self._quality_profile_drop_down_menu_model = None
|
||||||
|
@ -751,6 +753,8 @@ class CuraApplication(QtApplication):
|
||||||
# Initialize setting visibility presets model.
|
# Initialize setting visibility presets model.
|
||||||
self._setting_visibility_presets_model = SettingVisibilityPresetsModel(self.getPreferences(), parent = self)
|
self._setting_visibility_presets_model = SettingVisibilityPresetsModel(self.getPreferences(), parent = self)
|
||||||
|
|
||||||
|
self._first_start_machine_actions_model.initialize()
|
||||||
|
|
||||||
# Initialize Cura API
|
# Initialize Cura API
|
||||||
self._cura_API.initialize()
|
self._cura_API.initialize()
|
||||||
|
|
||||||
|
@ -855,6 +859,10 @@ class CuraApplication(QtApplication):
|
||||||
def getDiscoveredPrintersModel(self, *args) -> "DiscoveredPrintersModel":
|
def getDiscoveredPrintersModel(self, *args) -> "DiscoveredPrintersModel":
|
||||||
return self._discovered_printer_model
|
return self._discovered_printer_model
|
||||||
|
|
||||||
|
@pyqtSlot(result = QObject)
|
||||||
|
def getFirstStartMachineActionsModel(self, *args) -> "FirstStartMachineActionsModel":
|
||||||
|
return self._first_start_machine_actions_model
|
||||||
|
|
||||||
@pyqtSlot(result = QObject)
|
@pyqtSlot(result = QObject)
|
||||||
def getSettingVisibilityPresetsModel(self, *args) -> SettingVisibilityPresetsModel:
|
def getSettingVisibilityPresetsModel(self, *args) -> SettingVisibilityPresetsModel:
|
||||||
return self._setting_visibility_presets_model
|
return self._setting_visibility_presets_model
|
||||||
|
@ -1026,6 +1034,7 @@ class CuraApplication(QtApplication):
|
||||||
qmlRegisterType(MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler")
|
qmlRegisterType(MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler")
|
||||||
qmlRegisterType(SettingVisibilityPresetsModel, "Cura", 1, 0, "SettingVisibilityPresetsModel")
|
qmlRegisterType(SettingVisibilityPresetsModel, "Cura", 1, 0, "SettingVisibilityPresetsModel")
|
||||||
qmlRegisterType(QualitySettingsModel, "Cura", 1, 0, "QualitySettingsModel")
|
qmlRegisterType(QualitySettingsModel, "Cura", 1, 0, "QualitySettingsModel")
|
||||||
|
qmlRegisterType(FirstStartMachineActionsModel, "Cura", 1, 0, "FirstStartMachineActionsModel")
|
||||||
qmlRegisterType(MachineNameValidator, "Cura", 1, 0, "MachineNameValidator")
|
qmlRegisterType(MachineNameValidator, "Cura", 1, 0, "MachineNameValidator")
|
||||||
qmlRegisterType(UserChangesModel, "Cura", 1, 0, "UserChangesModel")
|
qmlRegisterType(UserChangesModel, "Cura", 1, 0, "UserChangesModel")
|
||||||
qmlRegisterSingletonType(ContainerManager, "Cura", 1, 0, "ContainerManager", ContainerManager.getInstance)
|
qmlRegisterSingletonType(ContainerManager, "Cura", 1, 0, "ContainerManager", ContainerManager.getInstance)
|
||||||
|
|
52
cura/Machines/Models/FirstStartMachineActionsModel.py
Normal file
52
cura/Machines/Models/FirstStartMachineActionsModel.py
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# Copyright (c) 2019 Ultimaker B.V.
|
||||||
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from PyQt5.QtCore import QObject, Qt
|
||||||
|
|
||||||
|
from UM.Qt.ListModel import ListModel
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# This model holds all first-start machine actions for the currently active machine. It has 2 roles:
|
||||||
|
# - title : the title/name of the action
|
||||||
|
# - content : the QObject of the QML content of the action
|
||||||
|
#
|
||||||
|
class FirstStartMachineActionsModel(ListModel):
|
||||||
|
|
||||||
|
TitleRole = Qt.UserRole + 1
|
||||||
|
ContentRole = Qt.UserRole + 2
|
||||||
|
|
||||||
|
def __init__(self, parent: Optional[QObject] = None) -> None:
|
||||||
|
super().__init__(parent)
|
||||||
|
|
||||||
|
self.addRoleName(self.TitleRole, "title")
|
||||||
|
self.addRoleName(self.ContentRole, "content")
|
||||||
|
|
||||||
|
from cura.CuraApplication import CuraApplication
|
||||||
|
self._application = CuraApplication.getInstance()
|
||||||
|
|
||||||
|
def initialize(self) -> None:
|
||||||
|
self._application.getMachineManager().globalContainerChanged.connect(self._update)
|
||||||
|
self._update()
|
||||||
|
|
||||||
|
def _update(self) -> None:
|
||||||
|
global_stack = self._application.getMachineManager().activeMachine
|
||||||
|
if global_stack is None:
|
||||||
|
self.setItems([])
|
||||||
|
return
|
||||||
|
|
||||||
|
definition_id = global_stack.definition.getId()
|
||||||
|
first_start_actions = self._application.getMachineActionManager().getFirstStartActions(definition_id)
|
||||||
|
|
||||||
|
item_list = []
|
||||||
|
for item in first_start_actions:
|
||||||
|
item_list.append({"title": item.label,
|
||||||
|
"content": item.displayItem,
|
||||||
|
})
|
||||||
|
|
||||||
|
self.setItems(item_list)
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["FirstStartMachineActionsModel"]
|
Loading…
Add table
Add a link
Reference in a new issue