| 1 |
/* |
| 2 |
* Copyright (C) 2014-2015 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License version 3 as |
| 6 |
* published by the Free Software Foundation. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.9 |
| 18 |
Item { |
| 19 |
id: mouseAreaWithMultipoint |
| 20 |
|
| 21 |
signal clicked(var mouse) |
| 22 |
signal doubleClicked(var mouse) |
| 23 |
signal wheel(var wheel) |
| 24 |
signal pressed(var mouse) |
| 25 |
|
| 26 |
property bool desktop: true |
| 27 |
property bool propagateComposedEvents: false |
| 28 |
|
| 29 |
anchors.fill: parent |
| 30 |
|
| 31 |
MouseArea { |
| 32 |
anchors.fill: parent |
| 33 |
enabled: mouseAreaWithMultipoint.desktop |
| 34 |
|
| 35 |
propagateComposedEvents: mouseAreaWithMultipoint.propagateComposedEvents |
| 36 |
|
| 37 |
onClicked: mouseAreaWithMultipoint.clicked(mouse); |
| 38 |
onDoubleClicked: mouseAreaWithMultipoint.doubleClicked(mouse); |
| 39 |
onWheel: mouseAreaWithMultipoint.wheel(wheel); |
| 40 |
onPressed: mouseAreaWithMultipoint.pressed(mouse); |
| 41 |
} |
| 42 |
|
| 43 |
MultiPointTouchArea { |
| 44 |
anchors.fill: parent |
| 45 |
enabled: !mouseAreaWithMultipoint.desktop |
| 46 |
|
| 47 |
Timer { |
| 48 |
id: dblTapTimeout |
| 49 |
interval: 600 |
| 50 |
repeat: false |
| 51 |
onTriggered: dblTapHandler.pressCount = 0 |
| 52 |
} |
| 53 |
|
| 54 |
touchPoints: TouchPoint { |
| 55 |
id: dblTapHandler |
| 56 |
property int pressCount: 0 |
| 57 |
onPressedChanged: { |
| 58 |
if (pressed) { |
| 59 |
pressCount++; |
| 60 |
dblTapTimeout.running = true; |
| 61 |
} else { |
| 62 |
if (pressCount == 1) { |
| 63 |
mouseAreaWithMultipoint.clicked({ x: dblTapHandler.x, y: dblTapHandler.y }); |
| 64 |
} else if (pressCount === 2) { |
| 65 |
mouseAreaWithMultipoint.doubleClicked({ x: dblTapHandler.x, y: dblTapHandler.y }); |
| 66 |
pressCount = 0; |
| 67 |
dblTapTimeout.stop(); |
| 68 |
} |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
} |
| 73 |
} |