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

« back to all changes in this revision

Viewing changes to input-context/maliit-input-context/minputcontext.h

  • 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 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
 
#ifndef MINPUTCONTEXT_H
16
 
#define MINPUTCONTEXT_H
17
 
 
18
 
#include <maliit/namespace.h>
19
 
#include <maliit/preeditinjectionevent.h>
20
 
 
21
 
#include <QObject>
22
 
#include <QInputContext>
23
 
#include <QTimer>
24
 
#include <QPointer>
25
 
 
26
 
class QGraphicsItem;
27
 
class QGraphicsView;
28
 
class MImServerConnection;
29
 
 
30
 
/*!
31
 
 * \brief On the application side, MInputContext implements input method
32
 
 *        support for the Meegotouch input method server.
33
 
 *
34
 
 * The base class QInputContext abstracts input method specific composing of
35
 
 * input. It acts in between the input method and the widget receiving the
36
 
 * composed input. MInputContext extends this functionality by connecting to
37
 
 * Meegotouch input method server and accepting input it creates. This input
38
 
 * is forwarded to the currently focused widget. MInputContext also notifies
39
 
 * the Meegotouch input method server about the current state of input widgets
40
 
 * on the application side.
41
 
 */
42
 
class MInputContext : public QInputContext
43
 
{
44
 
    Q_OBJECT
45
 
    friend class Ut_MInputContext;
46
 
 
47
 
public:
48
 
    //! \brief Constructor
49
 
    explicit MInputContext(QSharedPointer<MImServerConnection> imServer, const QString &name, QObject *parent = 0);
50
 
 
51
 
    //! \brief Destructor
52
 
    virtual ~MInputContext();
53
 
 
54
 
    //! \reimp
55
 
    virtual bool event(QEvent *event);
56
 
    virtual QString identifierName();
57
 
    virtual bool isComposing() const;
58
 
    virtual QString language();
59
 
    virtual void reset();
60
 
    virtual void update();
61
 
    virtual void mouseHandler(int x, QMouseEvent *event);
62
 
    virtual void setFocusWidget(QWidget *w); // note: qt marks this as internal
63
 
    virtual bool filterEvent(const QEvent *event);
64
 
 
65
 
#ifdef Q_WS_X11
66
 
    virtual bool x11FilterEvent(QWidget *widget, XEvent *event);
67
 
#endif
68
 
    //! \reimp_end
69
 
 
70
 
public Q_SLOTS:
71
 
    /* Hooked up to the input method server.
72
 
     * See MImServerConnection for documentation. */
73
 
    void activationLostEvent();
74
 
    void imInitiatedHide();
75
 
 
76
 
    void commitString(const QString &string, int replacementStart = 0,
77
 
                              int replacementLength = 0, int cursorPos = -1);
78
 
 
79
 
    void updatePreedit(const QString &string, const QList<Maliit::PreeditTextFormat> &preeditFormats,
80
 
                               int replacementStart = 0, int replacementLength = 0, int cursorPos = -1);
81
 
 
82
 
    void keyEvent(int type, int key, int modifiers, const QString &text, bool autoRepeat,
83
 
                          int count, Maliit::EventRequestType requestType
84
 
                          = Maliit::EventRequestBoth);
85
 
 
86
 
    void updateInputMethodArea(const QRect &rect);
87
 
 
88
 
    void setGlobalCorrectionEnabled(bool);
89
 
 
90
 
    void getPreeditRectangle(QRect &rectangle, bool &valid) const;
91
 
 
92
 
    Q_SLOT void onInvokeAction(const QString &action, const QKeySequence &sequence);
93
 
 
94
 
    void setRedirectKeys(bool enabled);
95
 
 
96
 
    void setDetectableAutoRepeat(bool enabled);
97
 
 
98
 
    void setSelection(int start, int length);
99
 
 
100
 
    void getSelection(QString &selection, bool &valid) const;
101
 
 
102
 
    void setLanguage(const QString &language);
103
 
    /* End input method server connection slots. */
104
 
 
105
 
public:
106
 
    static bool debug;
107
 
 
108
 
Q_SIGNALS:
109
 
    //! \internal
110
 
    /*! 
111
 
     * \brief Emitted when input method area is changed
112
 
     * \param region new input method area
113
 
     */
114
 
    void inputMethodAreaChanged(const QRect &region);
115
 
    //! \internal_end
116
 
 
117
 
private Q_SLOTS:
118
 
    //! hides input method
119
 
    void hideInputMethod();
120
 
 
121
 
    void onDBusDisconnection();
122
 
    void onDBusConnection();
123
 
 
124
 
    /*!
125
 
     * \brief Notifies input method server of copy availability.
126
 
     * \param copyAvailable bool Specifies wheter copy is available
127
 
     */
128
 
    void handleCopyAvailabilityChange(bool copyAvailable);
129
 
 
130
 
    /*!
131
 
     * \brief Notifies input method server when the QML TextInput element has selected text changes
132
 
     */
133
 
    void handleSelectedTextChange();
134
 
 
135
 
    /*!
136
 
     * \brief Notifies input method server when the QLineEdit object's selection changed
137
 
     */
138
 
    void handleSelectionChanged();
139
 
 
140
 
    //! Notify input method plugin about the application's active window prepare to change to a new \a orientation angle.
141
 
    void notifyOrientationAboutToChange(Maliit::OrientationAngle orientation);
142
 
 
143
 
    //! Notify input method plugin about new \a orientation angle of application's active window.
144
 
    //! \note this method is called when the orientation change is finished
145
 
    void notifyOrientationChanged(Maliit::OrientationAngle orientation);
146
 
 
147
 
    //! Checks whether there is someting to paste in the clipboard and notifies input method plugin about it.
148
 
    void handleClipboardDataChange();
149
 
 
150
 
private:
151
 
    Q_DISABLE_COPY(MInputContext)
152
 
 
153
 
    enum InputPanelState {
154
 
        InputPanelShowPending,   // input panel showing requested, but activation pending
155
 
        InputPanelShown,         // panel showing
156
 
        InputPanelHidden         // panel hidden
157
 
    };
158
 
 
159
 
    void updatePreeditInternally(const QString &string,
160
 
                                 const QList<Maliit::PreeditTextFormat> &preeditFormats,
161
 
                                 int replacementStart = 0, int replacementLength = 0, int cursorPos = -1);
162
 
 
163
 
    /* Hook up signals on the imServer to our slots. Used in constructor. */
164
 
    void connectInputMethodServer();
165
 
    /* Hook up signals and slots on the input method extension instance,
166
 
     * (MInputMethodState and Maliit::InputMethod). Used in constructor. */
167
 
    void connectInputMethodExtension();
168
 
 
169
 
    void notifyCopyPasteState();
170
 
 
171
 
    //! returns content type corresponding to specified hints
172
 
    Maliit::TextContentType contentType(Qt::InputMethodHints hints) const;
173
 
 
174
 
    //! returns the D-Bus object path for this instance
175
 
    QString dbusObjectPath() const;
176
 
 
177
 
    //! returns state for currently focused widget, key is attribute name.
178
 
    QMap<QString, QVariant> getStateInformation() const;
179
 
 
180
 
    //! finds focus scope item for item
181
 
    static QGraphicsItem *findFocusScopeItem(QGraphicsItem *item);
182
 
 
183
 
    bool isVisible(const QRect &rect, const QGraphicsView *view, const QGraphicsItem *item) const;
184
 
 
185
 
    bool handlePreeditInjectionEvent(const Maliit::PreeditInjectionEvent *event);
186
 
 
187
 
    //! Gets cursor start position, relative to widget surrounding text.
188
 
    //! Parameter valid set to false on failure.
189
 
    int cursorStartPosition(bool *valid);
190
 
 
191
 
    bool active; // is connection active
192
 
    InputPanelState inputPanelState; // state for the input method server's software input panel
193
 
 
194
 
    /*! Timer for hiding the current Software Input Panel.
195
 
     *  This is mainly for switching directly between widgets
196
 
     *  that has input method enabled.
197
 
     *  The delayed hiding is handled in input-context because
198
 
     *  this has to work also with plain qt apps.
199
 
     */
200
 
    QTimer sipHideTimer;
201
 
 
202
 
    QSharedPointer<MImServerConnection> imServer;
203
 
 
204
 
    bool correctionEnabled;
205
 
 
206
 
    QString preedit;
207
 
    int preeditCursorPos;
208
 
 
209
 
    QPointer<QObject> connectedObject;
210
 
    bool pasteAvailable;
211
 
    bool copyAvailable;
212
 
    bool copyAllowed;
213
 
    //! redirect all hw key events to the input method or not
214
 
    bool redirectKeys;
215
 
    const QString objectPath; //!< D-Bus object path for this instance.
216
 
    static int connectionCount; //!< Counter to allow multiple IC objects being registered via D-Bus
217
 
 
218
 
    unsigned long currentKeyEventTime;
219
 
 
220
 
    QString m_language;
221
 
    QString m_name;
222
 
};
223
 
 
224
 
#endif