1 changed files with 13 additions and 26 deletions
@ -1,40 +1,27 @@ |
|||||||
import QtQuick 2.6 |
import QtQuick |
||||||
import QtQuick.Layouts 1.0 |
import QtQuick.Layouts |
||||||
import QtQuick.Controls 2.0 |
import QtQuick.Controls |
||||||
import QtQuick.Controls.Material 2.0 |
import QtQuick.Controls.Material |
||||||
|
|
||||||
ListView { |
ListView { |
||||||
id: root |
id: root |
||||||
|
|
||||||
property int width_left_exclusion_zone: 0 |
// avoid interference with android back-gesture by defining deadzones |
||||||
property int width_right_exclusion_zone: 0 |
// you can override to 0 if listview is away from left or right edge. |
||||||
|
property int exclusionZone: constants.fingerWidth / 2 |
||||||
|
property int leftExclusionZone: exclusionZone |
||||||
|
property int rightExclusionZone: exclusionZone |
||||||
|
|
||||||
MouseArea { |
MouseArea { |
||||||
anchors {top: root.top; left: root.left; bottom: root.bottom } |
anchors {top: root.top; left: root.left; bottom: root.bottom } |
||||||
visible: width_left_exclusion_zone > 0 |
visible: leftExclusionZone > 0 |
||||||
width: width_left_exclusion_zone |
width: leftExclusionZone |
||||||
} |
} |
||||||
|
|
||||||
MouseArea { |
MouseArea { |
||||||
anchors { top: root.top; right: root.right; bottom: root.bottom } |
anchors { top: root.top; right: root.right; bottom: root.bottom } |
||||||
visible: width_right_exclusion_zone > 0 |
visible: rightExclusionZone > 0 |
||||||
width: width_right_exclusion_zone |
width: rightExclusionZone |
||||||
} |
} |
||||||
|
|
||||||
// determine distance from sides of window and reserve some |
|
||||||
// space using noop mouseareas in order to not emit clicks when |
|
||||||
// android back gesture is used |
|
||||||
function layoutExclusionZones() { |
|
||||||
var reserve = constants.fingerWidth / 2 |
|
||||||
var p = root.mapToGlobal(0, 0) // note: coords on whole *screen*, not just window |
|
||||||
width_left_exclusion_zone = Math.max(0, reserve - p.x) |
|
||||||
p = root.mapToGlobal(width, 0) |
|
||||||
width_right_exclusion_zone = Math.max(0, reserve - (app.width - p.x)) |
|
||||||
} |
|
||||||
|
|
||||||
Component.onCompleted: { |
|
||||||
if (AppController.isAndroid()) { |
|
||||||
layoutExclusionZones() |
|
||||||
} |
|
||||||
} |
|
||||||
} |
} |
||||||
|
|||||||
Loading…
Reference in new issue