Skip to content

Commit 091518e

Browse files
committed
qml: android back-gesture conflict hack not working on qt6, replace with simple properties
1 parent 459f4c1 commit 091518e

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed
Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,27 @@
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
55

66
ListView {
77
id: root
88

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
1114

1215
MouseArea {
1316
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
1619
}
1720

1821
MouseArea {
1922
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
2225
}
2326

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-
}
4027
}

0 commit comments

Comments
 (0)