From 2c7bdba7d009d8dfbcebb99a7e9b0b85172432f6 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 9 Nov 2018 15:20:26 +0100 Subject: [PATCH] Update ConfigurationSelector header to that it looks more like the new design CURA-5785 --- cura/Settings/ExtrudersModel.py | 11 ++- plugins/PrepareStage/PrepareMenu.qml | 10 ++- .../QuickConfigurationSelector.qml | 79 ++++++++++++++++++- 3 files changed, 92 insertions(+), 8 deletions(-) diff --git a/cura/Settings/ExtrudersModel.py b/cura/Settings/ExtrudersModel.py index 52fc502bfc..9b85afa10e 100644 --- a/cura/Settings/ExtrudersModel.py +++ b/cura/Settings/ExtrudersModel.py @@ -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) diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index e8514a9ef9..bcc8ec4c0a 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -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 { diff --git a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml index 740c12d340..966133d906 100644 --- a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml +++ b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml @@ -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 } -} \ No newline at end of file +}*/ \ No newline at end of file