From 0906e3f1e79d74736b96cd5c0dbd7158c0f70b2f Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Sat, 23 Jun 2018 16:16:06 +0200 Subject: [PATCH] Store custom Menu items in CuraApplication --- cura/CuraApplication.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 08f267d0e1..e5562745de 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -101,6 +101,7 @@ from cura.Settings.UserChangesModel import UserChangesModel from cura.Settings.ExtrudersModel import ExtrudersModel from cura.Settings.MaterialSettingsVisibilityHandler import MaterialSettingsVisibilityHandler from cura.Settings.ContainerManager import ContainerManager +from cura.Settings.SidebarCustomMenuItemsModel import SidebarCustomMenuItemsModel from cura.ObjectsModel import ObjectsModel @@ -219,6 +220,8 @@ class CuraApplication(QtApplication): self._need_to_show_user_agreement = True + self._sidebar_custom_menu_items = [] # type: list # Keeps list of custom menu items for the side bar + # Backups self._auto_save = None self._save_data_enabled = True @@ -943,6 +946,7 @@ class CuraApplication(QtApplication): qmlRegisterType(MachineNameValidator, "Cura", 1, 0, "MachineNameValidator") qmlRegisterType(UserChangesModel, "Cura", 1, 0, "UserChangesModel") qmlRegisterSingletonType(ContainerManager, "Cura", 1, 0, "ContainerManager", ContainerManager.getInstance) + qmlRegisterType(SidebarCustomMenuItemsModel, "Cura", 1, 0, "SidebarCustomMenuItemsModel") # As of Qt5.7, it is necessary to get rid of any ".." in the path for the singleton to work. actions_url = QUrl.fromLocalFile(os.path.abspath(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, "Actions.qml"))) @@ -1729,3 +1733,10 @@ class CuraApplication(QtApplication): @pyqtSlot() def showMoreInformationDialogForAnonymousDataCollection(self): self._plugin_registry.getPluginObject("SliceInfoPlugin").showMoreInfoDialog() + + + def addSidebarCustomMenuItem(self, menu_item: list) -> None: + self._sidebar_custom_menu_items.append(menu_item) + + def getSidebarCustomMenuItems(self) -> list: + return self._sidebar_custom_menu_items \ No newline at end of file