Skip to content
Snippets Groups Projects
PrivacyScreen.qml 2.88 KiB
Newer Older
  • Learn to ignore specific revisions
  • Nicolas Werner's avatar
    Nicolas Werner committed
    // SPDX-FileCopyrightText: 2021 Nheko Contributors
    
    Nicolas Werner's avatar
    Nicolas Werner committed
    // SPDX-License-Identifier: GPL-3.0-or-later
    
    
    import QtGraphicalEffects 1.0
    
    Joe Donofry's avatar
    Joe Donofry committed
    import QtQuick 2.12
    
    Joe Donofry's avatar
    Joe Donofry committed
    import im.nheko 1.0
    
    Joe Donofry's avatar
    Joe Donofry committed
        id: privacyScreen
    
    
        property var timelineRoot
        property int screenTimeout
    
    Joe Donofry's avatar
    Joe Donofry committed
    
    
    Joe Donofry's avatar
    Joe Donofry committed
        Connections {
    
            function onFocusChanged() {
    
    Joe Donofry's avatar
    Joe Donofry committed
                if (TimelineManager.isWindowFocused) {
                    screenSaverTimer.stop();
                    screenSaver.state = "Invisible";
                } else {
    
                    if (timelineRoot.visible)
    
    Joe Donofry's avatar
    Joe Donofry committed
                        screenSaverTimer.start();
    
    
            target: TimelineManager
    
        Timer {
            id: screenSaverTimer
    
    Joe Donofry's avatar
    Joe Donofry committed
    
    
            interval: screenTimeout * 1000
            running: true
            onTriggered: {
    
                screenSaver.state = "Visible";
    
            id: screenSaver
    
    Joe Donofry's avatar
    Joe Donofry committed
    
    
    Joe Donofry's avatar
    Joe Donofry committed
            state: "Invisible"
    
            anchors.fill: parent
            visible: false
    
    Joe Donofry's avatar
    Joe Donofry committed
            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: "Visible"
                    to: "Invisible"
    
                    SequentialAnimation {
                        NumberAnimation {
                            target: screenSaver
                            property: "opacity"
                            duration: 250
                            easing.type: Easing.InQuad
                        }
    
                        NumberAnimation {
                            target: screenSaver
                            property: "visible"
                            duration: 0
                        }
    
                    }
    
                },
                Transition {
                    from: "Invisible"
                    to: "Visible"
    
                    SequentialAnimation {
                        NumberAnimation {
                            target: screenSaver
                            property: "visible"
                            duration: 0
                        }
    
                        NumberAnimation {
                            target: screenSaver
                            property: "opacity"
                            duration: 500
                            easing.type: Easing.InQuad
                        }
    
                    }
    
                }
            ]
    
    Joe Donofry's avatar
    Joe Donofry committed
            FastBlur {
    
                id: blur
    
    Joe Donofry's avatar
    Joe Donofry committed
    
    
                anchors.fill: parent
                source: timelineRoot
    
    Joe Donofry's avatar
    Joe Donofry committed
    
    }