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

« back to all changes in this revision

Viewing changes to 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 "dbusserverconnection.h"
 
20
 
 
21
#include <QObject>
 
22
#include <QTimer>
 
23
#include <QPointer>
 
24
#include <QRect>
 
25
 
 
26
#include <qpa/qplatforminputcontext.h>
 
27
 
 
28
class MImServerConnection;
 
29
 
 
30
class MInputContext : public QPlatformInputContext
 
31
{
 
32
    Q_OBJECT
 
33
 
 
34
public:
 
35
    enum OrientationAngle {
 
36
        Angle0   =   0,
 
37
        Angle90  =  90,
 
38
        Angle180 = 180,
 
39
        Angle270 = 270
 
40
    };
 
41
 
 
42
    MInputContext();
 
43
    virtual ~MInputContext();
 
44
 
 
45
    // reimplemented methods
 
46
    virtual bool isValid() const;
 
47
    virtual void reset();
 
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);
 
60
 
 
61
public Q_SLOTS:
 
62
    // Hooked up to the input method server
 
63
    void activationLostEvent();
 
64
    void imInitiatedHide();
 
65
 
 
66
    void commitString(const QString &string, int replacementStart = 0,
 
67
                      int replacementLength = 0, int cursorPos = -1);
 
68
 
 
69
    void updatePreedit(const QString &string, const QList<Maliit::PreeditTextFormat> &preeditFormats,
 
70
                       int replacementStart = 0, int replacementLength = 0, int cursorPos = -1);
 
71
 
 
72
    void keyEvent(int type, int key, int modifiers, const QString &text, bool autoRepeat,
 
73
                  int count, Maliit::EventRequestType requestType = Maliit::EventRequestBoth);
 
74
 
 
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.
 
85
 
 
86
private Q_SLOTS:
 
87
    void sendHideInputMethod();
 
88
    void updateServerOrientation(Qt::ScreenOrientation orientation);
 
89
 
 
90
    void onDBusDisconnection();
 
91
    void onDBusConnection();
 
92
 
 
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);
 
95
 
 
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);
 
99
 
 
100
private:
 
101
    Q_DISABLE_COPY(MInputContext)
 
102
 
 
103
    enum InputPanelState {
 
104
        InputPanelShowPending,   // input panel showing requested, but activation pending
 
105
        InputPanelShown,
 
106
        InputPanelHidden
 
107
    };
 
108
 
 
109
    void updatePreeditInternally(const QString &string, const QList<Maliit::PreeditTextFormat> &preeditFormats,
 
110
                                 int replacementStart = 0, int replacementLength = 0, int cursorPos = -1);
 
111
 
 
112
    void connectInputMethodServer();
 
113
 
 
114
    void updateInputMethodExtensions();
 
115
 
 
116
    // returns content type corresponding to specified hints
 
117
    Maliit::TextContentType contentType(Qt::InputMethodHints hints) const;
 
118
 
 
119
    // returns state for currently focused widget, key is attribute name.
 
120
    QMap<QString, QVariant> getStateInformation() const;
 
121
 
 
122
    // Gets cursor start position, relative to widget surrounding text.
 
123
    // Parameter valid set to false on failure.
 
124
    int cursorStartPosition(bool *valid);
 
125
 
 
126
    static bool debug;
 
127
 
 
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
 
133
 
 
134
    /* Timer for hiding the current Software Input Panel.
 
135
     *  This is mainly for switching directly between widgets that have input method enabled. */
 
136
    QTimer sipHideTimer;
 
137
    QString preedit;
 
138
    int preeditCursorPos;
 
139
    bool redirectKeys; // redirect all hw key events to the input method or not
 
140
    QLocale inputLocale;
 
141
};
 
142
 
 
143
#endif