Debian Codegraph @

online-accounts-plugins/lib/module/qml5/KeyboardRectangle.qml

raw
1 /*
2 * This file is part of liblomiri-online-accounts-plugin
3 *
4 * Copyright (C) 2013 Canonical Ltd.
5 *
6 * Contact: Alberto Mardegan <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 import QtQuick 2.9
22
23 Item {
24 id: keyboardRect
25 anchors.left: parent.left
26 anchors.right: parent.right
27 anchors.bottom: parent.bottom
28 height: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
29
30 Behavior on height {
31 StandardAnimation { }
32 }
33
34 function recursiveFindFocusedItem(parent) {
35 if (parent.activeFocus) {
36 return parent;
37 }
38
39 for (var i in parent.children) {
40 var child = parent.children[i];
41 if (child.activeFocus) {
42 return child;
43 }
44
45 var item = recursiveFindFocusedItem(child);
46
47 if (item != null) {
48 return item;
49 }
50 }
51
52 return null;
53 }
54
55 Connections {
56 target: Qt.inputMethod
57
58 onVisibleChanged: {
59 if (!Qt.inputMethod.visible) {
60 var focusedItem = recursiveFindFocusedItem(keyboardRect.parent);
61 if (focusedItem != null) {
62 focusedItem.focus = false;
63 }
64 }
65 }
66 }
67 }