qml format

This commit is contained in:
quadbyte 2025-08-10 17:04:51 -04:00
parent 9418d94f6d
commit eda4bc8a6a
4 changed files with 159 additions and 161 deletions

View file

@ -46,8 +46,6 @@ PanelWindow {
})
}
// Main notification container
Column {
id: notificationStack
@ -57,8 +55,6 @@ PanelWindow {
width: 360 * scaling
visible: true
// Multiple notifications display
Repeater {
model: notificationModel
@ -126,8 +122,6 @@ PanelWindow {
}
}
Column {
id: contentColumn
anchors.fill: parent
@ -142,12 +136,15 @@ PanelWindow {
font.pointSize: Style.fontSizeSmall
}
Rectangle {
width: 6 * scaling; height: 6 * scaling; radius: 3 * scaling
color: (model.urgency === NotificationUrgency.Critical) ? Colors.error :
(model.urgency === NotificationUrgency.Low) ? Colors.textSecondary : Colors.accentPrimary
width: 6 * scaling
height: 6 * scaling
radius: 3 * scaling
color: (model.urgency === NotificationUrgency.Critical) ? Colors.error : (model.urgency === NotificationUrgency.Low) ? Colors.textSecondary : Colors.accentPrimary
Layout.alignment: Qt.AlignVCenter
}
Item { Layout.fillWidth: true }
Item {
Layout.fillWidth: true
}
NText {
text: notificationService.formatTimestamp(model.timestamp)
color: Colors.textSecondary

View file

@ -22,7 +22,9 @@ NBox {
anchors.margins: Style.marginMedium * scaling
spacing: Style.marginMedium * scaling
Item { height: Style.marginLarge * scaling }
Item {
height: Style.marginLarge * scaling
}
Text {
text: "music_note"
@ -38,6 +40,8 @@ NBox {
anchors.horizontalCenter: parent.horizontalCenter
}
Item { height: Style.marginLarge * scaling }
Item {
height: Style.marginLarge * scaling
}
}
}

View file

@ -2,7 +2,6 @@ import QtQuick
import qs.Services
import Quickshell.Services.Notifications
QtObject {
id: root
@ -67,12 +66,12 @@ QtObject {
// Function to add notification to model
function addNotification(notification) {
notificationModel.insert(0, {
rawNotification: notification,
summary: notification.summary,
body: notification.body,
appName: notification.appName,
urgency: notification.urgency,
timestamp: new Date()
"rawNotification": notification,
"summary": notification.summary,
"body": notification.body,
"appName": notification.appName,
"urgency": notification.urgency,
"timestamp": new Date()
})
// Remove oldest notifications if we exceed maxVisible
@ -90,7 +89,7 @@ QtObject {
// Function to remove notification from model
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) {
// Emit signal to trigger animation first
animateAndRemove(notification, i)
@ -101,7 +100,7 @@ QtObject {
// Function to actually remove notification after animation
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) {
notificationModel.remove(i)
break
@ -111,7 +110,8 @@ QtObject {
// Function to format timestamp
function formatTimestamp(timestamp) {
if (!timestamp) return ""
if (!timestamp)
return ""
const now = new Date()
const diff = now - timestamp
@ -119,18 +119,15 @@ QtObject {
// Less than 1 minute
if (diff < 60000) {
return "now"
}
// Less than 1 hour
} // Less than 1 hour
else if (diff < 3600000) {
const minutes = Math.floor(diff / 60000)
return `${minutes}m ago`
}
// Less than 24 hours
} // Less than 24 hours
else if (diff < 86400000) {
const hours = Math.floor(diff / 3600000)
return `${hours}h ago`
}
// More than 24 hours
} // More than 24 hours
else {
const days = Math.floor(diff / 86400000)
return `${days}d ago`