Update the profile selector to new style for the intents

CURA-6598
This commit is contained in:
Jaime van Kessel 2019-08-06 10:49:42 +02:00
parent 7d65951f43
commit 92be261178
3 changed files with 326 additions and 24 deletions

View file

@ -6,7 +6,7 @@ import QtQuick.Controls 2.0
import QtQuick.Controls 1.1 as OldControls import QtQuick.Controls 1.1 as OldControls
import UM 1.3 as UM import UM 1.3 as UM
import Cura 1.0 as Cura import Cura 1.6 as Cura
Item Item
@ -18,18 +18,6 @@ Item
property var extrudersModel: CuraApplication.getExtrudersModel() 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 Item
{ {
id: intent id: intent
@ -37,7 +25,7 @@ Item
anchors anchors
{ {
top: globalProfileRow.bottom top: parent.top
topMargin: UM.Theme.getSize("default_margin").height topMargin: UM.Theme.getSize("default_margin").height
left: parent.left left: parent.left
leftMargin: parent.padding leftMargin: parent.padding
@ -60,20 +48,93 @@ Item
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
OldControls.ToolButton
Button
{ {
id: intentSelection id: intentSelection
text: Cura.MachineManager.activeStack != null ? Cura.MachineManager.activeStack.intent.name : "" onClicked: menu.opened ? menu.close() : menu.open()
tooltip: text text: generateActiveQualityText()
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 } anchors.right: parent.right
width: UM.Theme.getSize("print_setup_big_item").width
height: textLabel.contentHeight + 2 * UM.Theme.getSize("narrow_margin").height
contentItem: Label
{
id: textLabel
text: intentSelection.text
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.verticalCenter: intentSelection.verticalCenter
height: contentHeight
verticalAlignment: Text.AlignVCenter
}
background: Rectangle
{
border.color: UM.Theme.getColor("lining")
border.width: UM.Theme.getSize("default_lining").width
radius: UM.Theme.getSize("default_radius").width
}
function generateActiveQualityText()
{
var result = Cura.MachineManager.activeQualityOrQualityChangesName
if (Cura.MachineManager.isActiveQualityExperimental)
{
result += " (Experimental)"
}
if (Cura.MachineManager.isActiveQualitySupported)
{
if (Cura.MachineManager.activeQualityLayerHeight > 0)
{
result += " <font color=\"" + UM.Theme.getColor("text_detail") + "\">"
result += " - "
result += Cura.MachineManager.activeQualityLayerHeight + "mm"
result += "</font>"
}
}
return result
}
UM.SimpleButton
{
id: customisedSettings
visible: Cura.MachineManager.hasUserSettings
width: UM.Theme.getSize("print_setup_icon").width
height: UM.Theme.getSize("print_setup_icon").height
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: UM.Theme.getSize("thick_margin").width
color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button");
iconSource: UM.Theme.getIcon("star")
onClicked:
{
forceActiveFocus();
Cura.Actions.manageProfiles.trigger()
}
onEntered:
{
var content = catalog.i18nc("@tooltip", "Some setting/override values are different from the values stored in the profile.\n\nClick to open the profile manager.")
base.showTooltip(intent, Qt.point(-UM.Theme.getSize("default_margin").width, 0), content)
}
onExited: base.hideTooltip()
}
} }
QualitiesWithIntentMenu
{
id: menu
y: intentSelection.y + intentSelection.height
x: intentSelection.x
width: intentSelection.width
}
} }
UM.TabRow UM.TabRow

View file

@ -0,0 +1,242 @@
import QtQuick 2.0
import QtQuick.Controls 2.3
import Cura 1.6 as Cura
import UM 1.2 as UM
Popup
{
id: popup
implicitWidth: 400
property var dataModel: Cura.IntentCategoryModel {}
property int defaultMargin: 5
property int checkmarkSize: 12
property int buttonHeight: 25
property color backgroundColor: "#f2f2f2"
property color borderColor: "#cccccc"
padding: 0
background: Rectangle
{
color: backgroundColor
border.width: 1
border.color: borderColor
}
ButtonGroup
{
id: buttonGroup
exclusive: true
onClicked: popup.visible = false
}
contentItem: Column
{
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
height: childrenRect.height
// This repeater adds the intent labels
Repeater
{
model: dataModel
delegate: Item
{
// We need to set it like that, otherwise we'd have to set the sub model with model: model.qualities
// Which obviously won't work due to naming conflicts.
property variant subItemModel: model.qualities
height: childrenRect.height
anchors
{
left: parent.left
leftMargin: defaultMargin
right: parent.right
rightMargin: defaultMargin
}
Label
{
id: headerLabel
text: model.name
height: visible ? contentHeight: 0
enabled: false
visible: qualitiesList.visibleChildren.length > 0
}
Column
{
id: qualitiesList
anchors.top: headerLabel.bottom
anchors.left: parent.left
anchors.right: parent.right
// We set it by means of a binding, since then we can use the when condition, which we need to
// prevent a binding loop.
Binding
{
target: parent
property: "height"
value: parent.childrenRect.height
when: parent.visibleChildren.lengt > 0
}
// Add the qualities that belong to the intent
Repeater
{
visible: false
model: subItemModel
Button
{
id: button
onClicked: Cura.IntentManager.selectIntent(model.intent_category, model.quality_type)
width: parent.width
height: buttonHeight
checkable: true
visible: model.available
checked:
{
if(Cura.MachineManager.hasCustomQuality)
{
// When user created profile is active, no quality tickbox should be active.
return false
}
return Cura.MachineManager.activeQualityType == model.quality_type && Cura.MachineManager.activeIntentCategory == model.intent_category
}
ButtonGroup.group: buttonGroup
background: Item {}
contentItem: Item
{
Rectangle
{
id: checkmark
width: checkmarkSize
height: checkmarkSize
anchors.verticalCenter: parent.verticalCenter
color: "black"
visible: button.checked
}
Label
{
id: label
text: model.name + " - " + model.layer_height + " mm"
verticalAlignment: Text.AlignVCenter
anchors
{
left: checkmark.right
leftMargin: defaultMargin
top: parent.top
bottom: parent.bottom
right: parent.right
}
}
}
}
}
}
}
}
Rectangle
{
height: 1
anchors.left: parent.left
anchors.right: parent.right
color: borderColor
}
Button
{
text: Cura.Actions.addProfile.text
anchors.left: parent.left
anchors.leftMargin: defaultMargin
enabled: Cura.Actions.addProfile.enabled
background: Item {}
onClicked:
{
Cura.Actions.addProfile.trigger()
popup.visible = false
}
}
Button
{
text: Cura.Actions.updateProfile.text
anchors.left: parent.left
anchors.leftMargin: defaultMargin
enabled: Cura.Actions.updateProfile.enabled
background: Item {}
onClicked:
{
popup.visible = false
Cura.Actions.updateProfile.trigger()
}
}
Button
{
text: catalog.i18nc("@action:button", "Discard current changes")
anchors.left: parent.left
anchors.leftMargin: defaultMargin
enabled: Cura.MachineManager.hasUserSettings
background: Item {}
onClicked:
{
popup.visible = false
Cura.ContainerManager.clearUserContainers()
}
}
Rectangle
{
height: 1
anchors.left: parent.left
anchors.right: parent.right
color: borderColor
}
Button
{
id: manageProfilesButton
text: Cura.Actions.manageProfiles.text
anchors
{
left: parent.left
leftMargin: defaultMargin
right: parent.right
rightMargin: defaultMargin
}
height: textLabel.contentHeight + 2 * UM.Theme.getSize("narrow_margin").height
background: Item {}
contentItem: Item
{
width: manageProfilesButton.width
Label
{
id: textLabel
text: manageProfilesButton.text
height: contentHeight
}
Label
{
id: shortcutLabel
text: Cura.Actions.manageProfiles.shortcut
anchors.right: parent.right
}
}
onClicked:
{
popup.visible = false
Cura.Actions.manageProfiles.trigger()
}
}
}
}

View file

@ -34,7 +34,6 @@ Item
id: activeProfileButtonGroup id: activeProfileButtonGroup
exclusive: true exclusive: true
onClicked: Cura.IntentManager.selectIntent(button.modelData.intent_category, button.modelData.quality_type) onClicked: Cura.IntentManager.selectIntent(button.modelData.intent_category, button.modelData.quality_type)
} }
Item Item