1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 13:35:36 -05:00

refactor all modals and popouts so they retain animations on exit

This commit is contained in:
bbedward
2025-08-19 15:44:43 -04:00
parent 5fba96f345
commit 2a28f99831
36 changed files with 1499 additions and 1452 deletions

View File

@@ -9,14 +9,12 @@ import qs.Services
import qs.Widgets
import qs.Modules.Notifications.Center
PanelWindow {
DankPopout {
id: root
property bool notificationHistoryVisible: false
property real triggerX: Screen.width - 400 - Theme.spacingL
property real triggerY: Theme.barHeight - 4 + SettingsData.topBarSpacing + Theme.spacingXS
property real triggerWidth: 40
property string triggerSection: "right"
property var triggerScreen: null
NotificationKeyboardController {
id: keyboardController
@@ -25,185 +23,143 @@ PanelWindow {
onClose: function() { notificationHistoryVisible = false }
}
NotificationKeyboardHints {
id: keyboardHints
anchors.bottom: mainRect.bottom
anchors.left: mainRect.left
anchors.right: mainRect.right
anchors.margins: Theme.spacingL
showHints: keyboardController.showKeyboardHints
z: 200
}
function setTriggerPosition(x, y, width, section) {
function setTriggerPosition(x, y, width, section, screen) {
triggerX = x
triggerY = y
triggerWidth = width
triggerSection = section
triggerScreen = screen
}
visible: notificationHistoryVisible
popupWidth: 400
popupHeight: {
let baseHeight = Theme.spacingL * 2
baseHeight += 40 // notificationHeader height estimate
baseHeight += 0 // notificationSettings when collapsed
baseHeight += Theme.spacingM * 2
let listHeight = 200 // default list height
baseHeight += Math.min(listHeight, 600)
return Math.max(300, Math.min(baseHeight, Screen.height * 0.8))
}
triggerX: Screen.width - 400 - Theme.spacingL
triggerY: Theme.barHeight - 4 + SettingsData.topBarSpacing + Theme.spacingXS
triggerWidth: 40
positioning: "center"
WlrLayershell.namespace: "quickshell-notifications"
screen: triggerScreen
shouldBeVisible: notificationHistoryVisible
visible: shouldBeVisible
onNotificationHistoryVisibleChanged: {
NotificationService.disablePopups(notificationHistoryVisible)
}
implicitWidth: 400
implicitHeight: Math.min(Screen.height * 0.8, 400)
WlrLayershell.layer: WlrLayershell.Overlay
WlrLayershell.exclusiveZone: -1
WlrLayershell.keyboardFocus: notificationHistoryVisible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
color: "transparent"
anchors {
top: true
left: true
right: true
bottom: true
}
MouseArea {
anchors.fill: parent
onClicked: {
notificationHistoryVisible = false
if (notificationHistoryVisible) {
open()
NotificationService.disablePopups(true)
} else {
close()
NotificationService.disablePopups(false)
}
}
Rectangle {
id: mainRect
readonly property real popupWidth: 400
readonly property real calculatedX: {
var centerX = root.triggerX + (root.triggerWidth / 2) - (popupWidth / 2)
if (centerX >= Theme.spacingM
&& centerX + popupWidth <= Screen.width - Theme.spacingM) {
return centerX
}
if (centerX < Theme.spacingM) {
return Theme.spacingM
}
if (centerX + popupWidth > Screen.width - Theme.spacingM) {
return Screen.width - popupWidth - Theme.spacingM
}
return centerX
}
width: popupWidth
height: {
let baseHeight = Theme.spacingL * 2
baseHeight += notificationHeader.height
// Use the final content height when expanded, not the animating height
baseHeight += (notificationSettings.expanded ? notificationSettings.contentHeight : 0)
baseHeight += Theme.spacingM * 2
let listHeight = notificationList.listContentHeight
if (NotificationService.groupedNotifications.length === 0)
listHeight = 200
baseHeight += Math.min(listHeight, 600)
return Math.max(300, Math.min(baseHeight, Screen.height * 0.8))
}
x: calculatedX
y: root.triggerY
color: Theme.popupBackground()
radius: Theme.cornerRadius
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g,
Theme.outline.b, 0.08)
border.width: 1
opacity: notificationHistoryVisible ? 1 : 0
scale: notificationHistoryVisible ? 1 : 0.9
MouseArea {
anchors.fill: parent
onClicked: {
}
}
FocusScope {
id: contentColumn
anchors.fill: parent
anchors.margins: Theme.spacingL
focus: true
content: Component {
Rectangle {
id: notificationContent
implicitHeight: {
let baseHeight = Theme.spacingL * 2
baseHeight += notificationHeader.height
baseHeight += (notificationSettings.expanded ? notificationSettings.contentHeight : 0)
baseHeight += Theme.spacingM * 2
let listHeight = notificationList.listContentHeight
if (NotificationService.groupedNotifications.length === 0)
listHeight = 200
baseHeight += Math.min(listHeight, 600)
return Math.max(300, Math.min(baseHeight, root.screen ? root.screen.height * 0.8 : Screen.height * 0.8))
}
color: Theme.popupBackground()
radius: Theme.cornerRadius
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g,
Theme.outline.b, 0.08)
border.width: 1
focus: true
Component.onCompleted: {
if (notificationHistoryVisible)
if (root.shouldBeVisible)
forceActiveFocus()
}
Keys.onPressed: function(event) {
keyboardController.handleKey(event)
}
Column {
id: contentColumnInner
anchors.fill: parent
spacing: Theme.spacingM
Connections {
function onNotificationHistoryVisibleChanged() {
if (notificationHistoryVisible)
function onShouldBeVisibleChanged() {
if (root.shouldBeVisible)
Qt.callLater(function () {
contentColumn.forceActiveFocus()
notificationContent.forceActiveFocus()
})
else
contentColumn.focus = false
notificationContent.focus = false
}
target: root
}
NotificationHeader {
id: notificationHeader
keyboardController: keyboardController
}
NotificationSettings {
id: notificationSettings
expanded: notificationHeader.showSettings
}
FocusScope {
id: contentColumn
KeyboardNavigatedNotificationList {
id: notificationList
width: parent.width
height: parent.height - notificationHeader.height - notificationSettings.height - contentColumnInner.spacing * 2
anchors.fill: parent
anchors.margins: Theme.spacingL
focus: true
Component.onCompleted: {
if (keyboardController && notificationList) {
keyboardController.listView = notificationList
notificationList.keyboardController = keyboardController
Column {
id: contentColumnInner
anchors.fill: parent
spacing: Theme.spacingM
NotificationHeader {
id: notificationHeader
keyboardController: keyboardController
}
NotificationSettings {
id: notificationSettings
expanded: notificationHeader.showSettings
}
KeyboardNavigatedNotificationList {
id: notificationList
width: parent.width
height: parent.height - notificationHeader.height - notificationSettings.height - contentColumnInner.spacing * 2
Component.onCompleted: {
if (keyboardController && notificationList) {
keyboardController.listView = notificationList
notificationList.keyboardController = keyboardController
}
}
}
}
}
NotificationKeyboardHints {
id: keyboardHints
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: Theme.spacingL
showHints: keyboardController.showKeyboardHints
z: 200
}
}
Behavior on height {
NumberAnimation {
duration: Anims.durShort
easing.type: Easing.BezierSpline
easing.bezierCurve: Anims.emphasized
}
}
Behavior on opacity {
NumberAnimation {
duration: Anims.durMed
easing.type: Easing.BezierSpline
easing.bezierCurve: Anims.emphasized
}
}
Behavior on scale {
NumberAnimation {
duration: Anims.durMed
easing.type: Easing.BezierSpline
easing.bezierCurve: Anims.emphasized
Behavior on implicitHeight {
NumberAnimation {
duration: Anims.durShort
easing.type: Easing.BezierSpline
easing.bezierCurve: Anims.emphasized
}
}
}
}
}
}