mirror of
https://github.com/kossLAN/dots.git
synced 2025-11-05 06:59:50 -05:00
new popup system
This commit is contained in:
parent
d32bedda31
commit
a416887d3b
5 changed files with 138 additions and 255 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue