1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-28 15:32:50 -05:00

fix notif center popout keyboard events

This commit is contained in:
bbedward
2025-08-19 19:35:41 -04:00
parent 72677dfad7
commit 85b687bfe9
3 changed files with 79 additions and 19 deletions

View File

@@ -46,17 +46,62 @@ DankPopout {
onNotificationHistoryVisibleChanged: { onNotificationHistoryVisibleChanged: {
if (notificationHistoryVisible) { if (notificationHistoryVisible) {
open() open()
NotificationService.disablePopups(true)
} else { } else {
close() close()
NotificationService.disablePopups(false)
} }
} }
onShouldBeVisibleChanged: {
if (shouldBeVisible) {
NotificationService.disablePopups(true)
// Set up keyboard controller when content is loaded
Qt.callLater(function() {
if (contentLoader.item) {
contentLoader.item.externalKeyboardController = keyboardController
// Find the notification list and set up the connection
var notificationList = findChild(contentLoader.item, "notificationList")
var notificationHeader = findChild(contentLoader.item, "notificationHeader")
if (notificationList) {
keyboardController.listView = notificationList
notificationList.keyboardController = keyboardController
}
if (notificationHeader) {
notificationHeader.keyboardController = keyboardController
}
keyboardController.reset()
keyboardController.rebuildFlatNavigation()
}
})
} else {
NotificationService.disablePopups(false)
// Reset keyboard state when closing
keyboardController.keyboardNavigationActive = false
}
}
function findChild(parent, objectName) {
if (parent.objectName === objectName) {
return parent
}
for (var i = 0; i < parent.children.length; i++) {
var child = parent.children[i]
var result = findChild(child, objectName)
if (result) {
return result
}
}
return null
}
content: Component { content: Component {
Rectangle { Rectangle {
id: notificationContent id: notificationContent
property var externalKeyboardController: null
implicitHeight: { implicitHeight: {
let baseHeight = Theme.spacingL * 2 let baseHeight = Theme.spacingL * 2
baseHeight += notificationHeader.height baseHeight += notificationHeader.height
@@ -82,7 +127,12 @@ DankPopout {
} }
Keys.onPressed: function(event) { Keys.onPressed: function(event) {
keyboardController.handleKey(event) if (event.key === Qt.Key_Escape) {
root.close()
event.accepted = true
} else if (externalKeyboardController) {
externalKeyboardController.handleKey(event)
}
} }
Connections { Connections {
@@ -111,7 +161,7 @@ DankPopout {
NotificationHeader { NotificationHeader {
id: notificationHeader id: notificationHeader
keyboardController: keyboardController objectName: "notificationHeader"
} }
NotificationSettings { NotificationSettings {
@@ -121,16 +171,10 @@ DankPopout {
KeyboardNavigatedNotificationList { KeyboardNavigatedNotificationList {
id: notificationList id: notificationList
objectName: "notificationList"
width: parent.width width: parent.width
height: parent.height - notificationHeader.height - notificationSettings.height - contentColumnInner.spacing * 2 height: parent.height - notificationHeader.height - notificationSettings.height - contentColumnInner.spacing * 2
Component.onCompleted: {
if (keyboardController && notificationList) {
keyboardController.listView = notificationList
notificationList.keyboardController = keyboardController
}
}
} }
} }
} }
@@ -141,7 +185,7 @@ DankPopout {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.margins: Theme.spacingL anchors.margins: Theme.spacingL
showHints: keyboardController.showKeyboardHints showHints: externalKeyboardController ? externalKeyboardController.showKeyboardHints : false
z: 200 z: 200
} }

View File

@@ -16,21 +16,28 @@ Rectangle {
z: 100 z: 100
Column { Column {
anchors.centerIn: parent anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: Theme.spacingS
spacing: 2 spacing: 2
StyledText { StyledText {
text: "↑/↓: Nav • Space: Expand • Enter: Action/Expand • E: Text" text: "↑/↓: Nav • Space: Expand • Enter: Action/Expand • E: Text"
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText color: Theme.surfaceText
anchors.horizontalCenter: parent.horizontalCenter width: parent.width
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
} }
StyledText { StyledText {
text: "Del: Clear • Shift+Del: Clear All • 1-9: Actions • F10: Help • Esc: Close" text: "Del: Clear • Shift+Del: Clear All • 1-9: Actions • F10: Help • Esc: Close"
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText color: Theme.surfaceText
anchors.horizontalCenter: parent.horizontalCenter width: parent.width
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
} }
} }

View File

@@ -140,15 +140,24 @@ PanelWindow {
visible: shouldBeVisible visible: shouldBeVisible
focus: shouldBeVisible focus: shouldBeVisible
Keys.onEscapePressed: (event) => { Keys.onPressed: (event) => {
close(); if (event.key === Qt.Key_Escape) {
event.accepted = true; close();
event.accepted = true;
} else {
// Forward all non-escape keys to content
event.accepted = false;
}
} }
onVisibleChanged: { onVisibleChanged: {
if (visible) { if (visible) {
Qt.callLater(function() { Qt.callLater(function() {
forceActiveFocus(); if (contentLoader.item) {
contentLoader.item.forceActiveFocus();
} else {
forceActiveFocus();
}
}); });
} }
} }