From 3aa37296358192ca34f767e1de175dc4d4f2df34 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Wed, 28 Feb 2018 13:36:39 +0100 Subject: [PATCH] CURA-4870 Add printer type selector that show the unique name list of all the types of printers in a group. --- ...erOuputModel.py => ExtruderOutputModel.py} | 0 cura/PrinterOutput/PrinterOutputController.py | 4 +-- cura/PrinterOutput/PrinterOutputModel.py | 2 +- resources/qml/Menus/ConfigurationItem.qml | 2 +- .../qml/Menus/ConfigurationSelection.qml | 24 +++++++++++-- resources/qml/Menus/PrinterTypeMenu.qml | 36 +++++++++++++++++++ resources/qml/SidebarHeader.qml | 11 +----- 7 files changed, 62 insertions(+), 17 deletions(-) rename cura/PrinterOutput/{ExtruderOuputModel.py => ExtruderOutputModel.py} (100%) create mode 100644 resources/qml/Menus/PrinterTypeMenu.qml diff --git a/cura/PrinterOutput/ExtruderOuputModel.py b/cura/PrinterOutput/ExtruderOutputModel.py similarity index 100% rename from cura/PrinterOutput/ExtruderOuputModel.py rename to cura/PrinterOutput/ExtruderOutputModel.py diff --git a/cura/PrinterOutput/PrinterOutputController.py b/cura/PrinterOutput/PrinterOutputController.py index 86ca10e2d3..1d658e79be 100644 --- a/cura/PrinterOutput/PrinterOutputController.py +++ b/cura/PrinterOutput/PrinterOutputController.py @@ -6,7 +6,7 @@ from UM.Logger import Logger MYPY = False if MYPY: from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel - from cura.PrinterOutput.ExtruderOuputModel import ExtruderOuputModel + from cura.PrinterOutput.ExtruderOutputModel import ExtruderOutputModel from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel @@ -18,7 +18,7 @@ class PrinterOutputController: self.can_control_manually = True self._output_device = output_device - def setTargetHotendTemperature(self, printer: "PrinterOutputModel", extruder: "ExtruderOuputModel", temperature: int): + def setTargetHotendTemperature(self, printer: "PrinterOutputModel", extruder: "ExtruderOutputModel", temperature: int): Logger.log("w", "Set target hotend temperature not implemented in controller") def setTargetBedTemperature(self, printer: "PrinterOutputModel", temperature: int): diff --git a/cura/PrinterOutput/PrinterOutputModel.py b/cura/PrinterOutput/PrinterOutputModel.py index 8234989519..01a8203c32 100644 --- a/cura/PrinterOutput/PrinterOutputModel.py +++ b/cura/PrinterOutput/PrinterOutputModel.py @@ -5,7 +5,7 @@ from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant, pyqtSlot from UM.Logger import Logger from typing import Optional, List from UM.Math.Vector import Vector -from cura.PrinterOutput.ExtruderOuputModel import ExtruderOutputModel +from cura.PrinterOutput.ExtruderOutputModel import ExtruderOutputModel MYPY = False if MYPY: diff --git a/resources/qml/Menus/ConfigurationItem.qml b/resources/qml/Menus/ConfigurationItem.qml index aed37facf9..8ed2ebafc2 100644 --- a/resources/qml/Menus/ConfigurationItem.qml +++ b/resources/qml/Menus/ConfigurationItem.qml @@ -33,7 +33,7 @@ ItemDelegate border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border") radius: Math.round(width / 2) - color: control.model.getItem(index).color + color: model.color } } diff --git a/resources/qml/Menus/ConfigurationSelection.qml b/resources/qml/Menus/ConfigurationSelection.qml index d0784f4432..e40e8025a4 100644 --- a/resources/qml/Menus/ConfigurationSelection.qml +++ b/resources/qml/Menus/ConfigurationSelection.qml @@ -13,7 +13,25 @@ ComboBox property var panelWidth: control.width - model: Cura.ExtrudersModel { } + model: ListModel { + + ListElement { + name: "Configuration 1" + color: "yellow" + } + ListElement { + name: "Configuration 2" + color: "black" + } + ListElement { + name: "Configuration 3" + color: "green" + } + ListElement { + name: "Configuration 4" + color: "red" + } + } textRole: "name" @@ -85,7 +103,7 @@ ComboBox implicitHeight: contentItem.implicitHeight padding: UM.Theme.getSize("default_lining").width - contentItem: GridView { + contentItem: ListView { clip: true implicitHeight: contentHeight model: control.popup.visible ? control.delegateModel : null @@ -103,7 +121,7 @@ ComboBox delegate: ConfigurationItem { width: panelWidth - 2 * UM.Theme.getSize("default_lining").width - height: control.height + height: control.height - 2 * UM.Theme.getSize("default_lining").height highlighted: control.highlightedIndex == index } } \ No newline at end of file diff --git a/resources/qml/Menus/PrinterTypeMenu.qml b/resources/qml/Menus/PrinterTypeMenu.qml new file mode 100644 index 0000000000..b4fdb0a1d4 --- /dev/null +++ b/resources/qml/Menus/PrinterTypeMenu.qml @@ -0,0 +1,36 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 1.1 + +import UM 1.3 as UM +import Cura 1.0 as Cura + +Menu +{ + id: menu + title: "Printer type" + property var outputDevice: Cura.MachineManager.printerOutputDevices[0] + + Instantiator + { + id: printerTypeInstantiator + model: outputDevice != null ? outputDevice.connectedPrintersTypeCount : null + + MenuItem { + text: modelData.machine_type + checkable: true + checked: false + exclusiveGroup: group +// onTriggered: +// { +// TODO +// } + } + onObjectAdded: menu.insertItem(index, object) + onObjectRemoved: menu.removeItem(object) + } + + ExclusiveGroup { id: group } +} diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index 52a03b46bb..637db76c4f 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -71,16 +71,7 @@ Column anchors.right: parent.right style: UM.Theme.styles.sidebar_header_button activeFocusOnPress: true; - menu: Menu { - MenuItem - { - text: "Printer type 1" - } - MenuItem - { - text: "Printer type 2" - } - } + menu: PrinterTypeMenu { } } }