mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 20:48:59 +08:00
Merge branch '4.0' into STAR-322_cloud-connection
This commit is contained in:
commit
2772b3bcbd
@ -198,6 +198,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
|
||||
@ -855,6 +857,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:
|
||||
|
@ -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([])
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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 : ""
|
||||
|
@ -163,7 +163,7 @@ Cura.ExpandableComponent
|
||||
|
||||
Repeater
|
||||
{
|
||||
model: Cura.ExtrudersModel{}
|
||||
model: CuraApplication.getExtrudersModel()
|
||||
|
||||
CheckBox
|
||||
{
|
||||
|
@ -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()
|
||||
|
||||
|
@ -83,9 +83,7 @@ Item {
|
||||
|
||||
Column {
|
||||
Repeater {
|
||||
model: Cura.ExtrudersModel {
|
||||
simpleNames: true;
|
||||
}
|
||||
model: CuraApplication.getExtrudersModel()
|
||||
|
||||
Label {
|
||||
text: model.name;
|
||||
|
@ -41,7 +41,7 @@ Column
|
||||
{
|
||||
left: parent.left
|
||||
right: printInformationPanel.left
|
||||
rightMargin: UM.Theme.getSize("thin_margin").height
|
||||
rightMargin: printInformationPanel.visible ? UM.Theme.getSize("thin_margin").width : 0
|
||||
}
|
||||
|
||||
Cura.IconWithText
|
||||
|
@ -12,7 +12,7 @@ UM.RecolorImage
|
||||
id: widget
|
||||
|
||||
source: UM.Theme.getIcon("info")
|
||||
width: UM.Theme.getSize("section_icon").width
|
||||
width: visible ? UM.Theme.getSize("section_icon").width : 0
|
||||
height: UM.Theme.getSize("section_icon").height
|
||||
|
||||
color: UM.Theme.getColor("icon")
|
||||
|
@ -49,7 +49,7 @@ Item
|
||||
anchors.centerIn: parent
|
||||
text: index + 1
|
||||
font: UM.Theme.getFont("very_small")
|
||||
color: UM.Theme.getColor("text")
|
||||
color: UM.Theme.getColor("text")
|
||||
width: contentWidth
|
||||
height: contentHeight
|
||||
visible: extruderEnabled
|
||||
|
@ -54,7 +54,7 @@ Item
|
||||
{
|
||||
text: model.name.toUpperCase()
|
||||
checkable: true
|
||||
checked: UM.Controller.activeStage != null ? model.id == UM.Controller.activeStage.stageId : false
|
||||
checked: UM.Controller.activeStage !== null && model.id == UM.Controller.activeStage.stageId
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
exclusiveGroup: mainWindowHeaderMenuGroup
|
||||
|
@ -17,10 +17,7 @@ Cura.ExpandablePopup
|
||||
{
|
||||
id: base
|
||||
|
||||
Cura.ExtrudersModel
|
||||
{
|
||||
id: extrudersModel
|
||||
}
|
||||
property var extrudersModel: CuraApplication.getExtrudersModel()
|
||||
|
||||
UM.I18nCatalog
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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"; }
|
||||
|
||||
|
@ -60,11 +60,7 @@ Rectangle
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
Cura.ExtrudersModel
|
||||
{
|
||||
id: extrudersModel
|
||||
simpleNames: true
|
||||
}
|
||||
property var extrudersModel: CuraApplication.getExtrudersModel()
|
||||
|
||||
OutputDeviceHeader
|
||||
{
|
||||
|
@ -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
|
||||
@ -113,9 +110,11 @@ Item
|
||||
}
|
||||
z: tabBar.z - 1
|
||||
// Don't show the border when only one extruder
|
||||
|
||||
border.color: tabBar.visible ? UM.Theme.getColor("lining") : "transparent"
|
||||
border.width: UM.Theme.getSize("default_lining").width
|
||||
|
||||
color: UM.Theme.getColor("main_background")
|
||||
Cura.SettingView
|
||||
{
|
||||
anchors
|
||||
|
@ -26,10 +26,7 @@ Cura.ExpandableComponent
|
||||
|
||||
headerItem: PrintSetupSelectorHeader {}
|
||||
|
||||
Cura.ExtrudersModel
|
||||
{
|
||||
id: extrudersModel
|
||||
}
|
||||
property var extrudersModel: CuraApplication.getExtrudersModel()
|
||||
|
||||
contentItem: PrintSetupSelectorContents {}
|
||||
}
|
@ -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()
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
@ -144,10 +144,7 @@ Item
|
||||
}
|
||||
}
|
||||
|
||||
Cura.ExtrudersModel
|
||||
{
|
||||
id: extrudersModel
|
||||
}
|
||||
property var extrudersModel: CuraApplication.getExtrudersModel()
|
||||
|
||||
UM.PointingRectangle
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -99,11 +99,11 @@
|
||||
"scrollbar_handle_hover": [255, 255, 255, 255],
|
||||
"scrollbar_handle_down": [255, 255, 255, 255],
|
||||
|
||||
"setting_category": [39, 44, 48, 255],
|
||||
"setting_category_disabled": [39, 44, 48, 255],
|
||||
"setting_category_hover": [39, 44, 48, 255],
|
||||
"setting_category_active": [39, 44, 48, 255],
|
||||
"setting_category_active_hover": [39, 44, 48, 255],
|
||||
"setting_category": [75, 80, 83, 255],
|
||||
"setting_category_disabled": [75, 80, 83, 255],
|
||||
"setting_category_hover": [75, 80, 83, 255],
|
||||
"setting_category_active": [75, 80, 83, 255],
|
||||
"setting_category_active_hover": [75, 80, 83, 255],
|
||||
"setting_category_text": [255, 255, 255, 152],
|
||||
"setting_category_disabled_text": [255, 255, 255, 101],
|
||||
"setting_category_hover_text": [255, 255, 255, 204],
|
||||
|
@ -349,7 +349,7 @@
|
||||
},
|
||||
|
||||
"sizes": {
|
||||
"window_minimum_size": [106, 66],
|
||||
"window_minimum_size": [100, 60],
|
||||
|
||||
"main_window_header": [0.0, 4.0],
|
||||
"main_window_header_button": [8, 2.35],
|
||||
|
Loading…
x
Reference in New Issue
Block a user