Move tooltip window hover detector to HToolTip

Having a HoverHandler covering the root ApplicationWindow causes
problems for some Qt Quick Controls with pen/touch, e.g. it's impossible
to focus a TextArea/TextField.

The HoverHandler is moved to HToolTip (since it's used for those),
targets the ApplicationWindow but is now only enabled while a tooltip is
visible.
This commit is contained in:
miruka 2020-08-23 15:17:06 -04:00
parent f68dda9f14
commit 71a2951f5b
2 changed files with 6 additions and 7 deletions

View File

@ -12,8 +12,6 @@ ToolTip {
property alias label: label property alias label: label
property alias backgroundColor: background.color property alias backgroundColor: background.color
readonly property bool hideNow: ! window.hovered
function instantShow(timeout=-1) { function instantShow(timeout=-1) {
if (visible) return if (visible) return
@ -58,8 +56,6 @@ ToolTip {
HNumberAnimation { property: "opacity"; to: 0.0 } HNumberAnimation { property: "opacity"; to: 0.0 }
} }
onHideNowChanged: if (visible && hideNow) toolTip.hide()
TapHandler { TapHandler {
onTapped: toolTip.hide() onTapped: toolTip.hide()
} }
@ -67,4 +63,10 @@ ToolTip {
HoverHandler { HoverHandler {
onHoveredChanged: if (! hovered) toolTip.hide() onHoveredChanged: if (! hovered) toolTip.hide()
} }
HoverHandler {
target: mainUI
enabled: toolTip.visible
onHoveredChanged: if (toolTip.visible && ! hovered) toolTip.hide()
}
} }

View File

@ -10,7 +10,6 @@ ApplicationWindow {
// FIXME: Qt 5.13.1 bug, this randomly stops updating after the cursor // FIXME: Qt 5.13.1 bug, this randomly stops updating after the cursor
// leaves the window until it's clicked again. // leaves the window until it's clicked again.
readonly property alias hovered: windowHover.hovered
readonly property bool hidden: readonly property bool hidden:
Qt.application.state === Qt.ApplicationSuspended || Qt.application.state === Qt.ApplicationSuspended ||
@ -85,8 +84,6 @@ ApplicationWindow {
Utils { id: utils } Utils { id: utils }
HoverHandler { id: windowHover }
HLoader { HLoader {
anchors.fill: parent anchors.fill: parent
source: py.ready ? "" : "LoadingScreen.qml" source: py.ready ? "" : "LoadingScreen.qml"