nheko/resources/qml/PrivacyScreen.qml

99 lines
2.3 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: Nheko Contributors
//
2021-03-05 00:35:15 +01:00
// SPDX-License-Identifier: GPL-3.0-or-later
2023-06-02 00:43:38 +02:00
import QtQuick
import QtQuick.Window
import im.nheko
import QtQuick.Effects
Item {
id: privacyScreen
2023-02-23 02:16:55 +01:00
readonly property bool active: Settings.privacyScreen && screenSaver.state === "Visible"
property int screenTimeout
2023-06-02 01:45:24 +02:00
property var timelineRoot
required property var windowTarget
Connections {
2022-05-12 18:48:12 +02:00
function onActiveChanged() {
if (windowTarget.active) {
screenSaverTimer.stop();
screenSaver.state = "Invisible";
} else {
if (timelineRoot.visible)
2021-02-02 00:57:59 +01:00
screenSaverTimer.start();
}
}
target: windowTarget
}
Timer {
id: screenSaverTimer
2021-01-26 06:03:09 +01:00
interval: screenTimeout * 1000
running: !windowTarget.active
2023-06-02 01:45:24 +02:00
onTriggered: {
screenSaver.state = "Visible";
}
}
Item {
id: screenSaver
2021-01-26 06:03:09 +01:00
anchors.fill: parent
2023-06-02 01:45:24 +02:00
state: "Invisible"
visible: false
2023-06-02 01:45:24 +02:00
states: [
State {
name: "Visible"
PropertyChanges {
2023-10-26 16:43:09 +02:00
screenSaver.visible: true
screenSaver.opacity: 1
}
},
State {
name: "Invisible"
PropertyChanges {
2023-10-26 16:43:09 +02:00
screenSaver.opacity: 0
screenSaver.visible: false
}
}
]
transitions: [
Transition {
from: "Invisible"
reversible: true
2023-06-02 01:45:24 +02:00
to: "Visible"
SequentialAnimation {
NumberAnimation {
duration: 0
2023-06-02 01:45:24 +02:00
property: "visible"
target: screenSaver
}
NumberAnimation {
duration: 300
easing.type: Easing.Linear
2023-06-02 01:45:24 +02:00
property: "opacity"
target: screenSaver
}
}
}
]
2023-06-02 00:43:38 +02:00
MultiEffect {
id: blur
2021-01-26 06:03:09 +01:00
anchors.fill: parent
2023-06-02 00:43:38 +02:00
blur: 1.0
2023-06-02 01:45:24 +02:00
blurEnabled: true
2023-06-02 00:43:38 +02:00
blurMax: 32
2023-06-02 01:45:24 +02:00
source: timelineRoot
}
}
2021-01-26 06:03:09 +01:00
}