You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nheko/resources/qml/PrivacyScreen.qml

107 lines
2.5 KiB

// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Window
import im.nheko
import QtQuick.Effects
Item {
id: privacyScreen
readonly property bool active: Settings.privacyScreen && screenSaver.state === "Visible"
property int screenTimeout
2 years ago
property var timelineRoot
required property var windowTarget
Connections {
function onActiveChanged() {
if (windowTarget.active) {
screenSaverTimer.stop();
screenSaver.state = "Invisible";
} else {
if (timelineRoot.visible)
4 years ago
screenSaverTimer.start();
}
}
target: windowTarget
}
Timer {
id: screenSaverTimer
4 years ago
interval: screenTimeout * 1000
running: !windowTarget.active
2 years ago
onTriggered: {
screenSaver.state = "Visible";
}
}
Item {
id: screenSaver
4 years ago
anchors.fill: parent
2 years ago
state: "Invisible"
visible: false
2 years ago
states: [
State {
name: "Visible"
PropertyChanges {
target: screenSaver
visible: true
}
PropertyChanges {
opacity: 1
2 years ago
target: screenSaver
}
},
State {
name: "Invisible"
PropertyChanges {
opacity: 0
2 years ago
target: screenSaver
}
PropertyChanges {
target: screenSaver
visible: false
}
}
]
transitions: [
Transition {
from: "Invisible"
reversible: true
2 years ago
to: "Visible"
SequentialAnimation {
NumberAnimation {
duration: 0
2 years ago
property: "visible"
target: screenSaver
}
NumberAnimation {
duration: 300
easing.type: Easing.Linear
2 years ago
property: "opacity"
target: screenSaver
}
}
}
]
MultiEffect {
id: blur
4 years ago
anchors.fill: parent
blur: 1.0
2 years ago
blurEnabled: true
blurMax: 32
2 years ago
source: timelineRoot
}
}
4 years ago
}