Workaround for continued xChanged after window was hid.

This commit is contained in:
Hannah von Reth 2015-09-28 12:00:52 +02:00
parent f143a9aced
commit 57f117da29

View File

@ -6,6 +6,9 @@ Rectangle {
property int snoreBaseSize: body.font.pixelSize property int snoreBaseSize: body.font.pixelSize
Drag.active: mouseAreaAccept.drag.active
width: snoreBaseSize * 30 width: snoreBaseSize * 30
height: snoreBaseSize * 9 height: snoreBaseSize * 9
color: window.color color: window.color
@ -23,16 +26,22 @@ Rectangle {
onXChanged: { onXChanged: {
// There is a Qt bug which will not stop the mouse tracking if the
// item is hid during a drag event.
if(Drag.active){
window.x += x window.x += x
if(window.visible && Math.abs((window.isOrientatedLeft?
var visibleWidth = window.isOrientatedLeft?
window.x - window.animationTo: window.x - window.animationTo:
window.x - window.animationFrom window.x - window.animationFrom) + mouseAreaAccept.mouseX) <= width * 0.05){
if(window.visible && Math.abs(visibleWidth + mouseAreaAccept.mouseX) <= width * 0.05){ Drag.cancel()
window.visible = false window.visible = false
window.dismissed() window.dismissed()
} }
} else {
x = 0
} }
}
NumberAnimation{ NumberAnimation{
id: animation id: animation
@ -48,7 +57,6 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
z: 90 z: 90
onClicked: { onClicked: {
console.log("invoked")
window.invoked() window.invoked()
} }
drag.target: parent drag.target: parent