From ca557f1c2b95262069f49021df42e9b9b31c691e Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Sat, 9 May 2026 10:49:25 +0200 Subject: [PATCH] Delay convergence dock tooltips Stop dock tooltips from appearing immediately under the pointer and hide them as soon as the user presses or opens a context menu. --- .../homescreens/folio/qml/FavouritesBar.qml | 117 +++++++++++++++++- 1 file changed, 111 insertions(+), 6 deletions(-) diff --git a/containments/homescreens/folio/qml/FavouritesBar.qml b/containments/homescreens/folio/qml/FavouritesBar.qml index be33359c..c5419de9 100644 --- a/containments/homescreens/folio/qml/FavouritesBar.qml +++ b/containments/homescreens/folio/qml/FavouritesBar.qml @@ -107,6 +107,41 @@ MouseArea { Behavior on trashButtonWidth { NumberAnimation { duration: Kirigami.Units.longDuration; easing.type: Easing.InOutCubic } } Behavior on searchButtonWidth { NumberAnimation { duration: Kirigami.Units.longDuration; easing.type: Easing.InOutCubic } } + property Item pendingDockToolTipItem: null + property Item activeDockToolTipItem: null + + Timer { + id: dockToolTipTimer + interval: Kirigami.Units.toolTipDelay + onTriggered: { + root.activeDockToolTipItem = root.pendingDockToolTipItem + root.pendingDockToolTipItem = null + dockToolTipHideTimer.restart() + } + } + + Timer { + id: dockToolTipHideTimer + interval: Kirigami.Units.toolTipDelay * 3 + onTriggered: root.hideDockToolTip(root.activeDockToolTipItem) + } + + function requestDockToolTip(item) { + activeDockToolTipItem = null + pendingDockToolTipItem = item + dockToolTipHideTimer.stop() + dockToolTipTimer.restart() + } + + function hideDockToolTip(item) { + if (!item || pendingDockToolTipItem === item || activeDockToolTipItem === item) { + pendingDockToolTipItem = null + activeDockToolTipItem = null + dockToolTipTimer.stop() + dockToolTipHideTimer.stop() + } + } + function pagerDesktopName(index) { let names = virtualDesktopInfo.desktopNames if (names && index < names.length && String(names[index]).length > 0) @@ -336,7 +371,7 @@ MouseArea { } PC3.ToolTip { - visible: desktopMouseArea.containsMouse && !desktopContextMenu.opened + visible: root.activeDockToolTipItem === desktopButton && desktopMouseArea.containsMouse && !desktopMouseArea.containsPress && !desktopContextMenu.opened text: desktopButton.Accessible.name } @@ -347,6 +382,7 @@ MouseArea { acceptedButtons: Qt.LeftButton | Qt.RightButton cursorShape: root.convergenceMode ? Qt.PointingHandCursor : Qt.ArrowCursor onClicked: (mouse) => { + root.hideDockToolTip(desktopButton) if (mouse.button === Qt.RightButton) { desktopContextMenu.open() } else { @@ -354,9 +390,22 @@ MouseArea { } } onPressAndHold: { + root.hideDockToolTip(desktopButton) desktopContextMenu.open() haptics.buttonVibrate() } + onContainsMouseChanged: { + if (containsMouse) { + root.requestDockToolTip(desktopButton) + } else { + root.hideDockToolTip(desktopButton) + } + } + onPressedChanged: { + if (pressed) { + root.hideDockToolTip(desktopButton) + } + } } PC3.Menu { @@ -496,7 +545,7 @@ MouseArea { } PC3.ToolTip { - visible: searchMouseArea.containsMouse + visible: root.activeDockToolTipItem === searchButton && searchMouseArea.containsMouse && !searchMouseArea.containsPress text: i18n("Search") } @@ -505,7 +554,22 @@ MouseArea { anchors.fill: parent hoverEnabled: true cursorShape: root.convergenceMode ? Qt.PointingHandCursor : Qt.ArrowCursor - onClicked: root.folio.HomeScreenState.openSearchWidget() + onClicked: { + root.hideDockToolTip(searchButton) + root.folio.HomeScreenState.openSearchWidget() + } + onContainsMouseChanged: { + if (containsMouse) { + root.requestDockToolTip(searchButton) + } else { + root.hideDockToolTip(searchButton) + } + } + onPressedChanged: { + if (pressed) { + root.hideDockToolTip(searchButton) + } + } } } @@ -554,7 +618,7 @@ MouseArea { } PC3.ToolTip { - visible: leftPagerHover.containsMouse + visible: root.activeDockToolTipItem === leftDesktopBtn && leftPagerHover.containsMouse && !leftPagerHover.containsPress && !leftPagerContextMenu.opened text: root.pagerDesktopName(leftDesktopBtn.index) } @@ -565,6 +629,7 @@ MouseArea { acceptedButtons: Qt.LeftButton | Qt.RightButton cursorShape: Qt.PointingHandCursor onClicked: (mouse) => { + root.hideDockToolTip(leftDesktopBtn) if (mouse.button === Qt.RightButton) { leftPagerContextMenu.open() } else if (leftDesktopBtn.desktopId) { @@ -572,9 +637,22 @@ MouseArea { } } onPressAndHold: { + root.hideDockToolTip(leftDesktopBtn) leftPagerContextMenu.open() haptics.buttonVibrate() } + onContainsMouseChanged: { + if (containsMouse) { + root.requestDockToolTip(leftDesktopBtn) + } else { + root.hideDockToolTip(leftDesktopBtn) + } + } + onPressedChanged: { + if (pressed) { + root.hideDockToolTip(leftDesktopBtn) + } + } } PC3.Menu { @@ -648,7 +726,7 @@ MouseArea { } PC3.ToolTip { - visible: rightPagerHover.containsMouse + visible: root.activeDockToolTipItem === rightDesktopBtn && rightPagerHover.containsMouse && !rightPagerHover.containsPress && !rightPagerContextMenu.opened text: root.pagerDesktopName(rightDesktopBtn.desktopIndex) } @@ -659,6 +737,7 @@ MouseArea { acceptedButtons: Qt.LeftButton | Qt.RightButton cursorShape: Qt.PointingHandCursor onClicked: (mouse) => { + root.hideDockToolTip(rightDesktopBtn) if (mouse.button === Qt.RightButton) { rightPagerContextMenu.open() } else if (rightDesktopBtn.desktopId) { @@ -666,9 +745,22 @@ MouseArea { } } onPressAndHold: { + root.hideDockToolTip(rightDesktopBtn) rightPagerContextMenu.open() haptics.buttonVibrate() } + onContainsMouseChanged: { + if (containsMouse) { + root.requestDockToolTip(rightDesktopBtn) + } else { + root.hideDockToolTip(rightDesktopBtn) + } + } + onPressedChanged: { + if (pressed) { + root.hideDockToolTip(rightDesktopBtn) + } + } } PC3.Menu { @@ -778,7 +870,7 @@ MouseArea { } PC3.ToolTip { - visible: trashMouseArea.containsMouse + visible: root.activeDockToolTipItem === trashButton && trashMouseArea.containsMouse && !trashMouseArea.containsPress && !trashContextMenu.opened text: trashFilesModel.count > 0 ? i18np("Trash — 1 item", "Trash — %1 items", trashFilesModel.count) : i18n("Trash") @@ -791,12 +883,25 @@ MouseArea { cursorShape: Qt.PointingHandCursor acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: (mouse) => { + root.hideDockToolTip(trashButton) if (mouse.button === Qt.RightButton) { trashContextMenu.open() } else { Qt.openUrlExternally("trash:/") } } + onContainsMouseChanged: { + if (containsMouse) { + root.requestDockToolTip(trashButton) + } else { + root.hideDockToolTip(trashButton) + } + } + onPressedChanged: { + if (pressed) { + root.hideDockToolTip(trashButton) + } + } } PC3.Menu {