mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-08 22:45:38 -05:00
Updated image & theme logic and added proper close buttons to the notifications
This commit is contained in:
@@ -69,6 +69,7 @@ PanelWindow {
|
|||||||
height: 32
|
height: 32
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
id: notificationsTitle
|
||||||
text: "Notifications"
|
text: "Notifications"
|
||||||
font.pixelSize: Theme.fontSizeLarge
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
color: Theme.surfaceText
|
color: Theme.surfaceText
|
||||||
@@ -76,62 +77,73 @@ PanelWindow {
|
|||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
Item { width: parent.width - 200; height: 1 }
|
Item {
|
||||||
}
|
width: parent.width - notificationsTitle.width - clearButton.width - Theme.spacingM
|
||||||
|
height: 1
|
||||||
Rectangle {
|
|
||||||
width: parent.width
|
|
||||||
height: 36
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: clearArea.containsMouse ? Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.16) : Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12)
|
|
||||||
border.color: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.5)
|
|
||||||
border.width: 1
|
|
||||||
visible: notificationHistory.count > 0
|
|
||||||
|
|
||||||
Row {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
spacing: Theme.spacingS
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: "delete_sweep"
|
|
||||||
font.family: Theme.iconFont
|
|
||||||
font.pixelSize: Theme.iconSizeSmall + 2
|
|
||||||
color: Theme.error
|
|
||||||
font.weight: Theme.iconFontWeight
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: "Clear All Notifications"
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
color: Theme.error
|
|
||||||
font.weight: Font.Medium
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
// Compact Clear All Button
|
||||||
id: clearArea
|
Rectangle {
|
||||||
anchors.fill: parent
|
id: clearButton
|
||||||
hoverEnabled: true
|
width: 120
|
||||||
cursorShape: Qt.PointingHandCursor
|
height: 28
|
||||||
|
radius: Theme.cornerRadius
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
visible: notificationHistory.count > 0
|
||||||
|
|
||||||
onClicked: {
|
color: clearArea.containsMouse ?
|
||||||
notificationHistory.clear()
|
Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) :
|
||||||
|
Theme.surfaceContainer
|
||||||
|
|
||||||
|
border.color: clearArea.containsMouse ?
|
||||||
|
Theme.primary :
|
||||||
|
Theme.outline
|
||||||
|
border.width: 1
|
||||||
|
|
||||||
|
Row {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: "delete_sweep"
|
||||||
|
font.family: Theme.iconFont
|
||||||
|
font.pixelSize: Theme.iconSizeSmall
|
||||||
|
color: clearArea.containsMouse ? Theme.primary : Theme.surfaceText
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: "Clear All"
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: clearArea.containsMouse ? Theme.primary : Theme.surfaceText
|
||||||
|
font.weight: Font.Medium
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
MouseArea {
|
||||||
Behavior on color {
|
id: clearArea
|
||||||
ColorAnimation {
|
anchors.fill: parent
|
||||||
duration: Theme.shortDuration
|
hoverEnabled: true
|
||||||
easing.type: Theme.standardEasing
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
notificationHistory.clear()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Behavior on color {
|
||||||
Behavior on border.color {
|
ColorAnimation {
|
||||||
ColorAnimation {
|
duration: Theme.shortDuration
|
||||||
duration: Theme.shortDuration
|
easing.type: Theme.standardEasing
|
||||||
easing.type: Theme.standardEasing
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on border.color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: Theme.shortDuration
|
||||||
|
easing.type: Theme.standardEasing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,9 +166,46 @@ PanelWindow {
|
|||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
color: notifArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08)
|
color: notifArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08)
|
||||||
|
|
||||||
|
// Close button for individual notification
|
||||||
|
Rectangle {
|
||||||
|
width: 24
|
||||||
|
height: 24
|
||||||
|
radius: 12
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.margins: 8
|
||||||
|
color: closeNotifArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent"
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: "close"
|
||||||
|
font.family: Theme.iconFont
|
||||||
|
font.pixelSize: 14
|
||||||
|
color: closeNotifArea.containsMouse ? Theme.primary : Theme.surfaceText
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: closeNotifArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: {
|
||||||
|
notificationHistory.remove(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: Theme.shortDuration
|
||||||
|
easing.type: Theme.standardEasing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Theme.spacingM
|
anchors.margins: Theme.spacingM
|
||||||
|
anchors.rightMargin: 36 // Don't overlap with close button
|
||||||
spacing: Theme.spacingM
|
spacing: Theme.spacingM
|
||||||
|
|
||||||
// Notification icon based on EXAMPLE NotificationAppIcon pattern
|
// Notification icon based on EXAMPLE NotificationAppIcon pattern
|
||||||
@@ -212,8 +261,6 @@ PanelWindow {
|
|||||||
Image {
|
Image {
|
||||||
id: historyNotifImage
|
id: historyNotifImage
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
readonly property int size: parent.width
|
|
||||||
property bool imageValid: true
|
|
||||||
|
|
||||||
source: model.image || ""
|
source: model.image || ""
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
@@ -221,38 +268,33 @@ PanelWindow {
|
|||||||
antialiasing: true
|
antialiasing: true
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
smooth: true
|
smooth: true
|
||||||
visible: imageValid
|
|
||||||
|
|
||||||
// Proper sizing like EXAMPLE
|
// Use the parent size for optimization
|
||||||
width: size
|
sourceSize.width: parent.width
|
||||||
height: size
|
sourceSize.height: parent.height
|
||||||
sourceSize.width: size
|
|
||||||
sourceSize.height: size
|
|
||||||
|
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
layer.effect: MultiEffect {
|
layer.effect: MultiEffect {
|
||||||
maskEnabled: true
|
maskEnabled: true
|
||||||
maskSource: Rectangle {
|
maskSource: Rectangle {
|
||||||
width: historyNotifImage.size
|
width: 48
|
||||||
height: historyNotifImage.size
|
height: 48
|
||||||
radius: historyNotifImage.size / 2 // Fully rounded
|
radius: 24 // Fully rounded
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onStatusChanged: {
|
onStatusChanged: {
|
||||||
if (status === Image.Error) {
|
if (status === Image.Error) {
|
||||||
console.warn("Failed to load notification history image:", source)
|
console.warn("Failed to load notification history image:", source)
|
||||||
imageValid = false
|
|
||||||
} else if (status === Image.Ready) {
|
} else if (status === Image.Ready) {
|
||||||
console.log("Notification history image loaded:", source, "size:", sourceSize.width + "x" + sourceSize.height)
|
console.log("Notification history image loaded:", source, "size:", sourceSize.width + "x" + sourceSize.height)
|
||||||
imageValid = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to app icon when primary image fails
|
// Fallback to app icon when primary image fails
|
||||||
Loader {
|
Loader {
|
||||||
active: !historyNotifImage.imageValid && model.appIcon && model.appIcon !== ""
|
active: model.appIcon && model.appIcon !== "" && historyNotifImage.status === Image.Error
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
sourceComponent: IconImage {
|
sourceComponent: IconImage {
|
||||||
width: 32
|
width: 32
|
||||||
@@ -270,7 +312,7 @@ PanelWindow {
|
|||||||
|
|
||||||
// Small app icon overlay when showing notification image
|
// Small app icon overlay when showing notification image
|
||||||
Loader {
|
Loader {
|
||||||
active: historyNotifImage.imageValid && model.appIcon && model.appIcon !== ""
|
active: model.appIcon && model.appIcon !== "" && historyNotifImage.status === Image.Ready
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
sourceComponent: IconImage {
|
sourceComponent: IconImage {
|
||||||
@@ -329,6 +371,7 @@ PanelWindow {
|
|||||||
MouseArea {
|
MouseArea {
|
||||||
id: notifArea
|
id: notifArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
anchors.rightMargin: 32 // Don't overlap with close button area
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
|
|||||||
@@ -76,14 +76,14 @@ PanelWindow {
|
|||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.margins: 8
|
anchors.margins: 8
|
||||||
color: closeButtonArea.containsMouse ? Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) : "transparent"
|
color: closeButtonArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent"
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: "close"
|
text: "close"
|
||||||
font.family: Theme.iconFont
|
font.family: Theme.iconFont
|
||||||
font.pixelSize: 16
|
font.pixelSize: 16
|
||||||
color: closeButtonArea.containsMouse ? Theme.error : Theme.surfaceText
|
color: closeButtonArea.containsMouse ? Theme.primary : Theme.surfaceText
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
@@ -163,7 +163,6 @@ PanelWindow {
|
|||||||
Image {
|
Image {
|
||||||
id: notifImage
|
id: notifImage
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
readonly property int size: parent.width
|
|
||||||
|
|
||||||
source: root.activeNotification ? root.activeNotification.image : ""
|
source: root.activeNotification ? root.activeNotification.image : ""
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
@@ -172,19 +171,17 @@ PanelWindow {
|
|||||||
asynchronous: true
|
asynchronous: true
|
||||||
smooth: true
|
smooth: true
|
||||||
|
|
||||||
// Proper sizing like EXAMPLE
|
// Use the parent size for optimization
|
||||||
width: size
|
sourceSize.width: parent.width
|
||||||
height: size
|
sourceSize.height: parent.height
|
||||||
sourceSize.width: size
|
|
||||||
sourceSize.height: size
|
|
||||||
|
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
layer.effect: MultiEffect {
|
layer.effect: MultiEffect {
|
||||||
maskEnabled: true
|
maskEnabled: true
|
||||||
maskSource: Rectangle {
|
maskSource: Rectangle {
|
||||||
width: notifImage.size
|
width: 48
|
||||||
height: notifImage.size
|
height: 48
|
||||||
radius: notifImage.size / 2 // Fully rounded
|
radius: 24 // Fully rounded
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user