92 lines
2 KiB
QML
92 lines
2 KiB
QML
import qs.config
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Hyprland
|
|
|
|
PopupWindow {
|
|
id: root
|
|
required property Component content
|
|
|
|
color: "transparent"
|
|
|
|
function toggle() {
|
|
background.state = background.state == "opened" ? "closed" : "opened";
|
|
}
|
|
|
|
HyprlandFocusGrab {
|
|
id: grab
|
|
active: root.visible
|
|
windows: [root]
|
|
onCleared: {
|
|
background.state = "closed";
|
|
}
|
|
}
|
|
|
|
implicitWidth: background.width
|
|
implicitHeight: background.height
|
|
|
|
StyledWrapperRectangle {
|
|
id: background
|
|
|
|
margin: 16
|
|
focus: true
|
|
onFocusChanged: {
|
|
if (!focus) {
|
|
grab.active = false;
|
|
}
|
|
}
|
|
|
|
Behavior on opacity {
|
|
NumberAnimation {
|
|
duration: Styling.animations.speed.normal
|
|
}
|
|
}
|
|
|
|
state: "closed"
|
|
states: [
|
|
State {
|
|
name: "closed"
|
|
PropertyChanges {
|
|
background {
|
|
opacity: 0
|
|
}
|
|
}
|
|
},
|
|
State {
|
|
name: "opened"
|
|
PropertyChanges {
|
|
background {
|
|
opacity: 1
|
|
}
|
|
}
|
|
}
|
|
]
|
|
|
|
transitions: [
|
|
Transition {
|
|
from: "closed"
|
|
to: "opened"
|
|
ScriptAction {
|
|
script: root.visible = true
|
|
}
|
|
},
|
|
Transition {
|
|
from: "opened"
|
|
to: "closed"
|
|
SequentialAnimation {
|
|
PauseAnimation {
|
|
duration: root.animationDuration
|
|
}
|
|
ScriptAction {
|
|
script: root.visible = false
|
|
}
|
|
}
|
|
}
|
|
]
|
|
|
|
Loader {
|
|
active: root.visible
|
|
sourceComponent: root.content
|
|
}
|
|
}
|
|
}
|