notifications working
This commit is contained in:
93
Bar/Time.qml
93
Bar/Time.qml
@@ -1,7 +1,9 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
|
import Quickshell.Services.Notifications
|
||||||
|
|
||||||
import "../Color.js" as Colors
|
import "../Color.js" as Colors
|
||||||
import "../Components/"
|
import "../Components/"
|
||||||
@@ -10,32 +12,121 @@ import "../Services/"
|
|||||||
Container {
|
Container {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property Notification latestNotif
|
||||||
|
property double latestNotifId: latestNotif.id || 0
|
||||||
required property HyprlandMonitor monitor
|
required property HyprlandMonitor monitor
|
||||||
|
property bool notified: false
|
||||||
|
property bool overriden: false
|
||||||
|
|
||||||
boxColor: Colors.mauve
|
boxColor: Colors.mauve
|
||||||
defaultItem: time
|
defaultItem: time
|
||||||
exclusiveMonitor: root.monitor
|
exclusiveMonitor: root.monitor
|
||||||
|
|
||||||
states: [
|
states: [
|
||||||
|
State {
|
||||||
|
name: "closed"
|
||||||
|
when: root.hovered == false && root.overriden == false
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
root.boxHeight: 28
|
||||||
|
root.boxRadius: 9
|
||||||
|
root.boxWidth: 100
|
||||||
|
}
|
||||||
|
|
||||||
|
StateChangeScript {
|
||||||
|
script: {
|
||||||
|
if (root.stack.currentItem.component != "time") {
|
||||||
|
root.stack.replace(time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
State {
|
State {
|
||||||
name: "hovered"
|
name: "hovered"
|
||||||
when: root.hovered == true
|
when: root.hovered == true && root.overriden == false
|
||||||
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
root.boxHeight: 32
|
root.boxHeight: 32
|
||||||
root.boxRadius: 12
|
root.boxRadius: 12
|
||||||
root.boxWidth: 107
|
root.boxWidth: 107
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StateChangeScript {
|
||||||
|
script: {
|
||||||
|
root.stack.replace(time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "notified"
|
||||||
|
when: root.notified == true
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
root.boxHeight: 32
|
||||||
|
root.boxRadius: 12
|
||||||
|
root.boxWidth: 200
|
||||||
|
}
|
||||||
|
|
||||||
|
StateChangeScript {
|
||||||
|
script: {
|
||||||
|
root.stack.replace(notification);
|
||||||
|
console.log("notification");
|
||||||
|
notificationTimer.restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
function onNewNotification() {
|
||||||
|
notification => {
|
||||||
|
if (notification != root.latestNotif) {
|
||||||
|
root.latestNotif = notification;
|
||||||
|
root.overriden = true;
|
||||||
|
root.notified = true;
|
||||||
|
} else {
|
||||||
|
console.log("notif already called");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
target: NotificationManager
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: notificationTimer
|
||||||
|
|
||||||
|
interval: 2000
|
||||||
|
repeat: false
|
||||||
|
running: false
|
||||||
|
|
||||||
|
onTriggered: {
|
||||||
|
root.notified = false;
|
||||||
|
root.overriden = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: time
|
id: time
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
|
property string component: "time"
|
||||||
|
|
||||||
horizontalAlignment: Qt.AlignCenter
|
horizontalAlignment: Qt.AlignCenter
|
||||||
text: Time.time
|
text: Time.time
|
||||||
verticalAlignment: Qt.AlignVCenter
|
verticalAlignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: notification
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
property string component: "notification"
|
||||||
|
|
||||||
|
horizontalAlignment: Qt.AlignCenter
|
||||||
|
text: root.latestNotif.summary
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ Singleton {
|
|||||||
|
|
||||||
property alias notif: server
|
property alias notif: server
|
||||||
|
|
||||||
|
signal newNotification(notificiation: Notification)
|
||||||
|
|
||||||
function getLatestNotification() {
|
function getLatestNotification() {
|
||||||
let notificationList = server.trackedNotifications.values;
|
let notificationList = server.trackedNotifications.values;
|
||||||
let len = notificationList.length;
|
let len = notificationList.length;
|
||||||
@@ -27,6 +29,7 @@ Singleton {
|
|||||||
|
|
||||||
onNotification: notification => {
|
onNotification: notification => {
|
||||||
notification.tracked = true;
|
notification.tracked = true;
|
||||||
|
root.newNotification(notification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user