Make it possible to swap between auto and custom configuration

We're going to need to make this disappear when the printer is not connected. But that is for later.

Contributes to issue CURA-5876.
This commit is contained in:
Ghostkeeper 2018-11-19 17:11:51 +01:00
parent 16deeb0951
commit a04db164e6
No known key found for this signature in database
GPG Key ID: 86BEF881AE2CF276
3 changed files with 263 additions and 137 deletions

View File

@ -0,0 +1,25 @@
// 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 UM 1.3 as UM
Item
{
Label
{
id: header
text: catalog.i18nc("@header", "Configurations")
font: UM.Theme.getFont("large")
color: UM.Theme.getColor("text")
anchors
{
top: parent.top
left: parent.left
right: parent.right
}
}
}

View File

@ -6,8 +6,6 @@ import QtQuick.Controls 2.0
import QtQuick.Controls.Styles 1.4 import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.11 import QtQuick.Layouts 1.11
import QtQuick.Controls 1.1 as OldControls
import UM 1.2 as UM import UM 1.2 as UM
import Cura 1.0 as Cura import Cura 1.0 as Cura
@ -100,163 +98,98 @@ Cura.ExpandableComponent
popupItem: Item popupItem: Item
{ {
id: popup
width: base.width - 2 * UM.Theme.getSize("default_margin").width width: base.width - 2 * UM.Theme.getSize("default_margin").width
height: 200 height: 200
Label property var configuration_method: "auto"
{
id: customHeader
text: catalog.i18nc("@header", "Custom")
font: UM.Theme.getFont("large")
color: UM.Theme.getColor("text")
AutoConfiguration
{
id: autoConfiguration
visible: popup.configuration_method === "auto"
anchors.top: header.bottom
height: visible ? childrenRect.height : 0
}
CustomConfiguration
{
id: customConfiguration
visible: popup.configuration_method === "custom"
anchors.top: header.bottom
height: visible ? childrenRect.height : 0
}
Rectangle
{
id: separator
anchors anchors
{ {
top: parent.top
left: parent.left left: parent.left
right: parent.right right: parent.right
bottom: buttonBar.top
bottomMargin: UM.Theme.getSize("default_margin").height
} }
height: UM.Theme.getSize("default_lining").height
color: UM.Theme.getColor("lining")
} }
TabBar Rectangle
{ {
id: tabBar id: buttonBar
onCurrentIndexChanged: Cura.ExtruderManager.setActiveExtruderIndex(currentIndex) anchors
anchors.top: customHeader.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height
width: parent.width
height: 50
Repeater
{ {
model: extrudersModel left: parent.left
right: parent.right
delegate: TabButton bottom: parent.bottom
{
width: ListView.view != null ? Math.round(ListView.view.width / extrudersModel.rowCount()): 0
height: parent.height
contentItem: Item
{
Cura.ExtruderIcon
{
anchors.horizontalCenter: parent.horizontalCenter
materialColor: model.color
extruderEnabled: model.enabled
width: parent.height
height: parent.height
}
}
}
} }
} height: childrenRect.height
Item Cura.ActionButton
{
id: tabControl
width: parent.width
anchors.top: tabBar.bottom
anchors.bottom: parent.bottom
property var model: extrudersModel.items[tabBar.currentIndex]
property real textWidth: Math.round(width * 0.3)
property real controlWidth: width - textWidth
Column
{ {
spacing: UM.Theme.getSize("default_margin").height id: goToCustom
Row visible: popup.configuration_method === "auto"
text: catalog.i18nc("@label", "Custom")
anchors
{ {
height: UM.Theme.getSize("print_setup_item").height right: parent.right
bottom: parent.bottom
Label
{
text: catalog.i18nc("@label", "Enabled")
verticalAlignment: Text.AlignVCenter
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
height: parent.height
width: tabControl.textWidth
}
OldControls.CheckBox
{
checked: tabControl.model != null ? Cura.MachineManager.getExtruder(tabControl.model.index).isEnabled: false
onClicked: Cura.MachineManager.setExtruderEnabled(tabControl.model.index, checked)
height: UM.Theme.getSize("setting_control").height
style: UM.Theme.styles.checkbox
}
} }
Row color: UM.Theme.getColor("secondary")
{ hoverColor: UM.Theme.getColor("secondary")
height: UM.Theme.getSize("print_setup_item").height textColor: UM.Theme.getColor("primary")
Label textHoverColor: UM.Theme.getColor("text")
{ height: UM.Theme.getSize("action_panel_button").height
text: catalog.i18nc("@label", "Material") leftPadding: UM.Theme.getSize("default_margin").width
verticalAlignment: Text.AlignVCenter rightPadding: UM.Theme.getSize("default_margin").width
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
height: parent.height
width: tabControl.textWidth
}
OldControls.ToolButton onClicked: popup.configuration_method = "custom"
{
id: materialSelection
property var activeExtruder: Cura.MachineManager.activeStack
property var hasActiveExtruder: activeExtruder != null
property var currentRootMaterialName: hasActiveExtruder ? activeExtruder.material.name : ""
property var valueError: hasActiveExtruder ? Cura.ContainerManager.getContainerMetaDataEntry(activeExtruder.material.id, "compatible", "") != "True" : true
property var valueWarning: ! Cura.MachineManager.isActiveQualitySupported
text: currentRootMaterialName
tooltip: currentRootMaterialName
visible: Cura.MachineManager.hasMaterials
enabled: Cura.ExtruderManager.activeExtruderIndex > -1
height: UM.Theme.getSize("setting_control").height
width: tabControl.controlWidth
style: UM.Theme.styles.sidebar_header_button
activeFocusOnPress: true
menu: Cura.MaterialMenu
{
extruderIndex: Cura.ExtruderManager.activeExtruderIndex
}
}
}
Row
{
height: UM.Theme.getSize("print_setup_item").height
Label
{
text: Cura.MachineManager.activeDefinitionVariantsName
verticalAlignment: Text.AlignVCenter
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
height: parent.height
width: tabControl.textWidth
}
OldControls.ToolButton
{
id: variantSelection
text: Cura.MachineManager.activeVariantName
tooltip: Cura.MachineManager.activeVariantName;
visible: Cura.MachineManager.hasVariants
height: UM.Theme.getSize("setting_control").height
width: tabControl.controlWidth
style: UM.Theme.styles.sidebar_header_button
activeFocusOnPress: true;
menu: Cura.NozzleMenu { extruderIndex: Cura.ExtruderManager.activeExtruderIndex }
}
}
} }
Cura.ActionButton
{
id: goToAuto
visible: popup.configuration_method === "custom"
text: catalog.i18nc("@label", "Configurations")
anchors
{
left: parent.left
bottom: parent.bottom
}
color: UM.Theme.getColor("secondary")
hoverColor: UM.Theme.getColor("secondary")
textColor: UM.Theme.getColor("primary")
textHoverColor: UM.Theme.getColor("text")
height: UM.Theme.getSize("action_panel_button").height
leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width
onClicked: popup.configuration_method = "auto"
}
} }
} }
} }

