1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-26 14:32:52 -05:00

modals: apply same pattern of multi-window

- fixes excessive repaints
fixes #716
This commit is contained in:
bbedward
2025-11-23 12:07:45 -05:00
parent 62845b470c
commit 42de6fd074
15 changed files with 1282 additions and 1279 deletions

View File

@@ -1,12 +1,10 @@
import QtQuick
import Quickshell
import Quickshell.Hyprland
import Quickshell.Io
import qs.Common
import qs.Modals.Common
import qs.Modules.Notifications.Center
import qs.Services
import qs.Widgets
DankModal {
id: notificationModal
@@ -22,58 +20,58 @@ DankModal {
property var notificationListRef: null
function show() {
notificationModalOpen = true
NotificationService.onOverlayOpen()
open()
modalKeyboardController.reset()
notificationModalOpen = true;
NotificationService.onOverlayOpen();
open();
modalKeyboardController.reset();
if (modalKeyboardController && notificationListRef) {
modalKeyboardController.listView = notificationListRef
modalKeyboardController.rebuildFlatNavigation()
modalKeyboardController.listView = notificationListRef;
modalKeyboardController.rebuildFlatNavigation();
Qt.callLater(() => {
modalKeyboardController.keyboardNavigationActive = true
modalKeyboardController.selectedFlatIndex = 0
modalKeyboardController.updateSelectedIdFromIndex()
modalKeyboardController.keyboardNavigationActive = true;
modalKeyboardController.selectedFlatIndex = 0;
modalKeyboardController.updateSelectedIdFromIndex();
if (notificationListRef) {
notificationListRef.keyboardActive = true
notificationListRef.currentIndex = 0
notificationListRef.keyboardActive = true;
notificationListRef.currentIndex = 0;
}
modalKeyboardController.selectionVersion++
modalKeyboardController.ensureVisible()
})
modalKeyboardController.selectionVersion++;
modalKeyboardController.ensureVisible();
});
}
}
function hide() {
notificationModalOpen = false
NotificationService.onOverlayClose()
close()
modalKeyboardController.reset()
notificationModalOpen = false;
NotificationService.onOverlayClose();
close();
modalKeyboardController.reset();
}
function toggle() {
if (shouldBeVisible) {
hide()
hide();
} else {
show()
show();
}
}
width: 500
height: 700
modalWidth: 500
modalHeight: 700
visible: false
onBackgroundClicked: hide()
onOpened: () => {
Qt.callLater(() => modalFocusScope.forceActiveFocus());
}
onShouldBeVisibleChanged: (shouldBeVisible) => {
onShouldBeVisibleChanged: shouldBeVisible => {
if (!shouldBeVisible) {
notificationModalOpen = false
modalKeyboardController.reset()
NotificationService.onOverlayClose()
notificationModalOpen = false;
modalKeyboardController.reset();
NotificationService.onOverlayClose();
}
}
modalFocusScope.Keys.onPressed: (event) => modalKeyboardController.handleKey(event)
modalFocusScope.Keys.onPressed: event => modalKeyboardController.handleKey(event)
NotificationKeyboardController {
id: modalKeyboardController
@@ -132,14 +130,13 @@ DankModal {
height: parent.height - y
keyboardController: modalKeyboardController
Component.onCompleted: {
notificationModal.notificationListRef = notificationList
notificationModal.notificationListRef = notificationList;
if (modalKeyboardController) {
modalKeyboardController.listView = notificationList
modalKeyboardController.rebuildFlatNavigation()
modalKeyboardController.listView = notificationList;
modalKeyboardController.rebuildFlatNavigation();
}
}
}
}
NotificationKeyboardHints {
@@ -151,9 +148,6 @@ DankModal {
anchors.margins: Theme.spacingL
showHints: modalKeyboardController.showKeyboardHints
}
}
}
}