Merge branch '4.0'

This commit is contained in:
Ghostkeeper 2018-12-14 15:02:30 +01:00
commit 2e835bf48d
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
19 changed files with 64 additions and 64 deletions

View file

@ -205,6 +205,8 @@ class CuraApplication(QtApplication):
self._container_manager = None
self._object_manager = None
self._extruders_model = None
self._extruders_model_with_optional = None
self._build_plate_model = None
self._multi_build_plate_model = None
self._setting_visibility_presets_model = None
@ -862,6 +864,19 @@ class CuraApplication(QtApplication):
self._object_manager = ObjectsModel.createObjectsModel()
return self._object_manager
@pyqtSlot(result = QObject)
def getExtrudersModel(self, *args) -> "ExtrudersModel":
if self._extruders_model is None:
self._extruders_model = ExtrudersModel(self)
return self._extruders_model
@pyqtSlot(result = QObject)
def getExtrudersModelWithOptional(self, *args) -> "ExtrudersModel":
if self._extruders_model_with_optional is None:
self._extruders_model_with_optional = ExtrudersModel(self)
self._extruders_model_with_optional.setAddOptionalExtruder(True)
return self._extruders_model_with_optional
@pyqtSlot(result = QObject)
def getMultiBuildPlateModel(self, *args) -> MultiBuildPlateModel:
if self._multi_build_plate_model is None:

View file

@ -33,8 +33,6 @@ class NozzleModel(ListModel):
def _update(self):
Logger.log("d", "Updating {model_class_name}.".format(model_class_name = self.__class__.__name__))
self.items.clear()
global_stack = self._machine_manager.activeMachine
if global_stack is None:
self.setItems([])

View file

@ -1,7 +1,7 @@
# Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot, pyqtProperty, QTimer
from PyQt5.QtCore import Qt, pyqtSignal, pyqtProperty, QTimer
from typing import Iterable
from UM.i18n import i18nCatalog
@ -78,8 +78,6 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
self._update_extruder_timer.setSingleShot(True)
self._update_extruder_timer.timeout.connect(self.__updateExtruders)
self._simple_names = False
self._active_machine_extruders = [] # type: Iterable[ExtruderStack]
self._add_optional_extruder = False
@ -101,21 +99,6 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
def addOptionalExtruder(self):
return self._add_optional_extruder
## Set the simpleNames property.
def setSimpleNames(self, simple_names):
if simple_names != self._simple_names:
self._simple_names = simple_names
self.simpleNamesChanged.emit()
self._updateExtruders()
## Emitted when the simpleNames property changes.
simpleNamesChanged = pyqtSignal()
## Whether or not the model should show all definitions regardless of visibility.
@pyqtProperty(bool, fset = setSimpleNames, notify = simpleNamesChanged)
def simpleNames(self):
return self._simple_names
## Links to the stack-changed signal of the new extruders when an extruder
# is swapped out or added in the current machine.
#
@ -221,7 +204,12 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
"enabled": True,
"color": "#ffffff",
"index": -1,
"definition": ""
"definition": "",
"material": "",
"variant": "",
"stack": None,
"material_brand": "",
"color_name": "",
}
items.append(item)
if self._items != items:

View file

@ -88,12 +88,14 @@ class MachineManager(QObject):
self._onGlobalContainerChanged()
ExtruderManager.getInstance().activeExtruderChanged.connect(self._onActiveExtruderStackChanged)
extruder_manager = self._application.getExtruderManager()
extruder_manager.activeExtruderChanged.connect(self._onActiveExtruderStackChanged)
self._onActiveExtruderStackChanged()
ExtruderManager.getInstance().activeExtruderChanged.connect(self.activeMaterialChanged)
ExtruderManager.getInstance().activeExtruderChanged.connect(self.activeVariantChanged)
ExtruderManager.getInstance().activeExtruderChanged.connect(self.activeQualityChanged)
extruder_manager.activeExtruderChanged.connect(self.activeMaterialChanged)
extruder_manager.activeExtruderChanged.connect(self.activeVariantChanged)
extruder_manager.activeExtruderChanged.connect(self.activeQualityChanged)
self.globalContainerChanged.connect(self.activeStackChanged)
self.globalValueChanged.connect(self.activeStackValueChanged)

View file

