1
/* * This file is part of Maliit framework *
3
* Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies).
6
* Contact: maliit-discuss@lists.maliit.org
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
15
// Based on minputmethodstate.cpp from libmeegotouch
17
#include "inputmethod.h"
18
#include "inputmethod_p.h"
20
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
21
#include <QGuiApplication>
22
#include <QInputMethod>
24
#include <QApplication>
25
#include <QInputContext>
30
InputMethodPrivate::InputMethodPrivate() :
34
rotationInProgress(false)
38
InputMethodPrivate::~InputMethodPrivate()
42
InputMethod::InputMethod() :
44
d_ptr(new InputMethodPrivate)
48
InputMethod::~InputMethod()
52
InputMethod *InputMethod::instance()
54
static InputMethod singleton;
59
void InputMethod::setWidget(QWidget *widget)
65
QWidget *InputMethod::widget() const
67
Q_D(const InputMethod);
71
QRect InputMethod::area() const
73
Q_D(const InputMethod);
78
void InputMethod::setArea(const QRect &newArea)
82
if (d->area != newArea) {
84
Q_EMIT areaChanged(d->area);
88
void InputMethod::startOrientationAngleChange(OrientationAngle newOrientationAngle)
92
if (d->orientationAngle != newOrientationAngle) {
93
d->orientationAngle = newOrientationAngle;
94
d->rotationInProgress = true;
95
Q_EMIT orientationAngleAboutToChange(d->orientationAngle);
99
void InputMethod::setOrientationAngle(OrientationAngle newOrientationAngle)
103
if (d->orientationAngle != newOrientationAngle) {
104
d->orientationAngle = newOrientationAngle;
105
d->rotationInProgress = true;
108
if (d->rotationInProgress) {
109
d->rotationInProgress = false;
110
Q_EMIT orientationAngleChanged(d->orientationAngle);
114
OrientationAngle InputMethod::orientationAngle() const
116
Q_D(const InputMethod);
118
return d->orientationAngle;
121
void InputMethod::emitKeyPress(const QKeyEvent &event)
123
Q_EMIT keyPress(event);
126
void InputMethod::emitKeyRelease(const QKeyEvent &event)
128
Q_EMIT keyRelease(event);
131
void InputMethod::setLanguage(const QString &language)
134
if (d->language != language) {
135
d->language = language;
136
Q_EMIT languageChanged(language);
140
const QString &InputMethod::language() const
142
Q_D(const InputMethod);
146
void requestInputMethodPanel()
148
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
149
qApp->inputMethod()->show();
151
QInputContext *inputContext = qApp->inputContext();
157
QEvent request(QEvent::RequestSoftwareInputPanel);
158
inputContext->filterEvent(&request);
162
void closeInputMethodPanel()
164
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
165
qApp->inputMethod()->hide();
167
QInputContext *inputContext = qApp->inputContext();
173
QEvent close(QEvent::CloseSoftwareInputPanel);
174
inputContext->filterEvent(&close);
175
inputContext->reset();
179
} // namespace Maliit