Add toggle function to expandable popup

Also ensures that the machineSelector closes the popup on making a choice

CURA-5785
This commit is contained in:
Jaime van Kessel 2018-11-15 13:55:33 +01:00
parent f0b8c1e611
commit eca9820fc4
2 changed files with 25 additions and 3 deletions

View file

@ -40,6 +40,19 @@ Item
// Is the "drawer" open?
readonly property alias expanded: popup.visible
function togglePopup()
{
if(popup.visible)
{
popup.close()
}
else
{
popup.open()
}
}
onPopupItemChanged:
{
// Since we want the size of the popup to be set by the size of the content,
@ -100,7 +113,7 @@ Item
{
id: mouseArea
anchors.fill: parent
onClicked: popup.visible ? popup.close() : popup.open()
onClicked: togglePopup()
hoverEnabled: true
onEntered: background.color = headerHoverColor
onExited: background.color = headerBackgroundColor

View file

@ -77,8 +77,12 @@ Cura.ExpandableComponent
width: parent.width
checkable: true
onClicked: Cura.MachineManager.setActiveMachine(model.id)
radius: UM.Theme.getSize("default_radius").width
onClicked:
{
togglePopup()
Cura.MachineManager.setActiveMachine(model.id)
}
Connections
{
@ -114,8 +118,13 @@ Cura.ExpandableComponent
width: parent.width
checked: Cura.MachineManager.activeMachineId == model.id
checkable: true
onClicked: Cura.MachineManager.setActiveMachine(model.id)
radius: UM.Theme.getSize("default_radius").width
onClicked:
{
togglePopup()
Cura.MachineManager.setActiveMachine(model.id)
}
}
}