]> pilppa.org Git - vdr-tv-client.git/blob - qml/vdr-tv-client/qml/ServerSelectionEntry.qml
551f5fb9a104780ea855da0e4896333853cdf660
[vdr-tv-client.git] / qml / vdr-tv-client / qml / ServerSelectionEntry.qml
1 /*
2  * vdr-tv-client: TV frontend for watching tv streams from the vdr server.
3  *
4  * Copyright (c) 2011, Mika Laitio. <lamikr@pilppa.org>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
20  *
21  */
22
23 import Qt 4.7
24 import com.nokia.meego 1.0
25 import com.meego.vdrclient 1.0
26
27 Item {
28         property string locTxt_CaptionServerSelection: qsTr("Enter VDR server address:")
29         property string locTxt_BtnRestoreDefault: qsTr("Restore Default Address")
30         property string locTxt_BtnConnect: qsTr("Watch VDR TV")
31         property string defaultVDRServerAddress: "xvdr+tcp://192.168.2.1:37890"
32         property TextInput textInput: editVDRServerSelectionAddress
33         id: cmp
34         VDRClient { id: adapter } // callback to QMLVDRClient c++ class
35
36         function restoreDefaultVDRServerAddress() {
37                 editVDRServerSelectionAddress.color = "red";
38                 editVDRServerSelectionAddress.text = defaultVDRServerAddress;
39         }
40
41         function connectVDRServer() {
42                 if (editVDRServerSelectionAddress.text.length > 5) {
43                         adapter.launch_viewer(editVDRServerSelectionAddress.text);
44                 }
45         }
46
47         Text {
48                 font.pointSize: 24
49                 anchors {top: parent.top; left: parent.left; margins: 10}
50                 text: locTxt_CaptionServerSelection
51                 id: captionServerSelection
52         }
53
54         TextInput {
55                 id: editVDRServerSelectionAddress
56                 anchors {top: captionServerSelection.bottom; left: parent.left; right: parent.right; margins: 10}
57                 color: style.foregroundLight
58                 cursorVisible: true
59                 //activeFocusOnPress: true
60                 inputMethodHints: Qt.ImhDialableCharactersOnly
61                 font {pixelSize: 36}
62                 text: defaultVDRServerAddress
63                 //focus: true
64
65                 onTextChanged: {
66                         if (text.length == 0) {
67                                 cmp.restoreDefaultVDRServerAddress();
68                         }
69                         if (text == defaultVDRServerAddress) {
70                                 color = "red";
71                         }
72                         else {
73                                 color = "black";
74                         }
75                 }
76                 onAccepted: {
77                         if (text.length > 5) {
78                                 cmp.connectVDRServer(text)
79                         }
80                 }
81         }
82
83         Button {
84                 id: btnRestoreDefault
85                 anchors {top: editVDRServerSelectionAddress.bottom; left: parent.left; margins: 24}
86                 text: locTxt_BtnRestoreDefault
87         
88                 MouseArea {
89                         anchors.fill: parent
90                         onClicked: {
91                                 if (editVDRServerSelectionAddress.text != defaultVDRServerAddress) {
92                                         cmp.restoreDefaultVDRServerAddress();
93                                 }
94                         }       
95                 }
96         }
97
98         Button {
99                 id: btnConnect
100                 anchors {top: editVDRServerSelectionAddress.bottom; right: parent.right; margins: 24}
101                 text: locTxt_BtnConnect
102
103                 MouseArea {
104                         anchors.fill: parent
105                         onClicked: {
106                                 if (editVDRServerSelectionAddress.text.length > 5) {
107                                         cmp.connectVDRServer(editVDRServerSelectionAddress.text);
108                                 }
109                         }
110                 }
111         }
112 }