1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

modules cleanup and qmlfmt everywhere

- throw in 24H clock fix and app drawer fix too
This commit is contained in:
bbedward
2025-09-03 23:26:07 -04:00
parent 178ccd3634
commit 21867c842f
55 changed files with 2720 additions and 3236 deletions

View File

@@ -9,10 +9,15 @@ DankListView {
property var keyboardController: null
property bool keyboardActive: false
property bool autoScrollDisabled: false
property alias count: listView.count
property alias listContentHeight: listView.contentHeight
clip: true
model: NotificationService.groupedNotifications
spacing: Theme.spacingL
onIsUserScrollingChanged: {
if (isUserScrolling && keyboardController
&& keyboardController.keyboardNavigationActive) {
if (isUserScrolling && keyboardController && keyboardController.keyboardNavigationActive) {
autoScrollDisabled = true
}
}
@@ -21,24 +26,13 @@ DankListView {
autoScrollDisabled = false
}
property alias count: listView.count
property alias listContentHeight: listView.contentHeight
clip: true
model: NotificationService.groupedNotifications
spacing: Theme.spacingL
Timer {
id: positionPreservationTimer
interval: 200
running: keyboardController
&& keyboardController.keyboardNavigationActive
&& !autoScrollDisabled
running: keyboardController && keyboardController.keyboardNavigationActive && !autoScrollDisabled
repeat: true
onTriggered: {
if (keyboardController
&& keyboardController.keyboardNavigationActive
&& !autoScrollDisabled) {
if (keyboardController && keyboardController.keyboardNavigationActive && !autoScrollDisabled) {
keyboardController.ensureVisible()
}
}
@@ -50,107 +44,94 @@ DankListView {
}
onModelChanged: {
if (keyboardController && keyboardController.keyboardNavigationActive) {
keyboardController.rebuildFlatNavigation()
Qt.callLater(function () {
if (keyboardController
&& keyboardController.keyboardNavigationActive
&& !autoScrollDisabled) {
keyboardController.ensureVisible()
}
})
if (!keyboardController || !keyboardController.keyboardNavigationActive) {
return
}
keyboardController.rebuildFlatNavigation()
Qt.callLater(() => {
if (keyboardController && keyboardController.keyboardNavigationActive && !autoScrollDisabled) {
keyboardController.ensureVisible()
}
})
}
delegate: Item {
required property var modelData
required property int index
readonly property bool isExpanded: NotificationService.expandedGroups[modelData?.key]
|| false
readonly property bool isExpanded: (NotificationService.expandedGroups[modelData && modelData.key] || false)
width: ListView.view.width
height: notificationCardWrapper.height
height: notificationCard.height
Item {
id: notificationCardWrapper
NotificationCard {
id: notificationCard
width: parent.width
height: notificationCard.height
notificationGroup: modelData
keyboardNavigationActive: listView.keyboardActive
NotificationCard {
id: notificationCard
width: parent.width
notificationGroup: modelData
isGroupSelected: {
if (!keyboardController || !keyboardController.keyboardNavigationActive || !listView.keyboardActive) {
return false
}
keyboardController.selectionVersion
const selection = keyboardController.getCurrentSelection()
return selection.type === "group" && selection.groupIndex === index
}
isGroupSelected: {
if (!keyboardController
|| !keyboardController.keyboardNavigationActive)
return false
keyboardController.selectionVersion
if (!listView.keyboardActive)
return false
const selection = keyboardController.getCurrentSelection()
return selection.type === "group"
&& selection.groupIndex === index
selectedNotificationIndex: {
if (!keyboardController || !keyboardController.keyboardNavigationActive || !listView.keyboardActive) {
return -1
}
selectedNotificationIndex: {
if (!keyboardController
|| !keyboardController.keyboardNavigationActive)
return -1
keyboardController.selectionVersion
if (!listView.keyboardActive)
return -1
const selection = keyboardController.getCurrentSelection()
return (selection.type === "notification"
&& selection.groupIndex === index) ? selection.notificationIndex : -1
}
keyboardNavigationActive: listView.keyboardActive
keyboardController.selectionVersion
const selection = keyboardController.getCurrentSelection()
return (selection.type === "notification" && selection.groupIndex === index) ? selection.notificationIndex : -1
}
}
}
Connections {
target: NotificationService
function onGroupedNotificationsChanged() {
if (keyboardController) {
if (keyboardController.isTogglingGroup) {
keyboardController.rebuildFlatNavigation()
return
}
if (!keyboardController) {
return
}
if (keyboardController.isTogglingGroup) {
keyboardController.rebuildFlatNavigation()
return
}
if (keyboardController.keyboardNavigationActive) {
Qt.callLater(function () {
if (!autoScrollDisabled) {
keyboardController.ensureVisible()
}
})
}
keyboardController.rebuildFlatNavigation()
if (keyboardController.keyboardNavigationActive) {
Qt.callLater(() => {
if (!autoScrollDisabled) {
keyboardController.ensureVisible()
}
})
}
}
function onExpandedGroupsChanged() {
if (keyboardController
&& keyboardController.keyboardNavigationActive) {
Qt.callLater(function () {
if (!autoScrollDisabled) {
keyboardController.ensureVisible()
}
})
if (keyboardController && keyboardController.keyboardNavigationActive) {
Qt.callLater(() => {
if (!autoScrollDisabled) {
keyboardController.ensureVisible()
}
})
}
}
function onExpandedMessagesChanged() {
if (keyboardController
&& keyboardController.keyboardNavigationActive) {
Qt.callLater(function () {
if (!autoScrollDisabled) {
keyboardController.ensureVisible()
}
})
if (keyboardController && keyboardController.keyboardNavigationActive) {
Qt.callLater(() => {
if (!autoScrollDisabled) {
keyboardController.ensureVisible()
}
})
}
}
target: NotificationService
}
}

View File

@@ -11,13 +11,11 @@ Rectangle {
id: root
property var notificationGroup
property bool expanded: NotificationService.expandedGroups[notificationGroup?.key]
|| false
property bool descriptionExpanded: NotificationService.expandedMessages[notificationGroup?.latestNotification?.notification?.id + "_desc"]
|| false
property bool expanded: (NotificationService.expandedGroups[notificationGroup && notificationGroup.key] || false)
property bool descriptionExpanded: (NotificationService.expandedMessages[(notificationGroup && notificationGroup.latestNotification && notificationGroup.latestNotification.notification
&& notificationGroup.latestNotification.notification.id) ? (notificationGroup.latestNotification.notification.id + "_desc") : ""] || false)
property bool userInitiatedExpansion: false
// Selection properties for keyboard navigation
property bool isGroupSelected: false
property int selectedNotificationIndex: -1
property bool keyboardNavigationActive: false
@@ -29,8 +27,7 @@ Rectangle {
}
const baseHeight = 116
if (descriptionExpanded) {
return baseHeight + descriptionText.contentHeight
- (descriptionText.font.pixelSize * 1.2 * 2)
return baseHeight + descriptionText.contentHeight - (descriptionText.font.pixelSize * 1.2 * 2)
}
return baseHeight
}
@@ -51,50 +48,33 @@ Rectangle {
}
color: {
// Keyboard selection highlighting for groups (both collapsed and expanded)
if (isGroupSelected && keyboardNavigationActive) {
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g,
Theme.surfaceVariant.b, 0.2)
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.2)
}
// Very subtle group highlighting when navigating within expanded group
if (keyboardNavigationActive && expanded
&& selectedNotificationIndex >= 0) {
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g,
Theme.surfaceVariant.b, 0.12)
if (keyboardNavigationActive && expanded && selectedNotificationIndex >= 0) {
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.12)
}
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g,
Theme.surfaceVariant.b, 0.1)
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.1)
}
border.color: {
// Keyboard selection highlighting for groups (both collapsed and expanded)
if (isGroupSelected && keyboardNavigationActive) {
return Qt.rgba(Theme.primary.r, Theme.primary.g,
Theme.primary.b, 0.5)
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.5)
}
// Subtle group border when navigating within expanded group
if (keyboardNavigationActive && expanded
&& selectedNotificationIndex >= 0) {
return Qt.rgba(Theme.primary.r, Theme.primary.g,
Theme.primary.b, 0.2)
if (keyboardNavigationActive && expanded && selectedNotificationIndex >= 0) {
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.2)
}
// Critical notification styling
if (notificationGroup?.latestNotification?.urgency === NotificationUrgency.Critical) {
return Qt.rgba(Theme.primary.r, Theme.primary.g,
Theme.primary.b, 0.3)
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.3)
}
return Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.05)
}
border.width: {
// Keyboard selection highlighting for groups (both collapsed and expanded)
if (isGroupSelected && keyboardNavigationActive) {
return 1.5
}
// Subtle group border when navigating within expanded group
if (keyboardNavigationActive && expanded
&& selectedNotificationIndex >= 0) {
if (keyboardNavigationActive && expanded && selectedNotificationIndex >= 0) {
return 1
}
// Critical notification styling
if (notificationGroup?.latestNotification?.urgency === NotificationUrgency.Critical) {
return 2
}
@@ -142,8 +122,7 @@ Rectangle {
width: 55
height: 55
radius: 27.5
color: Qt.rgba(Theme.primary.r, Theme.primary.g,
Theme.primary.b, 0.1)
color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1)
border.color: "transparent"
border.width: 0
anchors.left: parent.left
@@ -158,9 +137,7 @@ Rectangle {
return notificationGroup.latestNotification.cleanImage
if (notificationGroup?.latestNotification?.appIcon) {
const appIcon = notificationGroup.latestNotification.appIcon
if (appIcon.startsWith("file://") || appIcon.startsWith(
"http://") || appIcon.startsWith(
"https://"))
if (appIcon.startsWith("file://") || appIcon.startsWith("http://") || appIcon.startsWith("https://"))
return appIcon
return Quickshell.iconPath(appIcon, true)
}
@@ -171,9 +148,7 @@ Rectangle {
StyledText {
anchors.centerIn: parent
visible: !parent.hasNotificationImage
&& (!notificationGroup?.latestNotification?.appIcon
|| notificationGroup.latestNotification.appIcon === "")
visible: !parent.hasNotificationImage && (!notificationGroup?.latestNotification?.appIcon || notificationGroup.latestNotification.appIcon === "")
text: {
const appName = notificationGroup?.appName || "?"
return appName.charAt(0).toUpperCase()
@@ -196,9 +171,7 @@ Rectangle {
StyledText {
anchors.centerIn: parent
text: (notificationGroup?.count
|| 0) > 99 ? "99+" : (notificationGroup?.count
|| 0).toString()
text: (notificationGroup?.count || 0) > 99 ? "99+" : (notificationGroup?.count || 0).toString()
color: Theme.primaryText
font.pixelSize: 9
font.weight: Font.Bold
@@ -231,13 +204,9 @@ Rectangle {
StyledText {
width: parent.width
text: {
const timeStr = notificationGroup?.latestNotification?.timeStr
|| ""
if (timeStr.length > 0)
return (notificationGroup?.appName
|| "") + " • " + timeStr
else
return notificationGroup?.appName || ""
const timeStr = (notificationGroup && notificationGroup.latestNotification && notificationGroup.latestNotification.timeStr) || ""
const appName = (notificationGroup && notificationGroup.appName) || ""
return timeStr.length > 0 ? `${appName} ${timeStr}` : appName
}
color: Theme.surfaceVariantText
font.pixelSize: Theme.fontSizeSmall
@@ -247,8 +216,7 @@ Rectangle {
}
StyledText {
text: notificationGroup?.latestNotification?.summary
|| ""
text: (notificationGroup && notificationGroup.latestNotification && notificationGroup.latestNotification.summary) || ""
color: Theme.surfaceText
font.pixelSize: Theme.fontSizeMedium
font.weight: Font.Medium
@@ -260,8 +228,7 @@ Rectangle {
StyledText {
id: descriptionText
property string fullText: notificationGroup?.latestNotification?.htmlBody
|| ""
property string fullText: (notificationGroup && notificationGroup.latestNotification && notificationGroup.latestNotification.htmlBody) || ""
property bool hasMoreText: truncated
text: fullText
@@ -280,12 +247,10 @@ Rectangle {
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : (parent.hasMoreText || descriptionExpanded) ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: mouse => {
if (!parent.hoveredLink
&& (parent.hasMoreText
|| descriptionExpanded)) {
const messageId = notificationGroup?.latestNotification?.notification?.id + "_desc"
NotificationService.toggleMessageExpansion(
messageId)
if (!parent.hoveredLink && (parent.hasMoreText || descriptionExpanded)) {
const messageId = (notificationGroup && notificationGroup.latestNotification && notificationGroup.latestNotification.notification
&& notificationGroup.latestNotification.notification.id) ? (notificationGroup.latestNotification.notification.id + "_desc") : ""
NotificationService.toggleMessageExpansion(messageId)
}
}
@@ -350,9 +315,7 @@ Rectangle {
StyledText {
anchors.centerIn: parent
text: (notificationGroup?.count
|| 0) > 99 ? "99+" : (notificationGroup?.count
|| 0).toString()
text: (notificationGroup?.count || 0) > 99 ? "99+" : (notificationGroup?.count || 0).toString()
color: Theme.primaryText
font.pixelSize: 9
font.weight: Font.Bold
@@ -371,8 +334,7 @@ Rectangle {
delegate: Rectangle {
required property var modelData
required property int index
readonly property bool messageExpanded: NotificationService.expandedMessages[modelData?.notification?.id]
|| false
readonly property bool messageExpanded: NotificationService.expandedMessages[modelData?.notification?.id] || false
readonly property bool isSelected: root.selectedNotificationIndex === index
width: parent.width
@@ -388,17 +350,8 @@ Rectangle {
return baseHeight
}
radius: Theme.cornerRadius
color: isSelected ? Qt.rgba(Theme.surfaceVariant.r,
Theme.surfaceVariant.g,
Theme.surfaceVariant.b,
0.25) : "transparent"
border.color: isSelected ? Qt.rgba(Theme.primary.r,
Theme.primary.g,
Theme.primary.b,
0.4) : Qt.rgba(
Theme.outline.r,
Theme.outline.g,
Theme.outline.b, 0.05)
color: isSelected ? Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.25) : "transparent"
border.color: isSelected ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.4) : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.05)
border.width: isSelected ? 1 : 1
Behavior on color {
@@ -427,8 +380,7 @@ Rectangle {
Rectangle {
id: messageIcon
readonly property bool hasNotificationImage: modelData?.image
&& modelData.image !== ""
readonly property bool hasNotificationImage: modelData?.image && modelData.image !== ""
width: 32
height: 32
@@ -436,11 +388,8 @@ Rectangle {
anchors.left: parent.left
anchors.top: parent.top
anchors.topMargin: 32
color: Qt.rgba(Theme.primary.r, Theme.primary.g,
Theme.primary.b, 0.1)
border.color: Qt.rgba(Theme.primary.r,
Theme.primary.g,
Theme.primary.b, 0.2)
color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1)
border.color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.2)
border.width: 1
IconImage {
@@ -452,10 +401,7 @@ Rectangle {
if (modelData?.appIcon) {
const appIcon = modelData.appIcon
if (appIcon.startsWith("file://")
|| appIcon.startsWith("http://")
|| appIcon.startsWith(
"https://"))
if (appIcon.startsWith("file://") || appIcon.startsWith("http://") || appIcon.startsWith("https://"))
return appIcon
return Quickshell.iconPath(appIcon, true)
@@ -467,9 +413,7 @@ Rectangle {
StyledText {
anchors.centerIn: parent
visible: !parent.hasNotificationImage
&& (!modelData?.appIcon
|| modelData.appIcon === "")
visible: !parent.hasNotificationImage && (!modelData?.appIcon || modelData.appIcon === "")
text: {
const appName = modelData?.appName || "?"
return appName.charAt(0).toUpperCase()
@@ -531,19 +475,14 @@ Rectangle {
wrapMode: Text.WordWrap
visible: text.length > 0
linkColor: Theme.primary
onLinkActivated: link => Qt.openUrlExternally(
link)
onLinkActivated: link => Qt.openUrlExternally(link)
MouseArea {
anchors.fill: parent
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : (bodyText.hasMoreText || messageExpanded) ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: mouse => {
if (!parent.hoveredLink
&& (bodyText.hasMoreText
|| messageExpanded)) {
NotificationService.toggleMessageExpansion(
modelData?.notification?.id
|| "")
if (!parent.hoveredLink && (bodyText.hasMoreText || messageExpanded)) {
NotificationService.toggleMessageExpansion(modelData?.notification?.id || "")
}
}
@@ -580,26 +519,16 @@ Rectangle {
Rectangle {
property bool isHovered: false
width: Math.max(
actionText.implicitWidth + 12,
50)
width: Math.max(actionText.implicitWidth + 12, 50)
height: 24
radius: 4
color: isHovered ? Qt.rgba(
Theme.primary.r,
Theme.primary.g,
Theme.primary.b,
0.1) : "transparent"
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
StyledText {
id: actionText
text: {
const baseText = modelData.text
|| "View"
if (keyboardNavigationActive
&& (isGroupSelected
|| selectedNotificationIndex
>= 0)) {
const baseText = modelData.text || "View"
if (keyboardNavigationActive && (isGroupSelected || selectedNotificationIndex >= 0)) {
return `${baseText} (${index + 1})`
}
return baseText
@@ -618,8 +547,7 @@ Rectangle {
onEntered: parent.isHovered = true
onExited: parent.isHovered = false
onClicked: {
if (modelData
&& modelData.invoke) {
if (modelData && modelData.invoke) {
modelData.invoke()
}
}
@@ -630,16 +558,10 @@ Rectangle {
Rectangle {
property bool isHovered: false
width: Math.max(
clearText.implicitWidth + 12,
50)
width: Math.max(clearText.implicitWidth + 12, 50)
height: 24
radius: 4
color: isHovered ? Qt.rgba(
Theme.primary.r,
Theme.primary.g,
Theme.primary.b,
0.1) : "transparent"
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
StyledText {
id: clearText
@@ -656,8 +578,7 @@ Rectangle {
cursorShape: Qt.PointingHandCursor
onEntered: parent.isHovered = true
onExited: parent.isHovered = false
onClicked: NotificationService.dismissNotification(
modelData)
onClicked: NotificationService.dismissNotification(modelData)
}
}
}
@@ -686,8 +607,7 @@ Rectangle {
width: Math.max(actionText.implicitWidth + 12, 50)
height: 24
radius: 4
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g,
Theme.primary.b, 0.1) : "transparent"
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
StyledText {
id: actionText
@@ -734,8 +654,7 @@ Rectangle {
width: clearText.width + 16
height: clearText.height + 8
radius: 6
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g,
Theme.primary.b, 0.1) : "transparent"
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
StyledText {
id: clearText
@@ -752,19 +671,16 @@ Rectangle {
cursorShape: Qt.PointingHandCursor
onEntered: clearButton.isHovered = true
onExited: clearButton.isHovered = false
onClicked: NotificationService.dismissGroup(
notificationGroup?.key || "")
onClicked: NotificationService.dismissGroup(notificationGroup?.key || "")
}
}
MouseArea {
anchors.fill: parent
visible: !expanded && (notificationGroup?.count || 0) > 1
&& !descriptionExpanded
visible: !expanded && (notificationGroup?.count || 0) > 1 && !descriptionExpanded
onClicked: {
root.userInitiatedExpansion = true
NotificationService.toggleGroupExpansion(
notificationGroup?.key || "")
NotificationService.toggleGroupExpansion(notificationGroup?.key || "")
}
z: -1
}
@@ -787,8 +703,7 @@ Rectangle {
buttonSize: 28
onClicked: {
root.userInitiatedExpansion = true
NotificationService.toggleGroupExpansion(
notificationGroup?.key || "")
NotificationService.toggleGroupExpansion(notificationGroup?.key || "")
}
}
@@ -798,8 +713,7 @@ Rectangle {
iconName: "close"
iconSize: 18
buttonSize: 28
onClicked: NotificationService.dismissGroup(
notificationGroup?.key || "")
onClicked: NotificationService.dismissGroup(notificationGroup?.key || "")
}
}

View File

@@ -20,9 +20,9 @@ DankPopout {
id: keyboardController
listView: null
isOpen: notificationHistoryVisible
onClose: function () {
notificationHistoryVisible = false
}
onClose: () => {
notificationHistoryVisible = false
}
}
function setTriggerPosition(x, y, width, section, screen) {
@@ -55,32 +55,27 @@ DankPopout {
onShouldBeVisibleChanged: {
if (shouldBeVisible) {
NotificationService.onOverlayOpen()
// Set up keyboard controller when content is loaded
Qt.callLater(function () {
if (contentLoader.item) {
contentLoader.item.externalKeyboardController = keyboardController
Qt.callLater(() => {
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")
const notificationList = findChild(contentLoader.item, "notificationList")
const notificationHeader = findChild(contentLoader.item, "notificationHeader")
if (notificationList) {
keyboardController.listView = notificationList
notificationList.keyboardController = keyboardController
}
if (notificationHeader) {
notificationHeader.keyboardController = keyboardController
}
if (notificationList) {
keyboardController.listView = notificationList
notificationList.keyboardController = keyboardController
}
if (notificationHeader) {
notificationHeader.keyboardController = keyboardController
}
keyboardController.reset()
keyboardController.rebuildFlatNavigation()
}
})
keyboardController.reset()
keyboardController.rebuildFlatNavigation()
}
})
} else {
NotificationService.onOverlayClose()
// Reset keyboard state when closing
keyboardController.keyboardNavigationActive = false
}
}
@@ -89,9 +84,9 @@ DankPopout {
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)
for (let i = 0; i < parent.children.length; i++) {
const child = parent.children[i]
const result = findChild(child, objectName)
if (result) {
return result
}
@@ -112,44 +107,44 @@ DankPopout {
baseHeight += (notificationSettings.expanded ? notificationSettings.contentHeight : 0)
baseHeight += Theme.spacingM * 2
let listHeight = notificationList.listContentHeight
if (NotificationService.groupedNotifications.length === 0)
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))
const maxHeight = root.screen ? root.screen.height * 0.8 : Screen.height * 0.8
return Math.max(300, Math.min(baseHeight, maxHeight))
}
color: Theme.popupBackground()
radius: Theme.cornerRadius
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g,
Theme.outline.b, 0.08)
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
border.width: 1
focus: true
Component.onCompleted: {
if (root.shouldBeVisible)
if (root.shouldBeVisible) {
forceActiveFocus()
}
Keys.onPressed: function (event) {
if (event.key === Qt.Key_Escape) {
root.close()
event.accepted = true
} else if (externalKeyboardController) {
externalKeyboardController.handleKey(event)
}
}
Keys.onPressed: event => {
if (event.key === Qt.Key_Escape) {
root.close()
event.accepted = true
} else if (externalKeyboardController) {
externalKeyboardController.handleKey(event)
}
}
Connections {
function onShouldBeVisibleChanged() {
if (root.shouldBeVisible)
Qt.callLater(function () {
notificationContent.forceActiveFocus()
})
else
if (root.shouldBeVisible) {
Qt.callLater(() => {
notificationContent.forceActiveFocus()
})
} else {
notificationContent.focus = false
}
}
target: root
}
@@ -182,8 +177,7 @@ DankPopout {
objectName: "notificationList"
width: parent.width
height: parent.height - notificationContent.cachedHeaderHeight
- notificationSettings.height - contentColumnInner.spacing * 2
height: parent.height - notificationContent.cachedHeaderHeight - notificationSettings.height - contentColumnInner.spacing * 2
}
}
}
@@ -194,7 +188,7 @@ DankPopout {
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: Theme.spacingL
showHints: externalKeyboardController ? externalKeyboardController.showKeyboardHints : false
showHints: (externalKeyboardController && externalKeyboardController.showKeyboardHints) || false
z: 200
}

View File

@@ -19,16 +19,14 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
name: "notifications_none"
size: Theme.iconSizeLarge + 16
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
Theme.surfaceText.b, 0.3)
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.3)
}
StyledText {
anchors.horizontalCenter: parent.horizontalCenter
text: "Nothing to see here"
font.pixelSize: Theme.fontSizeLarge
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
Theme.surfaceText.b, 0.3)
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.3)
font.weight: Font.Medium
horizontalAlignment: Text.AlignHCenter
}

View File

@@ -47,7 +47,7 @@ Item {
anchors.bottom: parent.top
anchors.bottomMargin: Theme.spacingS
anchors.horizontalCenter: parent.horizontalCenter
visible: doNotDisturbButton.children[1].containsMouse // Access StateLayer's containsMouse
visible: doNotDisturbButton.children[1].containsMouse
opacity: visible ? 1 : 0
StyledText {
@@ -76,12 +76,10 @@ Item {
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingXS
// Keyboard help button
DankActionButton {
id: helpButton
iconName: "info"
iconColor: keyboardController
&& keyboardController.showKeyboardHints ? Theme.primary : Theme.surfaceText
iconColor: (keyboardController && keyboardController.showKeyboardHints) ? Theme.primary : Theme.surfaceText
buttonSize: 28
visible: keyboardController !== null
anchors.verticalCenter: parent.verticalCenter
@@ -92,7 +90,6 @@ Item {
}
}
// Settings button
DankActionButton {
id: settingsButton
iconName: "settings"
@@ -109,17 +106,8 @@ Item {
height: 28
radius: Theme.cornerRadius
visible: NotificationService.notifications.length > 0
color: clearArea.containsMouse ? Qt.rgba(Theme.primary.r,
Theme.primary.g,
Theme.primary.b,
0.12) : Qt.rgba(
Theme.surfaceVariant.r,
Theme.surfaceVariant.g,
Theme.surfaceVariant.b, 0.3)
border.color: clearArea.containsMouse ? Theme.primary : Qt.rgba(
Theme.outline.r,
Theme.outline.g,
Theme.outline.b, 0.08)
color: clearArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.3)
border.color: clearArea.containsMouse ? Theme.primary : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
border.width: 1
Row {

View File

@@ -25,15 +25,13 @@ QtObject {
function rebuildFlatNavigation() {
isRebuilding = true
var nav = []
var groups = NotificationService.groupedNotifications
const nav = []
const groups = NotificationService.groupedNotifications
for (var i = 0; i < groups.length; i++) {
var group = groups[i]
var isExpanded = NotificationService.expandedGroups[group.key]
|| false
for (let i = 0; i < groups.length; i++) {
const group = groups[i]
const isExpanded = NotificationService.expandedGroups[group.key] || false
// Add the group itself
nav.push({
"type": "group",
"groupIndex": i,
@@ -42,12 +40,10 @@ QtObject {
"notificationId": ""
})
// If expanded, add individual notifications
if (isExpanded) {
var notifications = group.notifications || []
for (var j = 0; j < notifications.length; j++) {
var notifId = String(
notifications[j]?.notification?.id || "")
const notifications = group.notifications || []
for (let j = 0; j < notifications.length; j++) {
const notifId = String(notifications[j] && notifications[j].notification && notifications[j].notification.id ? notifications[j].notification.id : "")
nav.push({
"type": "notification",
"groupIndex": i,
@@ -65,22 +61,18 @@ QtObject {
}
function updateSelectedIndexFromId() {
if (!keyboardNavigationActive)
if (!keyboardNavigationActive) {
return
}
// Find the index that matches our selected ID/key
for (var i = 0; i < flatNavigation.length; i++) {
var item = flatNavigation[i]
for (let i = 0; i < flatNavigation.length; i++) {
const item = flatNavigation[i]
if (selectedItemType === "group" && item.type === "group"
&& item.groupKey === selectedGroupKey) {
if (selectedItemType === "group" && item.type === "group" && item.groupKey === selectedGroupKey) {
selectedFlatIndex = i
selectionVersion++ // Trigger UI update
return
} else if (selectedItemType === "notification"
&& item.type === "notification" && String(
item.notificationId) === String(
selectedNotificationId)) {
} else if (selectedItemType === "notification" && item.type === "notification" && String(item.notificationId) === String(selectedNotificationId)) {
selectedFlatIndex = i
selectionVersion++ // Trigger UI update
return
@@ -89,10 +81,9 @@ QtObject {
// If not found, try to find the same group but select the group header instead
if (selectedItemType === "notification") {
for (var j = 0; j < flatNavigation.length; j++) {
var groupItem = flatNavigation[j]
if (groupItem.type === "group"
&& groupItem.groupKey === selectedGroupKey) {
for (let j = 0; j < flatNavigation.length; j++) {
const groupItem = flatNavigation[j]
if (groupItem.type === "group" && groupItem.groupKey === selectedGroupKey) {
selectedFlatIndex = j
selectedItemType = "group"
selectedNotificationId = ""
@@ -104,8 +95,7 @@ QtObject {
// If still not found, clamp to valid range and update
if (flatNavigation.length > 0) {
selectedFlatIndex = Math.min(selectedFlatIndex,
flatNavigation.length - 1)
selectedFlatIndex = Math.min(selectedFlatIndex, flatNavigation.length - 1)
selectedFlatIndex = Math.max(selectedFlatIndex, 0)
updateSelectedIdFromIndex()
selectionVersion++ // Trigger UI update
@@ -113,9 +103,8 @@ QtObject {
}
function updateSelectedIdFromIndex() {
if (selectedFlatIndex >= 0
&& selectedFlatIndex < flatNavigation.length) {
var item = flatNavigation[selectedFlatIndex]
if (selectedFlatIndex >= 0 && selectedFlatIndex < flatNavigation.length) {
const item = flatNavigation[selectedFlatIndex]
selectedItemType = item.type
selectedGroupKey = item.groupKey
selectedNotificationId = item.notificationId
@@ -143,8 +132,7 @@ QtObject {
listView.enableAutoScroll()
}
selectedFlatIndex = Math.min(selectedFlatIndex + 1,
flatNavigation.length - 1)
selectedFlatIndex = Math.min(selectedFlatIndex + 1, flatNavigation.length - 1)
updateSelectedIdFromIndex()
selectionVersion++
ensureVisible()
@@ -167,8 +155,7 @@ QtObject {
}
function toggleGroupExpanded() {
if (flatNavigation.length === 0
|| selectedFlatIndex >= flatNavigation.length)
if (flatNavigation.length === 0 || selectedFlatIndex >= flatNavigation.length)
return
const currentItem = flatNavigation[selectedFlatIndex]
@@ -182,8 +169,7 @@ QtObject {
if (notificationCount < 2)
return
const wasExpanded = NotificationService.expandedGroups[group.key]
|| false
const wasExpanded = NotificationService.expandedGroups[group.key] || false
const groupIndex = currentItem.groupIndex
isTogglingGroup = true
@@ -193,18 +179,16 @@ QtObject {
// Smart selection after toggle
if (!wasExpanded) {
// Just expanded - move to first notification in the group
for (var i = 0; i < flatNavigation.length; i++) {
if (flatNavigation[i].type === "notification"
&& flatNavigation[i].groupIndex === groupIndex) {
for (let i = 0; i < flatNavigation.length; i++) {
if (flatNavigation[i].type === "notification" && flatNavigation[i].groupIndex === groupIndex) {
selectedFlatIndex = i
break
}
}
} else {
// Just collapsed - stay on the group header
for (var i = 0; i < flatNavigation.length; i++) {
if (flatNavigation[i].type === "group"
&& flatNavigation[i].groupIndex === groupIndex) {
for (let i = 0; i < flatNavigation.length; i++) {
if (flatNavigation[i].type === "group" && flatNavigation[i].groupIndex === groupIndex) {
selectedFlatIndex = i
break
}
@@ -216,8 +200,7 @@ QtObject {
}
function handleEnterKey() {
if (flatNavigation.length === 0
|| selectedFlatIndex >= flatNavigation.length)
if (flatNavigation.length === 0 || selectedFlatIndex >= flatNavigation.length)
return
const currentItem = flatNavigation[selectedFlatIndex]
@@ -239,8 +222,7 @@ QtObject {
}
function toggleTextExpanded() {
if (flatNavigation.length === 0
|| selectedFlatIndex >= flatNavigation.length)
if (flatNavigation.length === 0 || selectedFlatIndex >= flatNavigation.length)
return
const currentItem = flatNavigation[selectedFlatIndex]
@@ -249,15 +231,12 @@ QtObject {
if (!group)
return
var messageId = ""
let messageId = ""
if (currentItem.type === "group") {
messageId = group.latestNotification?.notification?.id + "_desc"
} else if (currentItem.type === "notification"
&& currentItem.notificationIndex >= 0
&& currentItem.notificationIndex < group.notifications.length) {
messageId = group.notifications[currentItem.notificationIndex]?.notification?.id
+ "_desc"
} else if (currentItem.type === "notification" && currentItem.notificationIndex >= 0 && currentItem.notificationIndex < group.notifications.length) {
messageId = group.notifications[currentItem.notificationIndex]?.notification?.id + "_desc"
}
if (messageId) {
@@ -266,8 +245,7 @@ QtObject {
}
function executeAction(actionIndex) {
if (flatNavigation.length === 0
|| selectedFlatIndex >= flatNavigation.length)
if (flatNavigation.length === 0 || selectedFlatIndex >= flatNavigation.length)
return
const currentItem = flatNavigation[selectedFlatIndex]
@@ -276,15 +254,12 @@ QtObject {
if (!group)
return
var actions = []
let actions = []
if (currentItem.type === "group") {
actions = group.latestNotification?.actions || []
} else if (currentItem.type === "notification"
&& currentItem.notificationIndex >= 0
&& currentItem.notificationIndex < group.notifications.length) {
actions = group.notifications[currentItem.notificationIndex]?.actions
|| []
} else if (currentItem.type === "notification" && currentItem.notificationIndex >= 0 && currentItem.notificationIndex < group.notifications.length) {
actions = group.notifications[currentItem.notificationIndex]?.actions || []
}
if (actionIndex >= 0 && actionIndex < actions.length) {
@@ -298,8 +273,7 @@ QtObject {
}
function clearSelected() {
if (flatNavigation.length === 0
|| selectedFlatIndex >= flatNavigation.length)
if (flatNavigation.length === 0 || selectedFlatIndex >= flatNavigation.length)
return
const currentItem = flatNavigation[selectedFlatIndex]
@@ -330,24 +304,20 @@ QtObject {
}
function ensureVisible() {
if (flatNavigation.length === 0
|| selectedFlatIndex >= flatNavigation.length || !listView)
if (flatNavigation.length === 0 || selectedFlatIndex >= flatNavigation.length || !listView)
return
const currentItem = flatNavigation[selectedFlatIndex]
if (keyboardNavigationActive && currentItem
&& currentItem.groupIndex >= 0) {
if (keyboardNavigationActive && currentItem && currentItem.groupIndex >= 0) {
// Always center the selected item for better visibility
// This ensures the selected item stays in view even when new notifications arrive
if (currentItem.type === "notification") {
// For individual notifications, center on the group but bias towards the notification
listView.positionViewAtIndex(currentItem.groupIndex,
ListView.Center)
listView.positionViewAtIndex(currentItem.groupIndex, ListView.Center)
} else {
// For group headers, center on the group
listView.positionViewAtIndex(currentItem.groupIndex,
ListView.Center)
listView.positionViewAtIndex(currentItem.groupIndex, ListView.Center)
}
// Force immediate update
@@ -356,8 +326,7 @@ QtObject {
}
function handleKey(event) {
if ((event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace)
&& (event.modifiers & Qt.ShiftModifier)) {
if ((event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace) && (event.modifiers & Qt.ShiftModifier)) {
NotificationService.clearAllNotifications()
rebuildFlatNavigation()
if (flatNavigation.length === 0) {
@@ -430,15 +399,13 @@ QtObject {
if (event.key === Qt.Key_Space) {
toggleGroupExpanded()
event.accepted = true
} else if (event.key === Qt.Key_Return
|| event.key === Qt.Key_Enter) {
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
handleEnterKey()
event.accepted = true
} else if (event.key === Qt.Key_E) {
toggleTextExpanded()
event.accepted = true
} else if (event.key === Qt.Key_Delete
|| event.key === Qt.Key_Backspace) {
} else if (event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace) {
clearSelected()
event.accepted = true
} else if (event.key >= Qt.Key_1 && event.key <= Qt.Key_9) {
@@ -456,8 +423,7 @@ QtObject {
// Get current selection info for UI
function getCurrentSelection() {
if (!keyboardNavigationActive || selectedFlatIndex < 0
|| selectedFlatIndex >= flatNavigation.length) {
if (!keyboardNavigationActive || selectedFlatIndex < 0 || selectedFlatIndex >= flatNavigation.length) {
return {
"type": "",
"groupIndex": -1,

View File

@@ -9,8 +9,7 @@ Rectangle {
height: 80
radius: Theme.cornerRadius
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g,
Theme.surfaceContainer.b, 0.95)
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.95)
border.color: Theme.primary
border.width: 2
opacity: showHints ? 1 : 0

View File

@@ -15,10 +15,8 @@ Rectangle {
visible: expanded
clip: true
radius: Theme.cornerRadius
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g,
Theme.surfaceContainer.b, 0.3)
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g,
Theme.outline.b, 0.1)
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.3)
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.1)
border.width: 1
Behavior on height {
@@ -29,7 +27,6 @@ Rectangle {
}
}
// Ensure smooth opacity transition
opacity: expanded ? 1 : 0
Behavior on opacity {
NumberAnimation {
@@ -82,17 +79,20 @@ Rectangle {
return "5 seconds"
}
for (var i = 0; i < timeoutOptions.length; i++) {
for (let i = 0; i < timeoutOptions.length; i++) {
if (timeoutOptions[i].value === value) {
return timeoutOptions[i].text
}
}
if (value === 0)
if (value === 0) {
return "Never"
if (value < 1000)
}
if (value < 1000) {
return value + "ms"
if (value < 60000)
}
if (value < 60000) {
return Math.round(value / 1000) + " seconds"
}
return Math.round(value / 60000) + " minutes"
}
@@ -139,16 +139,14 @@ Rectangle {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
checked: SessionData.doNotDisturb
onToggled: SessionData.setDoNotDisturb(
!SessionData.doNotDisturb)
onToggled: SessionData.setDoNotDisturb(!SessionData.doNotDisturb)
}
}
Rectangle {
width: parent.width
height: 1
color: Qt.rgba(Theme.outline.r, Theme.outline.g,
Theme.outline.b, 0.1)
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.1)
}
StyledText {
@@ -165,10 +163,9 @@ Rectangle {
currentValue: getTimeoutText(SettingsData.notificationTimeoutLow)
options: timeoutOptions.map(opt => opt.text)
onValueChanged: value => {
for (var i = 0; i < timeoutOptions.length; i++) {
for (let i = 0; i < timeoutOptions.length; i++) {
if (timeoutOptions[i].text === value) {
SettingsData.setNotificationTimeoutLow(
timeoutOptions[i].value)
SettingsData.setNotificationTimeoutLow(timeoutOptions[i].value)
break
}
}
@@ -182,10 +179,9 @@ Rectangle {
currentValue: getTimeoutText(SettingsData.notificationTimeoutNormal)
options: timeoutOptions.map(opt => opt.text)
onValueChanged: value => {
for (var i = 0; i < timeoutOptions.length; i++) {
for (let i = 0; i < timeoutOptions.length; i++) {
if (timeoutOptions[i].text === value) {
SettingsData.setNotificationTimeoutNormal(
timeoutOptions[i].value)
SettingsData.setNotificationTimeoutNormal(timeoutOptions[i].value)
break
}
}
@@ -196,14 +192,12 @@ Rectangle {
width: parent.width
text: "Critical Priority"
description: "Timeout for critical priority notifications"
currentValue: getTimeoutText(
SettingsData.notificationTimeoutCritical)
currentValue: getTimeoutText(SettingsData.notificationTimeoutCritical)
options: timeoutOptions.map(opt => opt.text)
onValueChanged: value => {
for (var i = 0; i < timeoutOptions.length; i++) {
for (let i = 0; i < timeoutOptions.length; i++) {
if (timeoutOptions[i].text === value) {
SettingsData.setNotificationTimeoutCritical(
timeoutOptions[i].value)
SettingsData.setNotificationTimeoutCritical(timeoutOptions[i].value)
break
}
}
@@ -213,8 +207,7 @@ Rectangle {
Rectangle {
width: parent.width
height: 1
color: Qt.rgba(Theme.outline.r, Theme.outline.g,
Theme.outline.b, 0.1)
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.1)
}
Item {
@@ -255,8 +248,7 @@ Rectangle {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
checked: SettingsData.notificationOverlayEnabled
onToggled: toggled => SettingsData.setNotificationOverlayEnabled(
toggled)
onToggled: toggled => SettingsData.setNotificationOverlayEnabled(toggled)
}
}
}

View File

@@ -13,8 +13,7 @@ PanelWindow {
required property var notificationData
required property string notificationId
readonly property bool hasValidData: notificationData
&& notificationData.notification
readonly property bool hasValidData: notificationData && notificationData.notification
property int screenY: 0
property bool exiting: false
property bool _isDestroying: false
@@ -24,20 +23,20 @@ PanelWindow {
signal exitFinished
function startExit() {
if (exiting || _isDestroying)
if (exiting || _isDestroying) {
return
}
exiting = true
exitAnim.restart()
exitWatchdog.restart()
if (NotificationService.removeFromVisibleNotifications)
NotificationService.removeFromVisibleNotifications(
win.notificationData)
NotificationService.removeFromVisibleNotifications(win.notificationData)
}
function forceExit() {
if (_isDestroying)
if (_isDestroying) {
return
}
_isDestroying = true
exiting = true
visible = false
@@ -46,8 +45,9 @@ PanelWindow {
}
function finalizeExit(reason) {
if (_finalized)
if (_finalized) {
return
}
_finalized = true
_isDestroying = true
@@ -64,8 +64,7 @@ PanelWindow {
SettingsData.notificationOverlayEnabled
const shouldUseOverlay = (SettingsData.notificationOverlayEnabled)
|| (notificationData.urgency === NotificationUrgency.Critical)
const shouldUseOverlay = (SettingsData.notificationOverlayEnabled) || (notificationData.urgency === NotificationUrgency.Critical)
return shouldUseOverlay ? WlrLayershell.Overlay : WlrLayershell.Top
}
@@ -77,38 +76,33 @@ PanelWindow {
onScreenYChanged: margins.top = Theme.barHeight - 4 + SettingsData.topBarSpacing + 4 + screenY
onHasValidDataChanged: {
if (!hasValidData && !exiting && !_isDestroying) {
forceExit()
}
}
Component.onCompleted: {
if (hasValidData) {
Qt.callLater(() => {
return enterX.restart()
})
Qt.callLater(() => enterX.restart())
} else {
forceExit()
}
}
onNotificationDataChanged: {
if (!_isDestroying) {
wrapperConn.target = win.notificationData || null
notificationConn.target = (win.notificationData
&& win.notificationData.notification
&& win.notificationData.notification.Retainable)
|| null
notificationConn.target = (win.notificationData && win.notificationData.notification && win.notificationData.notification.Retainable) || null
}
}
onEntered: {
if (!_isDestroying)
if (!_isDestroying) {
enterDelay.start()
}
}
Component.onDestruction: {
_isDestroying = true
exitWatchdog.stop()
if (notificationData && notificationData.timer)
if (notificationData && notificationData.timer) {
notificationData.timer.stop()
}
}
anchors {
@@ -136,18 +130,8 @@ PanelWindow {
anchors.margins: 4
radius: Theme.cornerRadius
color: Theme.popupBackground()
border.color: notificationData && notificationData.urgency
=== NotificationUrgency.Critical ? Qt.rgba(
Theme.primary.r,
Theme.primary.g,
Theme.primary.b,
0.3) : Qt.rgba(
Theme.outline.r,
Theme.outline.g,
Theme.outline.b,
0.08)
border.width: notificationData
&& notificationData.urgency === NotificationUrgency.Critical ? 2 : 1
border.color: notificationData && notificationData.urgency === NotificationUrgency.Critical ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.3) : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
border.width: notificationData && notificationData.urgency === NotificationUrgency.Critical ? 2 : 1
clip: true
Rectangle {
@@ -179,8 +163,7 @@ PanelWindow {
anchors.fill: parent
color: "transparent"
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g,
Theme.outline.b, 0.12)
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.12)
border.width: 1
radius: parent.radius
z: -1
@@ -189,8 +172,7 @@ PanelWindow {
Rectangle {
anchors.fill: parent
radius: parent.radius
visible: notificationData
&& notificationData.urgency === NotificationUrgency.Critical
visible: notificationData && notificationData.urgency === NotificationUrgency.Critical
opacity: 1
gradient: Gradient {
@@ -227,15 +209,12 @@ PanelWindow {
Rectangle {
id: iconContainer
readonly property bool hasNotificationImage: notificationData
&& notificationData.image
&& notificationData.image !== ""
readonly property bool hasNotificationImage: notificationData && notificationData.image && notificationData.image !== ""
width: 55
height: 55
radius: 27.5
color: Qt.rgba(Theme.primary.r, Theme.primary.g,
Theme.primary.b, 0.1)
color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1)
border.color: "transparent"
border.width: 0
anchors.left: parent.left
@@ -256,9 +235,7 @@ PanelWindow {
if (notificationData.appIcon) {
const appIcon = notificationData.appIcon
if (appIcon.startsWith("file://")
|| appIcon.startsWith("http://")
|| appIcon.startsWith("https://"))
if (appIcon.startsWith("file://") || appIcon.startsWith("http://") || appIcon.startsWith("https://"))
return appIcon
return Quickshell.iconPath(appIcon, true)
@@ -270,13 +247,9 @@ PanelWindow {
StyledText {
anchors.centerIn: parent
visible: !parent.hasNotificationImage
&& (!notificationData
|| !notificationData.appIcon
|| notificationData.appIcon === "")
visible: !parent.hasNotificationImage && (!notificationData || !notificationData.appIcon || notificationData.appIcon === "")
text: {
const appName = notificationData
&& notificationData.appName ? notificationData.appName : "?"
const appName = notificationData && notificationData.appName ? notificationData.appName : "?"
return appName.charAt(0).toUpperCase()
}
font.pixelSize: 20
@@ -313,10 +286,8 @@ PanelWindow {
if (!notificationData)
return ""
const appName = notificationData.appName
|| ""
const timeStr = notificationData.timeStr
|| ""
const appName = notificationData.appName || ""
const timeStr = notificationData.timeStr || ""
if (timeStr.length > 0)
return appName + " • " + timeStr
else
@@ -330,8 +301,7 @@ PanelWindow {
}
StyledText {
text: notificationData ? (notificationData.summary
|| "") : ""
text: notificationData ? (notificationData.summary || "") : ""
color: Theme.surfaceText
font.pixelSize: Theme.fontSizeMedium
font.weight: Font.Medium
@@ -342,8 +312,7 @@ PanelWindow {
}
StyledText {
text: notificationData ? (notificationData.htmlBody
|| "") : ""
text: notificationData ? (notificationData.htmlBody || "") : ""
color: Theme.surfaceVariantText
font.pixelSize: Theme.fontSizeSmall
width: parent.width
@@ -353,8 +322,7 @@ PanelWindow {
visible: text.length > 0
linkColor: Theme.primary
onLinkActivated: link => {
return Qt.openUrlExternally(
link)
return Qt.openUrlExternally(link)
}
MouseArea {
@@ -394,8 +362,7 @@ PanelWindow {
z: 20
Repeater {
model: notificationData ? (notificationData.actions
|| []) : []
model: notificationData ? (notificationData.actions || []) : []
Rectangle {
property bool isHovered: false
@@ -403,10 +370,7 @@ PanelWindow {
width: Math.max(actionText.implicitWidth + 12, 50)
height: 24
radius: 4
color: isHovered ? Qt.rgba(Theme.primary.r,
Theme.primary.g,
Theme.primary.b,
0.1) : "transparent"
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
StyledText {
id: actionText
@@ -450,8 +414,7 @@ PanelWindow {
width: Math.max(clearText.implicitWidth + 12, 50)
height: 24
radius: 4
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g,
Theme.primary.b, 0.1) : "transparent"
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
z: 20
StyledText {
@@ -473,8 +436,7 @@ PanelWindow {
onExited: clearButton.isHovered = false
onClicked: {
if (notificationData && !win.exiting)
NotificationService.dismissNotification(
notificationData)
NotificationService.dismissNotification(notificationData)
}
}
}
@@ -492,8 +454,7 @@ PanelWindow {
notificationData.timer.stop()
}
onExited: {
if (notificationData && notificationData.popup
&& notificationData.timer)
if (notificationData && notificationData.popup && notificationData.timer)
notificationData.timer.restart()
}
onClicked: {
@@ -587,8 +548,7 @@ PanelWindow {
forceExit()
}
target: (win.notificationData && win.notificationData.notification
&& win.notificationData.notification.Retainable) || null
target: (win.notificationData && win.notificationData.notification && win.notificationData.notification.Retainable) || null
ignoreUnknownSignals: true
enabled: !win._isDestroying
}
@@ -599,8 +559,7 @@ PanelWindow {
interval: 160
repeat: false
onTriggered: {
if (notificationData && notificationData.timer && !exiting
&& !_isDestroying)
if (notificationData && notificationData.timer && !exiting && !_isDestroying)
notificationData.timer.start()
}
}

View File

@@ -38,125 +38,120 @@ QtObject {
running: false
repeat: true
onTriggered: {
let toRemove = []
for (let p of popupWindows) {
if (!p) { toRemove.push(p); continue }
const isZombie =
p.status === Component.Null ||
(!p.visible && !p.exiting) ||
(!p.notificationData && !p._isDestroying) ||
(!p.hasValidData && !p._isDestroying)
const toRemove = []
for (const p of popupWindows) {
if (!p) {
toRemove.push(p)
continue
}
const isZombie = p.status === Component.Null || (!p.visible && !p.exiting) || (!p.notificationData && !p._isDestroying) || (!p.hasValidData && !p._isDestroying)
if (isZombie) {
toRemove.push(p)
if (p.forceExit) p.forceExit()
else if (p.destroy) { try { p.destroy() } catch(e) {} }
if (p.forceExit) {
p.forceExit()
} else if (p.destroy) {
try {
p.destroy()
} catch (e) {
}
}
}
}
if (toRemove.length) {
popupWindows = popupWindows.filter(p => toRemove.indexOf(p) === -1)
const survivors = _active().sort((a,b)=>a.screenY-b.screenY)
for (var k=0; k<survivors.length; ++k)
const survivors = _active().sort((a, b) => a.screenY - b.screenY)
for (let k = 0; k < survivors.length; ++k) {
survivors[k].screenY = topMargin + k * baseNotificationHeight
}
}
if (popupWindows.length === 0) {
sweeper.stop()
}
if (popupWindows.length === 0) sweeper.stop()
}
}
function _hasWindowFor(w) {
return popupWindows.some(p => {
return p && p.notificationData === w
&& !p._isDestroying
&& p.status !== Component.Null
})
return popupWindows.some(p => p && p.notificationData === w && !p._isDestroying && p.status !== Component.Null)
}
function _isValidWindow(p) {
return p && p.status !== Component.Null && !p._isDestroying
&& p.hasValidData
return p && p.status !== Component.Null && !p._isDestroying && p.hasValidData
}
function _canMakeRoomFor(wrapper) {
const activeWindows = _active()
if (activeWindows.length < maxTargetNotifications)
if (activeWindows.length < maxTargetNotifications) {
return true
if (!wrapper || !wrapper.notification)
}
if (!wrapper || !wrapper.notification) {
return false
}
const incomingUrgency = wrapper.notification.urgency || 0
for (let p of activeWindows) {
if (!p.notificationData || !p.notificationData.notification)
for (const p of activeWindows) {
if (!p.notificationData || !p.notificationData.notification) {
continue
}
const existingUrgency = p.notificationData.notification.urgency || 0
if (existingUrgency < incomingUrgency)
if (existingUrgency < incomingUrgency) {
return true
}
if (existingUrgency === incomingUrgency) {
const timer = p.notificationData.timer
if (timer && !timer.running)
if (timer && !timer.running) {
return true
}
}
}
return false
}
function _makeRoomForNew(wrapper) {
const activeWindows = _active()
if (activeWindows.length < maxTargetNotifications)
if (activeWindows.length < maxTargetNotifications) {
return
}
const toRemove = _selectPopupToRemove(activeWindows, wrapper)
if (toRemove && !toRemove.exiting) {
toRemove.notificationData.removedByLimit = true
toRemove.notificationData.popup = false
if (toRemove.notificationData.timer)
if (toRemove.notificationData.timer) {
toRemove.notificationData.timer.stop()
}
}
}
function _selectPopupToRemove(activeWindows, incomingWrapper) {
const incomingUrgency = (incomingWrapper && incomingWrapper.notification)
? incomingWrapper.notification.urgency || 0 : 0
const incomingUrgency = (incomingWrapper && incomingWrapper.notification) ? incomingWrapper.notification.urgency || 0 : 0
const sortedWindows = activeWindows.slice().sort((a, b) => {
const aUrgency = (a.notificationData && a.notificationData.notification)
? a.notificationData.notification.urgency || 0 : 0
const bUrgency = (b.notificationData && b.notificationData.notification)
? b.notificationData.notification.urgency || 0 : 0
if (aUrgency !== bUrgency)
return aUrgency - bUrgency
const aTimer = a.notificationData && a.notificationData.timer
const bTimer = b.notificationData && b.notificationData.timer
const aRunning = aTimer && aTimer.running
const bRunning = bTimer && bTimer.running
if (aRunning !== bRunning)
return aRunning ? 1 : -1
return b.screenY - a.screenY
})
const aUrgency = (a.notificationData && a.notificationData.notification) ? a.notificationData.notification.urgency || 0 : 0
const bUrgency = (b.notificationData && b.notificationData.notification) ? b.notificationData.notification.urgency || 0 : 0
if (aUrgency !== bUrgency) {
return aUrgency - bUrgency
}
const aTimer = a.notificationData && a.notificationData.timer
const bTimer = b.notificationData && b.notificationData.timer
const aRunning = aTimer && aTimer.running
const bRunning = bTimer && bTimer.running
if (aRunning !== bRunning) {
return aRunning ? 1 : -1
}
return b.screenY - a.screenY
})
return sortedWindows[0]
}
function _sync(newWrappers) {
for (let w of newWrappers) {
if (w && !_hasWindowFor(w))
for (const w of newWrappers) {
if (w && !_hasWindowFor(w)) {
insertNewestAtTop(w)
}
}
for (let p of popupWindows.slice()) {
if (!_isValidWindow(p))
for (const p of popupWindows.slice()) {
if (!_isValidWindow(p)) {
continue
if (p.notificationData && newWrappers.indexOf(
p.notificationData) === -1 && !p.exiting) {
}
if (p.notificationData && newWrappers.indexOf(p.notificationData) === -1 && !p.exiting) {
p.notificationData.removedByLimit = true
p.notificationData.popup = false
}
@@ -165,21 +160,18 @@ QtObject {
function insertNewestAtTop(wrapper) {
if (!wrapper) {
return
}
for (let p of popupWindows) {
if (!_isValidWindow(p))
for (const p of popupWindows) {
if (!_isValidWindow(p)) {
continue
if (p.exiting)
}
if (p.exiting) {
continue
}
p.screenY = p.screenY + baseNotificationHeight
}
const notificationId = wrapper
&& wrapper.notification ? wrapper.notification.id : ""
const notificationId = wrapper && wrapper.notification ? wrapper.notification.id : ""
const win = popupComponent.createObject(null, {
"notificationData": wrapper,
"notificationId": notificationId,
@@ -187,30 +179,26 @@ QtObject {
"screen": manager.modelData
})
if (!win) {
return
}
if (!win.hasValidData) {
win.destroy()
return
}
popupWindows.push(win)
if (!sweeper.running)
if (!sweeper.running) {
sweeper.start()
}
}
function _active() {
return popupWindows.filter(p => {
return _isValidWindow(p)
&& p.notificationData
&& p.notificationData.popup && !p.exiting
})
return popupWindows.filter(p => _isValidWindow(p) && p.notificationData && p.notificationData.popup && !p.exiting)
}
function _bottom() {
let b = null, maxY = -1
for (let p of _active()) {
let b = null
let maxY = -1
for (const p of _active()) {
if (p.screenY > maxY) {
maxY = p.screenY
b = p
@@ -219,26 +207,25 @@ QtObject {
return b
}
function _onPopupEntered(p) {
}
function _onPopupEntered(p) {}
function _onPopupExitFinished(p) {
if (!p)
if (!p) {
return
}
const windowId = p.toString()
if (destroyingWindows.has(windowId))
if (destroyingWindows.has(windowId)) {
return
}
destroyingWindows.add(windowId)
const i = popupWindows.indexOf(p)
if (i !== -1) {
popupWindows.splice(i, 1)
popupWindows = popupWindows.slice()
}
if (NotificationService.releaseWrapper && p.notificationData)
if (NotificationService.releaseWrapper && p.notificationData) {
NotificationService.releaseWrapper(p.notificationData)
}
Qt.callLater(() => {
if (p && p.destroy) {
try {
@@ -247,27 +234,24 @@ QtObject {
}
}
Qt.callLater(() => {
destroyingWindows.delete(windowId)
})
Qt.callLater(() => destroyingWindows.delete(windowId))
})
const survivors = _active().sort((a, b) => {
return a.screenY - b.screenY
})
for (var k = 0; k < survivors.length; ++k) {
const survivors = _active().sort((a, b) => a.screenY - b.screenY)
for (let k = 0; k < survivors.length; ++k) {
survivors[k].screenY = topMargin + k * baseNotificationHeight
}
}
function cleanupAllWindows() {
sweeper.stop()
for (let p of popupWindows.slice()) {
for (const p of popupWindows.slice()) {
if (p) {
try {
if (p.forceExit)
if (p.forceExit) {
p.forceExit()
else if (p.destroy)
} else if (p.destroy) {
p.destroy()
}
} catch (e) {
}
@@ -278,9 +262,10 @@ QtObject {
}
onPopupWindowsChanged: {
if (popupWindows.length > 0 && !sweeper.running)
if (popupWindows.length > 0 && !sweeper.running) {
sweeper.start()
else if (popupWindows.length === 0 && sweeper.running)
} else if (popupWindows.length === 0 && sweeper.running) {
sweeper.stop()
}
}
}