summaryrefslogtreecommitdiff
path: root/modules/notifications/Content.qml
diff options
context:
space:
mode:
Diffstat (limited to 'modules/notifications/Content.qml')
-rw-r--r--modules/notifications/Content.qml58
1 files changed, 55 insertions, 3 deletions
diff --git a/modules/notifications/Content.qml b/modules/notifications/Content.qml
index 2d4590e..035a228 100644
--- a/modules/notifications/Content.qml
+++ b/modules/notifications/Content.qml
@@ -13,6 +13,8 @@ Item {
required property Item panels
readonly property int padding: Appearance.padding.large
+ property bool shouldShow: false
+
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
@@ -20,13 +22,16 @@ Item {
implicitWidth: Config.notifs.sizes.width + padding * 2
implicitHeight: {
const count = list.count;
- if (count === 0)
+ if (count === 0 || !shouldShow)
return 0;
let height = (count - 1) * Appearance.spacing.smaller;
for (let i = 0; i < count; i++)
height += list.itemAtIndex(i)?.nonAnimHeight ?? 0;
+ const screenHeight = QsWindow.window?.screen?.height ?? 0;
+ const maxHeight = Math.floor(screenHeight * 0.45);
+
if (visibilities && panels) {
if (visibilities.osd) {
const h = panels.osd.y - Config.border.rounding * 2 - padding * 2;
@@ -41,7 +46,8 @@ Item {
}
}
- return Math.min((QsWindow.window?.screen?.height ?? 0) - Config.border.thickness * 2, height + padding * 2);
+ const availableHeight = Math.min(maxHeight, screenHeight - Config.border.thickness * 2);
+ return Math.min(availableHeight, height + padding * 2);
}
ClippingWrapperRectangle {
@@ -55,7 +61,7 @@ Item {
id: list
model: ScriptModel {
- values: Notifs.popups.filter(n => !n.closed)
+ values: [...Notifs.notClosed]
}
anchors.fill: parent
@@ -192,6 +198,52 @@ Item {
}
}
+ Timer {
+ id: hideTimer
+
+ interval: 5000
+ onTriggered: {
+ if (list.count > 0)
+ root.shouldShow = false;
+ }
+ }
+
+ function show(): void {
+ if (list.count > 0) {
+ shouldShow = true;
+ hideTimer.restart();
+ }
+ }
+
+ Connections {
+ target: list
+
+ function onCountChanged(): void {
+ if (list.count === 0) {
+ root.shouldShow = false;
+ hideTimer.stop();
+ }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ acceptedButtons: Qt.NoButton
+ onEntered: {
+ if (list.count > 0) {
+ root.shouldShow = true;
+ hideTimer.restart();
+ }
+ }
+ onExited: {
+ if (list.count > 0) {
+ root.shouldShow = false;
+ hideTimer.stop();
+ }
+ }
+ }
+
Behavior on implicitHeight {
Anim {}
}