Integrated file selection dialogue with the main code. Improved the
[openvpnui.git] / qml / filebrowse / pages / ViewPage.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3 import "functions.js" as Functions
4 import "../components"
5
6 Page {
7     id: page
8     allowedOrientations: Orientation.All
9     property string path: ""
10
11     SilicaFlickable {
12         id: flickable
13         anchors.fill: parent
14         contentHeight: column.height
15         VerticalScrollDecorator { flickable: flickable }
16
17         Column {
18             id: column
19             anchors.left: parent.left
20             anchors.right: parent.right
21             anchors.leftMargin: Theme.paddingLarge
22             anchors.rightMargin: Theme.paddingLarge
23
24             PageHeader { title: Functions.lastPartOfPath(page.path) }
25
26             Label {
27                 id: portraitText
28                 textFormat: Text.PlainText
29                 width: parent.width
30                 wrapMode: Text.WrapAnywhere
31                 font.pixelSize: Theme.fontSizeTiny
32                 font.family: "Monospace"
33                 color: Theme.highlightColor
34                 visible: page.orientation === Orientation.Portrait
35             }
36             Label {
37                 id: landscapeText
38                 textFormat: Text.PlainText
39                 width: parent.width
40                 wrapMode: Text.WrapAnywhere
41                 font.pixelSize: Theme.fontSizeTiny
42                 font.family: "Monospace"
43                 color: Theme.highlightColor
44                 visible: page.orientation === Orientation.Landscape
45             }
46             Spacer {
47                 height: 40
48                 visible: message.text !== ""
49             }
50             Label {
51                 id: message
52                 width: parent.width
53                 wrapMode: Text.Wrap
54                 // show medium size if there is no portrait (or landscape text)
55                 // in that case, this message becomes main message
56                 font.pixelSize: portraitText.text === "" ? Theme.fontSizeMedium : Theme.fontSizeTiny
57                 color: portraitText.text === "" ? Theme.highlightColor : Theme.secondaryColor
58                 horizontalAlignment: Text.AlignHCenter
59                 visible: message.text !== ""
60             }
61             Spacer {
62                 height: 40
63                 visible: message.text !== ""
64             }
65         }
66     }
67
68     // update cover
69     onStatusChanged: {
70         if (status === PageStatus.Activating) {
71             // reading file returns three texts, message, portrait and landscape texts
72             var txts = engine.readFile(page.path);
73             message.text = txts[0];
74             portraitText.text = txts[1];
75             landscapeText.text = txts[2];
76         }
77     }
78 }
79
80