2019-12-19 07:46:16 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-07-12 18:02:14 -04:00
|
|
|
import QtQuick 2.12
|
2019-07-13 05:39:01 -04:00
|
|
|
import QtQuick.Controls 2.12
|
2019-09-11 16:47:13 -04:00
|
|
|
import QtQuick.Layouts 1.12
|
2019-07-09 22:51:52 -04:00
|
|
|
|
|
|
|
ToolTip {
|
2019-07-09 23:42:03 -04:00
|
|
|
id: toolTip
|
2020-07-12 00:25:57 -04:00
|
|
|
|
|
|
|
property bool instant: false
|
|
|
|
|
|
|
|
property alias label: label
|
|
|
|
property alias backgroundColor: background.color
|
|
|
|
|
|
|
|
readonly property bool hideNow: ! window.hovered
|
|
|
|
|
|
|
|
|
2020-07-26 20:56:42 -04:00
|
|
|
function instantShow(timeout=-1) {
|
2020-07-12 00:25:57 -04:00
|
|
|
if (visible) return
|
|
|
|
instant = true
|
2020-07-26 20:56:42 -04:00
|
|
|
timeout === -1 ? open() : show(text, timeout)
|
2020-07-12 00:25:57 -04:00
|
|
|
instant = false
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-13 11:35:05 -04:00
|
|
|
delay: instant ? 0 : theme.controls.toolTip.delay
|
2019-08-22 09:27:26 -04:00
|
|
|
padding: background.border.width
|
|
|
|
|
2019-08-27 22:46:31 -04:00
|
|
|
background: Rectangle {
|
2019-08-22 09:27:26 -04:00
|
|
|
id: background
|
|
|
|
color: theme.controls.toolTip.background
|
|
|
|
border.color: theme.controls.toolTip.border
|
|
|
|
border.width: theme.controls.toolTip.borderWidth
|
|
|
|
}
|
|
|
|
|
2019-09-11 16:47:13 -04:00
|
|
|
contentItem: HRowLayout {
|
|
|
|
HLabel {
|
|
|
|
id: label
|
|
|
|
color: theme.controls.toolTip.text
|
|
|
|
text: toolTip.text
|
2020-07-17 01:45:02 -04:00
|
|
|
wrapMode: HLabel.Wrap
|
2019-09-11 16:47:13 -04:00
|
|
|
|
|
|
|
leftPadding: theme.spacing / 1.5
|
|
|
|
rightPadding: leftPadding
|
|
|
|
topPadding: theme.spacing / 2
|
|
|
|
bottomPadding: topPadding
|
|
|
|
|
|
|
|
Layout.maximumWidth: Math.min(
|
2019-09-17 16:30:04 -04:00
|
|
|
window.width / 1.25, theme.fontSize.normal * 0.5 * 75,
|
2019-09-11 16:47:13 -04:00
|
|
|
)
|
|
|
|
}
|
2019-08-22 09:27:26 -04:00
|
|
|
}
|
2019-07-09 22:51:52 -04:00
|
|
|
|
|
|
|
enter: Transition {
|
|
|
|
HNumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
|
|
|
|
}
|
|
|
|
exit: Transition {
|
2019-09-17 16:30:04 -04:00
|
|
|
HNumberAnimation { property: "opacity"; to: 0.0 }
|
2019-07-09 22:51:52 -04:00
|
|
|
}
|
2019-07-09 23:49:59 -04:00
|
|
|
|
2020-03-13 11:35:05 -04:00
|
|
|
onHideNowChanged: if (visible && hideNow) toolTip.hide()
|
|
|
|
|
2019-07-12 18:02:14 -04:00
|
|
|
TapHandler {
|
2019-12-06 07:07:40 -04:00
|
|
|
onTapped: toolTip.hide()
|
2019-07-09 23:49:59 -04:00
|
|
|
}
|
2019-07-24 15:58:43 -04:00
|
|
|
|
|
|
|
HoverHandler {
|
2019-08-22 09:27:26 -04:00
|
|
|
onHoveredChanged: if (! hovered) toolTip.hide()
|
2019-07-24 15:58:43 -04:00
|
|
|
}
|
2019-07-09 22:51:52 -04:00
|
|
|
}
|