on 5d6ddf6 help sign in
unity8/qml/Components/InputMethod.qml
91 lines 2.4 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 Connections {
66 target: surface
67 ignoreUnknownSignals: true // don't wanna spam the log when surface is null
68 onStateChanged: {
69 if (state == MirSurfaceItem.Minimized) {
70 root.hide();
71 } else if (state == MirSurfaceItem.Maximized) {
72 root.show();
73 }
74 }
75 }
77 onSurfaceChanged: {
78 if (surface) {
79 surface.parent = root;
80 surface.anchors.fill = root;
81 }
82 }
84 Component.onDestruction: {
85 if (surface) {
86 surface.parent = null;
87 surface.release();
88 surface = null;
89 }
90 }