matrixion/resources/qml/PrivacyScreen.qml

116 lines
2.6 KiB
QML
Raw Normal View History

2021-03-05 02:35:15 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-FileCopyrightText: 2022 Nheko Contributors
// SPDX-FileCopyrightText: 2023 Nheko Contributors
//
2021-03-05 02:35:15 +03:00
// SPDX-License-Identifier: GPL-3.0-or-later
import QtGraphicalEffects 1.0
2021-01-26 08:03:09 +03:00
import QtQuick 2.12
2022-01-12 21:09:46 +03:00
import QtQuick.Window 2.2
import im.nheko 1.0
Item {
id: privacyScreen
readonly property bool active: screenSaver.state === "Visible"
property var timelineRoot
property int screenTimeout
2021-01-26 08:03:09 +03:00
required property var windowTarget
Connections {
2022-05-12 19:48:12 +03:00
function onActiveChanged() {
if (windowTarget.active) {
screenSaverTimer.stop();
screenSaver.state = "Invisible";
} else {
if (timelineRoot.visible)
2021-02-02 02:57:59 +03:00
screenSaverTimer.start();
}
}
target: windowTarget
}
Timer {
id: screenSaverTimer
2021-01-26 08:03:09 +03:00
interval: screenTimeout * 1000
running: !windowTarget.active
onTriggered: {
screenSaver.state = "Visible";
}
}
Item {
id: screenSaver
2021-01-26 08:03:09 +03:00
state: "Invisible"
anchors.fill: parent
visible: false
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: "Invisible"
to: "Visible"
reversible: true
SequentialAnimation {
NumberAnimation {
target: screenSaver
property: "visible"
duration: 0
}
NumberAnimation {
target: screenSaver
property: "opacity"
duration: 300
easing.type: Easing.Linear
}
}
}
]
2021-01-26 08:03:09 +03:00
FastBlur {
id: blur
2021-01-26 08:03:09 +03:00
anchors.fill: parent
source: timelineRoot
radius: 50
}
}
2021-01-26 08:03:09 +03:00
}