Improve global notifications menu

- More descriptive menu entries
- Indicate the current setting in the menu with a checkmark
- Remove menu button tooltip that gets in the way
- Remove unused icon
This commit is contained in:
miruka 2021-02-28 10:12:35 -04:00
parent 0017a1562c
commit 027454c6e0
5 changed files with 24 additions and 25 deletions

View File

@ -5,7 +5,7 @@
- combo box custom item
- explain pattern
- fix spinbox buttons
- quick room & sender rule changes
- HMenuItem checkbox styling
- config & keybind for global rule disabling
- quick settings
- import/export/json edit rules?
@ -22,7 +22,6 @@
- profiles missing in notifications
- option to use plaintext notifications
- Notification urgency level (plyer)?
- annoying tooltips when menu open
- add http_proxy support
- image viewer: can't expand image in reduced window layout

View File

@ -67,24 +67,23 @@ Rectangle {
backgroundColor: "transparent"
icon.name:
window.notificationLevel === Window.NotificationLevel.All ?
window.notificationLevel === Window.NotificationLevel.Enable ?
"notifications-all" :
window.notificationLevel === Window.NotificationLevel.None ?
window.notificationLevel === Window.NotificationLevel.Mute ?
"notifications-none" :
"notifications-mentions-keywords"
icon.color:
window.notificationLevel === Window.NotificationLevel.All ?
window.notificationLevel === Window.NotificationLevel.Enable ?
theme.icons.colorize :
window.notificationLevel === Window.NotificationLevel.None ?
window.notificationLevel === Window.NotificationLevel.Mute ?
theme.colors.negativeBackground :
theme.colors.middleBackground
toolTip.text: qsTr("Control global notifications")
onClicked: notificationsMenu.open()
Layout.fillHeight: true
@ -94,29 +93,33 @@ Rectangle {
y: parent.height
HMenuItem {
icon.name: "notifications-all"
text: qsTr("Normal notifications")
text: qsTr("Enable notifications")
checked:
window.notificationLevel ===
Window.NotificationLevel.Enable
onTriggered:
window.notificationLevel =
Window.NotificationLevel.All
Window.NotificationLevel.Enable
}
HMenuItem {
icon.name: "notifications-mentions-keywords"
icon.color: theme.colors.middleBackground
text: qsTr("Mentions & keywords")
text: qsTr("Highlights only (replies, keywords...)")
checked:
window.notificationLevel ===
Window.NotificationLevel.HighlightsOnly
onTriggered:
window.notificationLevel =
Window.NotificationLevel.MentionsKeywords
Window.NotificationLevel.HighlightsOnly
}
HMenuItem {
icon.name: "notifications-none"
icon.color: theme.colors.negativeBackground
text: qsTr("Nothing")
text: qsTr("Mute all notifications")
checked:
window.notificationLevel ===
Window.NotificationLevel.Mute
onTriggered:
window.notificationLevel =
Window.NotificationLevel.None
Window.NotificationLevel.Mute
}
}
}

View File

@ -13,8 +13,8 @@ QtObject {
) {
const level = window.notificationLevel
if (level === Window.NotificationLevel.None) return
if (level === Window.MentionsKeywords && ! critical) return
if (level === Window.NotificationLevel.Mute) return
if (level === Window.HighlightsOnly && ! critical) return
if (window.notifiedIds.has(id)) return
window.notifiedIds.add(id)

View File

@ -10,7 +10,7 @@ import "PythonBridge"
ApplicationWindow {
id: window
enum NotificationLevel { None, MentionsKeywords, All }
enum NotificationLevel { Mute, HighlightsOnly, Enable }
// FIXME: Qt 5.13.1 bug, this randomly stops updating after the cursor
// leaves the window until it's clicked again.
@ -21,7 +21,7 @@ ApplicationWindow {
window.visibility === window.Minimized ||
window.visibility === window.Hidden
property int notificationLevel: Window.NotificationLevel.All
property int notificationLevel: Window.NotificationLevel.Enable
property var notifiedIds: new Set()
property var mainUI: null

View File

@ -1,3 +0,0 @@
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
<path d="m15 21c0 1.598-1.392 3-2.971 3s-3.029-1.402-3.029-3zm.137-17.055c-.644-.374-1.042-1.07-1.041-1.82v-.003c.001-1.172-.938-2.122-2.096-2.122s-2.097.95-2.097 2.122v.003c.001.751-.396 1.446-1.041 1.82-4.668 2.709-1.985 11.715-6.862 13.306v1.749h20v-1.749c-4.877-1.591-2.193-10.598-6.863-13.306zm-3.137-2.945c.552 0 1 .449 1 1 0 .552-.448 1-1 1s-1-.448-1-1c0-.551.448-1 1-1zm-6.451 16c1.189-1.667 1.605-3.891 1.964-5.815.447-2.39.869-4.648 2.354-5.509 1.38-.801 2.956-.76 4.267 0 1.485.861 1.907 3.119 2.354 5.509.359 1.924.775 4.148 1.964 5.815z"/>
</svg>

Before

Width:  |  Height:  |  Size: 648 B