Update ConfigurationSelector header to that it looks more like the new design

CURA-5785
This commit is contained in:
Jaime van Kessel 2018-11-09 15:20:26 +01:00
parent 1d775c984e
commit 2c7bdba7d0
3 changed files with 92 additions and 8 deletions

View file

@ -47,6 +47,9 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
VariantRole = Qt.UserRole + 7
StackRole = Qt.UserRole + 8
MaterialBrandRole = Qt.UserRole + 9
ColorNameRole = Qt.UserRole + 10
## List of colours to display if there is no material or the material has no known
# colour.
defaultColors = ["#ffc924", "#86ec21", "#22eeee", "#245bff", "#9124ff", "#ff24c8"]
@ -67,7 +70,8 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
self.addRoleName(self.MaterialRole, "material")
self.addRoleName(self.VariantRole, "variant")
self.addRoleName(self.StackRole, "stack")
self.addRoleName(self.MaterialBrandRole, "material_brand")
self.addRoleName(self.ColorNameRole, "color_name")
self._update_extruder_timer = QTimer()
self._update_extruder_timer.setInterval(100)
self._update_extruder_timer.setSingleShot(True)
@ -183,7 +187,8 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
default_color = self.defaultColors[position] if 0 <= position < len(self.defaultColors) else self.defaultColors[0]
color = extruder.material.getMetaDataEntry("color_code", default = default_color) if extruder.material else default_color
material_brand = extruder.material.getMetaDataEntry("brand", default = "generic")
color_name = extruder.material.getMetaDataEntry("color_name")
# construct an item with only the relevant information
item = {
"id": extruder.getId(),
@ -195,6 +200,8 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
"material": extruder.material.getName() if extruder.material else "",
"variant": extruder.variant.getName() if extruder.variant else "", # e.g. print core
"stack": extruder,
"material_brand": material_brand,
"color_name": color_name
}
items.append(item)

View file

@ -50,16 +50,18 @@ Item
Cura.QuickConfigurationSelector
{
id: configSelection
height: prepareMenu.height
width: UM.Theme.getSize("configuration_selector_widget").width
/*id: configSelection
width: visible ? UM.Theme.getSize("machine_selector_widget").width * 0.2 : 0
panelWidth: UM.Theme.getSize("machine_selector_widget").width
height: prepareMenu.height
height: prepareMenu.height*/
}
Cura.CustomConfigurationSelector
/*Cura.CustomConfigurationSelector
{
width: UM.Theme.getSize("configuration_selector_widget").width
}
}*/
Cura.PrintSetupSelector
{

View file

@ -8,7 +8,82 @@ import QtQuick.Controls.Styles 1.4
import UM 1.2 as UM
import Cura 1.0 as Cura
Item
Cura.ExpandableComponent
{
id: base
headerItem: Item
{
Cura.ExtrudersModel
{
id: extrudersModel
}
ListView
{
// Horizontal list that shows the extruders
id: extrudersList
orientation: ListView.Horizontal
anchors.fill: parent
model: extrudersModel
Connections
{
target: Cura.MachineManager
onGlobalContainerChanged: forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
}
delegate: Item
{
height: parent.height
width: Math.round(ListView.view.width / extrudersModel.rowCount())
Cura.ExtruderIcon
{
id: extruderIcon
materialColor: model.color
height: parent.height
width: height
}
Label
{
id: brandNameLabel
text: model.material_brand
elide: Text.ElideRight
anchors
{
left: extruderIcon.right
leftMargin: UM.Theme.getSize("default_margin").width
right: parent.right
rightMargin: UM.Theme.getSize("default_margin").width
}
}
Label
{
text: model.color_name
elide: Text.ElideRight
anchors
{
left: extruderIcon.right
leftMargin: UM.Theme.getSize("default_margin").width
right: parent.right
rightMargin: UM.Theme.getSize("default_margin").width
top: brandNameLabel.bottom
}
}
}
}
}
}
/*Item
{
id: configurationSelector
property var connectedDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
@ -65,4 +140,4 @@ Item
onClosed: visible = false
onOpened: visible = true
}
}
}*/