move styledpopupwindow
This commit is contained in:
parent
7022c3a9ae
commit
96d1352666
5 changed files with 2 additions and 4 deletions
102
components/StyledPopupWindow.qml
Normal file
102
components/StyledPopupWindow.qml
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
import qs.services
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
|
||||
PopupWindow {
|
||||
id: root
|
||||
property bool opened: false
|
||||
property int animationDuration: 200
|
||||
property alias margins: background.margin
|
||||
property alias backgroundColor: background.color
|
||||
property alias radius: background.radius
|
||||
property alias state: background.state
|
||||
required property Component content
|
||||
|
||||
color: "transparent"
|
||||
|
||||
function toggle() {
|
||||
Visibility.togglePopup(this);
|
||||
}
|
||||
|
||||
implicitWidth: background.width
|
||||
Behavior on implicitWidth {
|
||||
NumberAnimation {
|
||||
duration: 100
|
||||
}
|
||||
}
|
||||
implicitHeight: background.height
|
||||
Behavior on implicitHeight {
|
||||
NumberAnimation {
|
||||
duration: 100
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: timer
|
||||
interval: 750
|
||||
onTriggered: {
|
||||
if (!root.visible) {
|
||||
return;
|
||||
}
|
||||
root.toggle();
|
||||
}
|
||||
}
|
||||
|
||||
WrapperMouseArea {
|
||||
hoverEnabled: true
|
||||
onExited: {
|
||||
timer.start();
|
||||
}
|
||||
onEntered: {
|
||||
timer.stop();
|
||||
}
|
||||
WrapperRectangle {
|
||||
id: background
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Loader {
|
||||
active: root.visible
|
||||
sourceComponent: root.content
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue