summary refs log tree commit diff
path: root/resources/qml/PrivacyScreen.qml
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2021-01-26 17:23:28 -0500
committerJoseph Donofry <joedonofry@gmail.com>2021-01-26 17:23:28 -0500
commitbfeb766a91e259dce7924fb0bbcfcac85b91092b (patch)
treef9423ca7fa9dbb324ba9372a29c292777a87c6cd /resources/qml/PrivacyScreen.qml
parentFix formatting (diff)
downloadnheko-bfeb766a91e259dce7924fb0bbcfcac85b91092b.tar.xz
Implement Privacy Screen
* Add handles for window focus gained / focus lossed and connect to timer
* Clean up some of the PrivacyScreen.qml code
* Connect settings to PrivacyScreen visibility
Diffstat (limited to 'resources/qml/PrivacyScreen.qml')
-rw-r--r--resources/qml/PrivacyScreen.qml120
1 files changed, 93 insertions, 27 deletions
diff --git a/resources/qml/PrivacyScreen.qml b/resources/qml/PrivacyScreen.qml
index 9fdd35e0..45ae5cb5 100644
--- a/resources/qml/PrivacyScreen.qml
+++ b/resources/qml/PrivacyScreen.qml
@@ -1,13 +1,28 @@
 import QtGraphicalEffects 1.0
 import QtQuick 2.12
+import im.nheko 1.0
 
 Item {
+    id: privacyScreen
+
     property var timelineRoot
-    property var imageSource
+    property var imageSource: ""
     property int screenTimeout
 
     anchors.fill: parent
 
+    Connections {
+        target: TimelineManager
+        onFocusChanged: {
+            if (TimelineManager.isWindowFocused) {
+                screenSaverTimer.stop();
+                screenSaver.state = "Invisible";
+            } else {
+                screenSaverTimer.start();
+            }
+        }
+    }
+
     Timer {
         id: screenSaverTimer
 
@@ -15,36 +30,98 @@ Item {
         running: true
         onTriggered: {
             timelineRoot.grabToImage(function(result) {
+                screenSaver.state = "Visible";
                 imageSource = result.url;
-                screenSaver.visible = true;
-                particles.resume();
             }, Qt.size(width, height));
         }
     }
 
-    // Reset screensaver timer when clicks are received
-    MouseArea {
-        anchors.fill: parent
-        // Pass mouse events through
-        propagateComposedEvents: true
-        hoverEnabled: true
-        onClicked: {
-            screenSaverTimer.restart();
-            mouse.accepted = false;
-        }
-    }
-
     Rectangle {
         id: screenSaver
 
+        state: "Invisible"
         anchors.fill: parent
         visible: false
         color: "transparent"
+        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
+                    }
+
+                }
+
+            }
+        ]
 
         Image {
             id: image
 
-            visible: screenSaver.visible
+            cache: false
             anchors.fill: parent
             source: imageSource
         }
@@ -65,17 +142,6 @@ Item {
             radius: 50
         }
 
-        MouseArea {
-            anchors.fill: parent
-            propagateComposedEvents: true
-            hoverEnabled: true
-            onClicked: {
-                screenSaver.visible = false;
-                screenSaverTimer.restart();
-                mouse.accepted = false;
-            }
-        }
-
     }
 
 }