diff --git a/cura/GlobalStacksModel.py b/cura/GlobalStacksModel.py index 32b0d9cead..3c3321e5ca 100644 --- a/cura/GlobalStacksModel.py +++ b/cura/GlobalStacksModel.py @@ -1,12 +1,16 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from PyQt5.QtCore import Qt from UM.Qt.ListModel import ListModel + +from PyQt5.QtCore import pyqtProperty, Qt, QTimer + from cura.PrinterOutputDevice import ConnectionType from cura.Settings.CuraContainerRegistry import CuraContainerRegistry +from cura.Settings.GlobalStack import GlobalStack + class GlobalStacksModel(ListModel): NameRole = Qt.UserRole + 1 @@ -23,20 +27,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): - from cura.Settings.GlobalStack import GlobalStack # otherwise circular imports - # 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 = [] 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() diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 03b04cc3bb..1b6c6e44f7 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -273,15 +273,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() 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 - } } } } diff --git a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml index f11047c2c6..f2f488a1b0 100644 --- a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml +++ b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml @@ -251,10 +251,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 width: selectors.controlWidth 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) } diff --git a/resources/qml/Preferences/GeneralPage.qml b/resources/qml/Preferences/GeneralPage.qml index 0dd6c6313a..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 @@ -130,8 +116,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"} @@ -672,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?") @@ -688,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.") 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" } } } diff --git a/resources/qml/Settings/SettingItem.qml b/resources/qml/Settings/SettingItem.qml index e1a13fe425..6bfcd66557 100644 --- a/resources/qml/Settings/SettingItem.qml +++ b/resources/qml/Settings/SettingItem.qml @@ -33,7 +33,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] @@ -234,19 +234,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 } @@ -317,6 +317,4 @@ Item height: UM.Theme.getSize("setting_control").height } } - - UM.I18nCatalog { id: catalog; name: "cura" } }