mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
notifications: try to prevent zombies better, markdown, re-org
This commit is contained in:
@@ -44,6 +44,7 @@ Singleton {
|
||||
property bool wallpaperDynamicTheming: true
|
||||
property string wallpaperLastPath: ""
|
||||
property string profileLastPath: ""
|
||||
property bool doNotDisturb: false
|
||||
|
||||
function loadSettings() {
|
||||
parseSettings(settingsFile.text());
|
||||
@@ -85,6 +86,7 @@ Singleton {
|
||||
wallpaperDynamicTheming = settings.wallpaperDynamicTheming !== undefined ? settings.wallpaperDynamicTheming : true;
|
||||
wallpaperLastPath = settings.wallpaperLastPath !== undefined ? settings.wallpaperLastPath : "";
|
||||
profileLastPath = settings.profileLastPath !== undefined ? settings.profileLastPath : "";
|
||||
doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false;
|
||||
applyStoredTheme();
|
||||
detectAvailableIconThemes();
|
||||
updateGtkIconTheme(iconTheme);
|
||||
@@ -130,7 +132,8 @@ Singleton {
|
||||
"wallpaperPath": wallpaperPath,
|
||||
"wallpaperDynamicTheming": wallpaperDynamicTheming,
|
||||
"wallpaperLastPath": wallpaperLastPath,
|
||||
"profileLastPath": profileLastPath
|
||||
"profileLastPath": profileLastPath,
|
||||
"doNotDisturb": doNotDisturb
|
||||
}, null, 2));
|
||||
}
|
||||
|
||||
@@ -481,6 +484,11 @@ gtk-application-prefer-dark-theme=true`;
|
||||
}
|
||||
}
|
||||
|
||||
function setDoNotDisturb(enabled) {
|
||||
doNotDisturb = enabled;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
Component.onCompleted: loadSettings()
|
||||
|
||||
|
||||
|
||||
57
Common/markdown2html.js
Normal file
57
Common/markdown2html.js
Normal file
@@ -0,0 +1,57 @@
|
||||
// This exists only beacause I haven't been able to get linkColor to work with MarkdownText
|
||||
// May not be necessary if that's possible tbh.
|
||||
function markdownToHtml(text) {
|
||||
if (!text) return "";
|
||||
|
||||
let html = text;
|
||||
|
||||
// Escape HTML entities first
|
||||
html = html.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
|
||||
// Headers
|
||||
html = html.replace(/^### (.*?)$/gm, '<h3>$1</h3>');
|
||||
html = html.replace(/^## (.*?)$/gm, '<h2>$1</h2>');
|
||||
html = html.replace(/^# (.*?)$/gm, '<h1>$1</h1>');
|
||||
|
||||
// Bold and italic
|
||||
html = html.replace(/\*\*\*(.*?)\*\*\*/g, '<b><i>$1</i></b>');
|
||||
html = html.replace(/\*\*(.*?)\*\*/g, '<b>$1</b>');
|
||||
html = html.replace(/\*(.*?)\*/g, '<i>$1</i>');
|
||||
html = html.replace(/___(.*?)___/g, '<b><i>$1</i></b>');
|
||||
html = html.replace(/__(.*?)__/g, '<b>$1</b>');
|
||||
html = html.replace(/_(.*?)_/g, '<i>$1</i>');
|
||||
|
||||
// Code blocks
|
||||
html = html.replace(/```([\s\S]*?)```/g, '<pre><code>$1</code></pre>');
|
||||
html = html.replace(/`(.*?)`/g, '<code>$1</code>');
|
||||
|
||||
// Links
|
||||
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>');
|
||||
|
||||
// Lists
|
||||
html = html.replace(/^\* (.*?)$/gm, '<li>$1</li>');
|
||||
html = html.replace(/^- (.*?)$/gm, '<li>$1</li>');
|
||||
html = html.replace(/^\d+\. (.*?)$/gm, '<li>$1</li>');
|
||||
|
||||
// Wrap consecutive list items in ul/ol tags
|
||||
html = html.replace(/(<li>[\s\S]*?<\/li>\s*)+/g, function(match) {
|
||||
return '<ul>' + match + '</ul>';
|
||||
});
|
||||
|
||||
// Detect plain URLs and wrap them in anchor tags (but not inside existing <a> or markdown links)
|
||||
html = html.replace(/(^|[^"'>])((https?|file):\/\/[^\s<]+)/g, '$1<a href="$2">$2</a>');
|
||||
|
||||
|
||||
// Line breaks
|
||||
html = html.replace(/\n\n/g, '</p><p>');
|
||||
html = html.replace(/\n/g, '<br/>');
|
||||
|
||||
// Wrap in paragraph tags if not already wrapped
|
||||
if (!html.startsWith('<')) {
|
||||
html = '<p>' + html + '</p>';
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
@@ -260,8 +260,8 @@ PanelWindow {
|
||||
function onIsVisibleChanged() {
|
||||
if (appDrawerPopout.isVisible)
|
||||
Qt.callLater(function() {
|
||||
searchField.forceActiveFocus();
|
||||
});
|
||||
searchField.forceActiveFocus();
|
||||
});
|
||||
else
|
||||
searchField.clearFocus();
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ Item {
|
||||
property var appUsageRanking: Prefs.appUsageRanking
|
||||
// Internal model
|
||||
property alias model: filteredModel
|
||||
// Watch AppSearchService.applications changes via property binding
|
||||
property var _watchApplications: AppSearchService.applications
|
||||
|
||||
// Signals
|
||||
signal appLaunched(var app)
|
||||
@@ -81,21 +83,21 @@ Item {
|
||||
var aUsage = appUsageRanking[aId] ? appUsageRanking[aId].usageCount : 0;
|
||||
var bUsage = appUsageRanking[bId] ? appUsageRanking[bId].usageCount : 0;
|
||||
if (aUsage !== bUsage)
|
||||
return bUsage - aUsage; // Higher usage first
|
||||
|
||||
return bUsage - aUsage;
|
||||
// Higher usage first
|
||||
return (a.name || "").localeCompare(b.name || ""); // Alphabetical fallback
|
||||
});
|
||||
// Convert to model format and populate
|
||||
apps.forEach((app) => {
|
||||
if (app)
|
||||
filteredModel.append({
|
||||
"name": app.name || "",
|
||||
"exec": app.execString || "",
|
||||
"icon": app.icon || "application-x-executable",
|
||||
"comment": app.comment || "",
|
||||
"categories": app.categories || [],
|
||||
"desktopEntry": app
|
||||
});
|
||||
"name": app.name || "",
|
||||
"exec": app.execString || "",
|
||||
"icon": app.icon || "application-x-executable",
|
||||
"comment": app.comment || "",
|
||||
"categories": app.categories || [],
|
||||
"desktopEntry": app
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
@@ -178,11 +180,7 @@ Item {
|
||||
}
|
||||
onSelectedCategoryChanged: updateFilteredModel()
|
||||
onAppUsageRankingChanged: updateFilteredModel()
|
||||
|
||||
// Watch AppSearchService.applications changes via property binding
|
||||
property var _watchApplications: AppSearchService.applications
|
||||
on_WatchApplicationsChanged: updateFilteredModel()
|
||||
|
||||
// Initialize
|
||||
Component.onCompleted: {
|
||||
updateFilteredModel();
|
||||
|
||||
@@ -179,7 +179,7 @@ Column {
|
||||
height: parent.height / 6
|
||||
color: "transparent"
|
||||
clip: true
|
||||
|
||||
|
||||
Rectangle {
|
||||
anchors.centerIn: parent
|
||||
width: parent.width - 4
|
||||
@@ -203,13 +203,22 @@ Column {
|
||||
anchors.fill: parent
|
||||
radius: parent.radius
|
||||
visible: CalendarService && CalendarService.khalAvailable && CalendarService.hasEventsForDate(dayDate)
|
||||
|
||||
opacity: {
|
||||
if (isSelected)
|
||||
return 0.9;
|
||||
else if (isToday)
|
||||
return 0.8;
|
||||
else
|
||||
return 0.6;
|
||||
}
|
||||
|
||||
gradient: Gradient {
|
||||
GradientStop {
|
||||
GradientStop {
|
||||
position: 0.89
|
||||
color: "transparent"
|
||||
color: "transparent"
|
||||
}
|
||||
GradientStop {
|
||||
|
||||
GradientStop {
|
||||
position: 0.9
|
||||
color: {
|
||||
if (isSelected)
|
||||
@@ -220,8 +229,9 @@ Column {
|
||||
return Theme.primary;
|
||||
}
|
||||
}
|
||||
GradientStop {
|
||||
position: 1.0
|
||||
|
||||
GradientStop {
|
||||
position: 1
|
||||
color: {
|
||||
if (isSelected)
|
||||
return Qt.lighter(Theme.primary, 1.3);
|
||||
@@ -231,15 +241,7 @@ Column {
|
||||
return Theme.primary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
opacity: {
|
||||
if (isSelected)
|
||||
return 0.9;
|
||||
else if (isToday)
|
||||
return 0.8;
|
||||
else
|
||||
return 0.6;
|
||||
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
@@ -247,9 +249,11 @@ Column {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
|
||||
@@ -98,11 +98,12 @@ PanelWindow {
|
||||
y: Theme.barHeight + 4
|
||||
// Only resize after animation is complete
|
||||
onOpacityChanged: {
|
||||
// Animation finished, now we can safely resize
|
||||
|
||||
if (opacity === 1)
|
||||
// Animation finished, now we can safely resize
|
||||
Qt.callLater(() => {
|
||||
height = calculateHeight();
|
||||
});
|
||||
height = calculateHeight();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -196,6 +197,7 @@ PanelWindow {
|
||||
width: parent.width
|
||||
height: 140
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Right section for calendar - enhanced container
|
||||
@@ -209,17 +211,22 @@ PanelWindow {
|
||||
|
||||
CalendarGrid {
|
||||
id: calendarGrid
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingS
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Events {
|
||||
id: events
|
||||
|
||||
width: parent.width
|
||||
selectedDate: calendarGrid.selectedDate
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
|
||||
@@ -11,7 +11,7 @@ Rectangle {
|
||||
|
||||
property var notificationGroup
|
||||
property bool expanded: NotificationService.expandedGroups[notificationGroup?.key] || false
|
||||
property bool descriptionExpanded: false
|
||||
property bool descriptionExpanded: NotificationService.expandedMessages[notificationGroup?.latestNotification?.notification?.id + "_desc"] || false
|
||||
property bool userInitiatedExpansion: false
|
||||
|
||||
width: parent ? parent.width : 400
|
||||
@@ -75,7 +75,8 @@ Rectangle {
|
||||
border.color: "transparent"
|
||||
border.width: 0
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 18
|
||||
|
||||
IconImage {
|
||||
anchors.fill: parent
|
||||
@@ -178,7 +179,7 @@ Rectangle {
|
||||
|
||||
Text {
|
||||
id: descriptionText
|
||||
property string fullText: notificationGroup?.latestNotification?.body || ""
|
||||
property string fullText: notificationGroup?.latestNotification?.htmlBody || ""
|
||||
property bool hasMoreText: truncated
|
||||
|
||||
text: fullText
|
||||
@@ -189,16 +190,33 @@ Rectangle {
|
||||
maximumLineCount: descriptionExpanded ? -1 : 2
|
||||
wrapMode: Text.WordWrap
|
||||
visible: text.length > 0
|
||||
textFormat: Text.PlainText
|
||||
linkColor: Theme.primary
|
||||
onLinkActivated: Qt.openUrlExternally(link)
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: (parent.hasMoreText || descriptionExpanded) ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
enabled: parent.hasMoreText || descriptionExpanded
|
||||
onClicked: {
|
||||
descriptionExpanded = !descriptionExpanded;
|
||||
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor :
|
||||
(parent.hasMoreText || descriptionExpanded) ? Qt.PointingHandCursor :
|
||||
Qt.ArrowCursor
|
||||
|
||||
onClicked: mouse => {
|
||||
if (!parent.hoveredLink && (parent.hasMoreText || descriptionExpanded)) {
|
||||
const messageId = notificationGroup?.latestNotification?.notification?.id + "_desc";
|
||||
NotificationService.toggleMessageExpansion(messageId);
|
||||
}
|
||||
}
|
||||
|
||||
propagateComposedEvents: true
|
||||
onPressed: mouse => {
|
||||
if (parent.hoveredLink) {
|
||||
mouse.accepted = false;
|
||||
}
|
||||
}
|
||||
onReleased: mouse => {
|
||||
if (parent.hoveredLink) {
|
||||
mouse.accepted = false;
|
||||
}
|
||||
}
|
||||
z: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -305,7 +323,8 @@ Rectangle {
|
||||
height: 32
|
||||
radius: 16
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 32
|
||||
color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1)
|
||||
border.color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.2)
|
||||
border.width: 1
|
||||
@@ -384,7 +403,7 @@ Rectangle {
|
||||
id: bodyText
|
||||
property bool hasMoreText: truncated
|
||||
|
||||
text: modelData?.body || ""
|
||||
text: modelData?.htmlBody || ""
|
||||
color: Theme.surfaceVariantText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
width: parent.width
|
||||
@@ -392,17 +411,31 @@ Rectangle {
|
||||
maximumLineCount: messageExpanded ? -1 : 2
|
||||
wrapMode: Text.WordWrap
|
||||
visible: text.length > 0
|
||||
textFormat: Text.PlainText
|
||||
|
||||
linkColor: Theme.primary
|
||||
onLinkActivated: Qt.openUrlExternally(link)
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
enabled: bodyText.hasMoreText || messageExpanded
|
||||
cursorShape: bodyText.hasMoreText || messageExpanded ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
onClicked: {
|
||||
if (bodyText.hasMoreText || messageExpanded) {
|
||||
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor :
|
||||
(bodyText.hasMoreText || messageExpanded) ? Qt.PointingHandCursor :
|
||||
Qt.ArrowCursor
|
||||
|
||||
onClicked: mouse => {
|
||||
if (!parent.hoveredLink && (bodyText.hasMoreText || messageExpanded)) {
|
||||
NotificationService.toggleMessageExpansion(modelData?.notification?.id || "");
|
||||
}
|
||||
}
|
||||
|
||||
propagateComposedEvents: true
|
||||
onPressed: mouse => {
|
||||
if (parent.hoveredLink) {
|
||||
mouse.accepted = false;
|
||||
}
|
||||
}
|
||||
onReleased: mouse => {
|
||||
if (parent.hoveredLink) {
|
||||
mouse.accepted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,16 +10,30 @@ Item {
|
||||
width: parent.width
|
||||
height: 32
|
||||
|
||||
Text {
|
||||
text: "Notifications"
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
color: Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
Text {
|
||||
text: "Notifications"
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
color: Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
DankActionButton {
|
||||
iconName: Prefs.doNotDisturb ? "notifications_off" : "notifications"
|
||||
iconColor: Prefs.doNotDisturb ? Theme.error : Theme.surfaceText
|
||||
buttonSize: 28
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: Prefs.setDoNotDisturb(!Prefs.doNotDisturb)
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: clearAllButton
|
||||
width: 120
|
||||
height: 28
|
||||
radius: Theme.cornerRadiusLarge
|
||||
@@ -1,139 +0,0 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
|
||||
QtObject {
|
||||
id: manager
|
||||
property int topMargin: 0
|
||||
property int baseNotificationHeight: 120
|
||||
property int maxTargetNotifications: 3
|
||||
property var popupWindows: [] // strong refs to windows (live until exitFinished)
|
||||
|
||||
// Factory
|
||||
property Component popupComponent: Component {
|
||||
NotificationPopup {
|
||||
onEntered: manager._onPopupEntered(this)
|
||||
onExitFinished: manager._onPopupExitFinished(this)
|
||||
}
|
||||
}
|
||||
|
||||
property Connections notificationConnections: Connections {
|
||||
target: NotificationService
|
||||
function onVisibleNotificationsChanged() {
|
||||
manager._sync(NotificationService.visibleNotifications);
|
||||
}
|
||||
}
|
||||
|
||||
function _hasWindowFor(w) {
|
||||
return popupWindows.some(p => p && p.notificationData === w);
|
||||
}
|
||||
|
||||
function _sync(newWrappers) {
|
||||
for (let w of newWrappers) {
|
||||
if (!_hasWindowFor(w)) insertNewestAtTop(w);
|
||||
}
|
||||
for (let p of popupWindows.slice()) {
|
||||
if (p && p.notificationData && newWrappers.indexOf(p.notificationData) === -1 && !p.exiting) {
|
||||
p.notificationData.removedByLimit = true;
|
||||
p.notificationData.popup = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Insert newest at top
|
||||
function insertNewestAtTop(wrapper) {
|
||||
// Shift live, non-exiting windows down *now*
|
||||
for (let p of popupWindows) {
|
||||
if (!p) continue;
|
||||
if (p.exiting) continue;
|
||||
// Guard: skip if p is already being destroyed
|
||||
if (p.status === Component.Null) continue;
|
||||
p.screenY = p.screenY + baseNotificationHeight;
|
||||
}
|
||||
|
||||
// Create the new top window at fixed Y
|
||||
const notificationId = wrapper && wrapper.notification ? wrapper.notification.id : "";
|
||||
const win = popupComponent.createObject(null, { notificationData: wrapper, notificationId: notificationId, screenY: topMargin });
|
||||
if (!win) {
|
||||
console.warn("Popup create failed");
|
||||
return;
|
||||
}
|
||||
popupWindows.push(win);
|
||||
|
||||
_maybeStartOverflow();
|
||||
}
|
||||
|
||||
|
||||
// Overflow: keep one extra (slot #4), then ask bottom to exit gracefully
|
||||
function _active() {
|
||||
return popupWindows.filter(p => p && p.notificationData && p.notificationData.popup);
|
||||
}
|
||||
|
||||
function _bottom() {
|
||||
let b = null, maxY = -1;
|
||||
for (let p of _active()) {
|
||||
if (p.exiting) continue;
|
||||
if (p.screenY > maxY) {
|
||||
maxY = p.screenY;
|
||||
b = p;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
function _maybeStartOverflow() {
|
||||
if (_active().length <= maxTargetNotifications + 1) return;
|
||||
const b = _bottom();
|
||||
if (b && !b.exiting) {
|
||||
// Tell the popup to animate out (don't destroy here)
|
||||
b.notificationData.removedByLimit = true;
|
||||
b.notificationData.popup = false;
|
||||
}
|
||||
}
|
||||
|
||||
// After entrance, you may kick overflow (optional)
|
||||
function _onPopupEntered(p) {
|
||||
_maybeStartOverflow();
|
||||
}
|
||||
|
||||
// Primary cleanup path (after the popup finishes its exit)
|
||||
function _onPopupExitFinished(p) {
|
||||
const i = popupWindows.indexOf(p);
|
||||
if (i !== -1) {
|
||||
popupWindows.splice(i,1);
|
||||
popupWindows = popupWindows.slice();
|
||||
}
|
||||
if (NotificationService.releaseWrapper)
|
||||
NotificationService.releaseWrapper(p.notificationData);
|
||||
// Finally destroy the window object
|
||||
p.destroy();
|
||||
|
||||
// Compact survivors (only live, non-exiting)
|
||||
const survivors = _active().filter(s => !s.exiting)
|
||||
.sort((a,b) => a.screenY - b.screenY);
|
||||
for (let k = 0; k < survivors.length; ++k)
|
||||
survivors[k].screenY = topMargin + k * baseNotificationHeight;
|
||||
|
||||
_maybeStartOverflow();
|
||||
}
|
||||
|
||||
// Optional sweeper (dev only): catch any stranded windows every 2s
|
||||
property Timer sweeper: Timer {
|
||||
interval: 2000
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
for (let p of popupWindows.slice()) {
|
||||
if (!p) continue;
|
||||
if (!p.visible && !p.notificationData) {
|
||||
const i = popupWindows.indexOf(p);
|
||||
if (i !== -1) {
|
||||
popupWindows.splice(i,1);
|
||||
popupWindows = popupWindows.slice();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,9 @@ PanelWindow {
|
||||
required property var notificationData
|
||||
required property string notificationId
|
||||
|
||||
visible: true
|
||||
readonly property bool hasValidData: notificationData && notificationData.notification
|
||||
|
||||
visible: hasValidData
|
||||
WlrLayershell.layer: WlrLayershell.Overlay
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
||||
@@ -31,14 +33,11 @@ PanelWindow {
|
||||
right: 12
|
||||
}
|
||||
|
||||
// Manager drives vertical stacking with this proxy:
|
||||
property int screenY: 0
|
||||
onScreenYChanged: margins.top = Theme.barHeight + 4 + screenY
|
||||
|
||||
// Disable vertical tween while exiting so there is never diagonal motion
|
||||
Behavior on screenY {
|
||||
id: screenYAnim
|
||||
enabled: !exiting
|
||||
enabled: !exiting && !_isDestroying
|
||||
NumberAnimation {
|
||||
duration: Anims.durShort
|
||||
easing.type: Easing.BezierSpline
|
||||
@@ -46,19 +45,25 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
|
||||
// State
|
||||
property bool exiting: false
|
||||
property bool _isDestroying: false
|
||||
property bool _finalized: false
|
||||
signal entered()
|
||||
signal exitFinished()
|
||||
onHasValidDataChanged: {
|
||||
if (!hasValidData && !exiting && !_isDestroying) {
|
||||
console.warn("NotificationPopup: Data became invalid, forcing exit");
|
||||
forceExit();
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: content
|
||||
anchors.fill: parent
|
||||
visible: win.hasValidData
|
||||
|
||||
// We animate a Translate so anchors never override horizontal motion
|
||||
transform: Translate { id: tx; x: Anims.slidePx } // start off-screen right
|
||||
transform: Translate { id: tx; x: Anims.slidePx }
|
||||
|
||||
// Optional: layer while animating for smoothness
|
||||
layer.enabled: (enterX.running || exitAnim.running)
|
||||
layer.smooth: true
|
||||
|
||||
@@ -144,7 +149,6 @@ PanelWindow {
|
||||
Rectangle {
|
||||
id: iconContainer
|
||||
readonly property bool hasNotificationImage: notificationData && notificationData.image && notificationData.image !== ""
|
||||
property alias iconImage: iconImage
|
||||
|
||||
width: 55
|
||||
height: 55
|
||||
@@ -242,7 +246,7 @@ PanelWindow {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: notificationData ? (notificationData.body || "") : ""
|
||||
text: notificationData ? (notificationData.htmlBody || "") : ""
|
||||
color: Theme.surfaceVariantText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
width: parent.width
|
||||
@@ -250,7 +254,13 @@ PanelWindow {
|
||||
maximumLineCount: 2
|
||||
wrapMode: Text.WordWrap
|
||||
visible: text.length > 0
|
||||
textFormat: Text.PlainText
|
||||
linkColor: Theme.primary
|
||||
onLinkActivated: Qt.openUrlExternally(link)
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.NoButton
|
||||
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,7 +280,7 @@ PanelWindow {
|
||||
buttonSize: 28
|
||||
z: 15
|
||||
onClicked: {
|
||||
if (notificationData)
|
||||
if (notificationData && !win.exiting)
|
||||
notificationData.popup = false;
|
||||
}
|
||||
}
|
||||
@@ -315,7 +325,7 @@ PanelWindow {
|
||||
if (modelData && modelData.invoke) {
|
||||
modelData.invoke();
|
||||
}
|
||||
if (notificationData) {
|
||||
if (notificationData && !win.exiting) {
|
||||
notificationData.popup = false;
|
||||
}
|
||||
}
|
||||
@@ -355,7 +365,7 @@ PanelWindow {
|
||||
onEntered: dismissButton.isHovered = true
|
||||
onExited: dismissButton.isHovered = false
|
||||
onClicked: {
|
||||
if (notificationData) {
|
||||
if (notificationData && !win.exiting) {
|
||||
NotificationService.dismissNotification(notificationData);
|
||||
}
|
||||
}
|
||||
@@ -378,24 +388,22 @@ PanelWindow {
|
||||
notificationData.timer.restart();
|
||||
}
|
||||
onClicked: {
|
||||
if (notificationData)
|
||||
if (notificationData && !win.exiting)
|
||||
notificationData.popup = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Entrance: slide in from right using slowed Anims curves
|
||||
NumberAnimation {
|
||||
id: enterX
|
||||
target: tx; property: "x"; from: Anims.slidePx; to: 0
|
||||
duration: Anims.durMed
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Anims.emphasizedDecel
|
||||
onStopped: if (!win.exiting && Math.abs(tx.x) < 0.5) win.entered();
|
||||
onStopped: if (!win.exiting && !win._isDestroying && Math.abs(tx.x) < 0.5) win.entered();
|
||||
}
|
||||
|
||||
// Exit: slide out to right + fade using slowed Anims curves
|
||||
ParallelAnimation {
|
||||
id: exitAnim
|
||||
PropertyAnimation {
|
||||
@@ -419,52 +427,94 @@ PanelWindow {
|
||||
onStopped: finalizeExit("animStopped")
|
||||
}
|
||||
|
||||
// Start entrance one tick after create (so it always animates)
|
||||
Component.onCompleted: Qt.callLater(() => enterX.restart())
|
||||
Component.onCompleted: {
|
||||
if (hasValidData) {
|
||||
Qt.callLater(() => enterX.restart())
|
||||
} else {
|
||||
console.warn("NotificationPopup created with invalid data");
|
||||
forceExit();
|
||||
}
|
||||
}
|
||||
|
||||
// Safe connection to wrapper: disable automatically when wrapper is null
|
||||
Connections {
|
||||
id: wrapperConn
|
||||
target: win.notificationData || null
|
||||
ignoreUnknownSignals: true
|
||||
enabled: !win._isDestroying
|
||||
|
||||
function onPopupChanged() {
|
||||
if (!win.notificationData) return; // guard
|
||||
if (!win.notificationData || win._isDestroying) return;
|
||||
if (!win.notificationData.popup && !win.exiting) {
|
||||
// Freeze vertical and start exit
|
||||
win.exiting = true; // disables screenY Behavior
|
||||
exitAnim.restart();
|
||||
exitWatchdog.restart(); // safety net
|
||||
if (NotificationService.removeFromVisibleNotifications)
|
||||
NotificationService.removeFromVisibleNotifications(win.notificationData);
|
||||
startExit();
|
||||
}
|
||||
}
|
||||
}
|
||||
onNotificationDataChanged: wrapperConn.target = win.notificationData || null
|
||||
onNotificationDataChanged: {
|
||||
if (!_isDestroying) {
|
||||
wrapperConn.target = win.notificationData || null;
|
||||
}
|
||||
}
|
||||
|
||||
// Timer to start on entrance
|
||||
Timer {
|
||||
id: enterDelay
|
||||
interval: 160
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
if (notificationData && notificationData.timer)
|
||||
if (notificationData && notificationData.timer && !exiting && !_isDestroying)
|
||||
notificationData.timer.start();
|
||||
}
|
||||
}
|
||||
|
||||
// Start timer after entrance animation
|
||||
onEntered: enterDelay.start()
|
||||
onEntered: {
|
||||
if (!_isDestroying) enterDelay.start();
|
||||
}
|
||||
|
||||
function startExit() {
|
||||
if (exiting || _isDestroying) return;
|
||||
|
||||
exiting = true;
|
||||
exitAnim.restart();
|
||||
exitWatchdog.restart();
|
||||
|
||||
if (NotificationService.removeFromVisibleNotifications) {
|
||||
NotificationService.removeFromVisibleNotifications(win.notificationData);
|
||||
}
|
||||
}
|
||||
|
||||
function forceExit() {
|
||||
if (_isDestroying) return;
|
||||
|
||||
_isDestroying = true;
|
||||
exiting = true;
|
||||
visible = false;
|
||||
exitWatchdog.stop();
|
||||
finalizeExit("forced");
|
||||
}
|
||||
|
||||
// Idempotent finalizer so we never "half-exit"
|
||||
property bool _finalized: false
|
||||
function finalizeExit(reason) {
|
||||
if (_finalized) return;
|
||||
_finalized = true;
|
||||
_isDestroying = true;
|
||||
exitWatchdog.stop();
|
||||
win.exitFinished(); // manager will destroy the window
|
||||
|
||||
wrapperConn.enabled = false;
|
||||
wrapperConn.target = null;
|
||||
|
||||
win.exitFinished();
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: exitWatchdog
|
||||
interval: 600
|
||||
repeat: false
|
||||
onTriggered: finalizeExit("watchdog")
|
||||
}
|
||||
Timer { id: exitWatchdog; interval: 600; repeat: false; onTriggered: finalizeExit("watchdog") }
|
||||
|
||||
// If the popup is torn down unexpectedly, don't leave dangling timers
|
||||
Component.onDestruction: { exitWatchdog.stop(); }
|
||||
Component.onDestruction: {
|
||||
_isDestroying = true;
|
||||
exitWatchdog.stop();
|
||||
if (notificationData && notificationData.timer) {
|
||||
notificationData.timer.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
288
Modules/Notifications/Popup/NotificationPopupManager.qml
Normal file
288
Modules/Notifications/Popup/NotificationPopupManager.qml
Normal file
@@ -0,0 +1,288 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
|
||||
QtObject {
|
||||
id: manager
|
||||
property int topMargin: 0
|
||||
property int baseNotificationHeight: 120
|
||||
property int maxTargetNotifications: 3
|
||||
property var popupWindows: [] // strong refs to windows (live until exitFinished)
|
||||
|
||||
// Track destroying windows to prevent duplicate cleanup
|
||||
property var destroyingWindows: new Set()
|
||||
|
||||
// Factory
|
||||
property Component popupComponent: Component {
|
||||
NotificationPopup {
|
||||
onEntered: manager._onPopupEntered(this)
|
||||
onExitFinished: manager._onPopupExitFinished(this)
|
||||
}
|
||||
}
|
||||
|
||||
property Connections notificationConnections: Connections {
|
||||
target: NotificationService
|
||||
function onVisibleNotificationsChanged() {
|
||||
manager._sync(NotificationService.visibleNotifications);
|
||||
}
|
||||
}
|
||||
|
||||
function _hasWindowFor(w) {
|
||||
return popupWindows.some(p => {
|
||||
// More robust check for valid windows
|
||||
return p &&
|
||||
p.notificationData === w &&
|
||||
!p._isDestroying &&
|
||||
p.status !== Component.Null;
|
||||
});
|
||||
}
|
||||
|
||||
function _isValidWindow(p) {
|
||||
return p &&
|
||||
p.status !== Component.Null &&
|
||||
!p._isDestroying &&
|
||||
p.hasValidData;
|
||||
}
|
||||
|
||||
function _sync(newWrappers) {
|
||||
// Add new notifications
|
||||
for (let w of newWrappers) {
|
||||
if (!_hasWindowFor(w)) {
|
||||
insertNewestAtTop(w);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove old notifications
|
||||
for (let p of popupWindows.slice()) {
|
||||
if (!_isValidWindow(p)) continue;
|
||||
|
||||
if (p.notificationData && newWrappers.indexOf(p.notificationData) === -1 && !p.exiting) {
|
||||
p.notificationData.removedByLimit = true;
|
||||
p.notificationData.popup = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Insert newest at top
|
||||
function insertNewestAtTop(wrapper) {
|
||||
if (!wrapper) {
|
||||
console.warn("insertNewestAtTop: wrapper is null");
|
||||
return;
|
||||
}
|
||||
|
||||
// Shift live, non-exiting windows down *now*
|
||||
for (let p of popupWindows) {
|
||||
if (!_isValidWindow(p)) continue;
|
||||
if (p.exiting) continue;
|
||||
|
||||
p.screenY = p.screenY + baseNotificationHeight;
|
||||
}
|
||||
|
||||
// Create the new top window at fixed Y
|
||||
const notificationId = wrapper && wrapper.notification ? wrapper.notification.id : "";
|
||||
const win = popupComponent.createObject(null, {
|
||||
notificationData: wrapper,
|
||||
notificationId: notificationId,
|
||||
screenY: topMargin
|
||||
});
|
||||
|
||||
if (!win) {
|
||||
console.warn("Popup create failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate the window was created properly
|
||||
if (!win.hasValidData) {
|
||||
console.warn("Popup created with invalid data, destroying");
|
||||
win.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
popupWindows.push(win);
|
||||
|
||||
// Start sweeper if it's not running
|
||||
if (!sweeper.running) {
|
||||
sweeper.start();
|
||||
}
|
||||
|
||||
_maybeStartOverflow();
|
||||
}
|
||||
|
||||
// Overflow: keep one extra (slot #4), then ask bottom to exit gracefully
|
||||
function _active() {
|
||||
return popupWindows.filter(p => {
|
||||
return _isValidWindow(p) &&
|
||||
p.notificationData &&
|
||||
p.notificationData.popup &&
|
||||
!p.exiting;
|
||||
});
|
||||
}
|
||||
|
||||
function _bottom() {
|
||||
let b = null, maxY = -1;
|
||||
for (let p of _active()) {
|
||||
if (p.screenY > maxY) {
|
||||
maxY = p.screenY;
|
||||
b = p;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
function _maybeStartOverflow() {
|
||||
const activeWindows = _active();
|
||||
if (activeWindows.length <= maxTargetNotifications + 1) return;
|
||||
|
||||
const b = _bottom();
|
||||
if (b && !b.exiting) {
|
||||
// Tell the popup to animate out (don't destroy here)
|
||||
b.notificationData.removedByLimit = true;
|
||||
b.notificationData.popup = false;
|
||||
}
|
||||
}
|
||||
|
||||
// After entrance, you may kick overflow (optional)
|
||||
function _onPopupEntered(p) {
|
||||
if (_isValidWindow(p)) {
|
||||
_maybeStartOverflow();
|
||||
}
|
||||
}
|
||||
|
||||
// Primary cleanup path (after the popup finishes its exit)
|
||||
function _onPopupExitFinished(p) {
|
||||
if (!p) return;
|
||||
|
||||
// Prevent duplicate cleanup
|
||||
const windowId = p.toString();
|
||||
if (destroyingWindows.has(windowId)) {
|
||||
return;
|
||||
}
|
||||
destroyingWindows.add(windowId);
|
||||
|
||||
// Remove from popupWindows
|
||||
const i = popupWindows.indexOf(p);
|
||||
if (i !== -1) {
|
||||
popupWindows.splice(i, 1);
|
||||
popupWindows = popupWindows.slice();
|
||||
}
|
||||
|
||||
// Release the wrapper
|
||||
if (NotificationService.releaseWrapper && p.notificationData) {
|
||||
NotificationService.releaseWrapper(p.notificationData);
|
||||
}
|
||||
|
||||
// Schedule destruction
|
||||
Qt.callLater(() => {
|
||||
if (p && p.destroy) {
|
||||
try {
|
||||
p.destroy();
|
||||
} catch (e) {
|
||||
console.warn("Error destroying popup:", e);
|
||||
}
|
||||
}
|
||||
// Clean up tracking after a delay
|
||||
Qt.callLater(() => {
|
||||
destroyingWindows.delete(windowId);
|
||||
});
|
||||
});
|
||||
|
||||
// Compact survivors (only live, non-exiting)
|
||||
const survivors = _active().sort((a, b) => a.screenY - b.screenY);
|
||||
for (let k = 0; k < survivors.length; ++k) {
|
||||
survivors[k].screenY = topMargin + k * baseNotificationHeight;
|
||||
}
|
||||
|
||||
_maybeStartOverflow();
|
||||
}
|
||||
|
||||
// Smart sweeper that only runs when needed
|
||||
property Timer sweeper: Timer {
|
||||
interval: 2000
|
||||
running: false // Not running by default
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
let toRemove = [];
|
||||
|
||||
for (let p of popupWindows) {
|
||||
if (!p) {
|
||||
toRemove.push(p);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check for various zombie conditions
|
||||
const isZombie =
|
||||
p.status === Component.Null ||
|
||||
(!p.visible && !p.exiting) ||
|
||||
(!p.notificationData && !p._isDestroying) ||
|
||||
(!p.hasValidData && !p._isDestroying);
|
||||
|
||||
if (isZombie) {
|
||||
console.warn("Sweeper found zombie window, cleaning up");
|
||||
toRemove.push(p);
|
||||
|
||||
// Try to force cleanup
|
||||
if (p.forceExit) {
|
||||
p.forceExit();
|
||||
} else if (p.destroy) {
|
||||
try {
|
||||
p.destroy();
|
||||
} catch (e) {
|
||||
console.warn("Error destroying zombie:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all zombies from array
|
||||
if (toRemove.length > 0) {
|
||||
for (let zombie of toRemove) {
|
||||
const i = popupWindows.indexOf(zombie);
|
||||
if (i !== -1) {
|
||||
popupWindows.splice(i, 1);
|
||||
}
|
||||
}
|
||||
popupWindows = popupWindows.slice();
|
||||
|
||||
// Recompact after cleanup
|
||||
const survivors = _active().sort((a, b) => a.screenY - b.screenY);
|
||||
for (let k = 0; k < survivors.length; ++k) {
|
||||
survivors[k].screenY = topMargin + k * baseNotificationHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// Stop the timer if no windows remain
|
||||
if (popupWindows.length === 0) {
|
||||
sweeper.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Watch for changes to popup windows array
|
||||
onPopupWindowsChanged: {
|
||||
if (popupWindows.length > 0 && !sweeper.running) {
|
||||
sweeper.start();
|
||||
} else if (popupWindows.length === 0 && sweeper.running) {
|
||||
sweeper.stop();
|
||||
}
|
||||
}
|
||||
|
||||
// Emergency cleanup function
|
||||
function cleanupAllWindows() {
|
||||
sweeper.stop();
|
||||
|
||||
for (let p of popupWindows.slice()) {
|
||||
if (p) {
|
||||
try {
|
||||
if (p.forceExit) p.forceExit();
|
||||
else if (p.destroy) p.destroy();
|
||||
} catch (e) {
|
||||
console.warn("Error during emergency cleanup:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
popupWindows = [];
|
||||
destroyingWindows.clear();
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,10 @@ PanelWindow {
|
||||
radius: Theme.cornerRadiusLarge
|
||||
border.color: Theme.outlineMedium
|
||||
border.width: 1
|
||||
|
||||
// Remove layer rendering for better performance
|
||||
antialiasing: true
|
||||
smooth: true
|
||||
|
||||
// Material 3 elevation with multiple layers
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
@@ -108,7 +111,7 @@ PanelWindow {
|
||||
border.width: 1
|
||||
z: -3
|
||||
}
|
||||
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.margins: -2
|
||||
@@ -118,7 +121,7 @@ PanelWindow {
|
||||
border.width: 1
|
||||
z: -2
|
||||
}
|
||||
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "transparent"
|
||||
@@ -127,10 +130,6 @@ PanelWindow {
|
||||
radius: parent.radius
|
||||
z: -1
|
||||
}
|
||||
|
||||
// Remove layer rendering for better performance
|
||||
antialiasing: true
|
||||
smooth: true
|
||||
|
||||
ScrollView {
|
||||
anchors.fill: parent
|
||||
@@ -180,7 +179,9 @@ PanelWindow {
|
||||
batteryPopupVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
||||
@@ -17,9 +17,9 @@ Rectangle {
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: "notifications"
|
||||
name: Prefs.doNotDisturb ? "notifications_off" : "notifications"
|
||||
size: Theme.iconSize - 6
|
||||
color: notificationArea.containsMouse || root.isActive ? Theme.primary : Theme.surfaceText
|
||||
color: Prefs.doNotDisturb ? Theme.error : (notificationArea.containsMouse || root.isActive ? Theme.primary : Theme.surfaceText)
|
||||
}
|
||||
|
||||
// Notification dot indicator
|
||||
|
||||
@@ -323,6 +323,7 @@ PanelWindow {
|
||||
if (controlCenterPopout.controlCenterVisible) {
|
||||
if (NetworkService.wifiEnabled)
|
||||
NetworkService.scanWifi();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -333,4 +334,4 @@ PanelWindow {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,17 @@ PanelWindow {
|
||||
|
||||
property bool volumePopupVisible: false
|
||||
|
||||
function show() {
|
||||
root.volumePopupVisible = true;
|
||||
hideTimer.restart();
|
||||
}
|
||||
|
||||
function resetHideTimer() {
|
||||
if (root.volumePopupVisible)
|
||||
hideTimer.restart();
|
||||
|
||||
}
|
||||
|
||||
visible: volumePopupVisible
|
||||
WlrLayershell.layer: WlrLayershell.Overlay
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
@@ -27,40 +38,30 @@ PanelWindow {
|
||||
|
||||
Timer {
|
||||
id: hideTimer
|
||||
|
||||
interval: 3000
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
if (!volumePopup.containsMouse) {
|
||||
root.volumePopupVisible = false
|
||||
} else {
|
||||
hideTimer.restart()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function show() {
|
||||
root.volumePopupVisible = true;
|
||||
hideTimer.restart();
|
||||
}
|
||||
|
||||
function resetHideTimer() {
|
||||
if (root.volumePopupVisible) {
|
||||
hideTimer.restart();
|
||||
if (!volumePopup.containsMouse)
|
||||
root.volumePopupVisible = false;
|
||||
else
|
||||
hideTimer.restart();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: AudioService
|
||||
function onVolumeChanged() {
|
||||
root.show();
|
||||
}
|
||||
function onSinkChanged() {
|
||||
if (root.volumePopupVisible) {
|
||||
root.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onSinkChanged() {
|
||||
if (root.volumePopupVisible)
|
||||
root.show();
|
||||
|
||||
}
|
||||
|
||||
target: AudioService
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: volumePopup
|
||||
@@ -72,28 +73,27 @@ PanelWindow {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: Theme.spacingM
|
||||
|
||||
color: Theme.popupBackground()
|
||||
radius: Theme.cornerRadiusLarge
|
||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
|
||||
border.width: 1
|
||||
|
||||
opacity: root.volumePopupVisible ? 1 : 0
|
||||
scale: root.volumePopupVisible ? 1 : 0.9
|
||||
layer.enabled: true
|
||||
|
||||
Column {
|
||||
id: volumeContent
|
||||
|
||||
|
||||
anchors.centerIn: parent
|
||||
width: parent.width - Theme.spacingS * 2
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
Item {
|
||||
property int gap: Theme.spacingS
|
||||
|
||||
width: parent.width
|
||||
height: 40
|
||||
|
||||
property int gap: Theme.spacingS
|
||||
|
||||
|
||||
Rectangle {
|
||||
width: Theme.iconSize
|
||||
height: Theme.iconSize
|
||||
@@ -104,14 +104,14 @@ PanelWindow {
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: AudioService.sink && AudioService.sink.audio && AudioService.sink.audio.muted ?
|
||||
"volume_off" : "volume_up"
|
||||
name: AudioService.sink && AudioService.sink.audio && AudioService.sink.audio.muted ? "volume_off" : "volume_up"
|
||||
size: Theme.iconSize
|
||||
color: muteButton.containsMouse ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: muteButton
|
||||
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
@@ -120,10 +120,12 @@ PanelWindow {
|
||||
root.resetHideTimer();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DankSlider {
|
||||
id: volumeSlider
|
||||
|
||||
width: parent.width - Theme.iconSize - parent.gap * 3
|
||||
height: 40
|
||||
x: parent.gap * 2 + Theme.iconSize
|
||||
@@ -133,33 +135,35 @@ PanelWindow {
|
||||
enabled: AudioService.sink && AudioService.sink.audio
|
||||
showValue: true
|
||||
unit: "%"
|
||||
|
||||
Connections {
|
||||
target: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio : null
|
||||
function onVolumeChanged() {
|
||||
volumeSlider.value = Math.round(AudioService.sink.audio.volume * 100);
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (AudioService.sink && AudioService.sink.audio) {
|
||||
if (AudioService.sink && AudioService.sink.audio)
|
||||
value = Math.round(AudioService.sink.audio.volume * 100);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onSliderValueChanged: function(newValue) {
|
||||
if (AudioService.sink && AudioService.sink.audio) {
|
||||
AudioService.sink.audio.volume = newValue / 100;
|
||||
root.resetHideTimer();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onVolumeChanged() {
|
||||
volumeSlider.value = Math.round(AudioService.sink.audio.volume * 100);
|
||||
}
|
||||
|
||||
target: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio : null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: popupMouseArea
|
||||
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.NoButton
|
||||
@@ -167,7 +171,6 @@ PanelWindow {
|
||||
z: -1
|
||||
}
|
||||
|
||||
layer.enabled: true
|
||||
layer.effect: MultiEffect {
|
||||
shadowEnabled: true
|
||||
shadowHorizontalOffset: 0
|
||||
@@ -186,6 +189,7 @@ PanelWindow {
|
||||
duration: Theme.mediumDuration
|
||||
easing.type: Theme.emphasizedEasing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Behavior on scale {
|
||||
@@ -193,6 +197,7 @@ PanelWindow {
|
||||
duration: Theme.mediumDuration
|
||||
easing.type: Theme.emphasizedEasing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Behavior on transform {
|
||||
@@ -200,10 +205,13 @@ PanelWindow {
|
||||
duration: Theme.mediumDuration
|
||||
easing.type: Theme.emphasizedEasing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mask: Region {
|
||||
item: volumePopup
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Services.Notifications
|
||||
import qs.Services
|
||||
import qs.Common
|
||||
import "../Common/markdown2html.js" as Markdown2Html
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
@@ -60,8 +62,9 @@ Singleton {
|
||||
onNotification: notif => {
|
||||
notif.tracked = true;
|
||||
|
||||
const shouldShowPopup = !root.popupsDisabled && !Prefs.doNotDisturb;
|
||||
const wrapper = notifComponent.createObject(root, {
|
||||
popup: !root.popupsDisabled,
|
||||
popup: shouldShowPopup,
|
||||
notification: notif
|
||||
});
|
||||
|
||||
@@ -70,7 +73,7 @@ Singleton {
|
||||
root.notifications.push(wrapper);
|
||||
addToPersistentStorage(wrapper);
|
||||
|
||||
if (!root.popupsDisabled) {
|
||||
if (shouldShowPopup) {
|
||||
notificationQueue = [...notificationQueue, wrapper];
|
||||
processQueue();
|
||||
}
|
||||
@@ -84,7 +87,6 @@ Singleton {
|
||||
property bool popup: false
|
||||
property bool removedByLimit: false
|
||||
property bool isPersistent: true
|
||||
property int initialOffset: 0
|
||||
property int seq: 0
|
||||
|
||||
onPopupChanged: {
|
||||
@@ -93,7 +95,6 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
// Don't override popup in onCompleted - it's set correctly during creation
|
||||
|
||||
readonly property Timer timer: Timer {
|
||||
interval: 5000
|
||||
@@ -120,14 +121,13 @@ Singleton {
|
||||
required property Notification notification
|
||||
readonly property string summary: notification.summary
|
||||
readonly property string body: notification.body
|
||||
readonly property string appIcon: notification.appIcon
|
||||
readonly property string cleanAppIcon: {
|
||||
if (!appIcon) return "";
|
||||
if (appIcon.startsWith("file://")) {
|
||||
return appIcon.substring(7);
|
||||
readonly property string htmlBody: {
|
||||
if (body && (body.includes('<') && body.includes('>'))) {
|
||||
return body;
|
||||
}
|
||||
return appIcon;
|
||||
return Markdown2Html.markdownToHtml(body);
|
||||
}
|
||||
readonly property string appIcon: notification.appIcon
|
||||
readonly property string appName: notification.appName
|
||||
readonly property string desktopEntry: notification.desktopEntry
|
||||
readonly property string image: notification.image
|
||||
@@ -141,7 +141,6 @@ Singleton {
|
||||
readonly property int urgency: notification.urgency
|
||||
readonly property list<NotificationAction> actions: notification.actions
|
||||
|
||||
// Enhanced properties for better handling
|
||||
readonly property bool hasImage: image && image.length > 0
|
||||
readonly property bool hasAppIcon: appIcon && appIcon.length > 0
|
||||
|
||||
@@ -159,7 +158,6 @@ Singleton {
|
||||
const groupKey = getGroupKey(wrapper);
|
||||
const remainingInGroup = root.notifications.filter(n => getGroupKey(n) === groupKey);
|
||||
|
||||
// Only collapse the group if there's 1 or fewer notifications left
|
||||
if (remainingInGroup.length <= 1) {
|
||||
clearGroupExpansionState(groupKey);
|
||||
}
|
||||
@@ -178,7 +176,6 @@ Singleton {
|
||||
NotifWrapper {}
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
function clearAllNotifications() {
|
||||
bulkDismissing = true;
|
||||
popupsDisabled = true;
|
||||
@@ -198,7 +195,7 @@ Singleton {
|
||||
for (let i = 0; i < toDismiss.length; ++i) {
|
||||
const w = toDismiss[i];
|
||||
if (w && w.notification) {
|
||||
try { w.notification.dismiss(); } catch (e) { /* ignore */ }
|
||||
try { w.notification.dismiss(); } catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,6 +226,7 @@ Singleton {
|
||||
function processQueue() {
|
||||
if (addGateBusy) return;
|
||||
if (popupsDisabled) return;
|
||||
if (Prefs.doNotDisturb) return;
|
||||
if (notificationQueue.length === 0) return;
|
||||
|
||||
const [next, ...rest] = notificationQueue;
|
||||
@@ -433,9 +431,10 @@ Singleton {
|
||||
}
|
||||
return `${group.count} notifications`;
|
||||
}
|
||||
|
||||
function getGroupBody(group) {
|
||||
if (group.count === 1) {
|
||||
return group.latestNotification.body;
|
||||
return group.latestNotification.htmlBody; // Use HTML body
|
||||
}
|
||||
return `Latest: ${group.latestNotification.summary}`;
|
||||
}
|
||||
@@ -446,6 +445,7 @@ Singleton {
|
||||
appName: wrapper.appName,
|
||||
summary: wrapper.summary,
|
||||
body: wrapper.body,
|
||||
htmlBody: wrapper.htmlBody, // Store HTML version too
|
||||
appIcon: wrapper.appIcon,
|
||||
image: wrapper.image,
|
||||
urgency: wrapper.urgency,
|
||||
@@ -467,19 +467,22 @@ Singleton {
|
||||
persistedNotifications = newPersisted;
|
||||
}
|
||||
|
||||
function getPersistentNotificationsByApp(appName) {
|
||||
return persistedNotifications.filter(notif => notif.appName.toLowerCase() === appName.toLowerCase());
|
||||
}
|
||||
function getPersistentNotificationsByType(type) {
|
||||
return persistedNotifications;
|
||||
}
|
||||
function searchPersistentNotifications(query) {
|
||||
const searchLower = query.toLowerCase();
|
||||
return persistedNotifications.filter(notif =>
|
||||
notif.appName.toLowerCase().includes(searchLower) ||
|
||||
notif.summary.toLowerCase().includes(searchLower) ||
|
||||
notif.body.toLowerCase().includes(searchLower)
|
||||
);
|
||||
|
||||
Connections {
|
||||
target: Prefs
|
||||
function onDoNotDisturbChanged() {
|
||||
if (Prefs.doNotDisturb) {
|
||||
// Hide all current popups when DND is enabled
|
||||
for (const notif of visibleNotifications) {
|
||||
notif.popup = false;
|
||||
}
|
||||
visibleNotifications = [];
|
||||
notificationQueue = [];
|
||||
} else {
|
||||
// Re-enable popup processing when DND is disabled
|
||||
processQueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
||||
@@ -42,8 +42,8 @@ Image {
|
||||
const grabPath = cachePath;
|
||||
if (visible && width > 0 && height > 0 && Window.window && Window.window.visible)
|
||||
grabToImage((res) => {
|
||||
return res.saveToFile(grabPath);
|
||||
});
|
||||
return res.saveToFile(grabPath);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ import qs.Modules.Settings
|
||||
import qs.Modules.ProcessList
|
||||
import qs.Modules.ControlCenter.Network
|
||||
import qs.Modules.Lock
|
||||
import qs.Modules.Notifications
|
||||
import qs.Modules.Notifications.Center
|
||||
import qs.Modules.Notifications.Popup
|
||||
import qs.Modals
|
||||
import qs.Services
|
||||
|
||||
|
||||
@@ -16,55 +16,55 @@ else
|
||||
ICON_BASE=""
|
||||
fi
|
||||
|
||||
# Test 1: Basic notifications
|
||||
echo "📱 Test 1: Basic notifications"
|
||||
notify-send -h string:desktop-entry:org.gnome.Settings -i preferences-desktop "Settings" "Basic notification message"
|
||||
# Test 1: Basic notifications with markdown
|
||||
echo "📱 Test 1: Basic notifications with markdown"
|
||||
notify-send -h string:desktop-entry:org.gnome.Settings -i preferences-desktop "Settings" "**Bold text** and *italic text* with [links](https://example.com) and \`code blocks\`"
|
||||
sleep 2
|
||||
|
||||
# Test 2: Media notifications (should group under Spotify)
|
||||
echo "🎵 Test 2: Media notifications (grouping)"
|
||||
notify-send -h string:desktop-entry:spotify -i audio-x-generic "Spotify" "Now Playing: Song 1 - Artist A"
|
||||
# Test 2: Media notifications with rich formatting (grouping)
|
||||
echo "🎵 Test 2: Media notifications with rich formatting (grouping)"
|
||||
notify-send -h string:desktop-entry:spotify -i audio-x-generic "Spotify" "**Now Playing:** *Song 1* by **Artist A**\n\nAlbum: ~Greatest Hits~\nDuration: \`3:45\`"
|
||||
sleep 1
|
||||
notify-send -h string:desktop-entry:spotify -i audio-x-generic "Spotify" "Now Playing: Song 2 - Artist B"
|
||||
notify-send -h string:desktop-entry:spotify -i audio-x-generic "Spotify" "**Now Playing:** *Song 2* by **Artist B**\n\n> From the album: \"New Releases\"\n- Track #4\n- \`4:12\`"
|
||||
sleep 1
|
||||
notify-send -h string:desktop-entry:spotify -i audio-x-generic "Spotify" "Now Playing: Song 3 - Artist C"
|
||||
notify-send -h string:desktop-entry:spotify -i audio-x-generic "Spotify" "**Now Playing:** *Song 3* by **Artist C**\n\n### Recently Added\n- [View on Spotify](https://spotify.com)\n- Duration: \`2:58\`"
|
||||
sleep 2
|
||||
|
||||
# Test 3: System notifications (separate groups)
|
||||
echo "🔋 Test 3: System notifications (separate apps)"
|
||||
notify-send -h string:desktop-entry:org.gnome.PowerStats -i battery "Power Manager" "Battery Low: 15% remaining"
|
||||
# Test 3: System notifications with markdown (separate groups)
|
||||
echo "🔋 Test 3: System notifications with markdown (separate apps)"
|
||||
notify-send -h string:desktop-entry:org.gnome.PowerStats -i battery "Power Manager" "⚠️ **Battery Low:** \`15%\` remaining\n\n### Power Saving Tips:\n- Reduce screen brightness\n- *Close unnecessary apps*\n- [Power settings](settings://power)"
|
||||
sleep 1
|
||||
notify-send -h string:desktop-entry:org.gnome.NetworkDisplays -i network-wired "Network Manager" "WiFi Connected: HomeNetwork"
|
||||
notify-send -h string:desktop-entry:org.gnome.NetworkDisplays -i network-wired "Network Manager" "✅ **WiFi Connected:** *HomeNetwork*\n\n**Signal Strength:** Strong (85%)\n**IP Address:** \`192.168.1.100\`\n\n> Connection established successfully"
|
||||
sleep 1
|
||||
notify-send -h string:desktop-entry:org.gnome.Software -i system-software-update "Software" "5 updates available"
|
||||
notify-send -h string:desktop-entry:org.gnome.Software -i system-software-update "Software" "📦 **Updates Available**\n\n### Pending Updates:\n- **Firefox** (v119.0)\n- *System libraries* (security)\n- \`python-requests\` (dependency)\n\n[Install All](software://updates) | [View Details](software://details)"
|
||||
sleep 2
|
||||
|
||||
# Test 4: Chat notifications (should group under Discord)
|
||||
echo "💬 Test 4: Chat notifications (grouping)"
|
||||
notify-send -h string:desktop-entry:discord -i internet-chat "Discord" "#general: User1 says Hello everyone!"
|
||||
# Test 4: Chat notifications with complex markdown (grouping)
|
||||
echo "💬 Test 4: Chat notifications with complex markdown (grouping)"
|
||||
notify-send -h string:desktop-entry:discord -i internet-chat "Discord" "**#general** - User1\n\nHello everyone! 👋\n\n> Just wanted to share this cool project I'm working on:\n- Built with **React** and *TypeScript*\n- Using \`styled-components\` for styling\n- [Check it out](https://github.com/user1/project)"
|
||||
sleep 1
|
||||
notify-send -h string:desktop-entry:discord -i internet-chat "Discord" "#general: User2 says Hey there!"
|
||||
notify-send -h string:desktop-entry:discord -i internet-chat "Discord" "**#general** - User2\n\nHey there! That looks awesome! 🚀\n\n### Quick question:\nDo you have any tips for:\n1. **State management** patterns?\n2. *Performance optimization*?\n3. Testing with \`jest\`?\n\n> I'm still learning React"
|
||||
sleep 1
|
||||
notify-send -h string:desktop-entry:discord -i internet-chat "Discord" "john_doe: Private message from John"
|
||||
notify-send -h string:desktop-entry:discord -i internet-chat "Discord" "**Direct Message** - john_doe\n\n*Private message from John* 💬\n\n**Subject:** Weekend plans\n\nHey! Want to grab coffee this weekend?\n\n### Suggestions:\n- ☕ Local café on Main St\n- 🥐 That new bakery downtown\n- 🏠 My place (I got a new espresso machine!)\n\n[Reply](discord://dm/john_doe) | [Call](discord://call/john_doe)"
|
||||
sleep 2
|
||||
|
||||
# Test 5: Urgent notifications
|
||||
echo "🚨 Test 5: Urgent notifications"
|
||||
notify-send -u critical -i dialog-warning "Critical Alert" "System overheating detected - Temperature: 85°C"
|
||||
# Test 5: Urgent notifications with markdown
|
||||
echo "🚨 Test 5: Urgent notifications with markdown"
|
||||
notify-send -u critical -i dialog-warning "Critical Alert" "🔥 **SYSTEM OVERHEATING** 🔥\n\n### Current Status:\n- **Temperature:** \`85°C\` (Critical)\n- **CPU Usage:** \`95%\`\n- *Thermal throttling active*\n\n> **Immediate Actions Required:**\n1. Close resource-intensive applications\n2. Check cooling system\n3. Reduce workload\n\n[System Monitor](gnome-system-monitor) | [Power Options](gnome-power-statistics)"
|
||||
sleep 2
|
||||
|
||||
# Test 6: Notifications with actions (simulated)
|
||||
echo "⚡ Test 6: Action buttons"
|
||||
notify-send -h string:desktop-entry:org.gnome.Software -i system-upgrade "Software" "Updates available - Click to install or remind later"
|
||||
# Test 6: Notifications with actions and markdown
|
||||
echo "⚡ Test 6: Action buttons with markdown"
|
||||
notify-send -h string:desktop-entry:org.gnome.Software -i system-upgrade "Software" "📦 **System Updates Available**\n\n### Ready to Install:\n- **Security patches** (High priority)\n- *Feature updates* for 3 applications\n- \`kernel\` update (5.15.0 → 5.16.2)\n\n> **Recommended:** Install now for optimal security\n\n**Estimated time:** ~15 minutes\n**Restart required:** Yes\n\n[Install Now](software://install) | [Schedule Later](software://schedule)"
|
||||
sleep 2
|
||||
|
||||
# Test 7: Multiple different apps
|
||||
echo "📊 Test 7: Multiple different apps"
|
||||
notify-send -h string:desktop-entry:thunderbird -i mail-message-new "Thunderbird" "You have 3 new emails"
|
||||
# Test 7: Multiple different apps with rich markdown
|
||||
echo "📊 Test 7: Multiple different apps with rich markdown"
|
||||
notify-send -h string:desktop-entry:thunderbird -i mail-message-new "Thunderbird" "📧 **New Messages** (3)\n\n### Recent Emails:\n1. **Sarah Johnson** - *Project Update*\n > \"The quarterly report is ready for review...\"\n \n2. **GitHub** - \`[user/repo]\` *Pull Request*\n > New PR: Fix memory leak in parser\n \n3. **Newsletter** - *Weekly Tech Digest*\n > This week: AI advancements, new frameworks...\n\n[Open Inbox](thunderbird://inbox) | [Mark All Read](thunderbird://markread)"
|
||||
sleep 0.5
|
||||
notify-send -h string:desktop-entry:org.gnome.Calendar -i office-calendar "Calendar" "Daily standup in 5 minutes"
|
||||
notify-send -h string:desktop-entry:org.gnome.Calendar -i office-calendar "Calendar" "📅 **Upcoming Meeting**\n\n### Daily Standup\n- **Time:** 5 minutes\n- **Location:** *Conference Room A*\n- **Attendees:** Team Alpha (8 people)\n\n#### Agenda:\n1. Yesterday's progress\n2. Today's goals \n3. Blockers discussion\n\n> **Reminder:** Prepare your status update\n\n[Join Video Call](meet://standup) | [Reschedule](calendar://reschedule)"
|
||||
sleep 0.5
|
||||
notify-send -h string:desktop-entry:org.gnome.Nautilus -i folder-downloads "Files" "document.pdf downloaded"
|
||||
notify-send -h string:desktop-entry:org.gnome.Nautilus -i folder-downloads "Files" "📁 **Download Complete**\n\n### File Details:\n- **Name:** \`document.pdf\`\n- **Size:** *2.4 MB*\n- **Location:** ~/Downloads/\n- **Type:** PDF Document\n\n> **Security:** Scanned ✅ (No threats detected)\n\n**Recent Downloads:**\n- presentation.pptx (1 hour ago)\n- backup.zip (yesterday)\n\n[Open File](file://document.pdf) | [Show in Folder](nautilus://downloads)"
|
||||
sleep 2
|
||||
|
||||
# notify-send --hint=boolean:resident:true "Resident Test" "Click an action - I should stay visible!" --action="Test Action" --action="Close Me"
|
||||
|
||||
Reference in New Issue
Block a user