qml format
This commit is contained in:
parent
9418d94f6d
commit
eda4bc8a6a
4 changed files with 159 additions and 161 deletions
|
|
@ -25,7 +25,7 @@ PanelWindow {
|
||||||
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
||||||
|
|
||||||
// Use the notification service
|
// Use the notification service
|
||||||
property var notificationService: NotificationService { }
|
property var notificationService: NotificationService {}
|
||||||
|
|
||||||
// Access the notification model from the service
|
// Access the notification model from the service
|
||||||
property ListModel notificationModel: notificationService.notificationModel
|
property ListModel notificationModel: notificationService.notificationModel
|
||||||
|
|
@ -35,7 +35,7 @@ PanelWindow {
|
||||||
|
|
||||||
// Connect to animation signal from service
|
// Connect to animation signal from service
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
notificationService.animateAndRemove.connect(function(notification, index) {
|
notificationService.animateAndRemove.connect(function (notification, index) {
|
||||||
// Find the delegate and trigger its animation
|
// Find the delegate and trigger its animation
|
||||||
if (notificationStack.children && notificationStack.children[index]) {
|
if (notificationStack.children && notificationStack.children[index]) {
|
||||||
let delegate = notificationStack.children[index]
|
let delegate = notificationStack.children[index]
|
||||||
|
|
@ -46,8 +46,6 @@ PanelWindow {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Main notification container
|
// Main notification container
|
||||||
Column {
|
Column {
|
||||||
id: notificationStack
|
id: notificationStack
|
||||||
|
|
@ -57,8 +55,6 @@ PanelWindow {
|
||||||
width: 360 * scaling
|
width: 360 * scaling
|
||||||
visible: true
|
visible: true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Multiple notifications display
|
// Multiple notifications display
|
||||||
Repeater {
|
Repeater {
|
||||||
model: notificationModel
|
model: notificationModel
|
||||||
|
|
@ -126,8 +122,6 @@ PanelWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: contentColumn
|
id: contentColumn
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -142,12 +136,15 @@ PanelWindow {
|
||||||
font.pointSize: Style.fontSizeSmall
|
font.pointSize: Style.fontSizeSmall
|
||||||
}
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: 6 * scaling; height: 6 * scaling; radius: 3 * scaling
|
width: 6 * scaling
|
||||||
color: (model.urgency === NotificationUrgency.Critical) ? Colors.error :
|
height: 6 * scaling
|
||||||
(model.urgency === NotificationUrgency.Low) ? Colors.textSecondary : Colors.accentPrimary
|
radius: 3 * scaling
|
||||||
|
color: (model.urgency === NotificationUrgency.Critical) ? Colors.error : (model.urgency === NotificationUrgency.Low) ? Colors.textSecondary : Colors.accentPrimary
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
Item { Layout.fillWidth: true }
|
Item {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
NText {
|
NText {
|
||||||
text: notificationService.formatTimestamp(model.timestamp)
|
text: notificationService.formatTimestamp(model.timestamp)
|
||||||
color: Colors.textSecondary
|
color: Colors.textSecondary
|
||||||
|
|
@ -182,7 +179,7 @@ PanelWindow {
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.margins: Style.marginSmall * scaling
|
anchors.margins: Style.marginSmall * scaling
|
||||||
icon: "close"
|
icon: "close"
|
||||||
onClicked: function() {
|
onClicked: function () {
|
||||||
animateOut()
|
animateOut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,9 @@ NBox {
|
||||||
anchors.margins: Style.marginMedium * scaling
|
anchors.margins: Style.marginMedium * scaling
|
||||||
spacing: Style.marginMedium * scaling
|
spacing: Style.marginMedium * scaling
|
||||||
|
|
||||||
Item { height: Style.marginLarge * scaling }
|
Item {
|
||||||
|
height: Style.marginLarge * scaling
|
||||||
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: "music_note"
|
text: "music_note"
|
||||||
|
|
@ -38,6 +40,8 @@ NBox {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
Item { height: Style.marginLarge * scaling }
|
Item {
|
||||||
|
height: Style.marginLarge * scaling
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import QtQuick
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import Quickshell.Services.Notifications
|
import Quickshell.Services.Notifications
|
||||||
|
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
|
@ -23,13 +22,13 @@ QtObject {
|
||||||
bodyImagesSupported: true
|
bodyImagesSupported: true
|
||||||
|
|
||||||
// Signal when notification is received
|
// Signal when notification is received
|
||||||
onNotification: function(notification) {
|
onNotification: function (notification) {
|
||||||
|
|
||||||
// Track the notification
|
// Track the notification
|
||||||
notification.tracked = true
|
notification.tracked = true
|
||||||
|
|
||||||
// Connect to closed signal for cleanup
|
// Connect to closed signal for cleanup
|
||||||
notification.closed.connect(function() {
|
notification.closed.connect(function () {
|
||||||
root.removeNotification(notification)
|
root.removeNotification(notification)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -39,7 +38,7 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
// List model to hold notifications
|
// List model to hold notifications
|
||||||
property ListModel notificationModel: ListModel { }
|
property ListModel notificationModel: ListModel {}
|
||||||
|
|
||||||
// Maximum visible notifications
|
// Maximum visible notifications
|
||||||
property int maxVisible: 5
|
property int maxVisible: 5
|
||||||
|
|
@ -67,12 +66,12 @@ QtObject {
|
||||||
// Function to add notification to model
|
// Function to add notification to model
|
||||||
function addNotification(notification) {
|
function addNotification(notification) {
|
||||||
notificationModel.insert(0, {
|
notificationModel.insert(0, {
|
||||||
rawNotification: notification,
|
"rawNotification": notification,
|
||||||
summary: notification.summary,
|
"summary": notification.summary,
|
||||||
body: notification.body,
|
"body": notification.body,
|
||||||
appName: notification.appName,
|
"appName": notification.appName,
|
||||||
urgency: notification.urgency,
|
"urgency": notification.urgency,
|
||||||
timestamp: new Date()
|
"timestamp": new Date()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Remove oldest notifications if we exceed maxVisible
|
// Remove oldest notifications if we exceed maxVisible
|
||||||
|
|
@ -90,7 +89,7 @@ QtObject {
|
||||||
|
|
||||||
// Function to remove notification from model
|
// Function to remove notification from model
|
||||||
function removeNotification(notification) {
|
function removeNotification(notification) {
|
||||||
for (let i = 0; i < notificationModel.count; i++) {
|
for (var i = 0; i < notificationModel.count; i++) {
|
||||||
if (notificationModel.get(i).rawNotification === notification) {
|
if (notificationModel.get(i).rawNotification === notification) {
|
||||||
// Emit signal to trigger animation first
|
// Emit signal to trigger animation first
|
||||||
animateAndRemove(notification, i)
|
animateAndRemove(notification, i)
|
||||||
|
|
@ -101,7 +100,7 @@ QtObject {
|
||||||
|
|
||||||
// Function to actually remove notification after animation
|
// Function to actually remove notification after animation
|
||||||
function forceRemoveNotification(notification) {
|
function forceRemoveNotification(notification) {
|
||||||
for (let i = 0; i < notificationModel.count; i++) {
|
for (var i = 0; i < notificationModel.count; i++) {
|
||||||
if (notificationModel.get(i).rawNotification === notification) {
|
if (notificationModel.get(i).rawNotification === notification) {
|
||||||
notificationModel.remove(i)
|
notificationModel.remove(i)
|
||||||
break
|
break
|
||||||
|
|
@ -111,7 +110,8 @@ QtObject {
|
||||||
|
|
||||||
// Function to format timestamp
|
// Function to format timestamp
|
||||||
function formatTimestamp(timestamp) {
|
function formatTimestamp(timestamp) {
|
||||||
if (!timestamp) return ""
|
if (!timestamp)
|
||||||
|
return ""
|
||||||
|
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const diff = now - timestamp
|
const diff = now - timestamp
|
||||||
|
|
@ -119,18 +119,15 @@ QtObject {
|
||||||
// Less than 1 minute
|
// Less than 1 minute
|
||||||
if (diff < 60000) {
|
if (diff < 60000) {
|
||||||
return "now"
|
return "now"
|
||||||
}
|
} // Less than 1 hour
|
||||||
// Less than 1 hour
|
|
||||||
else if (diff < 3600000) {
|
else if (diff < 3600000) {
|
||||||
const minutes = Math.floor(diff / 60000)
|
const minutes = Math.floor(diff / 60000)
|
||||||
return `${minutes}m ago`
|
return `${minutes}m ago`
|
||||||
}
|
} // Less than 24 hours
|
||||||
// Less than 24 hours
|
|
||||||
else if (diff < 86400000) {
|
else if (diff < 86400000) {
|
||||||
const hours = Math.floor(diff / 3600000)
|
const hours = Math.floor(diff / 3600000)
|
||||||
return `${hours}h ago`
|
return `${hours}h ago`
|
||||||
}
|
} // More than 24 hours
|
||||||
// More than 24 hours
|
|
||||||
else {
|
else {
|
||||||
const days = Math.floor(diff / 86400000)
|
const days = Math.floor(diff / 86400000)
|
||||||
return `${days}d ago`
|
return `${days}d ago`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue