on f621663 help sign in
unity8/qml/Components/InputMethod.qml
79 lines 2.1 kB history raw
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.0
18import Unity.Application 0.1
19import Ubuntu.Components 0.1
21Item {
22 id: root
24 property var surface: null
26 property int transitionDuration: UbuntuAnimation.FastDuration
28 state: {
29 if (surface && surface.state != MirSurfaceItem.Minimized) {
30 return "shown";
31 } else {
32 return "hidden";
33 }
34 }
36 states: [
37 State {
38 name: "shown"
39 PropertyChanges {
40 target: root
41 visible: true
42 y: 0
43 }
44 },
45 State {
46 name: "hidden"
47 PropertyChanges {
48 target: root
49 visible: false
50 // half-way down because the vkb occupies only the lower half of the surface
51 // TODO: consider keyboard rotation
52 y: root.parent.height / 2.0
53 }
54 }
55 ]
57 transitions: [
58 Transition {
59 from: "*"; to: "*"
60 PropertyAction { property: "visible"; value: true }
61 UbuntuNumberAnimation { property: "y"; duration: transitionDuration }
62 }
63 ]
65 onSurfaceChanged: {
66 if (surface) {
67 surface.parent = root;
68 surface.anchors.fill = root;
69 }
70 }
72 Component.onDestruction: {
73 if (surface) {
74 surface.parent = null;
75 surface.release();
76 surface = null;
77 }
78 }