1
/* * This file is part of Maliit framework *
3
* Copyright (C) 2010 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
#include "minputmethodhost.h"
16
#include "minputcontextconnection.h"
17
#include "mimpluginmanager.h"
18
#include "mindicatorserviceclient.h"
19
#include <maliit/plugins/abstractinputmethod.h>
22
#include <QGraphicsView>
24
#include <maliit/namespace.h>
26
MInputMethodHost::MInputMethodHost(const QSharedPointer<MInputContextConnection> &inputContextConnection,
27
MIMPluginManager *pluginManager,
28
MIndicatorServiceClient &indicatorService,
29
AbstractSurfaceFactory *surfaceFactory,
30
const QString &plugin,
31
const QString &description)
32
: MAbstractInputMethodHost(),
33
connection(inputContextConnection),
34
pluginManager(pluginManager),
37
indicatorService(indicatorService),
38
mSurfaceFactory(surfaceFactory),
40
pluginDescription(description)
46
MInputMethodHost::~MInputMethodHost()
52
void MInputMethodHost::setEnabled(bool enabled)
54
this->enabled = enabled;
57
void MInputMethodHost::setInputMethod(MAbstractInputMethod *inputMethod)
59
this->inputMethod = inputMethod;
62
int MInputMethodHost::contentType(bool &valid)
64
return connection->contentType(valid);
67
bool MInputMethodHost::correctionEnabled(bool &valid)
69
return connection->correctionEnabled(valid);
72
bool MInputMethodHost::predictionEnabled(bool &valid)
74
return connection->predictionEnabled(valid);
77
bool MInputMethodHost::autoCapitalizationEnabled(bool &valid)
79
return connection->autoCapitalizationEnabled(valid);
82
bool MInputMethodHost::surroundingText(QString &text, int &cursorPosition)
84
return connection->surroundingText(text, cursorPosition);
87
bool MInputMethodHost::hasSelection(bool &valid)
89
return connection->hasSelection(valid);
92
QString MInputMethodHost::selection(bool &valid)
94
return connection->selection(valid);
97
int MInputMethodHost::preeditClickPos(bool &valid) const
99
return connection->preeditClickPos(valid);
102
int MInputMethodHost::inputMethodMode(bool &valid)
104
return connection->inputMethodMode(valid);
107
QRect MInputMethodHost::preeditRectangle(bool &valid)
109
return connection->preeditRectangle(valid);
112
QRect MInputMethodHost::cursorRectangle(bool &valid)
114
return connection->cursorRectangle(valid);
117
bool MInputMethodHost::hiddenText(bool &valid)
119
return connection->hiddenText(valid);
122
void MInputMethodHost::sendPreeditString(const QString &string,
123
const QList<Maliit::PreeditTextFormat> &preeditFormats,
124
int replacementStart, int replacementLength,
128
connection->sendPreeditString(string, preeditFormats, replacementStart, replacementLength, cursorPos);
132
void MInputMethodHost::sendCommitString(const QString &string, int replaceStart,
133
int replaceLength, int cursorPos)
136
connection->sendCommitString(string, replaceStart, replaceLength, cursorPos);
140
void MInputMethodHost::sendKeyEvent(const QKeyEvent &keyEvent,
141
Maliit::EventRequestType requestType)
144
connection->sendKeyEvent(keyEvent, requestType);
148
void MInputMethodHost::notifyImInitiatedHiding()
151
connection->notifyImInitiatedHiding();
155
void MInputMethodHost::invokeAction(const QString &action,
156
const QKeySequence &sequence)
159
connection->invokeAction(action, sequence);
163
void MInputMethodHost::setRedirectKeys(bool redirectEnabled)
166
connection->setRedirectKeys(redirectEnabled);
170
void MInputMethodHost::setDetectableAutoRepeat(bool autoRepeatEnabled)
173
connection->setDetectableAutoRepeat(autoRepeatEnabled);
177
void MInputMethodHost::setGlobalCorrectionEnabled(bool correctionEnabled)
180
connection->setGlobalCorrectionEnabled(correctionEnabled);
184
void MInputMethodHost::setInputModeIndicator(Maliit::InputModeIndicator mode)
187
indicatorService.setInputModeIndicator(static_cast<Maliit::InputModeIndicator>(mode));
191
void MInputMethodHost::switchPlugin(Maliit::SwitchDirection direction)
194
pluginManager->switchPlugin(direction, inputMethod);
198
void MInputMethodHost::switchPlugin(const QString &pluginName)
201
pluginManager->switchPlugin(pluginName, inputMethod);
205
void MInputMethodHost::setScreenRegion(const QRegion ®ion)
208
pluginManager->updateRegion(region);
212
void MInputMethodHost::setInputMethodArea(const QRegion &)
214
// TODO: remove function since it is handled by surfaces now
217
void MInputMethodHost::setSelection(int start, int length)
220
connection->setSelection(start, length);
224
QList<MImPluginDescription> MInputMethodHost::pluginDescriptions(Maliit::HandlerState state) const
226
return pluginManager->pluginDescriptions(state);
229
QList<MImSubViewDescription>
230
MInputMethodHost::surroundingSubViewDescriptions(Maliit::HandlerState state) const
232
return pluginManager->surroundingSubViewDescriptions(state);
235
void MInputMethodHost::setLanguage(const QString &language)
238
connection->setLanguage(language);
242
void MInputMethodHost::setOrientationAngleLocked(bool)
247
int MInputMethodHost::anchorPosition(bool &valid)
249
return connection->anchorPosition(valid);
252
AbstractSurfaceFactory *MInputMethodHost::surfaceFactory()
254
return mSurfaceFactory;
257
AbstractPluginSetting *MInputMethodHost::registerPluginSetting(const QString &key,
258
const QString &description,
259
Maliit::SettingEntryType type,
260
const QVariantMap &attributes)
262
return pluginManager->registerPluginSetting(pluginId, pluginDescription, key, description, type, attributes);