matrixion/resources/qml/PrivacyScreen.qml

100 lines
2.4 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: Nheko Contributors
//
2021-03-05 02:35:15 +03:00
// SPDX-License-Identifier: GPL-3.0-or-later
2023-06-02 01:43:38 +03:00
import QtQuick
import QtQuick.Window
import im.nheko
import QtQuick.Effects
Item {
id: privacyScreen
2023-02-23 04:16:55 +03:00
readonly property bool active: Settings.privacyScreen && screenSaver.state === "Visible"
property int screenTimeout
2023-06-02 02:45:24 +03:00
property var timelineRoot
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
2023-06-02 02:45:24 +03:00
onTriggered: {
screenSaver.state = "Visible";
}
}
Item {
id: screenSaver
2021-01-26 08:03:09 +03:00
anchors.fill: parent
2023-06-02 02:45:24 +03:00
state: "Invisible"
visible: false
2023-06-02 02:45:24 +03:00
states: [
State {
name: "Visible"
PropertyChanges {
2023-10-26 17:43:09 +03:00
screenSaver.visible: true
screenSaver.opacity: 1
}
},
State {
name: "Invisible"
PropertyChanges {
2023-10-26 17:43:09 +03:00
screenSaver.opacity: 0
screenSaver.visible: false
}
}
]
transitions: [
Transition {
from: "Invisible"
reversible: true
2023-06-02 02:45:24 +03:00
to: "Visible"
enabled: !Settings.reducedMotion
SequentialAnimation {
NumberAnimation {
duration: 0
2023-06-02 02:45:24 +03:00
property: "visible"
target: screenSaver
}
NumberAnimation {
duration: 300
easing.type: Easing.Linear
2023-06-02 02:45:24 +03:00
property: "opacity"
target: screenSaver
}
}
}
]
2023-06-02 01:43:38 +03:00
MultiEffect {
id: blur
2021-01-26 08:03:09 +03:00
anchors.fill: parent
2023-06-02 01:43:38 +03:00
blur: 1.0
2023-06-02 02:45:24 +03:00
blurEnabled: true
2023-06-02 01:43:38 +03:00
blurMax: 32
2023-06-02 02:45:24 +03:00
source: timelineRoot
}
}
2021-01-26 08:03:09 +03:00
}