notifications working perfectly they look so cool
This commit is contained in:
85
Bar/Time.qml
85
Bar/Time.qml
@@ -1,9 +1,11 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
import Quickshell.Services.Notifications
|
import Quickshell.Services.Notifications
|
||||||
|
import Quickshell.Widgets
|
||||||
|
|
||||||
import "../Color.js" as Colors
|
import "../Color.js" as Colors
|
||||||
import "../Components/"
|
import "../Components/"
|
||||||
@@ -13,8 +15,9 @@ Container {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
property Notification latestNotif
|
property Notification latestNotif
|
||||||
property double latestNotifId: latestNotif.id || 0
|
|
||||||
required property HyprlandMonitor monitor
|
required property HyprlandMonitor monitor
|
||||||
|
property double notificationHeight: 100
|
||||||
|
property double notificationWidth: 350
|
||||||
property bool notified: false
|
property bool notified: false
|
||||||
property bool overriden: false
|
property bool overriden: false
|
||||||
|
|
||||||
@@ -35,6 +38,9 @@ Container {
|
|||||||
|
|
||||||
StateChangeScript {
|
StateChangeScript {
|
||||||
script: {
|
script: {
|
||||||
|
if (!root.stack.currentItem) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (root.stack.currentItem.component != "time") {
|
if (root.stack.currentItem.component != "time") {
|
||||||
root.stack.replace(time);
|
root.stack.replace(time);
|
||||||
}
|
}
|
||||||
@@ -62,15 +68,15 @@ Container {
|
|||||||
when: root.notified == true
|
when: root.notified == true
|
||||||
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
root.boxHeight: 32
|
root.boxHeight: root.notificationHeight
|
||||||
root.boxRadius: 12
|
root.boxRadius: 12
|
||||||
root.boxWidth: 200
|
root.boxWidth: root.notificationWidth
|
||||||
|
root.visibleTopMargin: 5
|
||||||
}
|
}
|
||||||
|
|
||||||
StateChangeScript {
|
StateChangeScript {
|
||||||
script: {
|
script: {
|
||||||
root.stack.replace(notification);
|
root.stack.replace(notification);
|
||||||
console.log("notification");
|
|
||||||
notificationTimer.restart();
|
notificationTimer.restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,12 +86,10 @@ Container {
|
|||||||
Connections {
|
Connections {
|
||||||
function onNewNotification() {
|
function onNewNotification() {
|
||||||
notification => {
|
notification => {
|
||||||
if (notification != root.latestNotif) {
|
if (notification.lastGeneration == false) {
|
||||||
root.latestNotif = notification;
|
root.latestNotif = notification;
|
||||||
root.overriden = true;
|
root.overriden = true;
|
||||||
root.notified = true;
|
root.notified = true;
|
||||||
} else {
|
|
||||||
console.log("notif already called");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -121,12 +125,71 @@ Container {
|
|||||||
Component {
|
Component {
|
||||||
id: notification
|
id: notification
|
||||||
|
|
||||||
StyledText {
|
Item {
|
||||||
property string component: "notification"
|
id: notificationRoot
|
||||||
|
|
||||||
horizontalAlignment: Qt.AlignCenter
|
property double innerMargin: 5
|
||||||
|
property double outerMargin: 6
|
||||||
|
|
||||||
|
function getInnerHeight() {
|
||||||
|
let fullHeight = root.notificationHeight;
|
||||||
|
let fullMargin = notificationRoot.innerMargin + notificationRoot.outerMargin;
|
||||||
|
|
||||||
|
return fullHeight - (fullMargin * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
color: Colors.surface1
|
||||||
|
radius: 9
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
fill: parent
|
||||||
|
margins: notificationRoot.outerMargin
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
Rectangle {
|
||||||
|
Layout.margins: notificationRoot.innerMargin
|
||||||
|
color: Colors.mauve
|
||||||
|
implicitHeight: notificationRoot.getInnerHeight()
|
||||||
|
implicitWidth: notificationRoot.getInnerHeight()
|
||||||
|
radius: 5
|
||||||
|
|
||||||
|
IconImage {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 10
|
||||||
|
source: root.latestNotif.image
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
property double textMargin: 4
|
||||||
|
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.leftMargin: 0
|
||||||
|
Layout.margins: notificationRoot.innerMargin + textMargin
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
color: Colors.text
|
||||||
|
fontSize: 14
|
||||||
text: root.latestNotif.summary
|
text: root.latestNotif.summary
|
||||||
verticalAlignment: Qt.AlignVCenter
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.maximumWidth: root.notificationWidth - ((notificationRoot.outerMargin * 2) + (
|
||||||
|
notificationRoot.innerMargin * 3) + notificationRoot.getInnerHeight())
|
||||||
|
color: Colors.subtext0
|
||||||
|
elide: Qt.ElideRight
|
||||||
|
fontWeight: 5
|
||||||
|
maximumLineCount: 2
|
||||||
|
text: root.latestNotif.body
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ pragma Singleton
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Services.Notifications
|
import Quickshell.Services.Notifications
|
||||||
|
import "../Color.js" as Colors
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
@@ -26,6 +27,7 @@ Singleton {
|
|||||||
actionsSupported: true
|
actionsSupported: true
|
||||||
bodyMarkupSupported: true
|
bodyMarkupSupported: true
|
||||||
bodySupported: true
|
bodySupported: true
|
||||||
|
imageSupported: true
|
||||||
|
|
||||||
onNotification: notification => {
|
onNotification: notification => {
|
||||||
notification.tracked = true;
|
notification.tracked = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user