feat: notif popups margin ignore border
This commit is contained in:
parent
713302c045
commit
573cc9def0
4 changed files with 17 additions and 9 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
|
import Caelestia
|
||||||
import Caelestia.Config
|
import Caelestia.Config
|
||||||
import qs.components
|
import qs.components
|
||||||
import qs.components.containers
|
import qs.components.containers
|
||||||
|
|
@ -16,12 +19,13 @@ Item {
|
||||||
required property Item sessionPanel
|
required property Item sessionPanel
|
||||||
required property Item utilitiesPanel
|
required property Item utilitiesPanel
|
||||||
readonly property int padding: Tokens.padding.large
|
readonly property int padding: Tokens.padding.large
|
||||||
|
readonly property int clampedPadding: CUtils.clamp(padding - Config.border.thickness, 0, padding)
|
||||||
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
implicitWidth: Tokens.sizes.notifs.width + padding * 2
|
implicitWidth: Tokens.sizes.notifs.width
|
||||||
implicitHeight: {
|
implicitHeight: {
|
||||||
const count = list.count;
|
const count = list.count;
|
||||||
if (count === 0)
|
if (count === 0)
|
||||||
|
|
@ -32,13 +36,13 @@ Item {
|
||||||
height += (list.itemAtIndex(i) as NotifWrapper)?.nonAnimHeight ?? 0;
|
height += (list.itemAtIndex(i) as NotifWrapper)?.nonAnimHeight ?? 0;
|
||||||
|
|
||||||
if (visibilities.osd) {
|
if (visibilities.osd) {
|
||||||
const h = osdPanel.y - padding;
|
const h = osdPanel.y - clampedPadding;
|
||||||
if (height > h)
|
if (height > h)
|
||||||
height = h;
|
height = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibilities.session) {
|
if (visibilities.session) {
|
||||||
const h = sessionPanel.y - padding;
|
const h = sessionPanel.y - clampedPadding;
|
||||||
if (height > h)
|
if (height > h)
|
||||||
height = h;
|
height = h;
|
||||||
}
|
}
|
||||||
|
|
@ -49,12 +53,14 @@ Item {
|
||||||
height = h;
|
height = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.min(((QsWindow.window as QsWindow)?.screen?.height ?? 0) - Config.border.thickness * 2, height + padding * 2);
|
return Math.min(((QsWindow.window as QsWindow)?.screen?.height ?? 0) + padding - clampedPadding * 2 - Config.border.thickness, height + padding + clampedPadding);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClippingWrapperRectangle {
|
ClippingWrapperRectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: root.padding
|
anchors.margins: root.padding
|
||||||
|
anchors.topMargin: root.clampedPadding
|
||||||
|
anchors.rightMargin: root.clampedPadding
|
||||||
|
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
radius: Tokens.rounding.large
|
radius: Tokens.rounding.large
|
||||||
|
|
@ -178,7 +184,7 @@ Item {
|
||||||
Anim {
|
Anim {
|
||||||
target: notif
|
target: notif
|
||||||
property: "x"
|
property: "x"
|
||||||
to: (notif.x >= 0 ? wrapper.Tokens.sizes.notifs.width : -wrapper.Tokens.sizes.notifs.width) * 2
|
to: (notif.x >= 0 ? root.implicitWidth : -root.implicitWidth) * 2
|
||||||
duration: Tokens.anim.durations.normal
|
duration: Tokens.anim.durations.normal
|
||||||
easing: Tokens.anim.emphasized
|
easing: Tokens.anim.emphasized
|
||||||
}
|
}
|
||||||
|
|
@ -202,6 +208,7 @@ Item {
|
||||||
id: notif
|
id: notif
|
||||||
|
|
||||||
modelData: wrapper.modelData
|
modelData: wrapper.modelData
|
||||||
|
implicitWidth: root.implicitWidth - root.padding - root.clampedPadding
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@ StyledRect {
|
||||||
|
|
||||||
color: root.modelData.urgency === NotificationUrgency.Critical ? Colours.palette.m3secondaryContainer : Colours.tPalette.m3surfaceContainer
|
color: root.modelData.urgency === NotificationUrgency.Critical ? Colours.palette.m3secondaryContainer : Colours.tPalette.m3surfaceContainer
|
||||||
radius: Tokens.rounding.large
|
radius: Tokens.rounding.large
|
||||||
implicitWidth: Tokens.sizes.notifs.width
|
|
||||||
implicitHeight: inner.implicitHeight
|
implicitHeight: inner.implicitHeight
|
||||||
|
|
||||||
x: Tokens.sizes.notifs.width
|
x: implicitWidth
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
x = 0;
|
x = 0;
|
||||||
modelData.lock(this);
|
modelData.lock(this);
|
||||||
|
|
@ -68,7 +68,7 @@ StyledRect {
|
||||||
if (!containsMouse)
|
if (!containsMouse)
|
||||||
root.modelData.timer.start();
|
root.modelData.timer.start();
|
||||||
|
|
||||||
if (Math.abs(root.x) < Tokens.sizes.notifs.width * Config.notifs.clearThreshold)
|
if (Math.abs(root.x) < root.implicitWidth * Config.notifs.clearThreshold)
|
||||||
root.x = 0;
|
root.x = 0;
|
||||||
else
|
else
|
||||||
root.modelData.popup = false;
|
root.modelData.popup = false;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ Item {
|
||||||
Content {
|
Content {
|
||||||
id: content
|
id: content
|
||||||
|
|
||||||
|
anchors.topMargin: -root.anchors.topMargin
|
||||||
visibilities: root.visibilities
|
visibilities: root.visibilities
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ class NotifsTokens : public ConfigObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ANONYMOUS
|
QML_ANONYMOUS
|
||||||
|
|
||||||
CONFIG_PROPERTY(int, width, 400)
|
CONFIG_PROPERTY(int, width, 430)
|
||||||
CONFIG_GLOBAL_PROPERTY(int, image, 42)
|
CONFIG_GLOBAL_PROPERTY(int, image, 42)
|
||||||
CONFIG_PROPERTY(int, badge, 20)
|
CONFIG_PROPERTY(int, badge, 20)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue