matrixion/resources/qml/PrivacyScreen.qml

152 lines
3.4 KiB
QML
Raw Normal View History

import QtGraphicalEffects 1.0
2021-01-26 08:03:09 +03:00
import QtQuick 2.12
import im.nheko 1.0
Item {
id: privacyScreen
property var timelineRoot
property var imageSource: ""
property int screenTimeout
2021-01-26 08:03:09 +03:00
anchors.fill: parent
Connections {
target: TimelineManager
onFocusChanged: {
if (TimelineManager.isWindowFocused) {
screenSaverTimer.stop();
screenSaver.state = "Invisible";
} else {
if (timelineRoot.visible)
2021-02-02 02:57:59 +03:00
screenSaverTimer.start();
}
}
}
Timer {
id: screenSaverTimer
2021-01-26 08:03:09 +03:00
interval: screenTimeout * 1000
running: true
onTriggered: {
if (MainWindow.visible)
timelineRoot.grabToImage(function(result) {
screenSaver.state = "Visible";
imageSource = result.url;
}, Qt.size(width, height));
}
}
Rectangle {
id: screenSaver
2021-01-26 08:03:09 +03:00
state: "Invisible"
anchors.fill: parent
visible: false
color: "transparent"
states: [
State {
name: "Visible"
PropertyChanges {
target: screenSaver
visible: true
}
PropertyChanges {
target: screenSaver
opacity: 1
}
},
State {
name: "Invisible"
PropertyChanges {
target: screenSaver
opacity: 0
}
PropertyChanges {
target: screenSaver
visible: false
}
}
]
transitions: [
Transition {
from: "Visible"
to: "Invisible"
SequentialAnimation {
NumberAnimation {
target: screenSaver
property: "opacity"
duration: 250
easing.type: Easing.InQuad
}
NumberAnimation {
target: screenSaver
property: "visible"
duration: 0
}
}
},
Transition {
from: "Invisible"
to: "Visible"
SequentialAnimation {
NumberAnimation {
target: screenSaver
property: "visible"
duration: 0
}
NumberAnimation {
target: screenSaver
property: "opacity"
duration: 500
easing.type: Easing.InQuad
}
}
}
]
Image {
id: image
2021-01-26 08:03:09 +03:00
cache: false
anchors.fill: parent
source: imageSource
}
ShaderEffectSource {
id: effectSource
sourceItem: image
anchors.fill: image
2021-01-26 08:03:09 +03:00
sourceRect: Qt.rect(0, 0, width, height)
}
2021-01-26 08:03:09 +03:00
FastBlur {
id: blur
2021-01-26 08:03:09 +03:00
anchors.fill: effectSource
source: effectSource
radius: 50
}
}
2021-01-26 08:03:09 +03:00
}