1
/* * This file is part of Maliit framework *
3
* Copyright (C) 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
#ifndef MEEGO_KEYBOARD_QUICK_H
16
#define MEEGO_KEYBOARD_QUICK_H
18
#include <maliit/plugins/abstractinputmethod.h>
19
#include <maliit/plugins/keyoverride.h>
25
#include <QGraphicsView>
26
#include <QGraphicsScene>
28
class MInputMethodQuickPrivate;
29
class MInputMethodQuickLoader;
30
class MKeyOverrideQuick;
32
//! \brief MInputMethodQuick is used for QML-based input method plugins.
34
//! It defines the interface between framework, applications and QML-based
35
//! input methods. Instead of allowing QML-based input methods to use the
36
//! MAbstractInputMethodHost interface directly, this class will forward the
37
//! necessary requests.
38
//! QML-based input methods on the other hand can use the properties of this
39
//! class to respond to requests from the framework.
40
class MInputMethodQuick
41
: public MAbstractInputMethod
46
//! Propagates screen width to QML components.
47
Q_PROPERTY(int screenWidth READ screenWidth
48
NOTIFY screenWidthChanged)
50
//! Propagates screen height to QML components.
51
Q_PROPERTY(int screenHeight READ screenHeight
52
NOTIFY screenHeightChanged)
54
//! Propagates application orientation to QML components.
55
Q_PROPERTY(int appOrientation READ appOrientation
56
NOTIFY appOrientationChanged)
58
//! Propagates action key override to QML components.
59
Q_PROPERTY(MKeyOverrideQuick *actionKeyOverride READ actionKeyOverride
60
NOTIFY actionKeyOverrideChanged)
62
//! Property for whether input method is active
63
Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
66
enum KeyEvent { KeyPress = QEvent::KeyPress,
67
KeyRelease = QEvent::KeyRelease };
70
//! \param host serves as communication link to framework and application. Managed by framework.
71
//! \param mainWindow should be used to install plugin's UI into it. Managed by framework.
72
//! \param qmlFileName the QML file that will be loaded.
73
explicit MInputMethodQuick(MAbstractInputMethodHost *host,
74
const QString &qmlFileName);
75
virtual ~MInputMethodQuick();
80
virtual void handleVisualizationPriorityChange(bool priority);
81
virtual void handleClientChange();
82
virtual void handleAppOrientationChanged(int angle);
83
virtual void setState(const QSet<Maliit::HandlerState> &state);
85
virtual void setKeyOverrides(const QMap<QString, QSharedPointer<MKeyOverride> > &overrides);
86
virtual void handleFocusChange(bool focusIn);
87
QList<MAbstractInputMethod::MInputMethodSubView> subViews(Maliit::HandlerState state) const;
90
//! Propagates screen size to QML components.
91
void propagateScreenSize();
93
//! Returns screen height.
94
int screenHeight() const;
96
//! Returns screen width.
97
int screenWidth() const;
99
//! Returns application orientation.
100
int appOrientation() const;
102
//! Returns input method area.
103
QRectF inputMethodArea() const;
105
//! Sets input method area. Called by QML components.
106
//! area the area consumed by the QML input method. On transitions can reserve target area at start.
107
Q_INVOKABLE void setInputMethodArea(const QRectF &area);
109
//! Sets area input method is actually using from the screen.
110
Q_INVOKABLE void setScreenRegion(const QRect ®ion);
112
//! Returns action key override.
113
MKeyOverrideQuick *actionKeyOverride() const;
115
//! Activates action key, that is - sends enter keypress.
116
Q_INVOKABLE void activateActionKey();
118
//! Return true on input method expected to be shown
119
bool isActive() const;
120
//! Sets input method expected to be shown/hidden
121
void setActive(bool enable);
124
//! Emitted when screen height changes.
125
void screenHeightChanged(int height);
127
//! Emitted when screen width changes.
128
void screenWidthChanged(int width);
130
//! Emitted when application orientation changes.
131
void appOrientationChanged(int angle);
133
//! Emitted when input method area changes.
134
void inputMethodAreaChanged(const QRect &area);
136
//! Emitted when key action override changes.
137
void actionKeyOverrideChanged(MKeyOverride *override);
139
void activeChanged();
142
//! Sends preedit string. Called by QML components.
143
//! \param text the preedit string.
144
void sendPreedit(const QString &text);
146
//! Sends an arbitrary key, optionally with modifiers.
147
//! \param key the Qt keycode to be sent, e.g., Qt.Key_Up.
148
//! \param modifiers optional modifiers to send along, like Qt.ControlModifier.
149
//! \param text an optional text to send along with the QKeyEvent.
150
void sendKey(int key, int modifiers = 0, const QString &text = QString());
152
//! Sends commit string. Called by QML components.
153
//! \param text the commit string.
154
void sendCommit(const QString &text);
156
//! Tells the framework to switch plugins. Called by QML components.
157
void pluginSwitchRequired(int switchDirection);
159
//! Tells the framework to close keyboard. Called by QML components.
163
Q_DISABLE_COPY(MInputMethodQuick)
164
Q_DECLARE_PRIVATE(MInputMethodQuick)
166
MInputMethodQuickPrivate *const d_ptr;
169
//! Propagates change to QML.
170
void onSentActionKeyAttributesChanged(const QString &keyId, const MKeyOverride::KeyOverrideAttributes changedAttributes);
173
#endif // MEEGO_KEYBOARD_QUICK_H