Debian Codegraph @

resources/qml/PrivacyScreen.qml

raw
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 import QtQuick
6 import QtQuick.Window
7 import im.nheko
8 import QtQuick.Effects
9
10 Item {
11 id: privacyScreen
12
13 readonly property bool active: Settings.privacyScreen && screenSaver.state === "Visible"
14 property int screenTimeout
15 property var timelineRoot
16 required property var windowTarget
17
18 Connections {
19 function onActiveChanged() {
20 if (windowTarget.active) {
21 screenSaverTimer.stop();
22 screenSaver.state = "Invisible";
23 } else {
24 if (timelineRoot.visible)
25 screenSaverTimer.start();
26 }
27 }
28
29 target: windowTarget
30 }
31 Timer {
32 id: screenSaverTimer
33
34 interval: screenTimeout * 1000
35 running: !windowTarget.active
36
37 onTriggered: {
38 screenSaver.state = "Visible";
39 }
40 }
41 Item {
42 id: screenSaver
43
44 anchors.fill: parent
45 state: "Invisible"
46 visible: false
47
48 states: [
49 State {
50 name: "Visible"
51
52 PropertyChanges {
53 screenSaver.visible: true
54 screenSaver.opacity: 1
55 }
56 },
57 State {
58 name: "Invisible"
59
60 PropertyChanges {
61 screenSaver.opacity: 0
62 screenSaver.visible: false
63 }
64 }
65 ]
66 transitions: [
67 Transition {
68 from: "Invisible"
69 reversible: true
70 to: "Visible"
71
72 SequentialAnimation {
73 NumberAnimation {
74 duration: 0
75 property: "visible"
76 target: screenSaver
77 }
78 NumberAnimation {
79 duration: 300
80 easing.type: Easing.Linear
81 property: "opacity"
82 target: screenSaver
83 }
84 }
85 }
86 ]
87
88 MultiEffect {
89 id: blur
90
91 anchors.fill: parent
92 blur: 1.0
93 blurEnabled: true
94 blurMax: 32
95 source: timelineRoot
96 }
97 }
98 }