@ -13,7 +13,7 @@ import Cura 1.0 as Cura
Cura.MachineAction
{
id: base
property var extrudersModel: Cura.ExtrudersModel{}
property var extrudersModel: CuraApplication.getExtrudersModel()
property int extruderTabsCount: 0
property var activeMachineId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.id : ""

View file

@ -163,7 +163,7 @@ Cura.ExpandableComponent
Repeater
{
model: Cura.ExtrudersModel{}
model: CuraApplication.getExtrudersModel()
CheckBox
{

View file

@ -12,7 +12,6 @@ from UM.Math.Color import Color
from UM.View.GL.OpenGL import OpenGL
from cura.Settings.ExtruderManager import ExtruderManager
from cura.Settings.ExtrudersModel import ExtrudersModel
import math
@ -29,13 +28,16 @@ class SolidView(View):
self._non_printing_shader = None
self._support_mesh_shader = None
self._extruders_model = ExtrudersModel()
self._extruders_model = None
self._theme = None
def beginRendering(self):
scene = self.getController().getScene()
renderer = self.getRenderer()
if not self._extruders_model:
self._extruders_model = Application.getInstance().getExtrudersModel()
if not self._theme:
self._theme = Application.getInstance().getTheme()

View file

@ -83,9 +83,7 @@ Item {
Column {
Repeater {
model: Cura.ExtrudersModel {
simpleNames: true;
}
model: CuraApplication.getExtrudersModel()
Label {
text: model.name;

View file

@ -17,10 +17,7 @@ Cura.ExpandablePopup
{
id: base
Cura.ExtrudersModel
{
id: extrudersModel
}
property var extrudersModel: CuraApplication.getExtrudersModel()
UM.I18nCatalog
{

View file

@ -27,7 +27,7 @@ Menu
MenuItem { id: extruderHeader; text: catalog.i18ncp("@label", "Print Selected Model With:", "Print Selected Models With:", UM.Selection.selectionCount); enabled: false; visible: base.shouldShowExtruders }
Instantiator
{
model: Cura.ExtrudersModel { id: extrudersModel }
model: CuraApplication.getExtrudersModel()
MenuItem {
text: "%1: %2 - %3".arg(model.name).arg(model.material).arg(model.variant)
visible: base.shouldShowExtruders

View file

@ -16,7 +16,7 @@ Item
property QtObject qualityManager: CuraApplication.getQualityManager()
property var resetEnabled: false // Keep PreferencesDialog happy
property var extrudersModel: Cura.ExtrudersModel {}
property var extrudersModel: CuraApplication.getExtrudersModel()
UM.I18nCatalog { id: catalog; name: "cura"; }

View file

@ -60,11 +60,7 @@ Rectangle
anchors.fill: parent
Cura.ExtrudersModel
{
id: extrudersModel
simpleNames: true
}
property var extrudersModel: CuraApplication.getExtrudersModel()
OutputDeviceHeader
{

View file

@ -16,10 +16,7 @@ Item
property real padding: UM.Theme.getSize("default_margin").width
property bool multipleExtruders: extrudersModel.count > 1
Cura.ExtrudersModel
{
id: extrudersModel
}
property var extrudersModel: CuraApplication.getExtrudersModel()
// Profile selector row
GlobalProfileSelector

View file

@ -26,10 +26,7 @@ Cura.ExpandableComponent
headerItem: PrintSetupSelectorHeader {}
Cura.ExtrudersModel
{
id: extrudersModel
}
property var extrudersModel: CuraApplication.getExtrudersModel()
contentItem: PrintSetupSelectorContents {}
}

View file

@ -156,9 +156,10 @@ Item
}
//: Model used to populate the extrudelModel
Cura.ExtrudersModel
property var extruders: CuraApplication.getExtrudersModel()
Connections
{
id: extruders
target: extruders
onModelChanged: populateExtruderModel()
}

View file

@ -17,11 +17,16 @@ SettingItem
id: control
anchors.fill: parent
model: Cura.ExtrudersModel
property var extrudersModel: CuraApplication.getExtrudersModel()
model: extrudersModel
Connections
{
target: extrudersModel
onModelChanged:
{
control.color = getItem(control.currentIndex).color
control.color = extrudersModel.getItem(control.currentIndex).color
}
}

View file

@ -12,15 +12,24 @@ SettingItem
id: base
property var focusItem: control
// Somehow if we directory set control.model to CuraApplication.getExtrudersModelWithOptional()
// and in the Connections.onModelChanged use control.model as a reference, it will complain about
// non-existing properties such as "onModelChanged" and "getItem". I guess if we access the model
// via "control.model", it gives back a generic/abstract model instance. To avoid this, we add
// this extra property to keep the ExtrudersModel and use this in the rest of the code.
property var extrudersWithOptionalModel: CuraApplication.getExtrudersModelWithOptional()
contents: ComboBox
{
id: control
anchors.fill: parent
model: Cura.ExtrudersModel
model: base.extrudersWithOptionalModel
Connections
{
onModelChanged: control.color = getItem(control.currentIndex).color
addOptionalExtruder: true
target: base.extrudersWithOptionalModel
onModelChanged: control.color = base.extrudersWithOptionalModel.getItem(control.currentIndex).color
}
textRole: "name"

View file

@ -144,10 +144,7 @@ Item
}
}
Cura.ExtrudersModel
{
id: extrudersModel
}
property var extrudersModel: CuraApplication.getExtrudersModel()
UM.PointingRectangle
{

View file

@ -78,8 +78,6 @@ Cura.ExpandablePopup
{
id: viewSelectorPopup
width: viewSelector.width - 2 * viewSelector.contentPadding
leftPadding: UM.Theme.getSize("default_lining").width
rightPadding: UM.Theme.getSize("default_lining").width
// For some reason the height/width of the column gets set to 0 if this is not set...
Component.onCompleted: