Hide notification depending on the touch point

This commit is contained in:
Patrick von Reth 2015-09-26 16:24:04 +02:00
parent a8e3cdbfd0
commit 052ddc718d
2 changed files with 16 additions and 18 deletions

View File

@ -29,7 +29,7 @@ namespace Snore
/**
* Icon is a convnience wrapper for QIcon.
* @author Patrick von Reth \<vonreth at kde.org\>
* @author Patrick von Reth \<vonreth at kde.org\>
*/
class SNORE_EXPORT Icon : public QIcon
{

View File

@ -9,30 +9,27 @@ Rectangle {
width: snoreBaseSize * 30
height: snoreBaseSize * 9
color: window.color
Drag.active: mouseAreaAccept.drag.active
visible: window.visible
x: 0
onVisibleChanged: {
if(visible){
x = 0
animation.from = window.animationFrom
animation.start()
Connections{
target: window
onVisibleChanged: {
if(visible){
x = 0
animation.from = window.animationFrom
animation.start()
}
}
}
onXChanged: {
window.x += x
var threashHold = 0
if(window.isOrientatedLeft) {
threashHold = Math.abs(window.x - window.animationTo + width)
}else{
threashHold = Math.abs(window.x - window.animationFrom)
}
if(window.visible && threashHold <= width * 0.3){
var visibleWidth = window.isOrientatedLeft?
window.x - window.animationTo:
window.x - window.animationFrom
if(window.visible && Math.abs(visibleWidth + mouseAreaAccept.mouseX) <= width * 0.05){
window.visible = false
Drag.cancel()
window.dismissed()
}
}
@ -51,6 +48,7 @@ Rectangle {
anchors.fill: parent
z: 90
onClicked: {
console.log("invoked")
window.invoked()
}
drag.target: parent