fix: autoclose only when not hovered
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import "../../config"
|
import "../../config"
|
||||||
|
import "./notificationServer"
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
|
|
||||||
@@ -46,6 +47,18 @@ Rectangle {
|
|||||||
property color textColor: urgency != 3 ? Colors.primary : Colors.tertiary
|
property color textColor: urgency != 3 ? Colors.primary : Colors.tertiary
|
||||||
property color textBGColor: urgency != 3 ? Qt.alpha(Colors.primaryContainer, 0.75) : Qt.alpha(Colors.tertiaryContainer, 0.75)
|
property color textBGColor: urgency != 3 ? Qt.alpha(Colors.primaryContainer, 0.75) : Qt.alpha(Colors.tertiaryContainer, 0.75)
|
||||||
|
|
||||||
|
// Expose hover state for history auto-close (reuse paused logic)
|
||||||
|
readonly property bool isHovered: mouseArea.containsMouse || closingMouseArea.containsMouse || inlineReplyButtonMouseArea.containsMouse || _hoveredActionCount > 0 || inlineReplyTextField.hovered || inlineReplyTextField.activeFocus
|
||||||
|
|
||||||
|
HoverHandler {
|
||||||
|
enabled: root.isHistory
|
||||||
|
blocking: false
|
||||||
|
grabPermissions: PointerHandler.CanTakeOverFromAnything
|
||||||
|
onHoveredChanged: if (hovered) NotificationS.historyHovered = true
|
||||||
|
}
|
||||||
|
// When in history, also keep historyHovered true while any inner element is hovered
|
||||||
|
onIsHoveredChanged: if (isHistory && isHovered) NotificationS.historyHovered = true
|
||||||
|
|
||||||
function closeNotification(dismiss){
|
function closeNotification(dismiss){
|
||||||
if (closing) {
|
if (closing) {
|
||||||
return
|
return
|
||||||
@@ -420,7 +433,7 @@ Rectangle {
|
|||||||
from: 1.0
|
from: 1.0
|
||||||
to: 0.0
|
to: 0.0
|
||||||
duration: root.duration
|
duration: root.duration
|
||||||
paused: (mouseArea.containsMouse || closingMouseArea.containsMouse || inlineReplyButtonMouseArea.containsMouse || root._hoveredActionCount > 0 || inlineReplyTextField.hovered || inlineReplyTextField.activeFocus) && !isHistory
|
paused: isHovered && !isHistory
|
||||||
onFinished: root.closeNotification(false)
|
onFinished: root.closeNotification(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,27 +74,12 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── Hover tracking via NotificationServer ──
|
// ── Hover tracking via NotificationServer ──
|
||||||
// History reports its hover state to the singleton; button does the same.
|
// History reports its hover state via background HoverHandler (non-exclusive)
|
||||||
// Timer auto-closes when neither is hovered for historyAutoCloseDelay ms.
|
// so hovering over inner buttons (closeArea, clearGroupArea, NotificationBody)
|
||||||
|
// does NOT clear historyHovered. Timer auto-closes when neither history nor
|
||||||
|
// bar button is hovered for historyAutoCloseDelay ms.
|
||||||
property bool _allowAutoClose: false
|
property bool _allowAutoClose: false
|
||||||
|
|
||||||
HoverHandler {
|
|
||||||
id: historyHoverHandler
|
|
||||||
onHoveredChanged: NotificationS.historyHovered = hovered
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback MouseArea that doesn't steal clicks (acceptedButtons: NoButton)
|
|
||||||
// Ensures hover is detected even if HoverHandler is missed on PanelWindow boundaries.
|
|
||||||
// Placed with high z but NoButton so it doesn't block inner MouseAreas.
|
|
||||||
MouseArea {
|
|
||||||
id: historyHoverMouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
acceptedButtons: Qt.NoButton
|
|
||||||
propagateComposedEvents: true
|
|
||||||
onContainsMouseChanged: NotificationS.historyHovered = containsMouse
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grace timer: don't allow auto-close immediately after opening,
|
// Grace timer: don't allow auto-close immediately after opening,
|
||||||
// giving keyboard users time to move mouse to history.
|
// giving keyboard users time to move mouse to history.
|
||||||
Timer {
|
Timer {
|
||||||
@@ -156,14 +141,22 @@ PanelWindow {
|
|||||||
border.color: textColor
|
border.color: textColor
|
||||||
radius: Config.screen_big_radius_fun(screen.height)
|
radius: Config.screen_big_radius_fun(screen.height)
|
||||||
|
|
||||||
// Text {
|
// HoverHandler on background (parent of all history UI) stays hovered
|
||||||
// anchors.centerIn: parent
|
// when pointer is over any descendant (topBar buttons, NotificationBody etc.)
|
||||||
// font.family: Config.font
|
// because HoverHandler is non-blocking PointerHandler and tracks parent
|
||||||
// font.pixelSize: bigFontSize
|
// bounds rather than exclusive MouseArea containsMouse. This fixes bug
|
||||||
// color: textColor
|
// where hovering over inner buttons made historyHovered false and triggered
|
||||||
// wrapMode: Text.Wrap
|
// auto-close. Using CanTakeOverFromAnything ensures it isn't blocked by
|
||||||
// text: NotificationS.trackedNotifications.values[0]
|
// child MouseAreas.
|
||||||
// }
|
HoverHandler {
|
||||||
|
id: backgroundHoverHandler
|
||||||
|
blocking: false
|
||||||
|
grabPermissions: PointerHandler.CanTakeOverFromAnything
|
||||||
|
onHoveredChanged: {
|
||||||
|
NotificationS.historyHovered = hovered
|
||||||
|
if (Config.debug == "Notification") console.log("[NotificationHistory] background hovered:", hovered)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Component.onCompleted: {
|
// Component.onCompleted: {
|
||||||
// for (var notification in NotificationS.trackedNotifications.values) {
|
// for (var notification in NotificationS.trackedNotifications.values) {
|
||||||
@@ -279,6 +272,9 @@ PanelWindow {
|
|||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
// Safety: hovering over button should keep history considered hovered
|
||||||
|
// even if background HoverHandler is blocked (exclusive hover)
|
||||||
|
onContainsMouseChanged: if (containsMouse) NotificationS.historyHovered = true
|
||||||
Rectangle{
|
Rectangle{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: closeArea.containsMouse ? "red" : textBGColor
|
color: closeArea.containsMouse ? "red" : textBGColor
|
||||||
@@ -356,6 +352,14 @@ PanelWindow {
|
|||||||
implicitHeight: isGrouped ? groupedCard.implicitHeight : singleBody.implicitHeight
|
implicitHeight: isGrouped ? groupedCard.implicitHeight : singleBody.implicitHeight
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
|
|
||||||
|
// Keep history hovered when pointer is over this delegate
|
||||||
|
// (covers NotificationBody and its inner buttons).
|
||||||
|
HoverHandler {
|
||||||
|
blocking: false
|
||||||
|
grabPermissions: PointerHandler.CanTakeOverFromAnything
|
||||||
|
onHoveredChanged: if (hovered) NotificationS.historyHovered = true
|
||||||
|
}
|
||||||
|
|
||||||
// ── Singleton: plain NotificationBody ──
|
// ── Singleton: plain NotificationBody ──
|
||||||
NotificationBody {
|
NotificationBody {
|
||||||
id: singleBody
|
id: singleBody
|
||||||
@@ -400,6 +404,8 @@ PanelWindow {
|
|||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
hoverEnabled: true
|
||||||
|
onContainsMouseChanged: if (containsMouse) NotificationS.historyHovered = true
|
||||||
onClicked: root.toggleGroup(group.appName)
|
onClicked: root.toggleGroup(group.appName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,6 +457,7 @@ PanelWindow {
|
|||||||
height: bigFontSize + Config.spacing
|
height: bigFontSize + Config.spacing
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onContainsMouseChanged: if (containsMouse) NotificationS.historyHovered = true
|
||||||
onClicked: function(mouse) {
|
onClicked: function(mouse) {
|
||||||
mouse.accepted = true
|
mouse.accepted = true
|
||||||
root.clearGroup(group.appName)
|
root.clearGroup(group.appName)
|
||||||
|
|||||||
Reference in New Issue
Block a user