Initial import from CES2017 repository
[src/qtquickcontrols2-agl.git] / imports / agl-demo-controls / Alphabet.qml
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 import QtQuick 2.6
18 import QtQuick.Window 2.0
19 import QtQuick.Layouts 1.1
20
21 AbstractKeyboard {
22     id: root
23
24     ColumnLayout {
25         anchors.fill: parent
26         anchors.margins: root.height / 10
27         RowLayout {
28             Layout.fillWidth: true
29             Layout.fillHeight: true
30             Repeater {
31                 model: ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p']
32                 delegate: Key {
33                     text: model.modelData
34                     Layout.preferredWidth: 2
35                     Layout.fillWidth: true
36                     Layout.fillHeight: true
37                     capital: shift.checked
38                 }
39             }
40         }
41         RowLayout {
42             Layout.fillWidth: true
43             Layout.fillHeight: true
44             Item {
45                 Layout.preferredWidth: 1
46                 Layout.fillWidth: true
47             }
48
49             Repeater {
50                 model: ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l']
51                 delegate: Key {
52                     text: model.modelData
53                     Layout.preferredWidth: 2
54                     Layout.fillWidth: true
55                     Layout.fillHeight: true
56                     capital: shift.checked
57                 }
58             }
59             Item {
60                 Layout.preferredWidth: 1
61                 Layout.fillWidth: true
62             }
63         }
64         RowLayout {
65             Layout.fillWidth: true
66             Layout.fillHeight: true
67             Key {
68                 id: shift
69                 image: './images/Keyboard_Shift.svg'
70                 checkable: true
71                 Layout.preferredWidth: 2
72                 Layout.fillWidth: true
73                 Layout.fillHeight: true
74             }
75             Repeater {
76                 model: ['z', 'x', 'c', 'v', 'b', 'n', 'm', '@']
77                 delegate: Key {
78                     text: model.modelData
79                     Layout.preferredWidth: 2
80                     Layout.fillWidth: true
81                     Layout.fillHeight: true
82                     capital: shift.checked
83                 }
84             }
85             Key {
86                 image: './images/Keyboard_Back.svg'
87                 Layout.preferredWidth: 2
88                 Layout.fillWidth: true
89                 Layout.fillHeight: true
90                 onClicked: {
91                     if (!clearSelctedText()) {
92                         var input = keyboard.target
93                         if (input.cursorPosition > 0)
94                             keyboard.target.remove(input.cursorPosition - 1, input.cursorPosition)
95                     }
96                 }
97             }
98         }
99         RowLayout {
100             Layout.fillWidth: true
101             Layout.fillHeight: true
102             Key {
103                 text: '123'
104                 Layout.preferredWidth: 2
105                 Layout.fillWidth: true
106                 Layout.fillHeight: true
107                 onClicked: root.toggleMode()
108             }
109             Key {
110                 text: '.'
111                 Layout.preferredWidth: 2
112                 Layout.fillWidth: true
113                 Layout.fillHeight: true
114             }
115             Key {
116                 text: ' '
117                 image: './images/Keyboard_Space.svg'
118                 Layout.preferredWidth: 12
119                 Layout.fillWidth: true
120                 Layout.fillHeight: true
121             }
122             Key {
123                 text: '!?'
124                 Layout.preferredWidth: 2
125                 Layout.fillWidth: true
126                 Layout.fillHeight: true
127                 onClicked: root.toggleMode()
128             }
129             Key {
130                 image: './images/Keyboard_Arrow.svg'
131                 Layout.preferredWidth: 2
132                 Layout.fillWidth: true
133                 Layout.fillHeight: true
134                 onClicked: {
135                     root.hide()
136                 }
137             }
138         }
139     }
140 }