]> pilppa.org Git - vdr-tv-client.git/blob - qml/vdr-tv-client/qml/ServerSelectionEntry.qml
show full keyboard instead of number-only
[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                 font {pixelSize: 36}
61                 text: defaultVDRServerAddress
62                 //focus: true
63
64                 onTextChanged: {
65                         if (text.length == 0) {
66                                 cmp.restoreDefaultVDRServerAddress();
67                         }
68                         if (text == defaultVDRServerAddress) {
69                                 color = "red";
70                         }
71                         else {
72                                 color = "black";
73                         }
74                 }
75                 onAccepted: {
76                         if (text.length > 5) {
77                                 cmp.connectVDRServer(text)
78                         }
79                 }
80         }
81
82         Button {
83                 id: btnRestoreDefault
84                 anchors {top: editVDRServerSelectionAddress.bottom; left: parent.left; margins: 24}
85                 text: locTxt_BtnRestoreDefault
86         
87                 MouseArea {
88                         anchors.fill: parent
89                         onClicked: {
90                                 if (editVDRServerSelectionAddress.text != defaultVDRServerAddress) {
91                                         cmp.restoreDefaultVDRServerAddress();
92                                 }
93                         }       
94                 }
95         }
96
97         Button {
98                 id: btnConnect
99                 anchors {top: editVDRServerSelectionAddress.bottom; right: parent.right; margins: 24}
100                 text: locTxt_BtnConnect
101
102                 MouseArea {
103                         anchors.fill: parent
104                         onClicked: {
105                                 if (editVDRServerSelectionAddress.text.length > 5) {
106                                         cmp.connectVDRServer(editVDRServerSelectionAddress.text);
107                                 }
108                         }
109                 }
110         }
111 }