mirror of
https://github.com/tomasriveral/nixos.git
synced 2026-08-11 18:18:37 +02:00
worked on QML and other minor details
This commit is contained in:
@@ -15,7 +15,6 @@ Item {
|
||||
|
||||
ColumnLayout {
|
||||
id: layout
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
@@ -30,15 +29,23 @@ Item {
|
||||
smooth: false
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Item {
|
||||
id: bannerRect
|
||||
|
||||
color: Theme.Colors.background
|
||||
//color: "transparent" //Theme.Colors.background
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: textColumn.height
|
||||
implicitHeight: textColumn.implicitHeight
|
||||
Layout.leftMargin: (width / trumpetTop.sourceSize.width) * 2 + 3
|
||||
Layout.rightMargin: (width / trumpetTop.sourceSize.width) * 2 + 3
|
||||
|
||||
Image {
|
||||
//anchors.right: parent.right
|
||||
height: textColumn.height
|
||||
width: textColumn.width
|
||||
source: "../assets/wood.png"
|
||||
smooth: false
|
||||
//opacity: 0.4
|
||||
}
|
||||
ColumnLayout {
|
||||
id: textColumn
|
||||
|
||||
@@ -69,7 +76,7 @@ Item {
|
||||
text: root.notif ? root.notif.summary + (root.notif.body ? "\n" : "") : ""
|
||||
font.family: "BigBlueTermPlusNerdFont"
|
||||
wrapMode: Text.Wrap
|
||||
font.pointSize: 18
|
||||
font.pointSize: 14
|
||||
font.bold: true
|
||||
color: Theme.Colors.displayColor1
|
||||
}
|
||||
@@ -78,7 +85,9 @@ Item {
|
||||
text: root.notif ? root.notif.body : ""
|
||||
font.family: "BigBlueTermPlusNerdFont"
|
||||
wrapMode: Text.Wrap
|
||||
font.pointSize: 14
|
||||
Layout.maximumWidth: bannerRect.width
|
||||
Layout.fillWidth: true
|
||||
font.pointSize: 11
|
||||
font.bold: false
|
||||
color: Theme.Colors.displayColor2
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "." as Notifs
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
PanelWindow {
|
||||
id: window
|
||||
visible: false
|
||||
|
||||
Notifs.NotificationCenterView {
|
||||
id: notificationCenter
|
||||
anchors.right: parent.right
|
||||
}
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "notifications"
|
||||
|
||||
function toggle() {
|
||||
window.visible = !window.visible
|
||||
if (window.visible)
|
||||
notificationCenter.reload()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
width: 1000
|
||||
height: 800
|
||||
color: "black"
|
||||
visible: false
|
||||
// Toggle the notification center visibility
|
||||
function toggleNotificationCenter() {
|
||||
root.visible = !root.visible
|
||||
console.log("DEBUG: Toggled NotificationCenter. Visible =", root.visible)
|
||||
if (root.visible) {
|
||||
reload()
|
||||
}
|
||||
}
|
||||
|
||||
// FileView for reading the notification cache
|
||||
FileView {
|
||||
id: historyFile
|
||||
path: Quickshell.env("HOME") + "/.cache/notify_history"
|
||||
blockLoading: true
|
||||
}
|
||||
|
||||
// Reload notifications from the file
|
||||
function reload() {
|
||||
root.visible = true
|
||||
/*var text = historyFile.text()
|
||||
if (!text || text.length === 0) {
|
||||
console.log("DEBUG: Notification file empty")
|
||||
return
|
||||
}
|
||||
|
||||
console.log("DEBUG: Raw notification file content:\n" + text)
|
||||
var lines = text.split("\n")
|
||||
console.log("DEBUG: Total lines in file:", lines.length)
|
||||
|
||||
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")
|
||||
|
||||
console.log("DEBUG: Parsed notification:", app, title, body, time, urgency)
|
||||
|
||||
}*/
|
||||
}
|
||||
Component.onCompleted: {
|
||||
console.log("DEBUG: NotificationCenterView component loaded")
|
||||
reload()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "." as Notifs
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
property bool isOpen: false
|
||||
|
||||
IpcHandler {
|
||||
target: "notifications"
|
||||
|
||||
function open() {
|
||||
root.isOpen = true
|
||||
}
|
||||
|
||||
function close() {
|
||||
root.isOpen = false
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
root.isOpen = !root.isOpen
|
||||
}
|
||||
}
|
||||
|
||||
LazyLoader {
|
||||
id: loader
|
||||
active: root.isOpen
|
||||
Notifs.NotificationCenterView {
|
||||
id: notificationCenter
|
||||
anchors.centerIn: parent
|
||||
width: 1000
|
||||
height: 800
|
||||
visible: true
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
// Empty init function to ensure singleton is loaded
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
width: 1000
|
||||
height: 800
|
||||
color: "black"
|
||||
|
||||
// Use ListModel so Repeater updates automatically
|
||||
ListModel {
|
||||
id: notificationsModel
|
||||
}
|
||||
// Toggle the notification center visibility
|
||||
function toggleNotificationCenter() {
|
||||
root.visible = !root.visible
|
||||
console.log("DEBUG: Toggled NotificationCenter. Visible =", root.visible)
|
||||
if (root.visible) {
|
||||
reload()
|
||||
}
|
||||
}
|
||||
|
||||
// FileView for reading the notification cache
|
||||
FileView {
|
||||
id: historyFile
|
||||
path: Quickshell.env("HOME") + "/.cache/notify_history"
|
||||
blockLoading: true
|
||||
}
|
||||
|
||||
// Reload notifications from the file
|
||||
function reload() {
|
||||
notificationsModel.clear()
|
||||
var text = historyFile.text()
|
||||
if (!text || text.length === 0) {
|
||||
console.log("DEBUG: Notification file empty")
|
||||
return
|
||||
}
|
||||
|
||||
console.log("DEBUG: Raw notification file content:\n" + text)
|
||||
var lines = text.split("\n")
|
||||
console.log("DEBUG: Total lines in file:", lines.length)
|
||||
|
||||
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")
|
||||
|
||||
console.log("DEBUG: Parsed notification:", app, title, body, time, urgency)
|
||||
|
||||
notificationsModel.insert(0, { app: app, title: title, body: body, time: time, urgency: urgency })
|
||||
}
|
||||
|
||||
console.log("DEBUG: Total notifications loaded:", notificationsModel.count)
|
||||
}
|
||||
Component.onCompleted: {
|
||||
console.log("DEBUG: NotificationCenter component completed")
|
||||
reload()
|
||||
}
|
||||
|
||||
// Scrollable list of notifications
|
||||
ScrollView {
|
||||
anchors.fill: parent
|
||||
|
||||
ColumnLayout {
|
||||
id: list
|
||||
width: parent.width
|
||||
spacing: 8
|
||||
Repeater {
|
||||
model: notificationsModel
|
||||
delegate: Rectangle {
|
||||
width: list.width
|
||||
height: columnContent.implicitHeight + 20
|
||||
color: "transparent"
|
||||
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
source: "../assets/wood.png"
|
||||
fillMode: Image.Stretch
|
||||
z: 0
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: columnContent
|
||||
width: parent.width
|
||||
//anchors.fill: parent
|
||||
anchors.margins: 10
|
||||
z: 1
|
||||
|
||||
Text {
|
||||
text: time + " | " + app
|
||||
color: urgency === "critical" ? "red" : "white"
|
||||
}
|
||||
|
||||
Text {
|
||||
text: title
|
||||
font.bold: true
|
||||
color: urgency === "critical" ? "red" : "white"
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
Text {
|
||||
text: body
|
||||
wrapMode: Text.Wrap
|
||||
color: urgency === "critical" ? "red" : "white"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,14 @@ pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Services.Notifications
|
||||
import "../theme" as Theme
|
||||
import "."
|
||||
|
||||
|
||||
|
||||
PanelWindow {
|
||||
id: root
|
||||
|
||||
@@ -23,8 +26,13 @@ PanelWindow {
|
||||
bottom: true
|
||||
right: true
|
||||
}
|
||||
|
||||
Process {
|
||||
id: notifLogger
|
||||
}
|
||||
NotificationServer {
|
||||
|
||||
|
||||
|
||||
actionsSupported: true
|
||||
|
||||
onNotification: notif => {
|
||||
@@ -33,6 +41,9 @@ PanelWindow {
|
||||
if (notif) {
|
||||
notif.tracked = true;
|
||||
root.notifs = [...root.notifs, notif];
|
||||
|
||||
notifLogger.command = ["QS-notifyhistory", notif.appName, notif.summary, notif.body, notif.urgency]
|
||||
notifLogger.running = true // logs the notification for later
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,10 @@ ShellRoot {
|
||||
bar: bar
|
||||
}
|
||||
|
||||
Component.onCompleted: () => {
|
||||
Component.onCompleted: {
|
||||
//Launcher.Controller.init();
|
||||
Screenshot.Controller.init();
|
||||
//Lock.Controller.init();
|
||||
}
|
||||
Notifs.NotificationCenter.init();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user