Add global notification control icon in top bar
The "Mentions & keywords only" option doesn't work yet in multi-account cases: when notifications arrive for a room that multiple accounts are part of, the first notification to arrive is let through, and the duplicate later ones are ignored. The first notification to arrive may not be from the account that gets highlighted, thus it is ignored under the "Mentions & keywords" setting.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import ".."
|
||||
import "../Base"
|
||||
|
||||
Rectangle {
|
||||
@@ -69,12 +70,60 @@ Rectangle {
|
||||
|
||||
HButton {
|
||||
backgroundColor: "transparent"
|
||||
icon.name: "reload-config-files"
|
||||
toolTip.text: qsTr("Reload config files")
|
||||
|
||||
onClicked: mainUI.reloadSettings()
|
||||
icon.name:
|
||||
window.notificationLevel === Window.NotificationLevel.All ?
|
||||
"notifications-all" :
|
||||
|
||||
window.notificationLevel === Window.NotificationLevel.None ?
|
||||
"notifications-none" :
|
||||
|
||||
"notifications-mentions-keywords"
|
||||
|
||||
icon.color:
|
||||
window.notificationLevel === Window.NotificationLevel.All ?
|
||||
theme.icons.colorize :
|
||||
|
||||
window.notificationLevel === Window.NotificationLevel.None ?
|
||||
theme.colors.negativeBackground :
|
||||
|
||||
theme.colors.middleBackground
|
||||
|
||||
toolTip.text: qsTr("Control global notifications")
|
||||
onClicked: notificationsMenu.open()
|
||||
|
||||
Layout.fillHeight: true
|
||||
|
||||
HMenu {
|
||||
id: notificationsMenu
|
||||
y: parent.height
|
||||
|
||||
HMenuItem {
|
||||
icon.name: "notifications-all"
|
||||
text: qsTr("Normal notifications")
|
||||
onTriggered:
|
||||
window.notificationLevel =
|
||||
Window.NotificationLevel.All
|
||||
}
|
||||
|
||||
HMenuItem {
|
||||
icon.name: "notifications-mentions-keywords"
|
||||
icon.color: theme.colors.middleBackground
|
||||
text: qsTr("Mentions & keywords")
|
||||
onTriggered:
|
||||
window.notificationLevel =
|
||||
Window.NotificationLevel.MentionsKeywords
|
||||
}
|
||||
|
||||
HMenuItem {
|
||||
icon.name: "notifications-none"
|
||||
icon.color: theme.colors.negativeBackground
|
||||
text: qsTr("Nothing")
|
||||
onTriggered:
|
||||
window.notificationLevel =
|
||||
Window.NotificationLevel.None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HButton {
|
||||
|
@@ -12,7 +12,11 @@ QtObject {
|
||||
}
|
||||
|
||||
function onNotificationRequested(title, body, image, highImportance) {
|
||||
const level = window.notificationLevel
|
||||
|
||||
if (Qt.application.state === Qt.ApplicationActive) return
|
||||
if (level === Window.NotificationLevel.None) return
|
||||
if (level === Window.MentionsKeywords && ! highImportance) return
|
||||
|
||||
py.callCoro("desktop_notify", [title, body, image])
|
||||
|
||||
|
@@ -8,6 +8,8 @@ import "PythonBridge"
|
||||
ApplicationWindow {
|
||||
id: window
|
||||
|
||||
enum NotificationLevel { None, MentionsKeywords, All }
|
||||
|
||||
// FIXME: Qt 5.13.1 bug, this randomly stops updating after the cursor
|
||||
// leaves the window until it's clicked again.
|
||||
|
||||
@@ -17,6 +19,8 @@ ApplicationWindow {
|
||||
window.visibility === window.Minimized ||
|
||||
window.visibility === window.Hidden
|
||||
|
||||
property int notificationLevel: Window.NotificationLevel.All
|
||||
|
||||
property var mainUI: null
|
||||
property var settings: ({})
|
||||
property var uiState: ({})
|
||||
|
Reference in New Issue
Block a user