Integrated file selection dialogue with the main code. Improved the
[openvpnui.git] / qml / filebrowse / pages / ViewPage.qml
diff --git a/qml/filebrowse/pages/ViewPage.qml b/qml/filebrowse/pages/ViewPage.qml
new file mode 100644 (file)
index 0000000..e0b945a
--- /dev/null
@@ -0,0 +1,80 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+import "functions.js" as Functions
+import "../components"
+
+Page {
+    id: page
+    allowedOrientations: Orientation.All
+    property string path: ""
+
+    SilicaFlickable {
+        id: flickable
+        anchors.fill: parent
+        contentHeight: column.height
+        VerticalScrollDecorator { flickable: flickable }
+
+        Column {
+            id: column
+            anchors.left: parent.left
+            anchors.right: parent.right
+            anchors.leftMargin: Theme.paddingLarge
+            anchors.rightMargin: Theme.paddingLarge
+
+            PageHeader { title: Functions.lastPartOfPath(page.path) }
+
+            Label {
+                id: portraitText
+                textFormat: Text.PlainText
+                width: parent.width
+                wrapMode: Text.WrapAnywhere
+                font.pixelSize: Theme.fontSizeTiny
+                font.family: "Monospace"
+                color: Theme.highlightColor
+                visible: page.orientation === Orientation.Portrait
+            }
+            Label {
+                id: landscapeText
+                textFormat: Text.PlainText
+                width: parent.width
+                wrapMode: Text.WrapAnywhere
+                font.pixelSize: Theme.fontSizeTiny
+                font.family: "Monospace"
+                color: Theme.highlightColor
+                visible: page.orientation === Orientation.Landscape
+            }
+            Spacer {
+                height: 40
+                visible: message.text !== ""
+            }
+            Label {
+                id: message
+                width: parent.width
+                wrapMode: Text.Wrap
+                // show medium size if there is no portrait (or landscape text)
+                // in that case, this message becomes main message
+                font.pixelSize: portraitText.text === "" ? Theme.fontSizeMedium : Theme.fontSizeTiny
+                color: portraitText.text === "" ? Theme.highlightColor : Theme.secondaryColor
+                horizontalAlignment: Text.AlignHCenter
+                visible: message.text !== ""
+            }
+            Spacer {
+                height: 40
+                visible: message.text !== ""
+            }
+        }
+    }
+
+    // update cover
+    onStatusChanged: {
+        if (status === PageStatus.Activating) {
+            // reading file returns three texts, message, portrait and landscape texts
+            var txts = engine.readFile(page.path);
+            message.text = txts[0];
+            portraitText.text = txts[1];
+            landscapeText.text = txts[2];
+        }
+    }
+}
+
+