Files
Quickbar/NotificationsWidget.qml
2025-10-09 22:32:48 -03:00

99 lines
2.7 KiB
QML

import QtQuick
import Quickshell
import Quickshell.Widgets
import qs.Services
import qs.Common
import qs.Common.Styled
import qs.Widgets
Item {
id: root
property var monitor: ""
property bool createWindow: false
property string notificationIcon: ""
MarginWrapperManager {
rightMargin: Theme.gaps
leftMargin: Theme.gaps
}
states: [
State {
name: "MuteActive"
when: NotificationService.notificationsMuted && NotificationService.notificationsNumber
PropertyChanges {
root.notificationIcon : "\udb80\udc9b " + NotificationService.notificationsNumber
}
},
State {
name: "Active"
when: !NotificationService.notificationsMuted && NotificationService.notificationsNumber
PropertyChanges {
root.notificationIcon : "\udb80\udc9a " + NotificationService.notificationsNumber
}
},
State {
name: "MuteEmpty"
when: NotificationService.notificationsMuted
PropertyChanges {
root.notificationIcon : "\uec08"
}
},
State {
name: "Empty"
when: !NotificationService.notificationsMuted && !NotificationService.notificationsNumber
PropertyChanges {
root.notificationIcon : "\ueaa2"
}
}
]
Binding {
target: root
property: "createWindow"
value: NotificationService.notificationsNumber > 0 && root.createWindow
}
BackgroundRectangle {
color: Theme.backgroudColor
implicitWidth: 60
implicitHeight: Theme.heightGaps
radius: 25
StyledText {
id: notifText
anchors.fill: parent
text: root.notificationIcon + " "
// text: {
// NotificationService.notificationsNumber > 0 ? "\udb80\udc9a " + NotificationService.notificationsNumber : "\ueaa2";
// }
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: mouse => {
if (mouse.button === Qt.RightButton) {
NotificationService.notificationsMuted = !NotificationService.notificationsMuted
return;
}
root.createWindow = !root.createWindow;
}
}
}
LazyLoader {
id: windowLoader
activeAsync: NotificationService.notificationsNumber ? createWindow : false
component: NotificationWindow {
onClear: root.createWindow = false
}
}
}