|
1 | | -import QtQuick 2.6 |
2 | | -import QtQuick.Layouts 1.0 |
3 | | -import QtQuick.Controls 2.0 |
4 | | -import QtQuick.Controls.Material 2.0 |
| 1 | +import QtQuick |
| 2 | +import QtQuick.Layouts |
| 3 | +import QtQuick.Controls |
| 4 | +import QtQuick.Controls.Material |
5 | 5 |
|
6 | 6 | ListView { |
7 | 7 | id: root |
8 | 8 |
|
9 | | - property int width_left_exclusion_zone: 0 |
10 | | - property int width_right_exclusion_zone: 0 |
| 9 | + // avoid interference with android back-gesture by defining deadzones |
| 10 | + // you can override to 0 if listview is away from left or right edge. |
| 11 | + property int exclusionZone: constants.fingerWidth / 2 |
| 12 | + property int leftExclusionZone: exclusionZone |
| 13 | + property int rightExclusionZone: exclusionZone |
11 | 14 |
|
12 | 15 | MouseArea { |
13 | 16 | anchors {top: root.top; left: root.left; bottom: root.bottom } |
14 | | - visible: width_left_exclusion_zone > 0 |
15 | | - width: width_left_exclusion_zone |
| 17 | + visible: leftExclusionZone > 0 |
| 18 | + width: leftExclusionZone |
16 | 19 | } |
17 | 20 |
|
18 | 21 | MouseArea { |
19 | 22 | anchors { top: root.top; right: root.right; bottom: root.bottom } |
20 | | - visible: width_right_exclusion_zone > 0 |
21 | | - width: width_right_exclusion_zone |
| 23 | + visible: rightExclusionZone > 0 |
| 24 | + width: rightExclusionZone |
22 | 25 | } |
23 | 26 |
|
24 | | - // determine distance from sides of window and reserve some |
25 | | - // space using noop mouseareas in order to not emit clicks when |
26 | | - // android back gesture is used |
27 | | - function layoutExclusionZones() { |
28 | | - var reserve = constants.fingerWidth / 2 |
29 | | - var p = root.mapToGlobal(0, 0) // note: coords on whole *screen*, not just window |
30 | | - width_left_exclusion_zone = Math.max(0, reserve - p.x) |
31 | | - p = root.mapToGlobal(width, 0) |
32 | | - width_right_exclusion_zone = Math.max(0, reserve - (app.width - p.x)) |
33 | | - } |
34 | | - |
35 | | - Component.onCompleted: { |
36 | | - if (AppController.isAndroid()) { |
37 | | - layoutExclusionZones() |
38 | | - } |
39 | | - } |
40 | 27 | } |
0 commit comments