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
|
- explain pattern
|
||||||
- fix spinbox buttons
|
- fix spinbox buttons
|
||||||
- HMenuItem checkbox styling
|
- HMenuItem checkbox styling
|
||||||
- config & keybind for global rule disabling
|
|
||||||
- quick settings
|
- quick settings
|
||||||
- import/export/json edit rules?
|
- import/export/json edit rules?
|
||||||
- fix flickable popups can't be flicked by keyboard
|
- 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.
|
# Switch to the last opened page/chat, similar to Alt+Tab on most desktops.
|
||||||
last_page = ["Ctrl+Tab"]
|
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.
|
# Toggle the QML developer console. Type ". help" inside it for more info.
|
||||||
qml_console = ["F1"]
|
qml_console = ["F1"]
|
||||||
|
|
||||||
|
@ -321,8 +328,8 @@ class Keys:
|
||||||
# list. What causes a highlight is controlled by push rules
|
# list. What causes a highlight is controlled by push rules
|
||||||
# (editable in GUI account settings): by default, this includes
|
# (editable in GUI account settings): by default, this includes
|
||||||
# when your name is mentioned, replied to, or messages with keywords.
|
# when your name is mentioned, replied to, or messages with keywords.
|
||||||
previous_highlight = ["Alt+Shift+M"]
|
previous_highlight = ["Alt+Shift+H"]
|
||||||
next_highlight = ["Alt+M"]
|
next_highlight = ["Alt+H"]
|
||||||
|
|
||||||
class AtIndex:
|
class AtIndex:
|
||||||
# Switch to room number X in the current account.
|
# Switch to room number X in the current account.
|
||||||
|
|
|
@ -67,19 +67,19 @@ Rectangle {
|
||||||
backgroundColor: "transparent"
|
backgroundColor: "transparent"
|
||||||
|
|
||||||
icon.name:
|
icon.name:
|
||||||
window.notificationLevel === Window.NotificationLevel.Enable ?
|
mainUI.notificationLevel === UI.NotificationLevel.Enable ?
|
||||||
"notifications-all" :
|
"notifications-all" :
|
||||||
|
|
||||||
window.notificationLevel === Window.NotificationLevel.Mute ?
|
mainUI.notificationLevel === UI.NotificationLevel.Mute ?
|
||||||
"notifications-none" :
|
"notifications-none" :
|
||||||
|
|
||||||
"notifications-mentions-keywords"
|
"notifications-mentions-keywords"
|
||||||
|
|
||||||
icon.color:
|
icon.color:
|
||||||
window.notificationLevel === Window.NotificationLevel.Enable ?
|
mainUI.notificationLevel === UI.NotificationLevel.Enable ?
|
||||||
theme.icons.colorize :
|
theme.icons.colorize :
|
||||||
|
|
||||||
window.notificationLevel === Window.NotificationLevel.Mute ?
|
mainUI.notificationLevel === UI.NotificationLevel.Mute ?
|
||||||
theme.colors.negativeBackground :
|
theme.colors.negativeBackground :
|
||||||
|
|
||||||
theme.colors.middleBackground
|
theme.colors.middleBackground
|
||||||
|
@ -95,31 +95,29 @@ Rectangle {
|
||||||
HMenuItem {
|
HMenuItem {
|
||||||
text: qsTr("Enable notifications")
|
text: qsTr("Enable notifications")
|
||||||
checked:
|
checked:
|
||||||
window.notificationLevel ===
|
mainUI.notificationLevel ===
|
||||||
Window.NotificationLevel.Enable
|
UI.NotificationLevel.Enable
|
||||||
onTriggered:
|
onTriggered:
|
||||||
window.notificationLevel =
|
mainUI.notificationLevel =
|
||||||
Window.NotificationLevel.Enable
|
UI.NotificationLevel.Enable
|
||||||
}
|
}
|
||||||
|
|
||||||
HMenuItem {
|
HMenuItem {
|
||||||
text: qsTr("Highlights only (replies, keywords...)")
|
text: qsTr("Highlights only (replies, keywords...)")
|
||||||
checked:
|
checked:
|
||||||
window.notificationLevel ===
|
mainUI.notificationLevel ===
|
||||||
Window.NotificationLevel.HighlightsOnly
|
UI.NotificationLevel.HighlightsOnly
|
||||||
onTriggered:
|
onTriggered:
|
||||||
window.notificationLevel =
|
mainUI.notificationLevel =
|
||||||
Window.NotificationLevel.HighlightsOnly
|
UI.NotificationLevel.HighlightsOnly
|
||||||
}
|
}
|
||||||
|
|
||||||
HMenuItem {
|
HMenuItem {
|
||||||
text: qsTr("Mute all notifications")
|
text: qsTr("Mute all notifications")
|
||||||
checked:
|
checked:
|
||||||
window.notificationLevel ===
|
mainUI.notificationLevel === UI.NotificationLevel.Mute
|
||||||
Window.NotificationLevel.Mute
|
|
||||||
onTriggered:
|
onTriggered:
|
||||||
window.notificationLevel =
|
mainUI.notificationLevel = UI.NotificationLevel.Mute
|
||||||
Window.NotificationLevel.Mute
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,10 @@ QtObject {
|
||||||
function onNotificationRequested(
|
function onNotificationRequested(
|
||||||
id, critical, bubble, sound, urgencyHint, title, body, image,
|
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 === UI.NotificationLevel.Mute) return
|
||||||
if (level === Window.HighlightsOnly && ! critical) return
|
if (level === UI.NotificationLevel.HighlightsOnly && ! critical) return
|
||||||
if (window.notifiedIds.has(id)) return
|
if (window.notifiedIds.has(id)) return
|
||||||
|
|
||||||
window.notifiedIds.add(id)
|
window.notifiedIds.add(id)
|
||||||
|
|
|
@ -6,12 +6,22 @@ import QtQuick.Controls 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
import QtQuick.Window 2.12
|
import QtQuick.Window 2.12
|
||||||
import QtGraphicalEffects 1.12
|
import QtGraphicalEffects 1.12
|
||||||
|
import "."
|
||||||
import "Base"
|
import "Base"
|
||||||
import "MainPane"
|
import "MainPane"
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: mainUI
|
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:
|
property bool accountsPresent:
|
||||||
ModelStore.get("accounts").count > 0 || py.startupAnyAccountsSaved
|
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 {
|
FontMetrics {
|
||||||
id: fontMetrics
|
id: fontMetrics
|
||||||
font.family: theme.fontFamily.sans
|
font.family: theme.fontFamily.sans
|
||||||
|
|
|
@ -10,8 +10,6 @@ import "PythonBridge"
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
id: window
|
id: window
|
||||||
|
|
||||||
enum NotificationLevel { Mute, HighlightsOnly, Enable }
|
|
||||||
|
|
||||||
// FIXME: Qt 5.13.1 bug, this randomly stops updating after the cursor
|
// FIXME: Qt 5.13.1 bug, this randomly stops updating after the cursor
|
||||||
// leaves the window until it's clicked again.
|
// leaves the window until it's clicked again.
|
||||||
|
|
||||||
|
@ -21,13 +19,6 @@ ApplicationWindow {
|
||||||
window.visibility === window.Minimized ||
|
window.visibility === window.Minimized ||
|
||||||
window.visibility === window.Hidden
|
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 notifiedIds: new Set()
|
||||||
|
|
||||||
property var mainUI: null
|
property var mainUI: null
|
||||||
|
|
Loading…
Reference in New Issue
Block a user