Compare commits

..
4 Commits
6 changed files with 151 additions and 37 deletions
+1 -1
View File
@@ -83,4 +83,4 @@ PanelWindow {
}
}
}
}
+13 -11
View File
@@ -13,11 +13,20 @@ MouseArea {
cursorShape: Qt.PointingHandCursor
onClicked: {
// NotificationS.soundEnabled = !NotificationS.soundEnabled
// NotificationS.notificationPopupEnabled = !NotificationS.notificationPopupEnabled
console.log("[NotificationButton] Opening NotificationHistory")
root.toggleNotificationHistory()
}
// ── Report hover to NotificationServer for auto-close logic ──
onContainsMouseChanged: NotificationS.buttonHovered = containsMouse
Component.onDestruction: {
if (containsMouse) NotificationS.buttonHovered = false
}
onVisibleChanged: {
if (!visible && NotificationS.buttonHovered) NotificationS.buttonHovered = false
}
Item {
anchors.top: parent.topBar
@@ -37,7 +46,7 @@ MouseArea {
color: Colors.secondaryContainer_fg
}
}
Rectangle {
anchors.fill: parent
color: "transparent"
@@ -46,18 +55,11 @@ MouseArea {
Text {
id: notificationText
anchors.centerIn: parent
// text: Quickshell.iconPath("discord")
text: NotificationS.soundEnabled ? "󰂚" : "󰂛"
// text: Quickshell.iconPath("discord")
text: NotificationS.notificationPopupEnabled ? "󰂚" : "󰂛"
font.pixelSize: Config.bigIconSize(bar.height)
font.family: Config.font
color: Colors.secondaryContainer_fg
}
// Image{
// id: iconImage
// source: Quickshell.iconPath("discord")
// width: Config.bigIconSize(notificationButton.height)
// height: Config.bigIconSize(notificationButton.height)
// }
}
}
+15 -3
View File
@@ -1,6 +1,7 @@
import QtQuick
import Quickshell
import "../../config"
import "./notificationServer"
import QtQuick.Layouts
import QtQuick.Controls
@@ -34,8 +35,7 @@ Rectangle {
implicitWidth: screen.width/7
// implicitHeight: screen.height/7
implicitHeight: contentRowRectangle.height+(actionRowRectangle.visible?actionRowRectangle.height:0)+(inlineReplyRectangle.visible?inlineReplyRectangle.height:0)+(progressBar.visible?progressBar
.height:0)
implicitHeight: contentRowRectangle.height+(actionRowRectangle.visible?actionRowRectangle.height:0)+(inlineReplyRectangle.visible?inlineReplyRectangle.height:0)+(progressBar.visible?progressBar.height:0)
color: textBGColor
border.width: Config.border_width
@@ -46,6 +46,18 @@ Rectangle {
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)
// 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){
if (closing) {
return
@@ -420,7 +432,7 @@ Rectangle {
from: 1.0
to: 0.0
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)
}
}
+87 -16
View File
@@ -31,8 +31,7 @@ PanelWindow {
property var grouped: {
const vals = NotificationS.trackedNotifications.values
const len = vals.length
if (len < 0) return []
if (!vals || vals.length === 0) return []
let map = {}
for (let i = 0; i < vals.length; ++i) {
const n = vals[i]
@@ -65,21 +64,71 @@ PanelWindow {
expandedGroups = ({})
}
function closeNHistory() {
// Centralized close via singleton signal fixes previous ReferenceError
// where this file tried to access notifificationHistoryLoader.id directly
// (that id lives in NotificationHistoryLoader.qml and is not in scope here).
console.log("[NotificationHistory] closeNHistory() requested")
NotificationS.historyHovered = false
NotificationS.closeHistoryRequested()
}
// ── Hover tracking via NotificationServer ──
// History reports its hover state via background HoverHandler (non-exclusive)
// 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
// Grace timer: don't allow auto-close immediately after opening,
// giving keyboard users time to move mouse to history.
Timer {
id: graceTimer
interval: 500
running: root.visible && !_allowAutoClose
repeat: false
onTriggered: _allowAutoClose = true
}
Timer {
id: hoverCloseTimer
interval: NotificationS.historyAutoCloseDelay
// Only run when panel is visible, grace passed, and neither element is hovered
running: root.visible && _allowAutoClose && !NotificationS.historyHovered && !NotificationS.buttonHovered
repeat: false
onTriggered: {
if (!NotificationS.historyHovered && !NotificationS.buttonHovered) {
console.log("[NotificationHistory] Auto-closing after hover timeout (" + interval + "ms)")
root.closeNHistory()
}
}
}
// Ensure hover state is cleared when window hides/destroys
onVisibleChanged: {
if (!visible) {
NotificationS.historyHovered = false
_allowAutoClose = false
}
}
Component.onDestruction: NotificationS.historyHovered = false
FocusScope {
id: nHistoryScope
anchors.fill: parent
focus: true
Keys.onReleased: function(event) {
if (event.key === Qt.Key_Escape) {
console.log("Pressed Escape, closing JLearner")
notifificationHistoryLoader.active = false
console.log("Pressed Escape, closing NotificationHistory")
root.closeNHistory()
}
}
Rectangle {
anchors.fill: parent
color: "lightblue"
visible: false // debug helper, keep hidden in normal use
}
}
@@ -92,14 +141,22 @@ PanelWindow {
border.color: textColor
radius: Config.screen_big_radius_fun(screen.height)
// Text {
// anchors.centerIn: parent
// font.family: Config.font
// font.pixelSize: bigFontSize
// color: textColor
// wrapMode: Text.Wrap
// text: NotificationS.trackedNotifications.values[0]
// }
// HoverHandler on background (parent of all history UI) stays hovered
// when pointer is over any descendant (topBar buttons, NotificationBody etc.)
// because HoverHandler is non-blocking PointerHandler and tracks parent
// bounds rather than exclusive MouseArea containsMouse. This fixes bug
// where hovering over inner buttons made historyHovered false and triggered
// auto-close. Using CanTakeOverFromAnything ensures it isn't blocked by
// 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: {
// for (var notification in NotificationS.trackedNotifications.values) {
@@ -154,7 +211,7 @@ PanelWindow {
spacing: Config.screen_spacing_fun(screen.height)
Text{
text: NotificationS.soundEnabled ? "󰂚" : "󰂛"
text: NotificationS.notificationPopupEnabled ? "󰂚" : "󰂛"
font.family: Config.font
font.pixelSize: topBar.height*0.75
color: textColor
@@ -166,7 +223,7 @@ PanelWindow {
implicitWidth: notificationVolumeSwitch.height*2
implicitHeight: topBar.height*0.75
anchors.verticalCenter: parent.verticalCenter
checked: NotificationS.soundEnabled
checked: NotificationS.notificationPopupEnabled
indicator: Rectangle {
implicitWidth: notificationVolumeSwitch.width
@@ -203,8 +260,8 @@ PanelWindow {
}
onCheckedChanged: {
NotificationS.soundEnabled = notificationVolumeSwitch.checked
console.log("NotificationS.soundEnabled:", NotificationS.soundEnabled)
NotificationS.notificationPopupEnabled = notificationVolumeSwitch.checked
console.log("NotificationS.notificationPopupEnabled:", NotificationS.notificationPopupEnabled)
}
}
@@ -215,6 +272,9 @@ PanelWindow {
anchors.verticalCenter: parent.verticalCenter
hoverEnabled: true
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{
anchors.fill: parent
color: closeArea.containsMouse ? "red" : textBGColor
@@ -292,6 +352,14 @@ PanelWindow {
implicitHeight: isGrouped ? groupedCard.implicitHeight : singleBody.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 ──
NotificationBody {
id: singleBody
@@ -336,6 +404,8 @@ PanelWindow {
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onContainsMouseChanged: if (containsMouse) NotificationS.historyHovered = true
onClicked: root.toggleGroup(group.appName)
}
@@ -387,6 +457,7 @@ PanelWindow {
height: bigFontSize + Config.spacing
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onContainsMouseChanged: if (containsMouse) NotificationS.historyHovered = true
onClicked: function(mouse) {
mouse.accepted = true
root.clearGroup(group.appName)
@@ -15,10 +15,20 @@ Item { // container, invisible
active: false
NotificationHistory {
id: nHistory
// closeNHistory() is defined inside NotificationHistory.qml and
// emits NotificationS.closeHistoryRequested(); the loader listens below
// and actually deactivates. Keeping instance id for potential direct access.
}
}
function closeNHistory() {
nHistoryLoader.closeNHistory()
}
// React to close requests coming from NotificationHistory (hover timer, Escape)
// or any other component via the singleton signal. This is the single
// source of truth for deactivating the history panel.
Connections {
target: NotificationS
function onCloseHistoryRequested() {
console.log("[NotificationHistoryLoader] closeHistoryRequested received -> closing")
nHistoryLoader.closeNHistory()
}
}
@@ -37,11 +47,19 @@ Item { // container, invisible
}
function closeNHistory() {
// Reset hover states so timer doesn't immediately re-trigger on next open
NotificationS.historyHovered = false
// buttonHovered is managed by the button itself; don't force false here
// in case button is still hovered when history closes
notifificationHistoryLoader.active = false
}
function toggleNHistory() {
notifificationHistoryLoader.active = !notifificationHistoryLoader.active
if (notifificationHistoryLoader.active) {
closeNHistory()
} else {
openNHistory()
}
}
Component.onCompleted: {
@@ -12,13 +12,24 @@ Item {
property var focusedMonitor: null
property var newestNotification: null
property bool soundEnabled: true
property bool notificationPopupEnabled: true
property alias trackedNotifications: notificationServer.trackedNotifications
property int notificationNum: trackedNotifications.values.length
signal notificationReceived(var notification)
// ── Hover state for history auto-close ──
// Updated by NotificationHistory.qml (PanelWindow hover) and NotificationButton.qml (bar button hover)
property bool historyHovered: false
property bool buttonHovered: false
property int historyAutoCloseDelay: 1000
signal closeHistoryRequested()
// Debug logging for hover transitions
onHistoryHoveredChanged: Config.debug == "Notification" && console.log("[NotificationServer] historyHovered:", historyHovered)
onButtonHoveredChanged: Config.debug == "Notification" && console.log("[NotificationServer] buttonHovered:", buttonHovered)
function correctMonitor(screen) {
return (Hyprland.monitorFor(screen) === focusedMonitor)
}
@@ -83,7 +94,7 @@ Item {
repeat: false
onTriggered: {
if((!notification.lastGeneration && notificationServerState.soundEnabled) || Config.debug == "Notification"){
if((!notification.lastGeneration && notificationServerState.notificationPopupEnabled) || Config.debug == "Notification"){
focusedMonitor = Hyprland.focusedMonitor
notificationReceived(notification)
notificationSound.play()