From 052ddc718d309610da5ac604f9e2068ef7435459 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Sat, 26 Sep 2015 16:24:04 +0200 Subject: [PATCH] Hide notification depending on the touch point --- src/libsnore/notification/icon.h | 2 +- src/plugins/backends/snore/notification.qml | 32 ++++++++++----------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/libsnore/notification/icon.h b/src/libsnore/notification/icon.h index 7016718..3802699 100644 --- a/src/libsnore/notification/icon.h +++ b/src/libsnore/notification/icon.h @@ -29,7 +29,7 @@ namespace Snore /** * Icon is a convnience wrapper for QIcon. - * @author Patrick von Reth \ + * @author Patrick von Reth \ */ class SNORE_EXPORT Icon : public QIcon { diff --git a/src/plugins/backends/snore/notification.qml b/src/plugins/backends/snore/notification.qml index 0d06242..2c100a3 100644 --- a/src/plugins/backends/snore/notification.qml +++ b/src/plugins/backends/snore/notification.qml @@ -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