// Copyright (c) 2018 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Controls 1.1 as OldControls import UM 1.3 as UM import Cura 1.0 as Cura Item { id: customPrintSetup property real padding: UM.Theme.getSize("default_margin").width property bool multipleExtruders: extrudersModel.count > 1 property var extrudersModel: CuraApplication.getExtrudersModel() // Profile selector row GlobalProfileSelector { id: globalProfileRow anchors { top: parent.top left: parent.left right: parent.right margins: parent.padding } } Item { id: intent height: childrenRect.height anchors { top: globalProfileRow.bottom topMargin: UM.Theme.getSize("default_margin").height left: parent.left leftMargin: parent.padding right: parent.right rightMargin: parent.padding } Label { id: intentLabel anchors { top: parent.top bottom: parent.bottom left: parent.left right: intentSelection.left } text: catalog.i18nc("@label", "Intent") font: UM.Theme.getFont("medium") color: UM.Theme.getColor("text") verticalAlignment: Text.AlignVCenter } OldControls.ToolButton { id: intentSelection text: Cura.MachineManager.activeStack != null ? Cura.MachineManager.activeStack.intent.name : "" tooltip: text height: UM.Theme.getSize("print_setup_big_item").height width: UM.Theme.getSize("print_setup_big_item").width anchors.right: parent.right style: UM.Theme.styles.print_setup_header_button activeFocusOnPress: true menu: Cura.IntentMenu { extruderIndex: Cura.ExtruderManager.activeExtruderIndex } } } UM.TabRow { id: tabBar visible: multipleExtruders // The tab row is only visible when there are more than 1 extruder anchors { top: intent.bottom topMargin: UM.Theme.getSize("default_margin").height left: parent.left leftMargin: parent.padding right: parent.right rightMargin: parent.padding } Repeater { id: repeater model: extrudersModel delegate: UM.TabRowButton { contentItem: Item { Cura.ExtruderIcon { anchors.horizontalCenter: parent.horizontalCenter materialColor: model.color extruderEnabled: model.enabled } } onClicked: { Cura.ExtruderManager.setActiveExtruderIndex(tabBar.currentIndex) } } } //When active extruder changes for some other reason, switch tabs. //Don't directly link currentIndex to Cura.ExtruderManager.activeExtruderIndex! //This causes a segfault in Qt 5.11. Something with VisualItemModel removing index -1. We have to use setCurrentIndex instead. Connections { target: Cura.ExtruderManager onActiveExtruderChanged: { tabBar.setCurrentIndex(Cura.ExtruderManager.activeExtruderIndex); } } //When the model of the extruders is rebuilt, the list of extruders is briefly emptied and rebuilt. //This causes the currentIndex of the tab to be in an invalid position which resets it to 0. //Therefore we need to change it back to what it was: The active extruder index. Connections { target: repeater.model onModelChanged: { tabBar.setCurrentIndex(Cura.ExtruderManager.activeExtruderIndex) } } } Rectangle { anchors { top: tabBar.visible ? tabBar.bottom : globalProfileRow.bottom topMargin: -UM.Theme.getSize("default_lining").width left: parent.left leftMargin: parent.padding right: parent.right rightMargin: parent.padding bottom: parent.bottom } 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 { fill: parent topMargin: UM.Theme.getSize("default_margin").height leftMargin: UM.Theme.getSize("default_margin").width // Small space for the scrollbar rightMargin: UM.Theme.getSize("narrow_margin").width // Compensate for the negative margin in the parent bottomMargin: UM.Theme.getSize("default_lining").width } } } }