From 11aa71a5dfa6e6bf321313511df61c019b80717b Mon Sep 17 00:00:00 2001 From: "saumya.jain" Date: Mon, 8 Jan 2024 14:41:41 +0100 Subject: [PATCH] Singleton management in Cura -QualityManagementModel, MaterialManagementModel, SimpleModeSettingsManager, MachineActionManager and CustomQualityProfilesDropDownMenuModel *deleted* -QualityProfilesDropDownmenuModel changed to RegisterType CURA-7812 --- cura/CuraApplication.py | 22 +++++++++---------- resources/qml/Preferences/MachinesPage.qml | 4 +++- .../Custom/QualitiesWithIntentMenu.qml | 2 +- .../ProfileWarningReset.qml | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 1ef2f63a9e..3243260b6e 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1138,6 +1138,10 @@ class CuraApplication(QtApplication): return cast(MachineActionManager.MachineActionManager, self._machine_action_manager) + @pyqtSlot(result = QObject) + def getMachineActionManagerQml(self)-> MachineActionManager.MachineActionManager: + return cast(QObject, self._machine_action_manager) + @pyqtSlot(result = QObject) def getMaterialManagementModel(self) -> MaterialManagementModel: if not self._material_management_model: @@ -1150,7 +1154,8 @@ class CuraApplication(QtApplication): self._quality_management_model = QualityManagementModel(parent = self) return self._quality_management_model - def getSimpleModeSettingsManager(self, *args): + @pyqtSlot(result=QObject) + def getSimpleModeSettingsManager(self)-> SimpleModeSettingsManager: if self._simple_mode_settings_manager is None: self._simple_mode_settings_manager = SimpleModeSettingsManager() return self._simple_mode_settings_manager @@ -1193,12 +1198,14 @@ class CuraApplication(QtApplication): return self._print_information - def getQualityProfilesDropDownMenuModel(self, *args, **kwargs): + pyqtSlot(result =QObject) + def getQualityProfilesDropDownMenuModel(self, *args, **kwargs)-> QualityProfilesDropDownMenuModel: if self._quality_profile_drop_down_menu_model is None: self._quality_profile_drop_down_menu_model = QualityProfilesDropDownMenuModel(self) return self._quality_profile_drop_down_menu_model - def getCustomQualityProfilesDropDownMenuModel(self, *args, **kwargs): + pyqtSlot(result=QObject) + def getCustomQualityProfilesDropDownMenuModel(self, *args, **kwargs)->CustomQualityProfilesDropDownMenuModel: if self._custom_quality_profile_drop_down_menu_model is None: self._custom_quality_profile_drop_down_menu_model = CustomQualityProfilesDropDownMenuModel(self) return self._custom_quality_profile_drop_down_menu_model @@ -1231,8 +1238,6 @@ class CuraApplication(QtApplication): qmlRegisterSingletonType(MachineManager, "Cura", 1, 0, self.getMachineManager, "MachineManager") qmlRegisterSingletonType(IntentManager, "Cura", 1, 6, self.getIntentManager, "IntentManager") qmlRegisterSingletonType(SettingInheritanceManager, "Cura", 1, 0, self.getSettingInheritanceManager, "SettingInheritanceManager") - qmlRegisterSingletonType(SimpleModeSettingsManager, "Cura", 1, 0, self.getSimpleModeSettingsManager, "SimpleModeSettingsManager") - qmlRegisterSingletonType(MachineActionManager.MachineActionManager, "Cura", 1, 0, self.getMachineActionManager, "MachineActionManager") self.processEvents() qmlRegisterType(NetworkingUtil, "Cura", 1, 5, "NetworkingUtil") @@ -1257,16 +1262,11 @@ class CuraApplication(QtApplication): qmlRegisterType(FavoriteMaterialsModel, "Cura", 1, 0, "FavoriteMaterialsModel") qmlRegisterType(GenericMaterialsModel, "Cura", 1, 0, "GenericMaterialsModel") qmlRegisterType(MaterialBrandsModel, "Cura", 1, 0, "MaterialBrandsModel") - qmlRegisterSingletonType(QualityManagementModel, "Cura", 1, 0, self.getQualityManagementModel, "QualityManagementModel") - qmlRegisterSingletonType(MaterialManagementModel, "Cura", 1, 5, self.getMaterialManagementModel, "MaterialManagementModel") self.processEvents() qmlRegisterType(DiscoveredPrintersModel, "Cura", 1, 0, "DiscoveredPrintersModel") qmlRegisterType(DiscoveredCloudPrintersModel, "Cura", 1, 7, "DiscoveredCloudPrintersModel") - qmlRegisterSingletonType(QualityProfilesDropDownMenuModel, "Cura", 1, 0, - self.getQualityProfilesDropDownMenuModel, "QualityProfilesDropDownMenuModel") - qmlRegisterSingletonType(CustomQualityProfilesDropDownMenuModel, "Cura", 1, 0, - self.getCustomQualityProfilesDropDownMenuModel, "CustomQualityProfilesDropDownMenuModel") + qmlRegisterType(QualityProfilesDropDownMenuModel, "Cura", 1, 0, "QualityProfilesDropDownMenuModel") qmlRegisterType(NozzleModel, "Cura", 1, 0, "NozzleModel") qmlRegisterType(IntentModel, "Cura", 1, 6, "IntentModel") qmlRegisterType(IntentCategoryModel, "Cura", 1, 6, "IntentCategoryModel") diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index fb98cb59c5..971de03696 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -12,6 +12,7 @@ import Cura 1.0 as Cura UM.ManagementPage { id: base + property var machineActionManager: CuraApplication.getMachineActionManagerQml() Item { enabled: false; UM.I18nCatalog { id: catalog; name: "cura"} } title: catalog.i18nc("@title:tab", "Printers") @@ -58,10 +59,11 @@ UM.ManagementPage anchors.fill: parent spacing: UM.Theme.getSize("default_margin").height + Repeater { id: machineActionRepeater - model: base.currentItem ? Cura.MachineActionManager.getSupportedActions(Cura.MachineManager.getDefinitionByMachineId(base.currentItem.id)) : null + model: base.currentItem ? machineActionManager.getSupportedActions(Cura.MachineManager.getDefinitionByMachineId(base.currentItem.id)) : null Item { diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml index 646e835cb2..9facc5095e 100644 --- a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -187,7 +187,7 @@ Popup //Add all the custom profiles. Repeater { - model: Cura.CustomQualityProfilesDropDownMenuModel + model: CuraApplication.getCustomQualityProfilesDropDownMenuModel() MenuButton { onClicked: Cura.MachineManager.setQualityChangesGroup(model.quality_changes_group) diff --git a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml index c44fcc8cc2..bf4385446d 100644 --- a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml +++ b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml @@ -11,7 +11,7 @@ import "../Dialogs" Item { property bool fullWarning: true // <- Can you see the warning icon and the text, or is it just the buttons? - + property var simpleModeSettingsManager :CuraApplication.getSimpleModeSettingsManager() height: visible ? UM.Theme.getSize("action_button_icon").height : 0 width: visible ? childrenRect.width: 0 visible: Cura.MachineManager.hasUserSettings || (fullWarning && Cura.MachineManager.hasCustomQuality) @@ -96,7 +96,7 @@ Item State { name: "custom settings changed" - when: Cura.SimpleModeSettingsManager.isProfileCustomized + when: simpleModeSettingsManager.isProfileCustomized PropertyChanges { target: warning