nheko/resources/qml/PrivacyScreen.qml

82 lines
1.7 KiB
QML
Raw Normal View History

import QtGraphicalEffects 1.0
2021-01-26 06:03:09 +01:00
import QtQuick 2.12
Item {
property var timelineRoot
property var imageSource
property int screenTimeout
2021-01-26 06:03:09 +01:00
anchors.fill: parent
Timer {
id: screenSaverTimer
2021-01-26 06:03:09 +01:00
interval: screenTimeout * 1000
running: true
onTriggered: {
timelineRoot.grabToImage(function(result) {
imageSource = result.url;
2021-01-26 06:03:09 +01:00
screenSaver.visible = true;
particles.resume();
}, Qt.size(width, height));
}
}
// Reset screensaver timer when clicks are received
MouseArea {
anchors.fill: parent
// Pass mouse events through
propagateComposedEvents: true
hoverEnabled: true
onClicked: {
screenSaverTimer.restart();
mouse.accepted = false;
}
}
Rectangle {
id: screenSaver
2021-01-26 06:03:09 +01:00
anchors.fill: parent
visible: false
color: "transparent"
Image {
id: image
2021-01-26 06:03:09 +01:00
visible: screenSaver.visible
anchors.fill: parent
source: imageSource
}
ShaderEffectSource {
id: effectSource
sourceItem: image
anchors.fill: image
2021-01-26 06:03:09 +01:00
sourceRect: Qt.rect(0, 0, width, height)
}
2021-01-26 06:03:09 +01:00
FastBlur {
id: blur
2021-01-26 06:03:09 +01:00
anchors.fill: effectSource
source: effectSource
radius: 50
}
MouseArea {
anchors.fill: parent
propagateComposedEvents: true
hoverEnabled: true
2021-01-26 06:03:09 +01:00
onClicked: {
screenSaver.visible = false;
screenSaverTimer.restart();
2021-01-26 06:03:09 +01:00
mouse.accepted = false;
}
}
2021-01-26 06:03:09 +01:00
}
2021-01-26 06:03:09 +01:00
}