Merge branch '4.0' of github.com:Ultimaker/Cura into 4.0

This commit is contained in:
Diego Prado Gesto 2019-02-22 13:18:36 +01:00
commit 4d030572ba
7 changed files with 33 additions and 8 deletions

View File

@ -3,7 +3,7 @@
from UM.Qt.ListModel import ListModel 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.PrinterOutputDevice import ConnectionType
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry from cura.Settings.CuraContainerRegistry import CuraContainerRegistry
@ -26,18 +26,26 @@ class GlobalStacksModel(ListModel):
self.addRoleName(self.MetaDataRole, "metadata") self.addRoleName(self.MetaDataRole, "metadata")
self._container_stacks = [] 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 # Listen to changes
CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerChanged) CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerChanged)
CuraContainerRegistry.getInstance().containerMetaDataChanged.connect(self._onContainerChanged) CuraContainerRegistry.getInstance().containerMetaDataChanged.connect(self._onContainerChanged)
CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged) CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged)
self._filter_dict = {} self._filter_dict = {}
self._update() self._updateDelayed()
## Handler for container added/removed events from registry ## Handler for container added/removed events from registry
def _onContainerChanged(self, container): def _onContainerChanged(self, container):
# We only need to update when the added / removed container GlobalStack # We only need to update when the added / removed container GlobalStack
if isinstance(container, GlobalStack): if isinstance(container, GlobalStack):
self._update() self._updateDelayed()
def _updateDelayed(self):
self._change_timer.start()
def _update(self) -> None: def _update(self) -> None:
items = [] items = []

View File

@ -16,6 +16,7 @@ from cura.Machines.MaterialNode import MaterialNode
class BaseMaterialsModel(ListModel): class BaseMaterialsModel(ListModel):
extruderPositionChanged = pyqtSignal() extruderPositionChanged = pyqtSignal()
enabledChanged = pyqtSignal()
def __init__(self, parent = None): def __init__(self, parent = None):
super().__init__(parent) super().__init__(parent)
@ -60,6 +61,7 @@ class BaseMaterialsModel(ListModel):
self._available_materials = None # type: Optional[Dict[str, MaterialNode]] self._available_materials = None # type: Optional[Dict[str, MaterialNode]]
self._favorite_ids = set() # type: Set[str] self._favorite_ids = set() # type: Set[str]
self._enabled = True
def _updateExtruderStack(self): def _updateExtruderStack(self):
global_stack = self._machine_manager.activeMachine global_stack = self._machine_manager.activeMachine
@ -86,6 +88,18 @@ class BaseMaterialsModel(ListModel):
def extruderPosition(self) -> int: def extruderPosition(self) -> int:
return self._extruder_position return self._extruder_position
def setEnabled(self, enabled):
if self._enabled != enabled:
self._enabled = enabled
if self._enabled:
# ensure the data is there again.
self._update()
self.enabledChanged.emit()
@pyqtProperty(bool, fset=setEnabled, notify=enabledChanged)
def enabled(self):
return self._enabled
## This is an abstract method that needs to be implemented by the specific ## This is an abstract method that needs to be implemented by the specific
# models themselves. # models themselves.
def _update(self): def _update(self):
@ -97,7 +111,7 @@ class BaseMaterialsModel(ListModel):
def _canUpdate(self): def _canUpdate(self):
global_stack = self._machine_manager.activeMachine global_stack = self._machine_manager.activeMachine
if global_stack is None: if global_stack is None or not self._enabled:
return False return False
extruder_position = str(self._extruder_position) extruder_position = str(self._extruder_position)

View File

@ -10,6 +10,7 @@ from UM.Settings.SettingFunction import SettingFunction
from cura.Machines.QualityManager import QualityGroup from cura.Machines.QualityManager import QualityGroup
# #
# QML Model for all built-in quality profiles. This model is used for the drop-down quality menu. # 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.setSingleShot(True)
self._update_timer.timeout.connect(self._update) self._update_timer.timeout.connect(self._update)
self._update() self._onChange()
def _onChange(self) -> None: def _onChange(self) -> None:
self._update_timer.start() self._update_timer.start()

View File

@ -254,6 +254,7 @@ Item
menu: Cura.MaterialMenu menu: Cura.MaterialMenu
{ {
extruderIndex: Cura.ExtruderManager.activeExtruderIndex extruderIndex: Cura.ExtruderManager.activeExtruderIndex
updateModels: materialSelection.visible
} }
} }
} }

View File

@ -15,22 +15,26 @@ Menu
property int extruderIndex: 0 property int extruderIndex: 0
property string currentRootMaterialId: Cura.MachineManager.currentRootMaterialId[extruderIndex] property string currentRootMaterialId: Cura.MachineManager.currentRootMaterialId[extruderIndex]
property string activeMaterialId: Cura.MachineManager.allActiveMaterialIds[Cura.ExtruderManager.extruderIds[extruderIndex]] property string activeMaterialId: Cura.MachineManager.allActiveMaterialIds[Cura.ExtruderManager.extruderIds[extruderIndex]]
property bool updateModels: true
Cura.FavoriteMaterialsModel Cura.FavoriteMaterialsModel
{ {
id: favoriteMaterialsModel id: favoriteMaterialsModel
extruderPosition: menu.extruderIndex extruderPosition: menu.extruderIndex
enabled: updateModels
} }
Cura.GenericMaterialsModel Cura.GenericMaterialsModel
{ {
id: genericMaterialsModel id: genericMaterialsModel
extruderPosition: menu.extruderIndex extruderPosition: menu.extruderIndex
enabled: updateModels
} }
Cura.MaterialBrandsModel Cura.MaterialBrandsModel
{ {
id: brandModel id: brandModel
extruderPosition: menu.extruderIndex extruderPosition: menu.extruderIndex
enabled: updateModels
} }
MenuItem MenuItem

View File

@ -11,7 +11,6 @@ Menu
{ {
title: catalog.i18nc("@title:menu menubar:toplevel", "&View") title: catalog.i18nc("@title:menu menubar:toplevel", "&View")
id: base id: base
enabled: !PrintInformation.preSliced
property var multiBuildPlateModel: CuraApplication.getMultiBuildPlateModel() property var multiBuildPlateModel: CuraApplication.getMultiBuildPlateModel()

View File

@ -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.")) 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() onExited: base.hideTooltip()
UM.I18nCatalog { id: catalog; name: "cura" }
} }
} }