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
#ifndef MINPUTCONTEXT_H
16
#define MINPUTCONTEXT_H
18
#include <maliit/namespace.h>
19
#include "dbusserverconnection.h"
26
#include <qpa/qplatforminputcontext.h>
28
class MImServerConnection;
30
class MInputContext : public QPlatformInputContext
35
enum OrientationAngle {
43
virtual ~MInputContext();
45
// reimplemented methods
46
virtual bool isValid() const;
48
virtual void commit();
49
virtual void update(Qt::InputMethodQueries);
50
virtual void invokeAction(QInputMethod::Action, int cursorPosition);
51
virtual bool filterEvent(const QEvent *event);
52
virtual QRectF keyboardRect() const;
53
virtual bool isAnimating() const;
54
virtual void showInputPanel();
55
virtual void hideInputPanel();
56
virtual bool isInputPanelVisible() const;
57
virtual QLocale locale() const;
58
virtual Qt::LayoutDirection inputDirection() const;
59
virtual void setFocusObject(QObject *object);
62
// Hooked up to the input method server
63
void activationLostEvent();
64
void imInitiatedHide();
66
void commitString(const QString &string, int replacementStart = 0,
67
int replacementLength = 0, int cursorPos = -1);
69
void updatePreedit(const QString &string, const QList<Maliit::PreeditTextFormat> &preeditFormats,
70
int replacementStart = 0, int replacementLength = 0, int cursorPos = -1);
72
void keyEvent(int type, int key, int modifiers, const QString &text, bool autoRepeat,
73
int count, Maliit::EventRequestType requestType = Maliit::EventRequestBoth);
75
void updateInputMethodArea(const QRect &rect);
76
void setGlobalCorrectionEnabled(bool);
77
void getPreeditRectangle(QRect &rectangle, bool &valid) const;
78
void onInvokeAction(const QString &action, const QKeySequence &sequence);
79
void setRedirectKeys(bool enabled);
80
void setDetectableAutoRepeat(bool enabled);
81
void setSelection(int start, int length);
82
void getSelection(QString &selection, bool &valid) const;
83
void setLanguage(const QString &language);
84
// End input method server connection slots.
87
void sendHideInputMethod();
88
void updateServerOrientation(Qt::ScreenOrientation orientation);
90
void onDBusDisconnection();
91
void onDBusConnection();
93
// Notify input method plugin about the application's active window prepare to change to a new orientation angle.
94
void notifyOrientationAboutToChange(MInputContext::OrientationAngle orientation);
96
// Notify input method plugin about new \a orientation angle of application's active window.
97
// note: this method is called when the orientation change is finished
98
void notifyOrientationChanged(MInputContext::OrientationAngle orientation);
101
Q_DISABLE_COPY(MInputContext)
103
enum InputPanelState {
104
InputPanelShowPending, // input panel showing requested, but activation pending
109
void updatePreeditInternally(const QString &string, const QList<Maliit::PreeditTextFormat> &preeditFormats,
110
int replacementStart = 0, int replacementLength = 0, int cursorPos = -1);
112
void connectInputMethodServer();
114
void updateInputMethodExtensions();
116
// returns content type corresponding to specified hints
117
Maliit::TextContentType contentType(Qt::InputMethodHints hints) const;
119
// returns state for currently focused widget, key is attribute name.
120
QMap<QString, QVariant> getStateInformation() const;
122
// Gets cursor start position, relative to widget surrounding text.
123
// Parameter valid set to false on failure.
124
int cursorStartPosition(bool *valid);
128
DBusServerConnection *imServer;
129
bool active; // is connection active
130
QPointer<QWindow> window;
131
QRect keyboardRectangle;
132
InputPanelState inputPanelState; // state for the input method server's software input panel
134
/* Timer for hiding the current Software Input Panel.
135
* This is mainly for switching directly between widgets that have input method enabled. */
138
int preeditCursorPos;
139
bool redirectKeys; // redirect all hw key events to the input method or not