~timo-jyrinki/ubuntu/trusty/maliit-framework/fix_qt52

« back to all changes in this revision

Viewing changes to maliit/inputmethod.cpp

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo, Sergio Schvezov, Ricardo Salveti de Araujo
  • Date: 2013-07-23 19:47:04 UTC
  • mfrom: (1.1.2) (1.2.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130723194704-1lsy1kmlda069cea
Tags: 0.99.0+git20130615+97e8335-0ubuntu1
[ Sergio Schvezov ]
* New build from HEAD 97e8335.
* Packaging import from lp:phablet-extras/maliit-framework.

[ Ricardo Salveti de Araujo ]
* debian/control: adding vcs and fixing dependencies
* General package cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* * This file is part of Maliit framework *
2
 
 *
3
 
 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies).
4
 
 * All rights reserved.
5
 
 *
6
 
 * Contact: maliit-discuss@lists.maliit.org
7
 
 *
8
 
 * This library is free software; you can redistribute it and/or
9
 
 * modify it under the terms of the GNU Lesser General Public
10
 
 * License version 2.1 as published by the Free Software Foundation
11
 
 * and appearing in the file LICENSE.LGPL included in the packaging
12
 
 * of this file.
13
 
 */
14
 
 
15
 
// Based on minputmethodstate.cpp from libmeegotouch
16
 
 
17
 
#include "inputmethod.h"
18
 
#include "inputmethod_p.h"
19
 
 
20
 
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
21
 
#include <QGuiApplication>
22
 
#include <QInputMethod>
23
 
#else
24
 
#include <QApplication>
25
 
#include <QInputContext>
26
 
#endif
27
 
 
28
 
namespace Maliit {
29
 
 
30
 
InputMethodPrivate::InputMethodPrivate() :
31
 
    area(),
32
 
    widget(0),
33
 
    orientationAngle(),
34
 
    rotationInProgress(false)
35
 
{
36
 
}
37
 
 
38
 
InputMethodPrivate::~InputMethodPrivate()
39
 
{
40
 
}
41
 
 
42
 
InputMethod::InputMethod() :
43
 
    QObject(),
44
 
    d_ptr(new InputMethodPrivate)
45
 
{
46
 
}
47
 
 
48
 
InputMethod::~InputMethod()
49
 
{
50
 
}
51
 
 
52
 
InputMethod *InputMethod::instance()
53
 
{
54
 
    static InputMethod singleton;
55
 
 
56
 
    return &singleton;
57
 
}
58
 
 
59
 
void InputMethod::setWidget(QWidget *widget)
60
 
{
61
 
    Q_D(InputMethod);
62
 
    d->widget = widget;
63
 
}
64
 
 
65
 
QWidget *InputMethod::widget() const
66
 
{
67
 
    Q_D(const InputMethod);
68
 
    return d->widget;
69
 
}
70
 
 
71
 
QRect InputMethod::area() const
72
 
{
73
 
    Q_D(const InputMethod);
74
 
 
75
 
    return d->area;
76
 
}
77
 
 
78
 
void InputMethod::setArea(const QRect &newArea)
79
 
{
80
 
    Q_D(InputMethod);
81
 
 
82
 
    if (d->area != newArea) {
83
 
        d->area = newArea;
84
 
        Q_EMIT areaChanged(d->area);
85
 
    }
86
 
}
87
 
 
88
 
void InputMethod::startOrientationAngleChange(OrientationAngle newOrientationAngle)
89
 
{
90
 
    Q_D(InputMethod);
91
 
 
92
 
    if (d->orientationAngle != newOrientationAngle) {
93
 
        d->orientationAngle = newOrientationAngle;
94
 
        d->rotationInProgress = true;
95
 
        Q_EMIT orientationAngleAboutToChange(d->orientationAngle);
96
 
    }
97
 
}
98
 
 
99
 
void InputMethod::setOrientationAngle(OrientationAngle newOrientationAngle)
100
 
{
101
 
    Q_D(InputMethod);
102
 
 
103
 
    if (d->orientationAngle != newOrientationAngle) {
104
 
        d->orientationAngle = newOrientationAngle;
105
 
        d->rotationInProgress = true;
106
 
    }
107
 
 
108
 
    if (d->rotationInProgress) {
109
 
        d->rotationInProgress = false;
110
 
        Q_EMIT orientationAngleChanged(d->orientationAngle);
111
 
    }
112
 
}
113
 
 
114
 
OrientationAngle InputMethod::orientationAngle() const
115
 
{
116
 
    Q_D(const InputMethod);
117
 
 
118
 
    return d->orientationAngle;
119
 
}
120
 
 
121
 
void InputMethod::emitKeyPress(const QKeyEvent &event)
122
 
{
123
 
    Q_EMIT keyPress(event);
124
 
}
125
 
 
126
 
void InputMethod::emitKeyRelease(const QKeyEvent &event)
127
 
{
128
 
    Q_EMIT keyRelease(event);
129
 
}
130
 
 
131
 
void InputMethod::setLanguage(const QString &language)
132
 
{
133
 
    Q_D(InputMethod);
134
 
    if (d->language != language) {
135
 
        d->language = language;
136
 
        Q_EMIT languageChanged(language);
137
 
    }
138
 
}
139
 
 
140
 
const QString &InputMethod::language() const
141
 
{
142
 
    Q_D(const InputMethod);
143
 
    return d->language;
144
 
}
145
 
 
146
 
void requestInputMethodPanel()
147
 
{
148
 
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
149
 
    qApp->inputMethod()->show();
150
 
#else
151
 
    QInputContext *inputContext = qApp->inputContext();
152
 
 
153
 
    if (!inputContext) {
154
 
        return;
155
 
    }
156
 
 
157
 
    QEvent request(QEvent::RequestSoftwareInputPanel);
158
 
    inputContext->filterEvent(&request);
159
 
#endif
160
 
}
161
 
 
162
 
void closeInputMethodPanel()
163
 
{
164
 
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
165
 
    qApp->inputMethod()->hide();
166
 
#else
167
 
    QInputContext *inputContext = qApp->inputContext();
168
 
 
169
 
    if (!inputContext) {
170
 
        return;
171
 
    }
172
 
 
173
 
    QEvent close(QEvent::CloseSoftwareInputPanel);
174
 
    inputContext->filterEvent(&close);
175
 
    inputContext->reset();
176
 
#endif
177
 
}
178
 
 
179
 
} // namespace Maliit