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