new popup system

This commit is contained in:
kossLAN 2025-08-10 21:12:41 -04:00
parent d32bedda31
commit a416887d3b
Signed by: kossLAN
SSH key fingerprint: SHA256:bdV0x+wdQHGJ6LgmstH3KV8OpWY+OOFmJcPcB0wQPV8
5 changed files with 138 additions and 255 deletions

View file

@ -1,8 +1,70 @@
import QtQuick
import qs.widgets
StyledMouseArea {
Item {
id: root
visible: false
opacity: root.targetOpacity
property QtObject menu
onShowChanged: {
if (show) {
popup.setItem(this);
} else {
popup.removeItem(this);
}
}
onTargetVisibleChanged: {
if (targetVisible) {
visible = true;
targetOpacity = 1;
} else {
console.log("closed");
closed();
targetOpacity = 0;
}
}
onTargetOpacityChanged: {
if (!targetVisible && targetOpacity == 0) {
visible = false;
this.parent = null;
if (popup)
popup.onHidden(this);
}
}
readonly property alias contentItem: contentItem
default property alias data: contentItem.data
readonly property Item item: contentItem
Item {
id: contentItem
anchors.fill: parent
// anchors.margins: 5
implicitHeight: children[0].implicitHeight
implicitWidth: children[0].implicitWidth
}
required property var popup
required property var owner
property bool show: false
signal closed
property bool targetVisible: false
property real targetOpacity: 0
Behavior on targetOpacity {
id: opacityAnimation
SmoothedAnimation {
velocity: 5
}
}
function snapOpacity(opacity: real) {
opacityAnimation.enabled = false;
targetOpacity = opacity;
opacityAnimation.enabled = true;
}
}