repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
quickshell/nuguland/features/notifications/fixtures/services/Notifications.qml
Rawimport QtQuick
Item {
// Pure Notifications double: one resident chat notification with an inline
// reply, a draft the double keeps like the service, and a reply that always
// fails. `fixtureState()` reports the draft only as booleans, never its text.
// Closing the popup marks it read; `receive(urgency)` makes it new again.
property bool cleared: false
property bool read: false
property string urgency: "normal"
readonly property int unreadCount: cleared || read ? 0 : 1
property bool dnd: false
property string replyDraft: ""
property string replyError: ""
property bool receivedKnownDraft: false
property int editCount: 0
property int sendCount: 0
property int externalUpdates: 0
property int actionCount: 0
property int discards: 0
// received two minutes before the double loaded, so the card reads "2m".
readonly property real receivedAt: Date.now() - 120000
// Adversarial sender: a desktop id for its name and a file uri for its summary.
property bool machineNames: false
function setMachineNames(enabled) {
machineNames = !!enabled;
}
function notificationRow() {
return {
"id": "notification-fixture",
"appName": machineNames ? "org.gnome.Nautilus" : "fixture chat",
"appIcon": "",
"image": "",
"summary": machineNames ? "file:///home/test/Downloads/report.pdf" : (externalUpdates > 0 ? "fixture message updated" : "fixture message"),
"body": "synthetic notification body",
"time": receivedAt,
"urgency": urgency,
"read": read,
"value": -1,
"resident": true,
"hasInlineReply": true,
"inlineReplyPlaceholder": "reply to fixture",
"actionRows": [],
"replyDraft": replyDraft,
"replyError": replyError
};
}
function groups() {
return cleared ? [] : [
{
"id": "fixture chat",
"appName": "fixture chat",
"count": 1,
"previewCount": 1,
"expanded": false,
"visibleNotifications": [notificationRow()]
}
];
}
function fixtureState() {
return {
"unreadCount": unreadCount,
"urgency": urgency,
"dnd": dnd,
"hasDraft": replyDraft.length > 0,
"knownDraft": receivedKnownDraft,
"edits": editCount,
"sends": sendCount,
"failed": replyError.length > 0,
"externalUpdates": externalUpdates,
"actions": actionCount,
"discards": discards
};
}
function setReplyDraft(id, text) {
replyDraft = String(text || "");
receivedKnownDraft = replyDraft === "fixture-only";
replyError = "";
editCount++;
}
function sendReply(id, text) {
replyDraft = String(text || "");
receivedKnownDraft = replyDraft === "fixture-only";
replyError = "reply not sent";
sendCount++;
}
function runAction(id, actionId) {
actionCount++;
}
function toggleGroup(appName) {
}
function markAllRead() {
read = true;
}
function receive(nextUrgency) {
urgency = String(nextUrgency);
read = false;
}
function toggleDnd() {
dnd = !dnd;
}
function discardAllNotifications() {
discards++;
cleared = true;
replyDraft = "";
replyError = "";
receivedKnownDraft = false;
}
function externalUpdate() {
externalUpdates++;
}
}