diff --git a/modules/bar/widgets/NotificationButton.qml b/modules/bar/widgets/NotificationButton.qml index 9326049..ea99716 100644 --- a/modules/bar/widgets/NotificationButton.qml +++ b/modules/bar/widgets/NotificationButton.qml @@ -13,7 +13,29 @@ MouseArea { cursorShape: Qt.PointingHandCursor onClicked: { - NotificationS.soundEnabled = !NotificationS.soundEnabled + // NotificationS.soundEnabled = !NotificationS.soundEnabled + console.log("[NotificationButton] Opening NotificationHistory") + root.toggleNotificationHistory() + } + + + Item { + anchors.top: parent.topBar + anchors.right: parent.right + anchors.topMargin: Config.spacing + anchors.rightMargin: Config.spacing + width: Config.screen_height_to_font_tiny(screen.height) + height: Config.screen_height_to_font_tiny(screen.height) + + visible: NotificationS.notificationNum > 0 + + Text{ + anchors.centerIn: parent + text: NotificationS.notificationNum + font.family: Config.font + font.pixelSize: Config.screen_height_to_font_tiny(screen.height) + color: Colors.secondaryContainer_fg + } } Rectangle { diff --git a/modules/notification/Notification.qml b/modules/notification/Notification.qml index 8a9c631..42ad251 100644 --- a/modules/notification/Notification.qml +++ b/modules/notification/Notification.qml @@ -58,6 +58,7 @@ PanelWindow { delegate: NotificationBody { required property int index required property var notificationData + implicitWidth: screen.width/7 screen: notificationWindow.screen notification: notificationData diff --git a/modules/notification/NotificationBody.qml b/modules/notification/NotificationBody.qml index 18bf616..07ec5f6 100644 --- a/modules/notification/NotificationBody.qml +++ b/modules/notification/NotificationBody.qml @@ -7,16 +7,16 @@ import QtQuick.Controls Rectangle { id: root - //TODO: urgency, expireTimeoutText, ... - required property var notification required property var screen property var urgency: (notification.urgency ?? notification.hints["urgency"]) != null ? (notification.urgency ?? notification.hints["urgency"]) + 1 : 0 property bool closing: false property int _hoveredActionCount: 0 + // When used in history overview we don't want auto-timeout or click-to-close + property bool isHistory: false - property real duration: ( + property real duration: isHistory ? 0 : ( notification.expireTimeout > 0 ? notification.expireTimeout*1000 : urgency ? urgency * 2000 : 5000 @@ -31,9 +31,11 @@ Rectangle { color: textBGColor border.width: Config.border_width border.color: textColor + radius: isHistory ? Config.small_radius : 0 + clip: isHistory - property string textColor: urgency != 3 ? Colors.primary : Colors.tertiary - property string textBGColor: urgency != 3 ? Qt.alpha(Colors.primaryContainer, 0.75) : Qt.alpha(Colors.tertiaryContainer, 0.75) + 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) function closeNotification(dismiss){ if (closing) { @@ -55,6 +57,8 @@ Rectangle { id: mouseArea anchors.fill: parent hoverEnabled: true + enabled: !root.isHistory + visible: !root.isHistory onClicked: { root.closeNotification(false) } @@ -389,7 +393,7 @@ Rectangle { running: root.duration > 0 from: 1.0 to: 0.0 - duration: root.duration + duration: root.duration paused: mouseArea.containsMouse || closingMouseArea.containsMouse || inlineReplyButtonMouseArea.containsMouse || root._hoveredActionCount > 0 || inlineReplyTextField.hovered || inlineReplyTextField.activeFocus onFinished: root.closeNotification(false) @@ -427,7 +431,7 @@ Rectangle { console.log("\x1b[31m\t"+"notification.transient: " + notification.transient+"\x1b[0m") console.log("\x1b[31m\t"+"notification.hasInlineReply: " + notification.hasInlineReply+"\x1b[0m") console.log("\x1b[31m\t"+"notification.hasActionIcons: " + notification.hasActionIcons+"\x1b[0m") - + console.log("\x1b[31m\t"+"image.source: " + iconImage.source+"\x1b[0m") console.log("\x1b[31m\t"+"urgency: " + urgency+"\x1b[0m") console.log("\x1b[31m\t"+"duration: " + duration+"\x1b[0m") diff --git a/modules/notification/NotificationHistory.qml b/modules/notification/NotificationHistory.qml new file mode 100644 index 0000000..3ea82e8 --- /dev/null +++ b/modules/notification/NotificationHistory.qml @@ -0,0 +1,276 @@ +import QtQuick +import Quickshell +import QtQuick.Controls +import Quickshell.Wayland +import Quickshell.Hyprland +import Quickshell.Services.Notifications +import "../../config" +import "./notificationServer" + +PanelWindow { + id: root + implicitWidth: screen.width/5 + implicitHeight: screen.height - Config.barHeight(screen.height)*2 + color: "transparent" + visible: true + focusable: true + + anchors { + top: true + right: true + } + + property string textColor: Colors.primary + property string textBGColor: Qt.alpha(Colors.primaryContainer, 0.75) + property string bGColor: Qt.alpha(Colors.primaryContainer, 0.5) + + property real bigFontSize: Config.screen_height_to_font_medium(screen.height) + property real fontSize: Config.screen_height_to_font_small(screen.height) + + property var expandedGroups: ({}) + + property var grouped: { + const vals = NotificationS.trackedNotifications.values + const len = vals.length + if (len < 0) return [] + let map = {} + for (let i = 0; i < vals.length; ++i) { + const n = vals[i] + const key = (n && n.appName && n.appName !== "") ? n.appName : "Unknown" + if (!map[key]) map[key] = [] + map[key].push(n) + } + let result = [] + for (const k in map) result.push({ appName: k, notes: map[k] }) + result.sort((a,b)=>a.appName.localeCompare(b.appName)) + return result + } + + function toggleGroup(appName) { + let copy = Object.assign({}, expandedGroups) + copy[appName] = !(copy[appName] === true) + expandedGroups = copy + } + function clearGroup(appName) { + const vals = NotificationS.trackedNotifications.values.slice() + for (let i=0;i