forked from Shinonome/dots-hyprland
notifications: add silent button
This commit is contained in:
@@ -17,6 +17,7 @@ Item {
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: statusRow.top
|
||||
anchors.bottomMargin: 5
|
||||
|
||||
clip: true
|
||||
layer.enabled: true
|
||||
@@ -65,17 +66,24 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Item {
|
||||
id: statusRow
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: Math.max(
|
||||
controls.implicitHeight,
|
||||
statusText.implicitHeight
|
||||
)
|
||||
|
||||
StyledText {
|
||||
Layout.margins: 10
|
||||
Layout.bottomMargin: 5
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
id: statusText
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.leftMargin: 10
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: `${Notifications.list.length} notifications`
|
||||
|
||||
opacity: Notifications.list.length > 0 ? 1 : 0
|
||||
@@ -85,16 +93,26 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Item { Layout.fillWidth: true }
|
||||
ButtonGroup {
|
||||
id: controls
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.rightMargin: 5
|
||||
|
||||
NotificationStatusButton {
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
Layout.margins: 5
|
||||
Layout.topMargin: 10
|
||||
buttonIcon: "clear_all"
|
||||
buttonText: qsTr("Clear")
|
||||
onClicked: () => {
|
||||
Notifications.discardAllNotifications()
|
||||
NotificationStatusButton {
|
||||
buttonIcon: "notifications_paused"
|
||||
buttonText: qsTr("Silent")
|
||||
toggled: Notifications.silent
|
||||
onClicked: () => {
|
||||
Notifications.silent = !Notifications.silent;
|
||||
}
|
||||
}
|
||||
NotificationStatusButton {
|
||||
buttonIcon: "clear_all"
|
||||
buttonText: qsTr("Clear")
|
||||
onClicked: () => {
|
||||
Notifications.discardAllNotifications()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,33 +9,34 @@ GroupButton {
|
||||
property string buttonText: ""
|
||||
property string buttonIcon: ""
|
||||
|
||||
baseWidth: contentRowLayout.implicitWidth + 10 * 2
|
||||
baseWidth: content.implicitWidth + 10 * 2
|
||||
baseHeight: 30
|
||||
clickedWidth: baseWidth + 15
|
||||
|
||||
buttonRadius: baseHeight / 2
|
||||
buttonRadiusPressed: Appearance.rounding.small
|
||||
colBackground: Appearance.colors.colLayer2
|
||||
colBackgroundHover: Appearance.colors.colLayer2Hover
|
||||
colBackgroundActive: Appearance.colors.colLayer2Active
|
||||
background.anchors.fill: button
|
||||
property color colText: toggled ? Appearance.m3colors.m3onPrimary : Appearance.colors.colOnLayer1
|
||||
|
||||
contentItem: Item {
|
||||
id: content
|
||||
anchors.fill: parent
|
||||
implicitWidth: contentRowLayout.implicitWidth
|
||||
implicitHeight: contentRowLayout.implicitHeight
|
||||
RowLayout {
|
||||
id: contentRowLayout
|
||||
anchors.centerIn: parent
|
||||
spacing: 0
|
||||
MaterialSymbol {
|
||||
text: buttonIcon
|
||||
Layout.fillWidth: false
|
||||
iconSize: Appearance.font.pixelSize.larger
|
||||
color: Appearance.colors.colOnLayer1
|
||||
color: button.colText
|
||||
}
|
||||
StyledText {
|
||||
text: buttonText
|
||||
Layout.fillWidth: false
|
||||
font.pixelSize: Appearance.font.pixelSize.small
|
||||
color: Appearance.colors.colOnLayer1
|
||||
color: button.colText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,10 +60,12 @@ Singleton {
|
||||
destroy()
|
||||
}
|
||||
}
|
||||
|
||||
property bool silent: false
|
||||
property var filePath: Directories.notificationsPath
|
||||
property list<Notif> list: []
|
||||
property var popupList: list.filter((notif) => notif.popup);
|
||||
property bool popupInhibited: GlobalStates?.sidebarRightOpen ?? false
|
||||
property bool popupInhibited: (GlobalStates?.sidebarRightOpen ?? false) || silent
|
||||
property var latestTimeForApp: ({})
|
||||
Component {
|
||||
id: notifComponent
|
||||
|
||||
Reference in New Issue
Block a user