This repository has been archived by the owner on Sep 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSwipeArea.qml
68 lines (51 loc) · 1.66 KB
/
SwipeArea.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import QtQuick 2.0
Item {
property int activationAreaX : parent.width/10;
property int activationAreaY : parent.height/10;
property bool mouseAreaActivated: false
property int currentX: -1
property int currentY: -1
signal left (bool border)
signal right (bool border)
signal top (bool border)
signal bottom (bool border)
MouseArea{
anchors.fill:parent
focus:true
property bool border : false;
onPressed:{
mouseAreaActivated = true;
}
onPositionChanged:{
if(mouseAreaActivated){
if (mouseX < 20 || mouseX > width - 20 || mouseY < 20 || mouseY > height - 20)
border = true;
else
border = false;
currentX = mouseX;
currentY = mouseY;
mouseAreaActivated = false;
}
else if (currentX > 0 && currentY > 0){
// X
if (mouseX > currentX + parent.activationAreaX){
parent.right(border);
currentX = -1;
}
else if (mouseX < currentX - parent.activationAreaX){
parent.left(border);
currentX = -1;
}
// Y
if (mouseY > currentY + parent.activationAreaY){
parent.bottom(border);
currentY = -1;
}
else if (mouseY < currentY - parent.activationAreaY){
parent.top(border);
currentY = -1;
}
}
}
}
}