View File

@ -0,0 +1,168 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Controls 1.1 as OldControls
import Cura 1.0 as Cura
import UM 1.3 as UM
Item
{
Label
{
id: header
text: catalog.i18nc("@header", "Custom")
font: UM.Theme.getFont("large")
color: UM.Theme.getColor("text")
anchors
{
top: parent.top
left: parent.left
right: parent.right
}
}
TabBar
{
id: tabBar
onCurrentIndexChanged: Cura.ExtruderManager.setActiveExtruderIndex(currentIndex)
anchors.top: header.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height
width: parent.width
height: 50
Repeater
{
model: extrudersModel
delegate: TabButton
{
width: ListView.view != null ? Math.round(ListView.view.width / extrudersModel.rowCount()): 0
height: parent.height
contentItem: Item
{
Cura.ExtruderIcon
{
anchors.horizontalCenter: parent.horizontalCenter
materialColor: model.color
extruderEnabled: model.enabled
width: parent.height
height: parent.height
}
}
}
}
}
Item
{
id: tabControl
width: parent.width
anchors.top: tabBar.bottom
anchors.bottom: parent.bottom
property var model: extrudersModel.items[tabBar.currentIndex]
property real textWidth: Math.round(width * 0.3)
property real controlWidth: width - textWidth
Column
{
spacing: UM.Theme.getSize("default_margin").height
Row
{
height: UM.Theme.getSize("print_setup_item").height
Label
{
text: catalog.i18nc("@label", "Enabled")
verticalAlignment: Text.AlignVCenter
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
height: parent.height
width: tabControl.textWidth
}
OldControls.CheckBox
{
checked: tabControl.model != null ? Cura.MachineManager.getExtruder(tabControl.model.index).isEnabled: false
onClicked: Cura.MachineManager.setExtruderEnabled(tabControl.model.index, checked)
height: UM.Theme.getSize("setting_control").height
style: UM.Theme.styles.checkbox
}
}
Row
{
height: UM.Theme.getSize("print_setup_item").height
Label
{
text: catalog.i18nc("@label", "Material")
verticalAlignment: Text.AlignVCenter
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
height: parent.height
width: tabControl.textWidth
}
OldControls.ToolButton
{
id: materialSelection
property var activeExtruder: Cura.MachineManager.activeStack
property var hasActiveExtruder: activeExtruder != null
property var currentRootMaterialName: hasActiveExtruder ? activeExtruder.material.name : ""
property var valueError: hasActiveExtruder ? Cura.ContainerManager.getContainerMetaDataEntry(activeExtruder.material.id, "compatible", "") != "True" : true
property var valueWarning: ! Cura.MachineManager.isActiveQualitySupported
text: currentRootMaterialName
tooltip: currentRootMaterialName
visible: Cura.MachineManager.hasMaterials
enabled: Cura.ExtruderManager.activeExtruderIndex > -1
height: UM.Theme.getSize("setting_control").height
width: tabControl.controlWidth
style: UM.Theme.styles.sidebar_header_button
activeFocusOnPress: true
menu: Cura.MaterialMenu
{
extruderIndex: Cura.ExtruderManager.activeExtruderIndex
}
}
}
Row
{
height: UM.Theme.getSize("print_setup_item").height
Label
{
text: Cura.MachineManager.activeDefinitionVariantsName
verticalAlignment: Text.AlignVCenter
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
height: parent.height
width: tabControl.textWidth
}
OldControls.ToolButton
{
id: variantSelection
text: Cura.MachineManager.activeVariantName
tooltip: Cura.MachineManager.activeVariantName;
visible: Cura.MachineManager.hasVariants
height: UM.Theme.getSize("setting_control").height
width: tabControl.controlWidth
style: UM.Theme.styles.sidebar_header_button
activeFocusOnPress: true;
menu: Cura.NozzleMenu { extruderIndex: Cura.ExtruderManager.activeExtruderIndex }
}
}
}
}
}