add notification icon pills to lock screen
This commit is contained in:
parent
a35f451fc0
commit
a17a365b81
4 changed files with 76 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ import Quickshell.Services.Mpris
|
|||
import Quickshell.Services.Pipewire
|
||||
import "../services" as S
|
||||
import "../applets" as C
|
||||
import "../modules" as M
|
||||
|
||||
WlSessionLockSurface {
|
||||
id: root
|
||||
|
|
@ -141,6 +142,74 @@ WlSessionLockSurface {
|
|||
}
|
||||
}
|
||||
|
||||
// Notification pills
|
||||
Row {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: 6
|
||||
visible: (S.Modules.lock.notifications ?? true) && _notifGroups.length > 0
|
||||
|
||||
readonly property var _notifGroups: {
|
||||
const notifs = M.NotifService.list.filter(n => n.state !== "dismissed");
|
||||
const groups = {};
|
||||
for (const n of notifs) {
|
||||
const key = n.appIcon || n.appName || "unknown";
|
||||
if (!groups[key])
|
||||
groups[key] = {
|
||||
icon: n.appIcon,
|
||||
name: n.appName,
|
||||
count: 0
|
||||
};
|
||||
groups[key].count++;
|
||||
}
|
||||
return Object.values(groups);
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: parent._notifGroups
|
||||
|
||||
delegate: Rectangle {
|
||||
required property var modelData
|
||||
width: _pillRow.implicitWidth + 12
|
||||
height: 24
|
||||
radius: 12
|
||||
color: Qt.rgba(S.Theme.base01.r, S.Theme.base01.g, S.Theme.base01.b, 0.7)
|
||||
border.color: Qt.rgba(S.Theme.base03.r, S.Theme.base03.g, S.Theme.base03.b, 0.3)
|
||||
border.width: 1
|
||||
|
||||
Row {
|
||||
id: _pillRow
|
||||
anchors.centerIn: parent
|
||||
spacing: 4
|
||||
|
||||
Image {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 14
|
||||
height: 14
|
||||
source: {
|
||||
const icon = modelData.icon;
|
||||
if (!icon)
|
||||
return "";
|
||||
if (icon.startsWith("/"))
|
||||
return icon;
|
||||
return Quickshell.iconPath(icon) ?? "";
|
||||
}
|
||||
sourceSize: Qt.size(14, 14)
|
||||
visible: source !== ""
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: modelData.count > 1 ? modelData.count.toString() : ""
|
||||
color: S.Theme.base04
|
||||
font.pixelSize: S.Theme.fontSize - 2
|
||||
font.family: S.Theme.fontFamily
|
||||
visible: modelData.count > 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Spacer
|
||||
Item {
|
||||
width: 1
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ QtObject {
|
|||
property var lock: ({
|
||||
enable: true,
|
||||
screenshot: true,
|
||||
notifications: true,
|
||||
mpris: true,
|
||||
volume: true
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue