97 lines
2.5 KiB
QML
97 lines
2.5 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
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
|
|
}
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
onClicked: mouse => {
|
|
if (mouse.button === Qt.RightButton) {
|
|
NotificationService.manualNotificationsMuted = !NotificationService.manualNotificationsMuted;
|
|
return;
|
|
}
|
|
root.createWindow = !root.createWindow;
|
|
}
|
|
}
|
|
}
|
|
|
|
LazyLoader {
|
|
id: windowLoader
|
|
|
|
active: NotificationService.notificationsNumber ? root.createWindow : false
|
|
|
|
component: NotificationWindow {
|
|
onClear: root.createWindow = false
|
|
}
|
|
}
|
|
}
|