47 readonly
property var qwertyLayout:
48 [ [ { label:
"1", shiftLabel:
"!" },
49 { label:
"2", shiftLabel:
"@" },
50 { label:
"3", shiftLabel:
"#" },
51 { label:
"4", shiftLabel:
"$" },
52 { label:
"5", shiftLabel:
"%" },
53 { label:
"6", shiftLabel:
"^" },
54 { label:
"7", shiftLabel:
"&" },
55 { label:
"8", shiftLabel:
"*" },
56 { label:
"9", shiftLabel:
"(" },
57 { label:
"0", shiftLabel:
")" },
58 { label:
"-", shiftLabel:
"_" },
59 { label:
"=", shiftLabel:
"+" } ],
61 [ { label:
"q", shiftLabel:
"Q" },
62 { label:
"w", shiftLabel:
"W" },
63 { label:
"e", shiftLabel:
"E" },
64 { label:
"r", shiftLabel:
"R" },
65 { label:
"t", shiftLabel:
"T" },
66 { label:
"y", shiftLabel:
"Y" },
67 { label:
"u", shiftLabel:
"U" },
68 { label:
"i", shiftLabel:
"I" },
69 { label:
"o", shiftLabel:
"O" },
70 { label:
"p", shiftLabel:
"P" } ],
72 [ { label:
"a", shiftLabel:
"A" },
73 { label:
"s", shiftLabel:
"S" },
74 { label:
"d", shiftLabel:
"D" },
75 { label:
"f", shiftLabel:
"F" },
76 { label:
"g", shiftLabel:
"G" },
77 { label:
"h", shiftLabel:
"H" },
78 { label:
"j", shiftLabel:
"J" },
79 { label:
"k", shiftLabel:
"K" },
80 { label:
"l", shiftLabel:
"L" } ],
82 [ { label:
"z", shiftLabel:
"Z" },
83 { label:
"x", shiftLabel:
"X" },
84 { label:
"c", shiftLabel:
"C" },
85 { label:
"v", shiftLabel:
"V" },
86 { label:
"b", shiftLabel:
"B" },
87 { label:
"n", shiftLabel:
"N" },
88 { label:
"m", shiftLabel:
"M" } ]]
94 readonly
property string backspace:
"\u2190"
100 readonly
property string shiftUpSymbol:
"\u21E7"
106 readonly
property string shiftDownSymbol:
"\u21E9"
147 property var layout: null
153 property bool shiftKey:
false
201 signal keypress(
string text)
208 signal error(
string msg)
219 height: visible ? priv.cHeight : 0
220 anchors.bottom: parent.bottom
221 anchors.horizontalCenter: parent.horizontalCenter
223 property int modifiers: Qt.NoModifier;
229 readonly
property int cHeight: numRows * keyboard.keyHeight +
230 (numRows + 1) * keyboard.rowSpacing
231 property
int numRows: 0
232 property
bool initialized:
false
236 function populateKeyboard(a)
242 if (!Array.isArray(a) || a.length < 1) {
243 error(
"VirtualKeyboard: Invalid layout, array of length > 0");
248 if (keyboard.shiftKey) {
250 label : keyboard.shiftUpSymbol +
" Shift",
251 shiftLabel: keyboard.shiftDownSymbol +
" Shift",
252 specialKeyValue: Qt.Key_Shift } ]);
256 for (i = 0; i < a.length; i++) {
257 if (!Array.isArray(a[i])) {
258 error(
"VirtualKeyboard: Invalid layout, expecting array of arrays of keys");
261 if (a[i].length > maxButtons)
262 maxButtons = a[i].length;
263 for (var j = 0; j < a[i].length; j++) {
264 if (undefined === a[i][j].label) {
265 error(
"VirtualKeyboard: Invalid layout, invalid key object");
268 if (undefined === a[i][j].specialKeyValue)
269 a[i][j].specialKeyValue = 0;
270 var label = a[i][j].label;
272 if (shiftKey && label == label.toLocaleUpperCase())
273 label = label.toLocaleLowerCase();
275 if (seenLabels.indexOf(label) !=-1) {
280 a[i][j].label = label;
281 seenLabels.push(label);
282 if (keyboard.shiftKey && undefined === a[i][j].shiftLabel)
283 a[i][j].shiftLabel = a[i][j].label.toLocaleUpperCase();
288 for (i = 0; i < a.length; i++) {
291 rowListModel.append({ rowNum: i,
296 priv.initialized = (priv.numRows > 0);
299 function handleVirtualKeyPress(virtualKey) {
300 if (virtualKey.specialKey == Qt.Key_Shift)
301 keyboard.modifiers ^= Qt.ShiftModifier;
305 keyboard.keypress(virtualKey.text);
309 rowListModel.clear();
310 priv.initialized =
false;
312 populateKeyboard(layout);
332 easing.type: Easing.OutCubic
340 height: keyboard.height
342 opacity: keyboard.opacity
347 anchors.top: parent.top
348 anchors.topMargin: keyboard.margin
349 anchors.left: parent.left
350 anchors.margins: keyboard.margin
352 height: parent.height - keyboard.margin * 2
353 spacing: keyboard.rowSpacing
354 orientation: Qt.Vertical
355 verticalLayoutDirection: ListView.TopToBottom
366 height: keyboardRow.height
374 propagateComposedEvents:
true
377 onEntered: rowList.currentIndex = index;
381 rowList.currentIndex = index;
383 mouse.accepted =
false;
389 spacing: keyboard.keySpacing
392 z: rowListDelegate.ListView.isCurrentItem ? 1 : -1
395 id: keyboardRowSpacing
397 height: keyboard.keyHeight
401 id: keyboardRowRepeater
403 z: rowListDelegate.ListView.isCurrentItem ? 1 : -1
406 delegate: VirtualKey {
407 width: (keyboard.width - keyboardRowRepeater.count *
408 keyboardRow.spacing - offset - keyboard.margin*2) /
409 keyboardRowRepeater.count
410 height: keyboard.keyHeight
411 modifiers: keyboard.modifiers
412 specialKey: specialKeyValue
415 onItemAdded: item.pressed.connect(keyboard.handleVirtualKeyPress);
417 onItemRemoved: item.pressed.disconnect(keyboard.handleVirtualKeyPress);
bool isVirtualKeyboard
Whether on-screen keyboard should be enabled per default in activities that use it.
Singleton that contains GCompris' persistent settings.
A general purpose singleton that exposes miscellaneous native functions to the QML layer...
qreal ratio
Ratio factor used for scaling of sizes on high-dpi devices.