generic styled popup window
This commit is contained in:
parent
6202b0d6c7
commit
7d7f7b9fd6
1 changed files with 75 additions and 0 deletions
75
styled/StyledPopupWindow.qml
Normal file
75
styled/StyledPopupWindow.qml
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
|
||||
PopupWindow {
|
||||
id: root
|
||||
property bool opened: false
|
||||
property int animationDuration: 200
|
||||
property int margins: 10
|
||||
property alias backgroundColor: background.color
|
||||
property alias radius: background.radius
|
||||
required property Component content
|
||||
|
||||
color: "transparent"
|
||||
|
||||
implicitWidth: background.width
|
||||
implicitHeight: background.height
|
||||
|
||||
Rectangle {
|
||||
id: background
|
||||
|
||||
implicitWidth: margins.width
|
||||
implicitHeight: margins.height
|
||||
|
||||
opacity: 0
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: root.animationDuration
|
||||
}
|
||||
}
|
||||
|
||||
states: State {
|
||||
name: "opened"
|
||||
when: root.opened
|
||||
PropertyChanges {
|
||||
background {
|
||||
opacity: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
transitions: [
|
||||
Transition {
|
||||
from: ""
|
||||
to: "opened"
|
||||
ScriptAction {
|
||||
script: root.visible = true
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
from: "opened"
|
||||
to: ""
|
||||
SequentialAnimation {
|
||||
PauseAnimation {
|
||||
duration: root.animationDuration
|
||||
}
|
||||
ScriptAction {
|
||||
script: root.visible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
WrapperItem {
|
||||
id: margins
|
||||
|
||||
margin: root.margins
|
||||
|
||||
Loader {
|
||||
active: root.visible
|
||||
sourceComponent: content
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue