Add printer cards

CURA-9278
This commit is contained in:
Joey de l'Arago 2022-09-05 17:38:21 +02:00
parent d3ee9c4c24
commit 7f98ef70f0
4 changed files with 168 additions and 16 deletions

View file

@ -3,16 +3,15 @@
# TODO?: documentation
from typing import Optional
from typing import Optional, Dict
from PyQt6.QtCore import Qt, QTimer, QObject, pyqtSlot, pyqtProperty, pyqtSignal
from PyQt6.QtCore import Qt, QObject, pyqtSlot, pyqtProperty, pyqtSignal
from UM.Qt.ListModel import ListModel
from UM.Settings.ContainerStack import ContainerStack
from UM.i18n import i18nCatalog
from UM.Util import parseBool
from cura.PrinterOutput.PrinterOutputDevice import ConnectionType
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry
@ -64,10 +63,19 @@ class CompatibleMachineModel(ListModel):
continue
self.addItem(container_stack)
def addItem(self, container_stack: ContainerStack, machine_count: int = 0) -> None:
def addItem(self, container_stack: ContainerStack) -> None:
extruders = CuraContainerRegistry.getInstance().findContainerStacks(type="extruder_train", machine=container_stack.getId())
self.appendItem({
"name": container_stack.getName(),
"id": container_stack.getId(),
"extruders": [extruder.getMetaData().copy() for extruder in extruders]
"extruders": [self.getExtruderModel(extruder) for extruder in extruders]
})
def getExtruderModel(self, extruders: ContainerStack) -> Dict:
# Temp Dummy Data
extruder_model = {
"core": "AA 0.4",
"materials": [{"name": "Ultimaker Blue", "color": "blue"}, {"name": "Ultimaker Red", "color": "red"}, {"name": "Ultimaker Orange", "color": "orange"}]
}
return extruder_model

View file

@ -3,6 +3,7 @@
import QtQuick 2.2
import QtQuick.Controls 2.9
import QtQuick.Layouts 2.10
import UM 1.5 as UM
import Cura 1.0 as Cura
@ -11,11 +12,16 @@ UM.Dialog
{
id: base
property string machine_id_filter: ""
backgroundColor: UM.Theme.getColor("background_2")
property string machine_id_filter: ""
ScrollView
{
anchors.fill: parent
Column
{
anchors.fill: parent
spacing: UM.Theme.getSize("default_margin").height
Repeater
{
@ -25,9 +31,12 @@ UM.Dialog
{
filter: machine_id_filter
}
delegate: UM.Label
delegate: Cura.PrintSelectorCard
{
text: model.name
name: model.name
extruders: model.extruders
}
}
}
}

View file

@ -0,0 +1,134 @@
import QtQuick 2.2
import QtQuick.Controls 2.9
import QtQuick.Layouts 2.10
import UM 1.5 as UM
import Cura 1.0 as Cura
Rectangle {
property alias name: printerTitle.text
property var extruders
width: parent.width
height: childrenRect.height + 2 * UM.Theme.getSize("default_margin").height
color: UM.Theme.getColor("background_1")
border.color: UM.Theme.getColor("border_main")
border.width: UM.Theme.getSize("default_lining").width
RowLayout
{
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: UM.Theme.getSize("default_margin").width
Cura.IconWithText
{
id: printerTitle
Layout.preferredWidth: parent.width / 3
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
Layout.fillHeight: false
source: UM.Theme.getIcon("Printer")
spacing: UM.Theme.getSize("thin_margin").width
iconSize: UM.Theme.getSize("medium_button_icon").width
font: UM.Theme.getFont("medium_bold")
}
ColumnLayout
{
id: extruderInformation
Layout.fillWidth: true
Layout.preferredWidth: parent.width / 2
Layout.alignment: Qt.AlignTop
spacing: UM.Theme.getSize("default_margin").width
Repeater
{
model: extruders
Item
{
height: childrenRect.height
Cura.ExtruderIcon
{
id: extruderIcon
anchors.top: parent.top
anchors.left: parent.left
materialColor: modelData.materials.length == 1 ? modelData.materials[0].color : "white"
iconSize: UM.Theme.getSize("medium_button_icon").width
}
UM.Label
{
id: extruderCore
anchors.verticalCenter: extruderIcon.verticalCenter
anchors.left: extruderIcon.right
anchors.leftMargin: UM.Theme.getSize("default_margin").width
text: modelData.core
font: UM.Theme.getFont("default_bold")
}
UM.Label
{
id: singleMaterialText
anchors.left: extruderCore.right
anchors.verticalCenter: extruderCore.verticalCenter
text: modelData.materials.length == 1 ? modelDatamaterials[0].name : "test"
visible: modelData.materials.length == 1
}
ColumnLayout
{
id: multiMaterialText
anchors.top: extruderCore.bottom
anchors.left: extruderCore.left
anchors.topMargin: UM.Theme.getSize("narrow_margin").height
Repeater
{
model: modelData.materials
visible: modelData.materials.length > 1
UM.Label
{
text: modelData.name
}
}
}
}
}
}
Button
{
id: PrintButton
implicitWidth: UM.Theme.getSize("medium_button").width
implicitHeight: implicitWidth
Layout.alignment: Qt.AlignTop
padding: 0
background: Rectangle
{
border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("border_accent_1")
color: control.hovered ? UM.Theme.getColor("toolbar_button_hover"): UM.Theme.getColor("background_1")
}
contentItem: Item
{
UM.ColorImage
{
anchors.centerIn: parent
source: UM.Theme.getIcon("Printer")
color: UM.Theme.getColor("border_accent_1")
width: UM.Theme.getSize("small_button_icon").width
height: width
}
}
}
}
}

View file

@ -17,6 +17,7 @@ PrinterTypeLabel 1.0 PrinterTypeLabel.qml
ViewsSelector 1.0 ViewsSelector.qml
SettingView 1.0 SettingView.qml
ProfileMenu 1.0 ProfileMenu.qml
PrintSelectorCard 1.0 PrintSelectorCard.qml
# Cura/WelcomePages