Integrated file selection dialogue with the main code. Improved the
[openvpnui.git] / qml / filebrowse / components / InteractionBlocker.qml
diff --git a/qml/filebrowse/components/InteractionBlocker.qml b/qml/filebrowse/components/InteractionBlocker.qml
new file mode 100644 (file)
index 0000000..89ea2e5
--- /dev/null
@@ -0,0 +1,38 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+// This component blocks all components under it and displays a dark background
+Rectangle {
+    id: interactionBlocker
+
+    // clicked signal is emitted when the component is clicked
+    signal clicked
+
+    visible: false
+    color: "#000000"
+    opacity: 0.4
+
+    MouseArea {
+        anchors.fill: parent
+        enabled: true
+        onClicked: interactionBlocker.clicked()
+    }
+    // use a timer to delay the visibility of interaction blocker by adjusting opacity
+    // this is done to prevent flashing if the file operation is fast
+    onVisibleChanged: {
+        if (visible === true) {
+            interactionBlocker.opacity = 0;
+            blockerTimer.start();
+        } else {
+            blockerTimer.stop();
+        }
+    }
+    Timer {
+        id: blockerTimer
+        interval: 300
+        onTriggered: {
+            interactionBlocker.opacity = 0.3;
+            stop();
+        }
+    }
+}