Navigate page history with mouse back/forward
This commit is contained in:
parent
b9ea61e133
commit
58b4667c31
27
src/gui/GlobalTapHandlers.qml
Normal file
27
src/gui/GlobalTapHandlers.qml
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property PageLoader pageLoader
|
||||
|
||||
// Raise our z-index as much as possible, so that mouse events go before
|
||||
// anything else through this item which the TapHandlers are watching
|
||||
z: 99999
|
||||
|
||||
implicitWidth: parent ? parent.width : 0
|
||||
implicitHeight: parent ? parent.height : 0
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.BackButton
|
||||
onTapped: root.pageLoader.moveThroughHistory(1)
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.ForwardButton
|
||||
onTapped: root.pageLoader.moveThroughHistory(-1)
|
||||
}
|
||||
}
|
@ -12,6 +12,13 @@ MultiviewPane {
|
||||
readonly property QtObject accountModel:
|
||||
ModelStore.get("accounts").find(chat.roomInfo.for_account)
|
||||
|
||||
// Using a property for this item because MultiviewPane sends its children
|
||||
// inside its SwipeView by default, while GTH must always cover the pane
|
||||
readonly property GlobalTapHandlers globalTapHandlers: GlobalTapHandlers {
|
||||
parent: roomPane.contentItem
|
||||
pageLoader: pageLoader
|
||||
}
|
||||
|
||||
function toggleFocus() {
|
||||
if (roomPane.activeFocus) {
|
||||
if (roomPane.collapse) roomPane.close()
|
||||
|
@ -157,6 +157,11 @@ Item {
|
||||
MainPane {
|
||||
id: mainPane
|
||||
maximumSize: parent.width - theme.minimumSupportedWidth * 1.5
|
||||
|
||||
// Drawers (side panes) are actually Popups, which are considered to be
|
||||
// different "layer". Input handlers will only get events occuring
|
||||
// in the layer they were declared in.
|
||||
GlobalTapHandlers { pageLoader: pageLoader }
|
||||
}
|
||||
|
||||
PageLoader {
|
||||
@ -169,5 +174,7 @@ Item {
|
||||
mainPane.visibleSize
|
||||
|
||||
visible: mainPane.visibleSize < mainUI.width
|
||||
|
||||
GlobalTapHandlers { pageLoader: parent }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user