fixed the clicked event
This commit is contained in:
parent
8c1835950b
commit
a75bd07cd8
1 changed files with 89 additions and 81 deletions
|
@ -34,6 +34,8 @@ Item {
|
||||||
|
|
||||||
state: "closed"
|
state: "closed"
|
||||||
|
|
||||||
|
Drag.active: dragArea.drag.active
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: draw2Background
|
id: draw2Background
|
||||||
|
|
||||||
|
@ -46,104 +48,110 @@ Item {
|
||||||
border.width: 1
|
border.width: 1
|
||||||
visible: true
|
visible: true
|
||||||
|
|
||||||
Rectangle {
|
MouseArea {
|
||||||
id: semiArea
|
id: fullArea
|
||||||
anchors.top: parent.top
|
anchors.fill: parent
|
||||||
height: parent.height - contentHeight
|
enabled: (root.state === "expanded" || root.state === "opened")
|
||||||
anchors.right: parent.right
|
onClicked: {
|
||||||
anchors.left: parent.left
|
if (root.state === "expanded") {
|
||||||
visible: true
|
root.state = "collapsed"
|
||||||
color: "transparent"
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
if (root.state === "opened") {
|
||||||
id: contentArea
|
root.state = "closed"
|
||||||
anchors.top: semiArea.bottom
|
return
|
||||||
height: contentHeight
|
}
|
||||||
radius: 16
|
}
|
||||||
color: root.defaultColor
|
|
||||||
border.width: 1
|
|
||||||
border.color: root.borderColor
|
|
||||||
width: parent.width
|
|
||||||
visible: true
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: parent.radius
|
id: semiArea
|
||||||
height: parent.radius
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
height: parent.height - contentHeight
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
color: parent.color
|
visible: true
|
||||||
}
|
color: "transparent"
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: fullArea
|
|
||||||
anchors.fill: parent
|
|
||||||
enabled: (root.state === "expanded" || root.state === "opened")
|
|
||||||
onClicked: {
|
|
||||||
if (root.state === "expanded") {
|
|
||||||
root.state = "collapsed"
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root.state === "opened") {
|
Rectangle {
|
||||||
root.state = "closed"
|
id: contentArea
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Drag.active: dragArea.drag.active
|
anchors.top: semiArea.bottom
|
||||||
|
height: contentHeight
|
||||||
|
radius: 16
|
||||||
|
color: root.defaultColor
|
||||||
|
border.width: 1
|
||||||
|
border.color: root.borderColor
|
||||||
|
width: parent.width
|
||||||
|
visible: true
|
||||||
|
|
||||||
MouseArea {
|
Rectangle {
|
||||||
id: dragArea
|
width: parent.radius
|
||||||
|
height: parent.radius
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.left: parent.left
|
||||||
|
color: parent.color
|
||||||
|
}
|
||||||
|
|
||||||
anchors.fill: parent
|
MouseArea {
|
||||||
|
id: dragArea
|
||||||
|
|
||||||
cursorShape: (root.state === "opened" || root.state === "expanded") ? Qt.PointingHandCursor : Qt.ArrowCursor
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
|
||||||
|
|
||||||
drag.target: parent
|
cursorShape: (root.state === "opened" || root.state === "expanded") ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||||
drag.axis: Drag.YAxis
|
hoverEnabled: true
|
||||||
drag.maximumY: parent.height
|
|
||||||
drag.minimumY: parent.height - root.height
|
|
||||||
|
|
||||||
/** If drag area is released at any point other than min or max y, transition to the other state */
|
drag.target: root
|
||||||
onReleased: {
|
drag.axis: Drag.YAxis
|
||||||
if (root.state === "closed" && root.y < dragArea.drag.maximumY) {
|
drag.maximumY: root.height
|
||||||
root.state = "opened"
|
drag.minimumY: root.height - root.height
|
||||||
PageController.drawerOpen()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root.state === "opened" && root.y > dragArea.drag.minimumY) {
|
/** If drag area is released at any point other than min or max y, transition to the other state */
|
||||||
root.state = "closed"
|
onReleased: {
|
||||||
PageController.drawerClose()
|
if (root.state === "closed" && root.y < dragArea.drag.maximumY) {
|
||||||
return
|
root.state = "opened"
|
||||||
}
|
PageController.drawerOpen()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (root.state === "collapsed" && root.y < dragArea.drag.maximumY) {
|
if (root.state === "opened" && root.y > dragArea.drag.minimumY) {
|
||||||
root.state = "expanded"
|
root.state = "closed"
|
||||||
return
|
PageController.drawerClose()
|
||||||
}
|
return
|
||||||
if (root.state === "expanded" && root.y > dragArea.drag.minimumY) {
|
}
|
||||||
root.state = "collapsed"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onClicked: {
|
if (root.state === "collapsed" && root.y < dragArea.drag.maximumY) {
|
||||||
if (root.state === "expanded") {
|
root.state = "expanded"
|
||||||
root.state = "collapsed"
|
return
|
||||||
return
|
}
|
||||||
}
|
if (root.state === "expanded" && root.y > dragArea.drag.minimumY) {
|
||||||
|
root.state = "collapsed"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (root.state === "opened") {
|
onClicked: {
|
||||||
root.state = "closed"
|
if (root.state === "expanded") {
|
||||||
return
|
root.state = "collapsed"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root.state === "opened") {
|
||||||
|
root.state = "closed"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// onEntered: {
|
||||||
|
// fullArea.enabled = false
|
||||||
|
// }
|
||||||
|
|
||||||
|
// onExited: {
|
||||||
|
// fullArea.enabled = true
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue