mirror of
https://github.com/tomasriveral/nixos.git
synced 2026-08-12 02:28:37 +02:00
worked on the notification center
This commit is contained in:
@@ -12,10 +12,18 @@ Singleton {
|
|||||||
PanelWindow {
|
PanelWindow {
|
||||||
id: window
|
id: window
|
||||||
visible: false
|
visible: false
|
||||||
|
implicitWidth: notificationCenter.width
|
||||||
|
implicitHeight: notificationCenter.height
|
||||||
|
anchors.right: notificationCenter.right
|
||||||
|
anchors.top: notificationCenter.top
|
||||||
|
|
||||||
Notifs.NotificationCenterView {
|
Notifs.NotificationCenterView {
|
||||||
id: notificationCenter
|
id: notificationCenter
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
//width: 500
|
||||||
|
//anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,64 +3,141 @@ import QtQuick.Controls
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
|
import "../theme" as Theme
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
width: 1000
|
width: 500
|
||||||
height: 800
|
height: 1000
|
||||||
color: "black"
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
color: Theme.Colors.notificationCenterColor1
|
||||||
visible: false
|
visible: false
|
||||||
// Toggle the notification center visibility
|
|
||||||
|
ListModel {
|
||||||
|
id: notificationsModel
|
||||||
|
}
|
||||||
|
|
||||||
function toggleNotificationCenter() {
|
function toggleNotificationCenter() {
|
||||||
root.visible = !root.visible
|
root.visible = !root.visible
|
||||||
console.log("DEBUG: Toggled NotificationCenter. Visible =", root.visible)
|
if (root.visible)
|
||||||
if (root.visible) {
|
|
||||||
reload()
|
reload()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FileView for reading the notification cache
|
|
||||||
FileView {
|
FileView {
|
||||||
id: historyFile
|
id: historyFile
|
||||||
path: Quickshell.env("HOME") + "/.cache/notify_history"
|
path: Quickshell.env("HOME") + "/.cache/notify_history"
|
||||||
blockLoading: true
|
blockLoading: true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reload notifications from the file
|
|
||||||
function reload() {
|
function reload() {
|
||||||
root.visible = true
|
notificationsModel.clear()
|
||||||
/*var text = historyFile.text()
|
|
||||||
if (!text || text.length === 0) {
|
var text = historyFile.text()
|
||||||
console.log("DEBUG: Notification file empty")
|
if (!text || text.length === 0)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
var lines = text.split("\n")
|
||||||
|
var i = 1
|
||||||
|
|
||||||
|
while (i < lines.length) {
|
||||||
|
|
||||||
|
var app = lines[i++] || ""
|
||||||
|
var title = lines[i++] || ""
|
||||||
|
var bodyLines = []
|
||||||
|
|
||||||
|
while (i < lines.length && !/^\d{2}:\d{2}:\d{2}$/.test(lines[i])) {
|
||||||
|
bodyLines.push(lines[i++])
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= lines.length)
|
||||||
|
break
|
||||||
|
|
||||||
|
var time = lines[i++] || ""
|
||||||
|
var urgency = lines[i++] || "normal"
|
||||||
|
var body = bodyLines.join("\n")
|
||||||
|
|
||||||
|
notificationsModel.append({
|
||||||
|
app: app,
|
||||||
|
title: title,
|
||||||
|
body: body,
|
||||||
|
time: time,
|
||||||
|
urgency: urgency
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("DEBUG: Raw notification file content:\n" + text)
|
Component.onCompleted: reload()
|
||||||
var lines = text.split("\n")
|
ListView {
|
||||||
console.log("DEBUG: Total lines in file:", lines.length)
|
id: listView
|
||||||
|
anchors.fill: parent
|
||||||
|
model: notificationsModel
|
||||||
|
spacing: 10
|
||||||
|
clip: true
|
||||||
|
|
||||||
var i = 1
|
Component.onCompleted: {
|
||||||
while (i < lines.length) {
|
console.log("DISPLAY DEBUG: ListView created")
|
||||||
var app = lines[i++] || ""
|
console.log("DISPLAY DEBUG: Model count =", notificationsModel.count)
|
||||||
var title = lines[i++] || ""
|
console.log("DISPLAY DEBUG: View width =", width, "height =", height)
|
||||||
var bodyLines = []
|
}
|
||||||
|
|
||||||
while (i < lines.length && !/^\d{2}:\d{2}:\d{2}$/.test(lines[i])) {
|
onCountChanged: {
|
||||||
bodyLines.push(lines[i++])
|
console.log("DISPLAY DEBUG: ListView count changed ->", count)
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: Rectangle {
|
||||||
|
width: ListView.view.width
|
||||||
|
color: "transparent"
|
||||||
|
border.color: "transparent"
|
||||||
|
border.width: 1
|
||||||
|
radius: 4
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
console.log("DISPLAY DEBUG: Delegate created")
|
||||||
|
console.log("DISPLAY DEBUG: app =", app)
|
||||||
|
console.log("DISPLAY DEBUG: title =", title)
|
||||||
|
console.log("DISPLAY DEBUG: body =", body)
|
||||||
|
console.log("DISPLAY DEBUG: delegate width =", width)
|
||||||
|
console.log("DISPLAY DEBUG: delegate height=", height)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= lines.length) break
|
Column {
|
||||||
|
id: columnContent
|
||||||
|
//anchors.fill: parent
|
||||||
|
anchors.margins: 8
|
||||||
|
spacing: 4
|
||||||
|
|
||||||
var time = lines[i++] || ""
|
Text {
|
||||||
var urgency = lines[i++] || "normal"
|
text: time + " | " + app
|
||||||
var body = bodyLines.join("\n")
|
color: "black"
|
||||||
|
width: ListView.view.width - 16
|
||||||
|
Component.onCompleted: {
|
||||||
|
console.log("DISPLAY DEBUG: time/app text created:", text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log("DEBUG: Parsed notification:", app, title, body, time, urgency)
|
Text {
|
||||||
|
text: title
|
||||||
|
color: "black"
|
||||||
|
font.bold: true
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
width: ListView.view.width - 16
|
||||||
|
Component.onCompleted: {
|
||||||
|
console.log("DISPLAY DEBUG: title text created:", text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}*/
|
Text {
|
||||||
}
|
text: body
|
||||||
Component.onCompleted: {
|
color: "black"
|
||||||
console.log("DEBUG: NotificationCenterView component loaded")
|
wrapMode: Text.Wrap
|
||||||
reload()
|
width: ListView.view.width - 16
|
||||||
|
Component.onCompleted: {
|
||||||
|
console.log("DISPLAY DEBUG: body text created:", text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
height: 100 + columnContent.implicitHeight // necessary gives the height for the delegate
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,4 +78,5 @@ QtObject {
|
|||||||
readonly property color notifsOverlayColor1: transparent // original color: "transparent"
|
readonly property color notifsOverlayColor1: transparent // original color: "transparent"
|
||||||
readonly property color screenshotOverlayColor1: "#44000000" // original color: "#44000000"
|
readonly property color screenshotOverlayColor1: "#44000000" // original color: "#44000000"
|
||||||
readonly property color screenshotOverlayColor2: woodBrown // original color: "#824524"
|
readonly property color screenshotOverlayColor2: woodBrown // original color: "#824524"
|
||||||
}
|
readonly property color notificationCenterColor1: "black"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user