From b07086dee4a319211fe2c93bfe034df601c5bbc3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 21 Feb 2019 14:49:25 +0100 Subject: [PATCH 01/11] Remove catalog creation from setting item This pretty much doubles the speed by which setting items are created. --- resources/qml/Settings/SettingItem.qml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/resources/qml/Settings/SettingItem.qml b/resources/qml/Settings/SettingItem.qml index 4dd53f8663..26ce791f81 100644 --- a/resources/qml/Settings/SettingItem.qml +++ b/resources/qml/Settings/SettingItem.qml @@ -315,7 +315,5 @@ Item width: UM.Theme.getSize("setting_control").width height: UM.Theme.getSize("setting_control").height } - } - - UM.I18nCatalog { id: catalog; name: "cura" } + } } From c2d783bf7aa7ae50bb381cefd76d696cc2a5f6e7 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 21 Feb 2019 15:05:40 +0100 Subject: [PATCH 02/11] Removed unused plugins model --- resources/qml/Preferences/GeneralPage.qml | 2 -- resources/qml/Settings/SettingItem.qml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/resources/qml/Preferences/GeneralPage.qml b/resources/qml/Preferences/GeneralPage.qml index 0dd6c6313a..6030bd2752 100644 --- a/resources/qml/Preferences/GeneralPage.qml +++ b/resources/qml/Preferences/GeneralPage.qml @@ -130,8 +130,6 @@ UM.PreferencesPage Column { - //: Model used to check if a plugin exists - UM.PluginsModel { id: plugins } //: Language selection label UM.I18nCatalog{id: catalog; name: "cura"} diff --git a/resources/qml/Settings/SettingItem.qml b/resources/qml/Settings/SettingItem.qml index 26ce791f81..c8f78bd91b 100644 --- a/resources/qml/Settings/SettingItem.qml +++ b/resources/qml/Settings/SettingItem.qml @@ -315,5 +315,5 @@ Item width: UM.Theme.getSize("setting_control").width height: UM.Theme.getSize("setting_control").height } - } + } } From b2df5c3445a4b7b5e0ec4da5e796cd0f0bb63fbc Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 21 Feb 2019 15:08:41 +0100 Subject: [PATCH 03/11] Remove the numSettingsVisible property from the workspace dialog This slows down the booting of Cura and it's probably not something people care about. --- .../qml/Dialogs/WorkspaceSummaryDialog.qml | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/resources/qml/Dialogs/WorkspaceSummaryDialog.qml b/resources/qml/Dialogs/WorkspaceSummaryDialog.qml index 35630bd19b..25cde33c99 100644 --- a/resources/qml/Dialogs/WorkspaceSummaryDialog.qml +++ b/resources/qml/Dialogs/WorkspaceSummaryDialog.qml @@ -226,32 +226,6 @@ UM.Dialog text: Cura.MachineManager.activeQualityOrQualityChangesName width: Math.floor(scroll.width / 3) | 0 } - - } - } - Column - { - width: parent.width - height: childrenRect.height - Label - { - text: catalog.i18nc("@action:label", "Setting visibility") - font.bold: true - } - Row - { - width: parent.width - height: childrenRect.height - Label - { - text: catalog.i18nc("@action:label", "Visible settings:") - width: Math.floor(scroll.width / 3) | 0 - } - Label - { - text: catalog.i18nc("@action:label", "%1 out of %2" ).arg(definitionsModel.visibleCount).arg(Cura.MachineManager.totalNumberOfSettings) - width: Math.floor(scroll.width / 3) | 0 - } } } } From 27370dd45d94bc05fef7cbf96ad53f01e52e67a3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 21 Feb 2019 15:26:25 +0100 Subject: [PATCH 04/11] Improve the bindings for the material menu This way the evaluation is significantly faster. --- resources/qml/Menus/MaterialMenu.qml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/resources/qml/Menus/MaterialMenu.qml b/resources/qml/Menus/MaterialMenu.qml index f9e343d2dd..0116169ed6 100644 --- a/resources/qml/Menus/MaterialMenu.qml +++ b/resources/qml/Menus/MaterialMenu.qml @@ -13,7 +13,8 @@ Menu title: catalog.i18nc("@label:category menu label", "Material") property int extruderIndex: 0 - + property string currentRootMaterialId: Cura.MachineManager.currentRootMaterialId[extruderIndex] + property string activeMaterialId: Cura.MachineManager.allActiveMaterialIds[Cura.ExtruderManager.extruderIds[extruderIndex]] Cura.FavoriteMaterialsModel { id: favoriteMaterialsModel @@ -45,7 +46,7 @@ Menu { text: model.brand + " " + model.name checkable: true - checked: model.root_material_id == Cura.MachineManager.currentRootMaterialId[extruderIndex] + checked: model.root_material_id === menu.currentRootMaterialId onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node) exclusiveGroup: group } @@ -67,7 +68,7 @@ Menu { text: model.name checkable: true - checked: model.root_material_id == Cura.MachineManager.currentRootMaterialId[extruderIndex] + checked: model.root_material_id === menu.currentRootMaterialId exclusiveGroup: group onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node) } @@ -105,7 +106,7 @@ Menu { text: model.name checkable: true - checked: model.id == Cura.MachineManager.allActiveMaterialIds[Cura.ExtruderManager.extruderIds[extruderIndex]] + checked: model.id === menu.activeMaterialId exclusiveGroup: group onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node) } From 1b36a8e12cf10985a15b9d7ab86f0b95ac812740 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 21 Feb 2019 16:17:25 +0100 Subject: [PATCH 05/11] Fix some more bindings for SettingItem --- resources/qml/Settings/SettingItem.qml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/qml/Settings/SettingItem.qml b/resources/qml/Settings/SettingItem.qml index c8f78bd91b..a236bb73c8 100644 --- a/resources/qml/Settings/SettingItem.qml +++ b/resources/qml/Settings/SettingItem.qml @@ -32,7 +32,7 @@ Item // Create properties to put property provider stuff in (bindings break in qt 5.5.1 otherwise) property var state: propertyProvider.properties.state // There is no resolve property if there is only one stack. - property var resolve: Cura.MachineManager.activeStackId != Cura.MachineManager.activeMachineId ? propertyProvider.properties.resolve : "None" + property var resolve: Cura.MachineManager.activeStackId !== Cura.MachineManager.activeMachineId ? propertyProvider.properties.resolve : "None" property var stackLevels: propertyProvider.stackLevels property var stackLevel: stackLevels[0] @@ -233,19 +233,19 @@ Item } // There are no settings with any warning. - if (Cura.SettingInheritanceManager.settingsWithInheritanceWarning.length == 0) + if (Cura.SettingInheritanceManager.settingsWithInheritanceWarning.length === 0) { return false } // This setting has a resolve value, so an inheritance warning doesn't do anything. - if (resolve != "None") + if (resolve !== "None") { return false } // If the setting does not have a limit_to_extruder property (or is -1), use the active stack. - if (globalPropertyProvider.properties.limit_to_extruder == null || String(globalPropertyProvider.properties.limit_to_extruder) == "-1") + if (globalPropertyProvider.properties.limit_to_extruder === null || String(globalPropertyProvider.properties.limit_to_extruder) === "-1") { return Cura.SettingInheritanceManager.settingsWithInheritanceWarning.indexOf(definition.key) >= 0 } From b64cf1fe1c7ac48ce81130ba857bf6409a463031 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 21 Feb 2019 16:19:16 +0100 Subject: [PATCH 06/11] Remove unneeded signal call --- cura/Settings/MachineManager.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 4bdcc022df..bb0c0c00ed 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -281,15 +281,8 @@ class MachineManager(QObject): def _onActiveExtruderStackChanged(self) -> None: self.blurSettings.emit() # Ensure no-one has focus. - old_active_container_stack = self._active_container_stack - self._active_container_stack = ExtruderManager.getInstance().getActiveExtruderStack() - if old_active_container_stack != self._active_container_stack: - # Many methods and properties related to the active quality actually depend - # on _active_container_stack. If it changes, then the properties change. - self.activeQualityChanged.emit() - def __emitChangedSignals(self) -> None: self.activeQualityChanged.emit() self.activeVariantChanged.emit() From d9c4edf0935d80bff6d474737a3f5b2d494ba997 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 21 Feb 2019 16:36:14 +0100 Subject: [PATCH 07/11] Prevent a few expensive conversions from happening in the QML --- resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml | 4 ++-- resources/qml/Menus/MaterialMenu.qml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml index 606dc142be..29e9cd6353 100644 --- a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml +++ b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml @@ -240,10 +240,10 @@ Item { id: materialSelection - property bool valueError: Cura.MachineManager.activeStack != null ? Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeStack.material.id, "compatible", "") != "True" : true + property bool valueError: Cura.MachineManager.activeStack !== null ? Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeStack.material.id, "compatible", "") !== "True" : true property bool valueWarning: !Cura.MachineManager.isActiveQualitySupported - text: Cura.MachineManager.activeStack != null ? Cura.MachineManager.activeStack.material.name : "" + text: Cura.MachineManager.activeStack !== null ? Cura.MachineManager.activeStack.material.name : "" tooltip: text height: UM.Theme.getSize("print_setup_big_item").height diff --git a/resources/qml/Menus/MaterialMenu.qml b/resources/qml/Menus/MaterialMenu.qml index 0116169ed6..0264ad8fc7 100644 --- a/resources/qml/Menus/MaterialMenu.qml +++ b/resources/qml/Menus/MaterialMenu.qml @@ -97,7 +97,7 @@ Menu id: brandMaterialsMenu title: materialName property string materialName: model.name - property var brandMaterialColors: model.colors + property ListModel brandMaterialColors: model.colors Instantiator { From 48ed9b6e20d509c50eb9dcd19b0b5ed26d998d4d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 21 Feb 2019 17:16:59 +0100 Subject: [PATCH 08/11] Remove usage of plugin model --- resources/qml/Menus/MaterialMenu.qml | 2 +- resources/qml/Preferences/GeneralPage.qml | 24 ++++------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/resources/qml/Menus/MaterialMenu.qml b/resources/qml/Menus/MaterialMenu.qml index 0264ad8fc7..0116169ed6 100644 --- a/resources/qml/Menus/MaterialMenu.qml +++ b/resources/qml/Menus/MaterialMenu.qml @@ -97,7 +97,7 @@ Menu id: brandMaterialsMenu title: materialName property string materialName: model.name - property ListModel brandMaterialColors: model.colors + property var brandMaterialColors: model.colors Instantiator { diff --git a/resources/qml/Preferences/GeneralPage.qml b/resources/qml/Preferences/GeneralPage.qml index 6030bd2752..e8519c6abf 100644 --- a/resources/qml/Preferences/GeneralPage.qml +++ b/resources/qml/Preferences/GeneralPage.qml @@ -101,24 +101,10 @@ UM.PreferencesPage UM.Preferences.resetPreference("cura/choice_on_open_project") setDefaultOpenProjectOption(UM.Preferences.getValue("cura/choice_on_open_project")) - if (pluginExistsAndEnabled("SliceInfoPlugin")) { - UM.Preferences.resetPreference("info/send_slice_info") - sendDataCheckbox.checked = boolCheck(UM.Preferences.getValue("info/send_slice_info")) - } - if (pluginExistsAndEnabled("UpdateChecker")) { - UM.Preferences.resetPreference("info/automatic_update_check") - checkUpdatesCheckbox.checked = boolCheck(UM.Preferences.getValue("info/automatic_update_check")) - } - } - - function pluginExistsAndEnabled(pluginName) - { - var pluginItem = plugins.find("id", pluginName) - if (pluginItem > -1) - { - return plugins.getItem(pluginItem).enabled - } - return false + UM.Preferences.resetPreference("info/send_slice_info") + sendDataCheckbox.checked = boolCheck(UM.Preferences.getValue("info/send_slice_info")) + UM.Preferences.resetPreference("info/automatic_update_check") + checkUpdatesCheckbox.checked = boolCheck(UM.Preferences.getValue("info/automatic_update_check")) } ScrollView @@ -670,7 +656,6 @@ UM.PreferencesPage UM.TooltipArea { - visible: pluginExistsAndEnabled("UpdateChecker") width: childrenRect.width height: visible ? childrenRect.height : 0 text: catalog.i18nc("@info:tooltip","Should Cura check for updates when the program is started?") @@ -686,7 +671,6 @@ UM.PreferencesPage UM.TooltipArea { - visible: pluginExistsAndEnabled("SliceInfoPlugin") width: childrenRect.width height: visible ? childrenRect.height : 0 text: catalog.i18nc("@info:tooltip","Should anonymous data about your print be sent to Ultimaker? Note, no models, IP addresses or other personally identifiable information is sent or stored.") From 511895337394992ad9d4fa293b98cc1c9eed1a1f Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 21 Feb 2019 18:30:23 +0100 Subject: [PATCH 09/11] Put a change timer on the globalStacks model This decreases the time that a first thing is shown on the main screen (as the creation of the global stack model doesn't block the UI anymore) --- cura/GlobalStacksModel.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cura/GlobalStacksModel.py b/cura/GlobalStacksModel.py index ea8a9c7961..d67d283a1c 100644 --- a/cura/GlobalStacksModel.py +++ b/cura/GlobalStacksModel.py @@ -3,7 +3,7 @@ from UM.Qt.ListModel import ListModel -from PyQt5.QtCore import pyqtProperty, Qt, pyqtSignal +from PyQt5.QtCore import pyqtProperty, Qt, pyqtSignal, QTimer from cura.PrinterOutputDevice import ConnectionType from cura.Settings.CuraContainerRegistry import CuraContainerRegistry @@ -26,18 +26,26 @@ class GlobalStacksModel(ListModel): self.addRoleName(self.MetaDataRole, "metadata") self._container_stacks = [] + self._change_timer = QTimer() + self._change_timer.setInterval(200) + self._change_timer.setSingleShot(True) + self._change_timer.timeout.connect(self._update) + # Listen to changes CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerChanged) CuraContainerRegistry.getInstance().containerMetaDataChanged.connect(self._onContainerChanged) CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged) self._filter_dict = {} - self._update() + self._updateDelayed() ## Handler for container added/removed events from registry def _onContainerChanged(self, container): # We only need to update when the added / removed container GlobalStack if isinstance(container, GlobalStack): - self._update() + self._updateDelayed() + + def _updateDelayed(self): + self._change_timer.start() def _update(self) -> None: items = [] From fc11286c6cbfa416d69df1e3fd15dd7fe34df8e8 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 21 Feb 2019 18:38:51 +0100 Subject: [PATCH 10/11] Also ensure that the QualtiyProfilesModel is on a changeTimer on create --- cura/Machines/Models/QualityProfilesDropDownMenuModel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cura/Machines/Models/QualityProfilesDropDownMenuModel.py b/cura/Machines/Models/QualityProfilesDropDownMenuModel.py index 7ccc886bfe..deabb6e9ba 100644 --- a/cura/Machines/Models/QualityProfilesDropDownMenuModel.py +++ b/cura/Machines/Models/QualityProfilesDropDownMenuModel.py @@ -10,6 +10,7 @@ from UM.Settings.SettingFunction import SettingFunction from cura.Machines.QualityManager import QualityGroup + # # QML Model for all built-in quality profiles. This model is used for the drop-down quality menu. # @@ -51,7 +52,7 @@ class QualityProfilesDropDownMenuModel(ListModel): self._update_timer.setSingleShot(True) self._update_timer.timeout.connect(self._update) - self._update() + self._onChange() def _onChange(self) -> None: self._update_timer.start() From 8409d7d6455517624d88f267b314a6649fb51059 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 21 Feb 2019 18:42:06 +0100 Subject: [PATCH 11/11] Remove another unneeded catalog --- resources/qml/Settings/SettingCategory.qml | 2 -- 1 file changed, 2 deletions(-) diff --git a/resources/qml/Settings/SettingCategory.qml b/resources/qml/Settings/SettingCategory.qml index 1e88867889..18c5820832 100644 --- a/resources/qml/Settings/SettingCategory.qml +++ b/resources/qml/Settings/SettingCategory.qml @@ -237,7 +237,5 @@ Button onEntered: base.showTooltip(catalog.i18nc("@label","Some hidden settings use values different from their normal calculated value.\n\nClick to make these settings visible.")) onExited: base.hideTooltip() - - UM.I18nCatalog { id: catalog; name: "cura" } } }