~osomon/ubuntu-system-settings/autopkgtest

« back to all changes in this revision

Viewing changes to wizard/qml/Components/InputMethod.qml

  • Committer: CI bot
  • Author(s): Michael Terry
  • Date: 2014-12-02 19:39:44 UTC
  • mfrom: (1202.1.2 drop-wizard)
  • Revision ID: ps-jenkins@lists.canonical.com-20141202193944-iv7x24asrsor6tyi
Drop wizard code from ubuntu-system-settings, moving it to unity8. 
Approved by: Ken VanDine

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
// TODO: try to share this code with that from the unity8 shell
22
 
 
23
 
Item {
24
 
    id: root
25
 
 
26
 
    Connections {
27
 
        target: SurfaceManager
28
 
        onSurfaceCreated: {
29
 
            if (surface.type == MirSurfaceItem.InputMethod) {
30
 
                root.surface = surface;
31
 
            }
32
 
        }
33
 
 
34
 
        onSurfaceDestroyed: {
35
 
            if (root.surface == surface) {
36
 
                root.surface = null;
37
 
                surface.parent = null;
38
 
            }
39
 
            if (!surface.parent) {
40
 
                // there's no one displaying it. delete it right away
41
 
                surface.release();
42
 
            }
43
 
        }
44
 
    }
45
 
 
46
 
    property var surface: null
47
 
 
48
 
    property int transitionDuration: UbuntuAnimation.FastDuration
49
 
 
50
 
    state: {
51
 
        if (surface && surface.state != MirSurfaceItem.Minimized) {
52
 
            return "shown";
53
 
        } else {
54
 
            return "hidden";
55
 
        }
56
 
    }
57
 
 
58
 
    states: [
59
 
        State {
60
 
            name: "shown"
61
 
            PropertyChanges {
62
 
                target: root
63
 
                visible: true
64
 
                y: 0
65
 
            }
66
 
        },
67
 
        State {
68
 
            name: "hidden"
69
 
            PropertyChanges {
70
 
                target: root
71
 
                visible: false
72
 
                // half-way down because the vkb occupies only the lower half of the surface
73
 
                // TODO: consider keyboard rotation
74
 
                y: root.parent.height / 2.0
75
 
            }
76
 
        }
77
 
    ]
78
 
 
79
 
    transitions: [
80
 
        Transition {
81
 
            from: "*"; to: "*"
82
 
            PropertyAction { property: "visible"; value: true }
83
 
            UbuntuNumberAnimation { property: "y"; duration: transitionDuration }
84
 
        }
85
 
    ]
86
 
 
87
 
    Connections {
88
 
        target: surface
89
 
        ignoreUnknownSignals: true // don't wanna spam the log when surface is null
90
 
        onStateChanged: {
91
 
            if (state == MirSurfaceItem.Minimized) {
92
 
                root.hide();
93
 
            } else if (state == MirSurfaceItem.Maximized) {
94
 
                root.show();
95
 
            }
96
 
        }
97
 
    }
98
 
 
99
 
    onSurfaceChanged: {
100
 
        if (surface) {
101
 
            surface.parent = root;
102
 
            surface.anchors.fill = root;
103
 
        }
104
 
    }
105
 
 
106
 
    Component.onDestruction: {
107
 
        if (surface) {
108
 
            surface.parent = null;
109
 
            surface.release();
110
 
            surface = null;
111
 
        }
112
 
    }
113
 
}