use loader for updates popout

This commit is contained in:
2026-05-28 00:53:49 +02:00
parent 8e14993633
commit 6209264744
2 changed files with 128 additions and 160 deletions
+20 -9
View File
@@ -11,21 +11,26 @@ import qs.Helpers
CustomClippingRect {
id: root
readonly property bool hasUpdates: Object.keys(Updates.updates)?.length > 0
readonly property int itemHeight: 50 + Appearance.padding.smaller * 2
required property var wrapper
color: DynamicColors.tPalette.m3surfaceContainer
implicitHeight: updatesList.visible ? updatesList.implicitHeight + Appearance.padding.small * 2 : noUpdates.height
implicitWidth: updatesList.visible ? updatesList.contentWidth + Appearance.padding.small * 2 : noUpdates.width
implicitHeight: hasUpdates ? updatesListLoader.item?.implicitHeight + Appearance.padding.small * 2 : noUpdatesLoader.item.height
implicitWidth: hasUpdates ? updatesListLoader.item?.contentWidth + Appearance.padding.small * 2 : noUpdatesLoader.item.width
radius: Appearance.rounding.small
Item {
Loader {
id: noUpdatesLoader
active: !root.hasUpdates
anchors.centerIn: parent
sourceComponent: Item {
id: noUpdates
anchors.centerIn: parent
height: 200
visible: script.values.length === 0
width: 600
width: 300
MaterialIcon {
id: noUpdatesIcon
@@ -47,11 +52,17 @@ CustomClippingRect {
verticalAlignment: Text.AlignVCenter
}
}
}
CustomListView {
Loader {
id: updatesListLoader
active: root.hasUpdates
anchors.centerIn: parent
sourceComponent: CustomListView {
id: updatesList
anchors.centerIn: parent
contentHeight: childrenRect.height
contentWidth: 600
displayMarginBeginning: root.itemHeight
@@ -59,7 +70,6 @@ CustomClippingRect {
implicitHeight: Math.min(contentHeight, (root.itemHeight + spacing) * 5 - spacing)
implicitWidth: contentWidth
spacing: Appearance.spacing.normal
visible: script.values.length > 0
delegate: CustomRect {
id: update
@@ -157,4 +167,5 @@ CustomClippingRect {
}))
}
}
}
}
+6 -49
View File
@@ -15,9 +15,8 @@ Item {
property real currentCenter
property alias currentName: popoutState.currentName
property string detachedMode
readonly property bool isDetached: detachedMode.length > 0
property alias hasCurrent: popoutState.hasCurrent
readonly property real nonAnimHeight: children.find(c => c.shouldBeActive)?.implicitHeight ?? content.implicitHeight
readonly property real nonAnimHeight: content.implicitHeight || 150
readonly property real nonAnimWidth: children.find(c => c.shouldBeActive)?.implicitWidth ?? content.implicitWidth
required property real offsetScale
property string queuedMode
@@ -28,29 +27,13 @@ Item {
detachedMode = "";
}
function detach(mode: string): void {
setAnims(true);
if (mode === "winfo") {
detachedMode = mode;
} else {
queuedMode = mode;
detachedMode = "any";
}
setAnims(false);
focus = true;
}
function setAnims(detach: bool): void {
const type = `expressive${detach ? "Slow" : "Default"}Spatial`;
animLength = Appearance.anim.durations[type];
animCurve = Appearance.anim.curves[type];
}
focus: hasCurrent
implicitHeight: nonAnimHeight
implicitWidth: nonAnimWidth
Behavior on implicitHeight {
enabled: root.offsetScale < 1
Anim {
duration: root.animLength
easing.bezierCurve: root.animCurve
@@ -72,41 +55,15 @@ Item {
Comp {
id: content
// anchors.horizontalCenter: parent.horizontalCenter
// anchors.top: parent.top
anchors.centerIn: parent
shouldBeActive: root.hasCurrent && !root.detachedMode
shouldBeActive: root.hasCurrent
sourceComponent: Content {
popouts: popoutState
}
}
// Comp {
// id: winfo
//
// anchors.centerIn: parent
// shouldBeActive: root.detachedMode === "winfo"
//
// sourceComponent: WindowInfo {
// client: Hypr.activeToplevel
// screen: root.screen
// }
// }
//
// Comp {
// id: controlCenter
//
// anchors.centerIn: parent
// shouldBeActive: root.detachedMode === "any"
//
// sourceComponent: ControlCenter {
// active: root.queuedMode
// screen: root.screen
//
// onClose: root.close()
// }
// }
onActiveChanged: console.log("active:", content.implicitHeight)
}
component Comp: Loader {
id: comp