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 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 = []

View File

@ -16,6 +16,7 @@ from cura.Machines.MaterialNode import MaterialNode
class BaseMaterialsModel(ListModel):
extruderPositionChanged = pyqtSignal()
enabledChanged = pyqtSignal()
def __init__(self, parent = None):
super().__init__(parent)
@ -60,6 +61,7 @@ class BaseMaterialsModel(ListModel):
self._available_materials = None # type: Optional[Dict[str, MaterialNode]]
self._favorite_ids = set() # type: Set[str]
self._enabled = True
def _updateExtruderStack(self):
global_stack = self._machine_manager.activeMachine
@ -86,6 +88,18 @@ class BaseMaterialsModel(ListModel):
def extruderPosition(self) -> int:
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
# models themselves.
def _update(self):
@ -97,7 +111,7 @@ class BaseMaterialsModel(ListModel):
def _canUpdate(self):
global_stack = self._machine_manager.activeMachine
if global_stack is None:
if global_stack is None or not self._enabled:
return False
extruder_position = str(self._extruder_position)

View File

@ -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()

View File

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

View File

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

View File

@ -11,7 +11,6 @@ Menu
{
title: catalog.i18nc("@title:menu menubar:toplevel", "&View")
id: base
enabled: !PrintInformation.preSliced
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."))
onExited: base.hideTooltip()
UM.I18nCatalog { id: catalog; name: "cura" }
}
}