mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-04 12:47:51 +02:00
Guard bar tooltips with live hover state
This commit is contained in:
@@ -56,6 +56,7 @@ Item {
|
||||
readonly property real scaledHorizontalMargin: Style.spaceReal(horizontalMargin)
|
||||
readonly property real scaledRightExtraMargin: Style.spaceReal(rightExtraMargin)
|
||||
readonly property real scaledVerticalPadding: Style.spaceReal(verticalPadding)
|
||||
readonly property bool tooltipHovered: visible && interactive && !concealed && mouseArea.containsMouse
|
||||
|
||||
visible: text !== "" || keepSpace
|
||||
opacity: text === "" || concealed ? 0 : (dimmed ? 0.45 : 1)
|
||||
|
||||
+34
-14
@@ -104,6 +104,19 @@ Item {
|
||||
return !!target && !!window && targetWindow(target) === window
|
||||
}
|
||||
|
||||
function targetTooltipHovered(target) {
|
||||
return !!target && target.visible !== false && target.opacity !== 0 && target.tooltipHovered === true
|
||||
}
|
||||
|
||||
function clearTooltip() {
|
||||
tooltipTimer.stop()
|
||||
pendingTooltipTarget = null
|
||||
pendingTooltipText = ""
|
||||
tooltipTarget = null
|
||||
tooltipText = ""
|
||||
tooltipShown = false
|
||||
}
|
||||
|
||||
function requestPopout(owner) {
|
||||
if (activePopout === owner) return
|
||||
if (activePopout && "close" in activePopout) activePopout.close()
|
||||
@@ -388,14 +401,9 @@ Item {
|
||||
}
|
||||
|
||||
function showTooltip(target, text) {
|
||||
tooltipTimer.stop()
|
||||
tooltipTarget = null
|
||||
tooltipText = ""
|
||||
tooltipShown = false
|
||||
clearTooltip()
|
||||
|
||||
if (!target || !text) {
|
||||
pendingTooltipTarget = null
|
||||
pendingTooltipText = ""
|
||||
if (!targetTooltipHovered(target) || !text) {
|
||||
tooltipRequest += 1
|
||||
return
|
||||
}
|
||||
@@ -407,6 +415,10 @@ Item {
|
||||
|
||||
Qt.callLater(function() {
|
||||
if (request !== tooltipRequest) return
|
||||
if (!targetTooltipHovered(pendingTooltipTarget)) {
|
||||
clearTooltip()
|
||||
return
|
||||
}
|
||||
tooltipTarget = pendingTooltipTarget
|
||||
tooltipText = pendingTooltipText
|
||||
pendingTooltipTarget = null
|
||||
@@ -418,13 +430,8 @@ Item {
|
||||
function hideTooltip(target) {
|
||||
if (tooltipTarget !== target && pendingTooltipTarget !== target) return
|
||||
|
||||
tooltipTimer.stop()
|
||||
tooltipRequest += 1
|
||||
pendingTooltipTarget = null
|
||||
pendingTooltipText = ""
|
||||
tooltipTarget = null
|
||||
tooltipText = ""
|
||||
tooltipShown = false
|
||||
clearTooltip()
|
||||
}
|
||||
|
||||
function refreshUpdate() {
|
||||
@@ -510,7 +517,17 @@ Item {
|
||||
Timer {
|
||||
id: tooltipTimer
|
||||
interval: 400
|
||||
onTriggered: root.tooltipShown = true
|
||||
onTriggered: {
|
||||
if (root.targetTooltipHovered(root.tooltipTarget)) root.tooltipShown = true
|
||||
else root.clearTooltip()
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 100
|
||||
running: root.tooltipShown
|
||||
repeat: true
|
||||
onTriggered: if (!root.targetTooltipHovered(root.tooltipTarget)) root.hideTooltip(root.tooltipTarget)
|
||||
}
|
||||
|
||||
Timer {
|
||||
@@ -1053,6 +1070,7 @@ Item {
|
||||
property real fixedWidth: -1
|
||||
property real fixedHeight: -1
|
||||
property string tooltipText: ""
|
||||
readonly property bool tooltipHovered: visible && opacity > 0 && mouseArea.containsMouse
|
||||
|
||||
signal pressed(int button)
|
||||
signal wheelMoved(int delta)
|
||||
@@ -1743,6 +1761,8 @@ Item {
|
||||
trayItemRoot.modelData.scroll(wheel.angleDelta.y, false)
|
||||
}
|
||||
}
|
||||
|
||||
readonly property bool tooltipHovered: visible && opacity > 0 && mouseArea.containsMouse
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user