Updated more copyright files
[openvpnui.git] / qml / cover / CoverPage.qml
1 /*
2   Copyright (C) 2014 David Llewellyn-Jones
3   Contact: David Llewellyn-Jones <david@flypig.co.uk>
4   All rights reserved.
5
6   You may use this file under the terms of BSD license as follows:
7
8   Redistribution and use in source and binary forms, with or without
9   modification, are permitted provided that the following conditions are met:
10     * Redistributions of source code must retain the above copyright
11       notice, this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright
13       notice, this list of conditions and the following disclaimer in the
14       documentation and/or other materials provided with the distribution.
15     * Neither the name of the Jolla Ltd nor the
16       names of its contributors may be used to endorse or promote products
17       derived from this software without specific prior written permission.
18
19   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
23   ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30   Built using the standard template from Jolla
31   Copyright (C) 2013 Jolla Ltd.
32   Contact: Thomas Perl <thomas.perl@jollamobile.com>
33 */
34
35 import QtQuick 2.0
36 import Sailfish.Silica 1.0
37
38 CoverBackground {
39     id: cover
40
41     Connections {
42         target:VpnControl
43         onStatusChanged: {
44             updateStatus(status)
45         }
46     }
47
48     Column {
49         anchors.centerIn: parent
50         spacing: Theme.paddingSmall
51         Label {
52             text: "OpenVPN"
53             color: Theme.highlightColor
54             font.pixelSize: Theme.fontSizeSmall
55             width: parent.parent.width - Theme.paddingMedium
56             wrapMode: Text.Wrap
57             horizontalAlignment: Text.AlignHCenter
58             anchors.horizontalCenter: parent.horizontalCenter
59         }
60         Label {
61             id: coverStatus
62             text: "Disconnected"
63             color: Theme.highlightColor
64             font.pixelSize: Theme.fontSizeMedium
65             width: parent.parent.width - Theme.paddingMedium
66             wrapMode: Text.Wrap
67             horizontalAlignment: Text.AlignHCenter
68             anchors.horizontalCenter: parent.horizontalCenter
69         }
70     }
71
72     function updateStatus(status) {
73         switch (status) {
74         case 0:
75             coverStatus.text = "Disconnected"
76             coverActionConnect.enabled = true;
77             coverActionDisconnect.enabled = false;
78             break
79         case 1:
80             coverStatus.text = "Initialising"
81             coverActionConnect.enabled = false;
82             coverActionDisconnect.enabled = false;
83             break
84         case 2:
85             coverStatus.text = "Connecting"
86             coverActionConnect.enabled = false;
87             coverActionDisconnect.enabled = true;
88             break
89         case 3:
90             coverStatus.text = "Connected"
91             coverActionConnect.enabled = false;
92             coverActionDisconnect.enabled = true;
93             break
94         case 4:
95             coverStatus.text = "Disconnecting"
96             coverActionConnect.enabled = false;
97             coverActionDisconnect.enabled = false;
98             break
99         default:
100             coverStatus.text = "Invalid"
101             coverActionConnect.enabled = true;
102             coverActionDisconnect.enabled = false;
103             break
104         }
105     }
106
107     CoverActionList {
108         id: coverActionConnect
109
110         enabled: true
111
112         CoverAction {
113             iconSource: "image://theme/icon-cover-next"
114             onTriggered: VpnControl.vpnConnect()
115         }
116     }
117
118     CoverActionList {
119         id: coverActionDisconnect
120
121         enabled: false
122
123         CoverAction {
124             iconSource: "image://theme/icon-cover-cancel"
125             onTriggered: VpnControl.vpnDisconnect()
126         }
127     }
128 }
129
130