Unity 8
 All Classes Functions
InputMethod.qml
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  */
16 
17 import QtQuick 2.0
18 import Unity.Application 0.1
19 import Ubuntu.Components 0.1
20 
21 Item {
22  id: root
23 
24  property var surface: null
25 
26  property int transitionDuration: UbuntuAnimation.FastDuration
27 
28  state: {
29  if (surface && surface.state != MirSurfaceItem.Minimized) {
30  return "shown";
31  } else {
32  return "hidden";
33  }
34  }
35 
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  ]
56 
57  transitions: [
58  Transition {
59  from: "*"; to: "*"
60  PropertyAction { property: "visible"; value: true }
61  UbuntuNumberAnimation { property: "y"; duration: transitionDuration }
62  }
63  ]
64 
65  onSurfaceChanged: {
66  if (surface) {
67  surface.parent = root;
68  surface.anchors.fill = root;
69  }
70  }
71 
72  Component.onDestruction: {
73  if (surface) {
74  surface.parent = null;
75  surface.release();
76  surface = null;
77  }
78  }
79 }