2021-01-26 07:46:55 +03:00
|
|
|
import QtGraphicalEffects 1.0
|
2021-01-26 08:03:09 +03:00
|
|
|
import QtQuick 2.12
|
2021-01-27 01:23:28 +03:00
|
|
|
import im.nheko 1.0
|
2021-01-26 07:46:55 +03:00
|
|
|
|
|
|
|
Item {
|
2021-01-27 01:23:28 +03:00
|
|
|
id: privacyScreen
|
|
|
|
|
2021-01-26 07:46:55 +03:00
|
|
|
property var timelineRoot
|
2021-01-27 01:23:28 +03:00
|
|
|
property var imageSource: ""
|
2021-01-26 07:46:55 +03:00
|
|
|
property int screenTimeout
|
2021-01-26 08:03:09 +03:00
|
|
|
|
2021-01-26 07:46:55 +03:00
|
|
|
anchors.fill: parent
|
|
|
|
|
2021-01-27 01:23:28 +03:00
|
|
|
Connections {
|
|
|
|
target: TimelineManager
|
|
|
|
onFocusChanged: {
|
|
|
|
if (TimelineManager.isWindowFocused) {
|
|
|
|
screenSaverTimer.stop();
|
|
|
|
screenSaver.state = "Invisible";
|
|
|
|
} else {
|
2021-02-02 19:37:10 +03:00
|
|
|
if (timelineRoot.visible)
|
2021-02-02 02:57:59 +03:00
|
|
|
screenSaverTimer.start();
|
2021-02-02 19:37:10 +03:00
|
|
|
|
2021-01-27 01:23:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-26 07:46:55 +03:00
|
|
|
Timer {
|
|
|
|
id: screenSaverTimer
|
2021-01-26 08:03:09 +03:00
|
|
|
|
2021-01-26 07:46:55 +03:00
|
|
|
interval: screenTimeout * 1000
|
|
|
|
running: true
|
|
|
|
onTriggered: {
|
2021-02-02 19:37:10 +03:00
|
|
|
if (MainWindow.visible)
|
2021-02-02 02:42:18 +03:00
|
|
|
timelineRoot.grabToImage(function(result) {
|
2021-02-02 19:50:57 +03:00
|
|
|
screenSaver.state = "Visible";
|
|
|
|
imageSource = result.url;
|
|
|
|
}, Qt.size(width, height));
|
2021-02-02 19:37:10 +03:00
|
|
|
|
2021-01-26 07:46:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: screenSaver
|
2021-01-26 08:03:09 +03:00
|
|
|
|
2021-01-27 01:23:28 +03:00
|
|
|
state: "Invisible"
|
2021-01-26 07:46:55 +03:00
|
|
|
anchors.fill: parent
|
|
|
|
visible: false
|
|
|
|
color: "transparent"
|
2021-01-27 01:23:28 +03:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
]
|
2021-01-26 07:46:55 +03:00
|
|
|
|
|
|
|
Image {
|
|
|
|
id: image
|
2021-01-26 08:03:09 +03:00
|
|
|
|
2021-01-27 01:23:28 +03:00
|
|
|
cache: false
|
2021-01-26 07:46:55 +03:00
|
|
|
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 07:46:55 +03:00
|
|
|
}
|
|
|
|
|
2021-01-26 08:03:09 +03:00
|
|
|
FastBlur {
|
2021-01-26 07:46:55 +03:00
|
|
|
id: blur
|
2021-01-26 08:03:09 +03:00
|
|
|
|
2021-01-26 07:46:55 +03:00
|
|
|
anchors.fill: effectSource
|
|
|
|
source: effectSource
|
|
|
|
radius: 50
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-01-26 08:03:09 +03:00
|
|
|
|
|
|
|
}
|