Add keybinds to control global notifications
Alt+M: toggle "mute all notifications except highlights" Alt+Shift+M: toggle "mute all notifications" The Keys.Rooms.(previous/next)_highlight keybinds, previously bound to Alt+(Shift+)M (stood for "mention") now defaults to Alt+(Shift+)H. The NotificationLevel enum and notificationLevel property had to be moved from Window to UI due to QML having a global "Window" object that causes conflicts when trying to access the enum as "Window.NotificationLevel" from UI.qml.
This commit is contained in:
parent
93ced92cda
commit
d7fbe8c222
|
@ -6,7 +6,6 @@
|
|||
- explain pattern
|
||||
- fix spinbox buttons
|
||||
- HMenuItem checkbox styling
|
||||
- config & keybind for global rule disabling
|
||||
- quick settings
|
||||
- import/export/json edit rules?
|
||||
- fix flickable popups can't be flicked by keyboard
|
||||
|
|
|
@ -236,6 +236,13 @@ class Keys:
|
|||
# Switch to the last opened page/chat, similar to Alt+Tab on most desktops.
|
||||
last_page = ["Ctrl+Tab"]
|
||||
|
||||
# Toggle muting all notifications in the running client,
|
||||
# except highlights (e.g. replies or keywords)
|
||||
notifications_highlights_only = ["Alt+M"]
|
||||
|
||||
# Toggle muting all notifications in the running client
|
||||
notifications_mute = ["Alt+Shift+M"]
|
||||
|
||||
# Toggle the QML developer console. Type ". help" inside it for more info.
|
||||
qml_console = ["F1"]
|
||||
|
||||
|
@ -321,8 +328,8 @@ class Keys:
|
|||
# list. What causes a highlight is controlled by push rules
|
||||
# (editable in GUI account settings): by default, this includes
|
||||
# when your name is mentioned, replied to, or messages with keywords.
|
||||
previous_highlight = ["Alt+Shift+M"]
|
||||
next_highlight = ["Alt+M"]
|
||||
previous_highlight = ["Alt+Shift+H"]
|
||||
next_highlight = ["Alt+H"]
|
||||
|
||||
class AtIndex:
|
||||
# Switch to room number X in the current account.
|
||||
|
|
|
@ -67,19 +67,19 @@ Rectangle {
|
|||
backgroundColor: "transparent"
|
||||
|
||||
icon.name:
|
||||
window.notificationLevel === Window.NotificationLevel.Enable ?
|
||||
mainUI.notificationLevel === UI.NotificationLevel.Enable ?
|
||||
"notifications-all" :
|
||||
|
||||
window.notificationLevel === Window.NotificationLevel.Mute ?
|
||||
mainUI.notificationLevel === UI.NotificationLevel.Mute ?
|
||||
"notifications-none" :
|
||||
|
||||
"notifications-mentions-keywords"
|
||||
|
||||
icon.color:
|
||||
window.notificationLevel === Window.NotificationLevel.Enable ?
|
||||
mainUI.notificationLevel === UI.NotificationLevel.Enable ?
|
||||
theme.icons.colorize :
|
||||
|
||||
window.notificationLevel === Window.NotificationLevel.Mute ?
|
||||
mainUI.notificationLevel === UI.NotificationLevel.Mute ?
|
||||
theme.colors.negativeBackground :
|
||||
|
||||
theme.colors.middleBackground
|
||||
|
@ -95,31 +95,29 @@ Rectangle {
|
|||
HMenuItem {
|
||||
text: qsTr("Enable notifications")
|
||||
checked:
|
||||
window.notificationLevel ===
|
||||
Window.NotificationLevel.Enable
|
||||
mainUI.notificationLevel ===
|
||||
UI.NotificationLevel.Enable
|
||||
onTriggered:
|
||||
window.notificationLevel =
|
||||
Window.NotificationLevel.Enable
|
||||
mainUI.notificationLevel =
|
||||
UI.NotificationLevel.Enable
|
||||
}
|
||||
|
||||
HMenuItem {
|
||||
text: qsTr("Highlights only (replies, keywords...)")
|
||||
checked:
|
||||
window.notificationLevel ===
|
||||
Window.NotificationLevel.HighlightsOnly
|
||||
mainUI.notificationLevel ===
|
||||
UI.NotificationLevel.HighlightsOnly
|
||||
onTriggered:
|
||||
window.notificationLevel =
|
||||
Window.NotificationLevel.HighlightsOnly
|
||||
mainUI.notificationLevel =
|
||||
UI.NotificationLevel.HighlightsOnly
|
||||
}
|
||||
|
||||
HMenuItem {
|
||||
text: qsTr("Mute all notifications")
|
||||
checked:
|
||||
window.notificationLevel ===
|
||||
Window.NotificationLevel.Mute
|
||||
mainUI.notificationLevel === UI.NotificationLevel.Mute
|
||||
onTriggered:
|
||||
window.notificationLevel =
|
||||
Window.NotificationLevel.Mute
|
||||
mainUI.notificationLevel = UI.NotificationLevel.Mute
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ QtObject {
|
|||
function onNotificationRequested(
|
||||
id, critical, bubble, sound, urgencyHint, title, body, image,
|
||||
) {
|
||||
const level = window.notificationLevel
|
||||
const level = window.mainUI.notificationLevel
|
||||
|
||||
if (level === Window.NotificationLevel.Mute) return
|
||||
if (level === Window.HighlightsOnly && ! critical) return
|
||||
if (level === UI.NotificationLevel.Mute) return
|
||||
if (level === UI.NotificationLevel.HighlightsOnly && ! critical) return
|
||||
if (window.notifiedIds.has(id)) return
|
||||
|
||||
window.notifiedIds.add(id)
|
||||
|
|
|
@ -6,12 +6,22 @@ import QtQuick.Controls 2.12
|
|||
import QtQuick.Layouts 1.12
|
||||
import QtQuick.Window 2.12
|
||||
import QtGraphicalEffects 1.12
|
||||
import "."
|
||||
import "Base"
|
||||
import "MainPane"
|
||||
|
||||
Item {
|
||||
id: mainUI
|
||||
|
||||
enum NotificationLevel { Mute, HighlightsOnly, Enable }
|
||||
|
||||
property int notificationLevel:
|
||||
settings.Notifications.start_level === "highlights_only" ?
|
||||
UI.NotificationLevel.HighlightsOnly :
|
||||
settings.Notifications.start_level === "mute" ?
|
||||
UI.NotificationLevel.Mute :
|
||||
UI.NotificationLevel.Enable
|
||||
|
||||
property bool accountsPresent:
|
||||
ModelStore.get("accounts").count > 0 || py.startupAnyAccountsSaved
|
||||
|
||||
|
@ -78,6 +88,25 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
HShortcut {
|
||||
sequences: window.settings.Keys.notifications_highlights_only
|
||||
onActivated:
|
||||
mainUI.notificationLevel =
|
||||
mainUI.notificationLevel ===
|
||||
UI.NotificationLevel.HighlightsOnly ?
|
||||
UI.NotificationLevel.Enable :
|
||||
UI.NotificationLevel.HighlightsOnly
|
||||
}
|
||||
|
||||
HShortcut {
|
||||
sequences: window.settings.Keys.notifications_mute
|
||||
onActivated:
|
||||
mainUI.notificationLevel =
|
||||
mainUI.notificationLevel === UI.NotificationLevel.Mute ?
|
||||
UI.NotificationLevel.Enable :
|
||||
UI.NotificationLevel.Mute
|
||||
}
|
||||
|
||||
FontMetrics {
|
||||
id: fontMetrics
|
||||
font.family: theme.fontFamily.sans
|
||||
|
|
|
@ -10,8 +10,6 @@ import "PythonBridge"
|
|||
ApplicationWindow {
|
||||
id: window
|
||||
|
||||
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,13 +19,6 @@ ApplicationWindow {
|
|||
window.visibility === window.Minimized ||
|
||||
window.visibility === window.Hidden
|
||||
|
||||
property int notificationLevel:
|
||||
py.ready && settings.Notifications.start_level === "highlights_only" ?
|
||||
Window.NotificationLevel.HighlightsOnly :
|
||||
py.ready && settings.Notifications.start_level === "mute" ?
|
||||
Window.NotificationLevel.Mute :
|
||||
Window.NotificationLevel.Enable
|
||||
|
||||
property var notifiedIds: new Set()
|
||||
|
||||
property var mainUI: null
|
||||
|
|
Loading…
Reference in New Issue
Block a user