mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-31 08:52:49 -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 bool wallpaperDynamicTheming: true
|
||||||
property string wallpaperLastPath: ""
|
property string wallpaperLastPath: ""
|
||||||
property string profileLastPath: ""
|
property string profileLastPath: ""
|
||||||
|
property bool doNotDisturb: false
|
||||||
|
|
||||||
function loadSettings() {
|
function loadSettings() {
|
||||||
parseSettings(settingsFile.text());
|
parseSettings(settingsFile.text());
|
||||||
@@ -85,6 +86,7 @@ Singleton {
|
|||||||
wallpaperDynamicTheming = settings.wallpaperDynamicTheming !== undefined ? settings.wallpaperDynamicTheming : true;
|
wallpaperDynamicTheming = settings.wallpaperDynamicTheming !== undefined ? settings.wallpaperDynamicTheming : true;
|
||||||
wallpaperLastPath = settings.wallpaperLastPath !== undefined ? settings.wallpaperLastPath : "";
|
wallpaperLastPath = settings.wallpaperLastPath !== undefined ? settings.wallpaperLastPath : "";
|
||||||
profileLastPath = settings.profileLastPath !== undefined ? settings.profileLastPath : "";
|
profileLastPath = settings.profileLastPath !== undefined ? settings.profileLastPath : "";
|
||||||
|
doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false;
|
||||||
applyStoredTheme();
|
applyStoredTheme();
|
||||||
detectAvailableIconThemes();
|
detectAvailableIconThemes();
|
||||||
updateGtkIconTheme(iconTheme);
|
updateGtkIconTheme(iconTheme);
|
||||||
@@ -130,7 +132,8 @@ Singleton {
|
|||||||
"wallpaperPath": wallpaperPath,
|
"wallpaperPath": wallpaperPath,
|
||||||
"wallpaperDynamicTheming": wallpaperDynamicTheming,
|
"wallpaperDynamicTheming": wallpaperDynamicTheming,
|
||||||
"wallpaperLastPath": wallpaperLastPath,
|
"wallpaperLastPath": wallpaperLastPath,
|
||||||
"profileLastPath": profileLastPath
|
"profileLastPath": profileLastPath,
|
||||||
|
"doNotDisturb": doNotDisturb
|
||||||
}, null, 2));
|
}, null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,6 +484,11 @@ gtk-application-prefer-dark-theme=true`;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setDoNotDisturb(enabled) {
|
||||||
|
doNotDisturb = enabled;
|
||||||
|
saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: loadSettings()
|
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() {
|
function onIsVisibleChanged() {
|
||||||
if (appDrawerPopout.isVisible)
|
if (appDrawerPopout.isVisible)
|
||||||
Qt.callLater(function() {
|
Qt.callLater(function() {
|
||||||
searchField.forceActiveFocus();
|
searchField.forceActiveFocus();
|
||||||
});
|
});
|
||||||
else
|
else
|
||||||
searchField.clearFocus();
|
searchField.clearFocus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ Item {
|
|||||||
property var appUsageRanking: Prefs.appUsageRanking
|
property var appUsageRanking: Prefs.appUsageRanking
|
||||||
// Internal model
|
// Internal model
|
||||||
property alias model: filteredModel
|
property alias model: filteredModel
|
||||||
|
// Watch AppSearchService.applications changes via property binding
|
||||||
|
property var _watchApplications: AppSearchService.applications
|
||||||
|
|
||||||
// Signals
|
// Signals
|
||||||
signal appLaunched(var app)
|
signal appLaunched(var app)
|
||||||
@@ -81,21 +83,21 @@ Item {
|
|||||||
var aUsage = appUsageRanking[aId] ? appUsageRanking[aId].usageCount : 0;
|
var aUsage = appUsageRanking[aId] ? appUsageRanking[aId].usageCount : 0;
|
||||||
var bUsage = appUsageRanking[bId] ? appUsageRanking[bId].usageCount : 0;
|
var bUsage = appUsageRanking[bId] ? appUsageRanking[bId].usageCount : 0;
|
||||||
if (aUsage !== bUsage)
|
if (aUsage !== bUsage)
|
||||||
return bUsage - aUsage; // Higher usage first
|
return bUsage - aUsage;
|
||||||
|
// Higher usage first
|
||||||
return (a.name || "").localeCompare(b.name || ""); // Alphabetical fallback
|
return (a.name || "").localeCompare(b.name || ""); // Alphabetical fallback
|
||||||
});
|
});
|
||||||
// Convert to model format and populate
|
// Convert to model format and populate
|
||||||
apps.forEach((app) => {
|
apps.forEach((app) => {
|
||||||
if (app)
|
if (app)
|
||||||
filteredModel.append({
|
filteredModel.append({
|
||||||
"name": app.name || "",
|
"name": app.name || "",
|
||||||
"exec": app.execString || "",
|
"exec": app.execString || "",
|
||||||
"icon": app.icon || "application-x-executable",
|
"icon": app.icon || "application-x-executable",
|
||||||
"comment": app.comment || "",
|
"comment": app.comment || "",
|
||||||
"categories": app.categories || [],
|
"categories": app.categories || [],
|
||||||
"desktopEntry": app
|
"desktopEntry": app
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -178,11 +180,7 @@ Item {
|
|||||||
}
|
}
|
||||||
onSelectedCategoryChanged: updateFilteredModel()
|
onSelectedCategoryChanged: updateFilteredModel()
|
||||||
onAppUsageRankingChanged: updateFilteredModel()
|
onAppUsageRankingChanged: updateFilteredModel()
|
||||||
|
|
||||||
// Watch AppSearchService.applications changes via property binding
|
|
||||||
property var _watchApplications: AppSearchService.applications
|
|
||||||
on_WatchApplicationsChanged: updateFilteredModel()
|
on_WatchApplicationsChanged: updateFilteredModel()
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
updateFilteredModel();
|
updateFilteredModel();
|
||||||
|
|||||||
@@ -203,12 +203,21 @@ Column {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: parent.radius
|
radius: parent.radius
|
||||||
visible: CalendarService && CalendarService.khalAvailable && CalendarService.hasEventsForDate(dayDate)
|
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 {
|
gradient: Gradient {
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0.89
|
position: 0.89
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
}
|
}
|
||||||
|
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0.9
|
position: 0.9
|
||||||
color: {
|
color: {
|
||||||
@@ -220,8 +229,9 @@ Column {
|
|||||||
return Theme.primary;
|
return Theme.primary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 1.0
|
position: 1
|
||||||
color: {
|
color: {
|
||||||
if (isSelected)
|
if (isSelected)
|
||||||
return Qt.lighter(Theme.primary, 1.3);
|
return Qt.lighter(Theme.primary, 1.3);
|
||||||
@@ -231,15 +241,7 @@ Column {
|
|||||||
return Theme.primary;
|
return Theme.primary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
opacity: {
|
|
||||||
if (isSelected)
|
|
||||||
return 0.9;
|
|
||||||
else if (isToday)
|
|
||||||
return 0.8;
|
|
||||||
else
|
|
||||||
return 0.6;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
@@ -247,9 +249,11 @@ Column {
|
|||||||
duration: Theme.shortDuration
|
duration: Theme.shortDuration
|
||||||
easing.type: Theme.standardEasing
|
easing.type: Theme.standardEasing
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
|||||||
@@ -98,11 +98,12 @@ PanelWindow {
|
|||||||
y: Theme.barHeight + 4
|
y: Theme.barHeight + 4
|
||||||
// Only resize after animation is complete
|
// Only resize after animation is complete
|
||||||
onOpacityChanged: {
|
onOpacityChanged: {
|
||||||
|
// Animation finished, now we can safely resize
|
||||||
|
|
||||||
if (opacity === 1)
|
if (opacity === 1)
|
||||||
// Animation finished, now we can safely resize
|
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
height = calculateHeight();
|
height = calculateHeight();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,6 +197,7 @@ PanelWindow {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
height: 140
|
height: 140
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right section for calendar - enhanced container
|
// Right section for calendar - enhanced container
|
||||||
@@ -209,17 +211,22 @@ PanelWindow {
|
|||||||
|
|
||||||
CalendarGrid {
|
CalendarGrid {
|
||||||
id: calendarGrid
|
id: calendarGrid
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Theme.spacingS
|
anchors.margins: Theme.spacingS
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Events {
|
Events {
|
||||||
id: events
|
id: events
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
selectedDate: calendarGrid.selectedDate
|
selectedDate: calendarGrid.selectedDate
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Rectangle {
|
|||||||
|
|
||||||
property var notificationGroup
|
property var notificationGroup
|
||||||
property bool expanded: NotificationService.expandedGroups[notificationGroup?.key] || false
|
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
|
property bool userInitiatedExpansion: false
|
||||||
|
|
||||||
width: parent ? parent.width : 400
|
width: parent ? parent.width : 400
|
||||||
@@ -75,7 +75,8 @@ Rectangle {
|
|||||||
border.color: "transparent"
|
border.color: "transparent"
|
||||||
border.width: 0
|
border.width: 0
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: 18
|
||||||
|
|
||||||
IconImage {
|
IconImage {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -178,7 +179,7 @@ Rectangle {
|
|||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: descriptionText
|
id: descriptionText
|
||||||
property string fullText: notificationGroup?.latestNotification?.body || ""
|
property string fullText: notificationGroup?.latestNotification?.htmlBody || ""
|
||||||
property bool hasMoreText: truncated
|
property bool hasMoreText: truncated
|
||||||
|
|
||||||
text: fullText
|
text: fullText
|
||||||
@@ -189,16 +190,33 @@ Rectangle {
|
|||||||
maximumLineCount: descriptionExpanded ? -1 : 2
|
maximumLineCount: descriptionExpanded ? -1 : 2
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
visible: text.length > 0
|
visible: text.length > 0
|
||||||
textFormat: Text.PlainText
|
linkColor: Theme.primary
|
||||||
|
onLinkActivated: Qt.openUrlExternally(link)
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: (parent.hasMoreText || descriptionExpanded) ? Qt.PointingHandCursor : Qt.ArrowCursor
|
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor :
|
||||||
enabled: parent.hasMoreText || descriptionExpanded
|
(parent.hasMoreText || descriptionExpanded) ? Qt.PointingHandCursor :
|
||||||
onClicked: {
|
Qt.ArrowCursor
|
||||||
descriptionExpanded = !descriptionExpanded;
|
|
||||||
|
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
|
height: 32
|
||||||
radius: 16
|
radius: 16
|
||||||
anchors.left: parent.left
|
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)
|
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.color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.2)
|
||||||
border.width: 1
|
border.width: 1
|
||||||
@@ -384,7 +403,7 @@ Rectangle {
|
|||||||
id: bodyText
|
id: bodyText
|
||||||
property bool hasMoreText: truncated
|
property bool hasMoreText: truncated
|
||||||
|
|
||||||
text: modelData?.body || ""
|
text: modelData?.htmlBody || ""
|
||||||
color: Theme.surfaceVariantText
|
color: Theme.surfaceVariantText
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@@ -392,17 +411,31 @@ Rectangle {
|
|||||||
maximumLineCount: messageExpanded ? -1 : 2
|
maximumLineCount: messageExpanded ? -1 : 2
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
visible: text.length > 0
|
visible: text.length > 0
|
||||||
textFormat: Text.PlainText
|
linkColor: Theme.primary
|
||||||
|
onLinkActivated: Qt.openUrlExternally(link)
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
enabled: bodyText.hasMoreText || messageExpanded
|
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor :
|
||||||
cursorShape: bodyText.hasMoreText || messageExpanded ? Qt.PointingHandCursor : Qt.ArrowCursor
|
(bodyText.hasMoreText || messageExpanded) ? Qt.PointingHandCursor :
|
||||||
onClicked: {
|
Qt.ArrowCursor
|
||||||
if (bodyText.hasMoreText || messageExpanded) {
|
|
||||||
|
onClicked: mouse => {
|
||||||
|
if (!parent.hoveredLink && (bodyText.hasMoreText || messageExpanded)) {
|
||||||
NotificationService.toggleMessageExpansion(modelData?.notification?.id || "");
|
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
|
width: parent.width
|
||||||
height: 32
|
height: 32
|
||||||
|
|
||||||
Text {
|
Row {
|
||||||
text: "Notifications"
|
|
||||||
font.pixelSize: Theme.fontSizeLarge
|
|
||||||
color: Theme.surfaceText
|
|
||||||
font.weight: Font.Medium
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
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 {
|
Rectangle {
|
||||||
|
id: clearAllButton
|
||||||
width: 120
|
width: 120
|
||||||
height: 28
|
height: 28
|
||||||
radius: Theme.cornerRadiusLarge
|
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 var notificationData
|
||||||
required property string notificationId
|
required property string notificationId
|
||||||
|
|
||||||
visible: true
|
readonly property bool hasValidData: notificationData && notificationData.notification
|
||||||
|
|
||||||
|
visible: hasValidData
|
||||||
WlrLayershell.layer: WlrLayershell.Overlay
|
WlrLayershell.layer: WlrLayershell.Overlay
|
||||||
WlrLayershell.exclusiveZone: -1
|
WlrLayershell.exclusiveZone: -1
|
||||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
||||||
@@ -31,14 +33,11 @@ PanelWindow {
|
|||||||
right: 12
|
right: 12
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manager drives vertical stacking with this proxy:
|
|
||||||
property int screenY: 0
|
property int screenY: 0
|
||||||
onScreenYChanged: margins.top = Theme.barHeight + 4 + screenY
|
onScreenYChanged: margins.top = Theme.barHeight + 4 + screenY
|
||||||
|
|
||||||
// Disable vertical tween while exiting so there is never diagonal motion
|
|
||||||
Behavior on screenY {
|
Behavior on screenY {
|
||||||
id: screenYAnim
|
id: screenYAnim
|
||||||
enabled: !exiting
|
enabled: !exiting && !_isDestroying
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: Anims.durShort
|
duration: Anims.durShort
|
||||||
easing.type: Easing.BezierSpline
|
easing.type: Easing.BezierSpline
|
||||||
@@ -46,19 +45,25 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// State
|
|
||||||
property bool exiting: false
|
property bool exiting: false
|
||||||
|
property bool _isDestroying: false
|
||||||
|
property bool _finalized: false
|
||||||
signal entered()
|
signal entered()
|
||||||
signal exitFinished()
|
signal exitFinished()
|
||||||
|
onHasValidDataChanged: {
|
||||||
|
if (!hasValidData && !exiting && !_isDestroying) {
|
||||||
|
console.warn("NotificationPopup: Data became invalid, forcing exit");
|
||||||
|
forceExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: content
|
id: content
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
visible: win.hasValidData
|
||||||
|
|
||||||
// We animate a Translate so anchors never override horizontal motion
|
transform: Translate { id: tx; x: Anims.slidePx }
|
||||||
transform: Translate { id: tx; x: Anims.slidePx } // start off-screen right
|
|
||||||
|
|
||||||
// Optional: layer while animating for smoothness
|
|
||||||
layer.enabled: (enterX.running || exitAnim.running)
|
layer.enabled: (enterX.running || exitAnim.running)
|
||||||
layer.smooth: true
|
layer.smooth: true
|
||||||
|
|
||||||
@@ -144,7 +149,6 @@ PanelWindow {
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
id: iconContainer
|
id: iconContainer
|
||||||
readonly property bool hasNotificationImage: notificationData && notificationData.image && notificationData.image !== ""
|
readonly property bool hasNotificationImage: notificationData && notificationData.image && notificationData.image !== ""
|
||||||
property alias iconImage: iconImage
|
|
||||||
|
|
||||||
width: 55
|
width: 55
|
||||||
height: 55
|
height: 55
|
||||||
@@ -242,7 +246,7 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: notificationData ? (notificationData.body || "") : ""
|
text: notificationData ? (notificationData.htmlBody || "") : ""
|
||||||
color: Theme.surfaceVariantText
|
color: Theme.surfaceVariantText
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@@ -250,7 +254,13 @@ PanelWindow {
|
|||||||
maximumLineCount: 2
|
maximumLineCount: 2
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
visible: text.length > 0
|
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
|
buttonSize: 28
|
||||||
z: 15
|
z: 15
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (notificationData)
|
if (notificationData && !win.exiting)
|
||||||
notificationData.popup = false;
|
notificationData.popup = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,7 +325,7 @@ PanelWindow {
|
|||||||
if (modelData && modelData.invoke) {
|
if (modelData && modelData.invoke) {
|
||||||
modelData.invoke();
|
modelData.invoke();
|
||||||
}
|
}
|
||||||
if (notificationData) {
|
if (notificationData && !win.exiting) {
|
||||||
notificationData.popup = false;
|
notificationData.popup = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -355,7 +365,7 @@ PanelWindow {
|
|||||||
onEntered: dismissButton.isHovered = true
|
onEntered: dismissButton.isHovered = true
|
||||||
onExited: dismissButton.isHovered = false
|
onExited: dismissButton.isHovered = false
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (notificationData) {
|
if (notificationData && !win.exiting) {
|
||||||
NotificationService.dismissNotification(notificationData);
|
NotificationService.dismissNotification(notificationData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -378,24 +388,22 @@ PanelWindow {
|
|||||||
notificationData.timer.restart();
|
notificationData.timer.restart();
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (notificationData)
|
if (notificationData && !win.exiting)
|
||||||
notificationData.popup = false;
|
notificationData.popup = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entrance: slide in from right using slowed Anims curves
|
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
id: enterX
|
id: enterX
|
||||||
target: tx; property: "x"; from: Anims.slidePx; to: 0
|
target: tx; property: "x"; from: Anims.slidePx; to: 0
|
||||||
duration: Anims.durMed
|
duration: Anims.durMed
|
||||||
easing.type: Easing.BezierSpline
|
easing.type: Easing.BezierSpline
|
||||||
easing.bezierCurve: Anims.emphasizedDecel
|
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 {
|
ParallelAnimation {
|
||||||
id: exitAnim
|
id: exitAnim
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
@@ -419,52 +427,94 @@ PanelWindow {
|
|||||||
onStopped: finalizeExit("animStopped")
|
onStopped: finalizeExit("animStopped")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start entrance one tick after create (so it always animates)
|
Component.onCompleted: {
|
||||||
Component.onCompleted: Qt.callLater(() => enterX.restart())
|
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 {
|
Connections {
|
||||||
id: wrapperConn
|
id: wrapperConn
|
||||||
target: win.notificationData || null
|
target: win.notificationData || null
|
||||||
ignoreUnknownSignals: true
|
ignoreUnknownSignals: true
|
||||||
|
enabled: !win._isDestroying
|
||||||
|
|
||||||
function onPopupChanged() {
|
function onPopupChanged() {
|
||||||
if (!win.notificationData) return; // guard
|
if (!win.notificationData || win._isDestroying) return;
|
||||||
if (!win.notificationData.popup && !win.exiting) {
|
if (!win.notificationData.popup && !win.exiting) {
|
||||||
// Freeze vertical and start exit
|
startExit();
|
||||||
win.exiting = true; // disables screenY Behavior
|
|
||||||
exitAnim.restart();
|
|
||||||
exitWatchdog.restart(); // safety net
|
|
||||||
if (NotificationService.removeFromVisibleNotifications)
|
|
||||||
NotificationService.removeFromVisibleNotifications(win.notificationData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onNotificationDataChanged: wrapperConn.target = win.notificationData || null
|
onNotificationDataChanged: {
|
||||||
|
if (!_isDestroying) {
|
||||||
|
wrapperConn.target = win.notificationData || null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Timer to start on entrance
|
|
||||||
Timer {
|
Timer {
|
||||||
id: enterDelay
|
id: enterDelay
|
||||||
interval: 160
|
interval: 160
|
||||||
repeat: false
|
repeat: false
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (notificationData && notificationData.timer)
|
if (notificationData && notificationData.timer && !exiting && !_isDestroying)
|
||||||
notificationData.timer.start();
|
notificationData.timer.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start timer after entrance animation
|
onEntered: {
|
||||||
onEntered: enterDelay.start()
|
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) {
|
function finalizeExit(reason) {
|
||||||
if (_finalized) return;
|
if (_finalized) return;
|
||||||
_finalized = true;
|
_finalized = true;
|
||||||
|
_isDestroying = true;
|
||||||
exitWatchdog.stop();
|
exitWatchdog.stop();
|
||||||
win.exitFinished(); // manager will destroy the window
|
|
||||||
}
|
|
||||||
Timer { id: exitWatchdog; interval: 600; repeat: false; onTriggered: finalizeExit("watchdog") }
|
|
||||||
|
|
||||||
// If the popup is torn down unexpectedly, don't leave dangling timers
|
wrapperConn.enabled = false;
|
||||||
Component.onDestruction: { exitWatchdog.stop(); }
|
wrapperConn.target = null;
|
||||||
|
|
||||||
|
win.exitFinished();
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: exitWatchdog
|
||||||
|
interval: 600
|
||||||
|
repeat: false
|
||||||
|
onTriggered: finalizeExit("watchdog")
|
||||||
|
}
|
||||||
|
|
||||||
|
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,6 +97,9 @@ PanelWindow {
|
|||||||
radius: Theme.cornerRadiusLarge
|
radius: Theme.cornerRadiusLarge
|
||||||
border.color: Theme.outlineMedium
|
border.color: Theme.outlineMedium
|
||||||
border.width: 1
|
border.width: 1
|
||||||
|
// Remove layer rendering for better performance
|
||||||
|
antialiasing: true
|
||||||
|
smooth: true
|
||||||
|
|
||||||
// Material 3 elevation with multiple layers
|
// Material 3 elevation with multiple layers
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -128,10 +131,6 @@ PanelWindow {
|
|||||||
z: -1
|
z: -1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove layer rendering for better performance
|
|
||||||
antialiasing: true
|
|
||||||
smooth: true
|
|
||||||
|
|
||||||
ScrollView {
|
ScrollView {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Theme.spacingL
|
anchors.margins: Theme.spacingL
|
||||||
@@ -180,7 +179,9 @@ PanelWindow {
|
|||||||
batteryPopupVisible = false;
|
batteryPopupVisible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ Rectangle {
|
|||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
name: "notifications"
|
name: Prefs.doNotDisturb ? "notifications_off" : "notifications"
|
||||||
size: Theme.iconSize - 6
|
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
|
// Notification dot indicator
|
||||||
|
|||||||
@@ -323,6 +323,7 @@ PanelWindow {
|
|||||||
if (controlCenterPopout.controlCenterVisible) {
|
if (controlCenterPopout.controlCenterVisible) {
|
||||||
if (NetworkService.wifiEnabled)
|
if (NetworkService.wifiEnabled)
|
||||||
NetworkService.scanWifi();
|
NetworkService.scanWifi();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,17 @@ PanelWindow {
|
|||||||
|
|
||||||
property bool volumePopupVisible: false
|
property bool volumePopupVisible: false
|
||||||
|
|
||||||
|
function show() {
|
||||||
|
root.volumePopupVisible = true;
|
||||||
|
hideTimer.restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetHideTimer() {
|
||||||
|
if (root.volumePopupVisible)
|
||||||
|
hideTimer.restart();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
visible: volumePopupVisible
|
visible: volumePopupVisible
|
||||||
WlrLayershell.layer: WlrLayershell.Overlay
|
WlrLayershell.layer: WlrLayershell.Overlay
|
||||||
WlrLayershell.exclusiveZone: -1
|
WlrLayershell.exclusiveZone: -1
|
||||||
@@ -27,40 +38,30 @@ PanelWindow {
|
|||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: hideTimer
|
id: hideTimer
|
||||||
|
|
||||||
interval: 3000
|
interval: 3000
|
||||||
repeat: false
|
repeat: false
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (!volumePopup.containsMouse) {
|
if (!volumePopup.containsMouse)
|
||||||
root.volumePopupVisible = false
|
root.volumePopupVisible = false;
|
||||||
} else {
|
else
|
||||||
hideTimer.restart()
|
hideTimer.restart();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function show() {
|
|
||||||
root.volumePopupVisible = true;
|
|
||||||
hideTimer.restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetHideTimer() {
|
|
||||||
if (root.volumePopupVisible) {
|
|
||||||
hideTimer.restart();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: AudioService
|
|
||||||
function onVolumeChanged() {
|
function onVolumeChanged() {
|
||||||
root.show();
|
root.show();
|
||||||
}
|
}
|
||||||
function onSinkChanged() {
|
|
||||||
if (root.volumePopupVisible) {
|
|
||||||
root.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
function onSinkChanged() {
|
||||||
|
if (root.volumePopupVisible)
|
||||||
|
root.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
target: AudioService
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: volumePopup
|
id: volumePopup
|
||||||
@@ -72,14 +73,13 @@ PanelWindow {
|
|||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.bottomMargin: Theme.spacingM
|
anchors.bottomMargin: Theme.spacingM
|
||||||
|
|
||||||
color: Theme.popupBackground()
|
color: Theme.popupBackground()
|
||||||
radius: Theme.cornerRadiusLarge
|
radius: Theme.cornerRadiusLarge
|
||||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
|
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
|
||||||
border.width: 1
|
border.width: 1
|
||||||
|
|
||||||
opacity: root.volumePopupVisible ? 1 : 0
|
opacity: root.volumePopupVisible ? 1 : 0
|
||||||
scale: root.volumePopupVisible ? 1 : 0.9
|
scale: root.volumePopupVisible ? 1 : 0.9
|
||||||
|
layer.enabled: true
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: volumeContent
|
id: volumeContent
|
||||||
@@ -89,11 +89,11 @@ PanelWindow {
|
|||||||
spacing: Theme.spacingXS
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
property int gap: Theme.spacingS
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 40
|
height: 40
|
||||||
|
|
||||||
property int gap: Theme.spacingS
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: Theme.iconSize
|
width: Theme.iconSize
|
||||||
height: Theme.iconSize
|
height: Theme.iconSize
|
||||||
@@ -104,14 +104,14 @@ PanelWindow {
|
|||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
name: AudioService.sink && AudioService.sink.audio && AudioService.sink.audio.muted ?
|
name: AudioService.sink && AudioService.sink.audio && AudioService.sink.audio.muted ? "volume_off" : "volume_up"
|
||||||
"volume_off" : "volume_up"
|
|
||||||
size: Theme.iconSize
|
size: Theme.iconSize
|
||||||
color: muteButton.containsMouse ? Theme.primary : Theme.surfaceText
|
color: muteButton.containsMouse ? Theme.primary : Theme.surfaceText
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: muteButton
|
id: muteButton
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
@@ -120,10 +120,12 @@ PanelWindow {
|
|||||||
root.resetHideTimer();
|
root.resetHideTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DankSlider {
|
DankSlider {
|
||||||
id: volumeSlider
|
id: volumeSlider
|
||||||
|
|
||||||
width: parent.width - Theme.iconSize - parent.gap * 3
|
width: parent.width - Theme.iconSize - parent.gap * 3
|
||||||
height: 40
|
height: 40
|
||||||
x: parent.gap * 2 + Theme.iconSize
|
x: parent.gap * 2 + Theme.iconSize
|
||||||
@@ -133,33 +135,35 @@ PanelWindow {
|
|||||||
enabled: AudioService.sink && AudioService.sink.audio
|
enabled: AudioService.sink && AudioService.sink.audio
|
||||||
showValue: true
|
showValue: true
|
||||||
unit: "%"
|
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: {
|
Component.onCompleted: {
|
||||||
if (AudioService.sink && AudioService.sink.audio) {
|
if (AudioService.sink && AudioService.sink.audio)
|
||||||
value = Math.round(AudioService.sink.audio.volume * 100);
|
value = Math.round(AudioService.sink.audio.volume * 100);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
onSliderValueChanged: function(newValue) {
|
onSliderValueChanged: function(newValue) {
|
||||||
if (AudioService.sink && AudioService.sink.audio) {
|
if (AudioService.sink && AudioService.sink.audio) {
|
||||||
AudioService.sink.audio.volume = newValue / 100;
|
AudioService.sink.audio.volume = newValue / 100;
|
||||||
root.resetHideTimer();
|
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 {
|
MouseArea {
|
||||||
id: popupMouseArea
|
id: popupMouseArea
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
acceptedButtons: Qt.NoButton
|
acceptedButtons: Qt.NoButton
|
||||||
@@ -167,7 +171,6 @@ PanelWindow {
|
|||||||
z: -1
|
z: -1
|
||||||
}
|
}
|
||||||
|
|
||||||
layer.enabled: true
|
|
||||||
layer.effect: MultiEffect {
|
layer.effect: MultiEffect {
|
||||||
shadowEnabled: true
|
shadowEnabled: true
|
||||||
shadowHorizontalOffset: 0
|
shadowHorizontalOffset: 0
|
||||||
@@ -186,6 +189,7 @@ PanelWindow {
|
|||||||
duration: Theme.mediumDuration
|
duration: Theme.mediumDuration
|
||||||
easing.type: Theme.emphasizedEasing
|
easing.type: Theme.emphasizedEasing
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on scale {
|
Behavior on scale {
|
||||||
@@ -193,6 +197,7 @@ PanelWindow {
|
|||||||
duration: Theme.mediumDuration
|
duration: Theme.mediumDuration
|
||||||
easing.type: Theme.emphasizedEasing
|
easing.type: Theme.emphasizedEasing
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on transform {
|
Behavior on transform {
|
||||||
@@ -200,10 +205,13 @@ PanelWindow {
|
|||||||
duration: Theme.mediumDuration
|
duration: Theme.mediumDuration
|
||||||
easing.type: Theme.emphasizedEasing
|
easing.type: Theme.emphasizedEasing
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mask: Region {
|
mask: Region {
|
||||||
item: volumePopup
|
item: volumePopup
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,8 @@ import QtQuick
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Services.Notifications
|
import Quickshell.Services.Notifications
|
||||||
import qs.Services
|
import qs.Services
|
||||||
|
import qs.Common
|
||||||
|
import "../Common/markdown2html.js" as Markdown2Html
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
@@ -60,8 +62,9 @@ Singleton {
|
|||||||
onNotification: notif => {
|
onNotification: notif => {
|
||||||
notif.tracked = true;
|
notif.tracked = true;
|
||||||
|
|
||||||
|
const shouldShowPopup = !root.popupsDisabled && !Prefs.doNotDisturb;
|
||||||
const wrapper = notifComponent.createObject(root, {
|
const wrapper = notifComponent.createObject(root, {
|
||||||
popup: !root.popupsDisabled,
|
popup: shouldShowPopup,
|
||||||
notification: notif
|
notification: notif
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -70,7 +73,7 @@ Singleton {
|
|||||||
root.notifications.push(wrapper);
|
root.notifications.push(wrapper);
|
||||||
addToPersistentStorage(wrapper);
|
addToPersistentStorage(wrapper);
|
||||||
|
|
||||||
if (!root.popupsDisabled) {
|
if (shouldShowPopup) {
|
||||||
notificationQueue = [...notificationQueue, wrapper];
|
notificationQueue = [...notificationQueue, wrapper];
|
||||||
processQueue();
|
processQueue();
|
||||||
}
|
}
|
||||||
@@ -84,7 +87,6 @@ Singleton {
|
|||||||
property bool popup: false
|
property bool popup: false
|
||||||
property bool removedByLimit: false
|
property bool removedByLimit: false
|
||||||
property bool isPersistent: true
|
property bool isPersistent: true
|
||||||
property int initialOffset: 0
|
|
||||||
property int seq: 0
|
property int seq: 0
|
||||||
|
|
||||||
onPopupChanged: {
|
onPopupChanged: {
|
||||||
@@ -93,7 +95,6 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't override popup in onCompleted - it's set correctly during creation
|
|
||||||
|
|
||||||
readonly property Timer timer: Timer {
|
readonly property Timer timer: Timer {
|
||||||
interval: 5000
|
interval: 5000
|
||||||
@@ -120,14 +121,13 @@ Singleton {
|
|||||||
required property Notification notification
|
required property Notification notification
|
||||||
readonly property string summary: notification.summary
|
readonly property string summary: notification.summary
|
||||||
readonly property string body: notification.body
|
readonly property string body: notification.body
|
||||||
readonly property string appIcon: notification.appIcon
|
readonly property string htmlBody: {
|
||||||
readonly property string cleanAppIcon: {
|
if (body && (body.includes('<') && body.includes('>'))) {
|
||||||
if (!appIcon) return "";
|
return body;
|
||||||
if (appIcon.startsWith("file://")) {
|
|
||||||
return appIcon.substring(7);
|
|
||||||
}
|
}
|
||||||
return appIcon;
|
return Markdown2Html.markdownToHtml(body);
|
||||||
}
|
}
|
||||||
|
readonly property string appIcon: notification.appIcon
|
||||||
readonly property string appName: notification.appName
|
readonly property string appName: notification.appName
|
||||||
readonly property string desktopEntry: notification.desktopEntry
|
readonly property string desktopEntry: notification.desktopEntry
|
||||||
readonly property string image: notification.image
|
readonly property string image: notification.image
|
||||||
@@ -141,7 +141,6 @@ Singleton {
|
|||||||
readonly property int urgency: notification.urgency
|
readonly property int urgency: notification.urgency
|
||||||
readonly property list<NotificationAction> actions: notification.actions
|
readonly property list<NotificationAction> actions: notification.actions
|
||||||
|
|
||||||
// Enhanced properties for better handling
|
|
||||||
readonly property bool hasImage: image && image.length > 0
|
readonly property bool hasImage: image && image.length > 0
|
||||||
readonly property bool hasAppIcon: appIcon && appIcon.length > 0
|
readonly property bool hasAppIcon: appIcon && appIcon.length > 0
|
||||||
|
|
||||||
@@ -159,7 +158,6 @@ Singleton {
|
|||||||
const groupKey = getGroupKey(wrapper);
|
const groupKey = getGroupKey(wrapper);
|
||||||
const remainingInGroup = root.notifications.filter(n => getGroupKey(n) === groupKey);
|
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) {
|
if (remainingInGroup.length <= 1) {
|
||||||
clearGroupExpansionState(groupKey);
|
clearGroupExpansionState(groupKey);
|
||||||
}
|
}
|
||||||
@@ -178,7 +176,6 @@ Singleton {
|
|||||||
NotifWrapper {}
|
NotifWrapper {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper functions
|
|
||||||
function clearAllNotifications() {
|
function clearAllNotifications() {
|
||||||
bulkDismissing = true;
|
bulkDismissing = true;
|
||||||
popupsDisabled = true;
|
popupsDisabled = true;
|
||||||
@@ -198,7 +195,7 @@ Singleton {
|
|||||||
for (let i = 0; i < toDismiss.length; ++i) {
|
for (let i = 0; i < toDismiss.length; ++i) {
|
||||||
const w = toDismiss[i];
|
const w = toDismiss[i];
|
||||||
if (w && w.notification) {
|
if (w && w.notification) {
|
||||||
try { w.notification.dismiss(); } catch (e) { /* ignore */ }
|
try { w.notification.dismiss(); } catch (e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,6 +226,7 @@ Singleton {
|
|||||||
function processQueue() {
|
function processQueue() {
|
||||||
if (addGateBusy) return;
|
if (addGateBusy) return;
|
||||||
if (popupsDisabled) return;
|
if (popupsDisabled) return;
|
||||||
|
if (Prefs.doNotDisturb) return;
|
||||||
if (notificationQueue.length === 0) return;
|
if (notificationQueue.length === 0) return;
|
||||||
|
|
||||||
const [next, ...rest] = notificationQueue;
|
const [next, ...rest] = notificationQueue;
|
||||||
@@ -433,9 +431,10 @@ Singleton {
|
|||||||
}
|
}
|
||||||
return `${group.count} notifications`;
|
return `${group.count} notifications`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGroupBody(group) {
|
function getGroupBody(group) {
|
||||||
if (group.count === 1) {
|
if (group.count === 1) {
|
||||||
return group.latestNotification.body;
|
return group.latestNotification.htmlBody; // Use HTML body
|
||||||
}
|
}
|
||||||
return `Latest: ${group.latestNotification.summary}`;
|
return `Latest: ${group.latestNotification.summary}`;
|
||||||
}
|
}
|
||||||
@@ -446,6 +445,7 @@ Singleton {
|
|||||||
appName: wrapper.appName,
|
appName: wrapper.appName,
|
||||||
summary: wrapper.summary,
|
summary: wrapper.summary,
|
||||||
body: wrapper.body,
|
body: wrapper.body,
|
||||||
|
htmlBody: wrapper.htmlBody, // Store HTML version too
|
||||||
appIcon: wrapper.appIcon,
|
appIcon: wrapper.appIcon,
|
||||||
image: wrapper.image,
|
image: wrapper.image,
|
||||||
urgency: wrapper.urgency,
|
urgency: wrapper.urgency,
|
||||||
@@ -467,19 +467,22 @@ Singleton {
|
|||||||
persistedNotifications = newPersisted;
|
persistedNotifications = newPersisted;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPersistentNotificationsByApp(appName) {
|
|
||||||
return persistedNotifications.filter(notif => notif.appName.toLowerCase() === appName.toLowerCase());
|
Connections {
|
||||||
}
|
target: Prefs
|
||||||
function getPersistentNotificationsByType(type) {
|
function onDoNotDisturbChanged() {
|
||||||
return persistedNotifications;
|
if (Prefs.doNotDisturb) {
|
||||||
}
|
// Hide all current popups when DND is enabled
|
||||||
function searchPersistentNotifications(query) {
|
for (const notif of visibleNotifications) {
|
||||||
const searchLower = query.toLowerCase();
|
notif.popup = false;
|
||||||
return persistedNotifications.filter(notif =>
|
}
|
||||||
notif.appName.toLowerCase().includes(searchLower) ||
|
visibleNotifications = [];
|
||||||
notif.summary.toLowerCase().includes(searchLower) ||
|
notificationQueue = [];
|
||||||
notif.body.toLowerCase().includes(searchLower)
|
} else {
|
||||||
);
|
// Re-enable popup processing when DND is disabled
|
||||||
|
processQueue();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ Image {
|
|||||||
const grabPath = cachePath;
|
const grabPath = cachePath;
|
||||||
if (visible && width > 0 && height > 0 && Window.window && Window.window.visible)
|
if (visible && width > 0 && height > 0 && Window.window && Window.window.visible)
|
||||||
grabToImage((res) => {
|
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.ProcessList
|
||||||
import qs.Modules.ControlCenter.Network
|
import qs.Modules.ControlCenter.Network
|
||||||
import qs.Modules.Lock
|
import qs.Modules.Lock
|
||||||
import qs.Modules.Notifications
|
import qs.Modules.Notifications.Center
|
||||||
|
import qs.Modules.Notifications.Popup
|
||||||
import qs.Modals
|
import qs.Modals
|
||||||
import qs.Services
|
import qs.Services
|
||||||
|
|
||||||
|
|||||||
@@ -16,55 +16,55 @@ else
|
|||||||
ICON_BASE=""
|
ICON_BASE=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test 1: Basic notifications
|
# Test 1: Basic notifications with markdown
|
||||||
echo "📱 Test 1: Basic notifications"
|
echo "📱 Test 1: Basic notifications with markdown"
|
||||||
notify-send -h string:desktop-entry:org.gnome.Settings -i preferences-desktop "Settings" "Basic notification message"
|
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
|
sleep 2
|
||||||
|
|
||||||
# Test 2: Media notifications (should group under Spotify)
|
# Test 2: Media notifications with rich formatting (grouping)
|
||||||
echo "🎵 Test 2: Media notifications (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 - Artist A"
|
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
|
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
|
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
|
sleep 2
|
||||||
|
|
||||||
# Test 3: System notifications (separate groups)
|
# Test 3: System notifications with markdown (separate groups)
|
||||||
echo "🔋 Test 3: System notifications (separate apps)"
|
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"
|
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
|
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
|
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
|
sleep 2
|
||||||
|
|
||||||
# Test 4: Chat notifications (should group under Discord)
|
# Test 4: Chat notifications with complex markdown (grouping)
|
||||||
echo "💬 Test 4: Chat notifications (grouping)"
|
echo "💬 Test 4: Chat notifications with complex markdown (grouping)"
|
||||||
notify-send -h string:desktop-entry:discord -i internet-chat "Discord" "#general: User1 says Hello everyone!"
|
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
|
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
|
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
|
sleep 2
|
||||||
|
|
||||||
# Test 5: Urgent notifications
|
# Test 5: Urgent notifications with markdown
|
||||||
echo "🚨 Test 5: Urgent notifications"
|
echo "🚨 Test 5: Urgent notifications with markdown"
|
||||||
notify-send -u critical -i dialog-warning "Critical Alert" "System overheating detected - Temperature: 85°C"
|
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
|
sleep 2
|
||||||
|
|
||||||
# Test 6: Notifications with actions (simulated)
|
# Test 6: Notifications with actions and markdown
|
||||||
echo "⚡ Test 6: Action buttons"
|
echo "⚡ Test 6: Action buttons with markdown"
|
||||||
notify-send -h string:desktop-entry:org.gnome.Software -i system-upgrade "Software" "Updates available - Click to install or remind later"
|
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
|
sleep 2
|
||||||
|
|
||||||
# Test 7: Multiple different apps
|
# Test 7: Multiple different apps with rich markdown
|
||||||
echo "📊 Test 7: Multiple different apps"
|
echo "📊 Test 7: Multiple different apps with rich markdown"
|
||||||
notify-send -h string:desktop-entry:thunderbird -i mail-message-new "Thunderbird" "You have 3 new emails"
|
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
|
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
|
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
|
sleep 2
|
||||||
|
|
||||||
# notify-send --hint=boolean:resident:true "Resident Test" "Click an action - I should stay visible!" --action="Test Action" --action="Close Me"
|
# 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