~michael-sheldon/ubuntu-keyboard/fix-oxide-dismiss-test

« back to all changes in this revision

Viewing changes to tests/qml-test-app/keyboard-test.qml

  • Committer: Thomas Moenicke
  • Date: 2013-07-19 12:05:07 UTC
  • Revision ID: thomas.moenicke@canonical.com-20130719120507-lzw5oq50xm567x0j
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
import QtQuick 2.0
 
4
import Ubuntu.Components 0.1
 
5
 
 
6
MainView {
 
7
    id: root
 
8
 
 
9
    automaticOrientation: true
 
10
 
 
11
    width: units.gu(18)
 
12
    height: units.gu(18)
 
13
 
 
14
    Rectangle {
 
15
        anchors.fill: parent
 
16
        color: "lightblue"
 
17
    }
 
18
 
 
19
    Column {
 
20
 
 
21
        y: units.gu(3)
 
22
        width: parent.width
 
23
        anchors.horizontalCenter: parent.horizontalCenter
 
24
        spacing: units.gu(1)
 
25
 
 
26
        anchors.margins: units.gu(1)
 
27
 
 
28
        Text {
 
29
            id: label
 
30
            text: "OSK TestApp"
 
31
            anchors.horizontalCenter: parent.horizontalCenter
 
32
            font.pixelSize: units.gu(2)
 
33
            font.bold: true
 
34
        }
 
35
 
 
36
        Row {
 
37
            anchors.horizontalCenter: parent.horizontalCenter;
 
38
            spacing: units.gu(1)
 
39
 
 
40
            Button {
 
41
                color: "red"
 
42
                text: "show()"
 
43
                width: units.gu(18)
 
44
                onClicked: Qt.inputMethod.show()
 
45
 
 
46
            }
 
47
 
 
48
            Button {
 
49
                color: "red"
 
50
                text: "hide()"
 
51
                width: units.gu(18)
 
52
                onClicked: Qt.inputMethod.hide()
 
53
            }
 
54
        }
 
55
 
 
56
        Text {
 
57
            anchors.horizontalCenter: parent.horizontalCenter;
 
58
 
 
59
            text: qsTr("note: show/hide requires focus on a text input")
 
60
            font.pixelSize: units.gu(1)
 
61
            color: "gray"
 
62
        }
 
63
 
 
64
        Row {
 
65
            anchors.horizontalCenter: parent.horizontalCenter
 
66
 
 
67
            spacing: units.gu(1)
 
68
 
 
69
            Rectangle {
 
70
                width: units.gu(18);
 
71
                height: firstInputButton.height;
 
72
 
 
73
                anchors.leftMargin: units.gu(1)
 
74
 
 
75
                color: "white"
 
76
 
 
77
                TextInput {
 
78
                    id: input;
 
79
                    anchors.fill: parent
 
80
                    color: "black"; selectionColor: "red"
 
81
 
 
82
                    // Qt.ImhPreferNumbers
 
83
                    inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhUrlCharactersOnly | Qt.ImhNoPredictiveText
 
84
                    font.pixelSize: units.gu(3)
 
85
                    font.bold: true
 
86
                }
 
87
            }
 
88
 
 
89
            Button {
 
90
                id: firstInputButton
 
91
                color: "yellow"
 
92
                text: "Focus/Unfocus"
 
93
                width: units.gu(18)
 
94
                onClicked: input.focus = !input.focus
 
95
            }
 
96
        }
 
97
 
 
98
        Row {
 
99
            anchors.horizontalCenter: parent.horizontalCenter;
 
100
 
 
101
            spacing: units.gu(1)
 
102
 
 
103
            Rectangle {
 
104
                width: units.gu(18);
 
105
                height: secondInputButton.height
 
106
 
 
107
                color: "white"
 
108
 
 
109
                TextInput {
 
110
                    id: secondInput;
 
111
 
 
112
                    anchors.fill: parent
 
113
 
 
114
                    font.pixelSize: units.gu(3)
 
115
                }
 
116
            }
 
117
 
 
118
            Button {
 
119
                id: secondInputButton
 
120
                color: "yellow"
 
121
                text: "Focus/Unfocus"
 
122
                width: units.gu(18)
 
123
                onClicked: secondInput.focus = !secondInput.focus
 
124
            }
 
125
        }
 
126
 
 
127
        Row {
 
128
            anchors.horizontalCenter: parent.horizontalCenter;
 
129
 
 
130
            Text {
 
131
                id: textRectangle
 
132
 
 
133
                font.pixelSize: units.gu(1)
 
134
                text: Qt.inputMethod.keyboardRectangle + " "
 
135
            }
 
136
 
 
137
            Rectangle {
 
138
                id: clickBehindOSKDetectedIndicator
 
139
 
 
140
                width: units.gu(18)
 
141
                height: units.gu(3)
 
142
                state: "default"
 
143
 
 
144
                Text {
 
145
                    id: clickBehindOSKDetectedIndicatorText
 
146
                    anchors.centerIn: parent
 
147
                    text: "clicked"
 
148
                    font.pixelSize: units.gu(2)
 
149
                    font.bold: true
 
150
                }
 
151
 
 
152
                states: [
 
153
                    State {
 
154
                        name: "default"
 
155
                        PropertyChanges {
 
156
                            target: clickBehindOSKDetectedIndicator
 
157
                            color: "gray"
 
158
                        }
 
159
                        PropertyChanges {
 
160
                            target: clickBehindOSKDetectedIndicatorText
 
161
                            color: "gray"
 
162
                        }
 
163
                    },
 
164
                    State {
 
165
                        name: "highlight"
 
166
                        PropertyChanges {
 
167
                            target: clickBehindOSKDetectedIndicator
 
168
                            color: "red"
 
169
                        }
 
170
                        PropertyChanges {
 
171
                            target: clickBehindOSKDetectedIndicatorText
 
172
                            color: "white"
 
173
                        }
 
174
                    }
 
175
                ]
 
176
            }
 
177
 
 
178
        }
 
179
 
 
180
        Text {
 
181
            id: textVisible
 
182
 
 
183
            anchors.horizontalCenter: parent.horizontalCenter;
 
184
 
 
185
            font.pixelSize: units.gu(2)
 
186
            text: "keyboard reports visible: " + Qt.inputMethod.visible
 
187
        }
 
188
 
 
189
    } // column
 
190
 
 
191
    Rectangle {
 
192
        id: fakeBrowserUrlBar
 
193
        width: keyboardRect.width
 
194
        height: units.gu(4)
 
195
        color: "orange"
 
196
        anchors.bottom: keyboardRect.top
 
197
 
 
198
        Text {
 
199
            visible: Qt.inputMethod.visible
 
200
            anchors.centerIn: parent
 
201
            font.pixelSize: units.gu(1)
 
202
            text: "browser url bar"
 
203
        }
 
204
    }
 
205
 
 
206
    Rectangle {
 
207
        id: keyboardRect
 
208
 
 
209
        width: Qt.inputMethod.keyboardRectangle.width
 
210
        height: Qt.inputMethod.keyboardRectangle.height
 
211
 
 
212
        anchors.bottom: parent.bottom
 
213
        color: " green"
 
214
 
 
215
        Text {
 
216
            visible: Qt.inputMethod.visible
 
217
            anchors.centerIn: parent
 
218
            font.pointSize: 24
 
219
            text: Qt.inputMethod.keyboardRectangle + " "
 
220
        }
 
221
 
 
222
        MouseArea {
 
223
            anchors.fill: parent
 
224
            onClicked: clickBehindOSKDetectedIndicator.visible = true
 
225
            onPressed: clickBehindOSKDetectedIndicator.state = "highlight"
 
226
            onReleased: clickBehindOSKDetectedIndicator.state = "default"
 
227
        }
 
228
    }
 
229
}