Qt 4.8
|
The QWSInputMethod class provides international input methods in Qt for Embedded Linux. More...
#include <qwindowsystem_qws.h>
Public Types | |
enum | UpdateType { Update, FocusIn, FocusOut, Reset, Destroyed } |
This enum describes the various types of update events recognized by the input method. More... | |
Public Functions | |
virtual bool | filter (int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat) |
Filters the key input identified by the given unicode, keycode, modifiers, isPress and autoRepeat parameters. More... | |
virtual bool | filter (const QPoint &, int state, int wheel) |
Filters the mouse input identified by the given position, state, and wheel parameters. More... | |
virtual void | mouseHandler (int pos, int state) |
Handles mouse events within the preedit text. More... | |
virtual void | queryResponse (int property, const QVariant &) |
Receive replies to an input method query. More... | |
QWSInputMethod () | |
Constructs a new input method. More... | |
virtual void | reset () |
Resets the state of the input method. More... | |
virtual void | updateHandler (int type) |
Handles update events including resets and focus changes. More... | |
virtual | ~QWSInputMethod () |
Destroys this input method, uninstalling it if it is installed. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
virtual bool | event (QEvent *) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Filters events if this object has been installed as an event filter for the watched object. More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Protected Functions | |
uint | inputResolutionShift () const |
Returns the number of bits shifted to go from pointer resolution to screen resolution when filtering mouse input. More... | |
void | sendCommitString (const QString &commitString, int replaceFrom=0, int replaceLength=0) |
Sends an event encapsulating the given commitString, to the focus widget. More... | |
void | sendEvent (const QInputMethodEvent *) |
Sends the given event to the focus widget. More... | |
void | sendMouseEvent (const QPoint &pos, int state, int wheel) |
Sends a mouse event specified by the given position, state and wheel parameters. More... | |
void | sendPreeditString (const QString &preeditString, int cursorPosition, int selectionLength=0) |
Sends an event encapsulating the given preeditString, to the focus widget. More... | |
void | sendQuery (int property) |
Sends an input method query (internally encapsulated by a QWSEvent of the QWSEvent::IMQuery{IMQuery} type) for the specified property. More... | |
uint | setInputResolution (bool isHigh) |
Sets and returns the number of bits shifted to go from pointer resolution to screen resolution when filtering mouse input. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Properties | |
bool | mIResolution |
Additional Inherited Members | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QWSInputMethod class provides international input methods in Qt for Embedded Linux.
This function is under development and subject to change.
Note that this class is only available in Qt for Embedded Linux.
A Qt for Embedded Linux application requires a server application to be running, or to be the server application itself. All system generated events, including keyboard and mouse events, are passed to the server application which then propagates the event to the appropriate client.
An input method consists of a filter and optionally a graphical interface, and is used to filter input events between the server and the client application.
To implement a custom input method, derive from the QWSInputMethod class, and use the server's QWSServer::setCurrentInputMethod() function to install it.
When subclassing QWSInputMethod, you can reimplement the filter() functions to handle input from both physical and virtual keyboards as well as mouse devices. Note that the default implementations do nothing. Use the setInputResolution() function to control the number of bits shifted when filtering mouse input, i.e., when going from pointer resolution to screen resolution (the current resolution can be retrieved using the inputResolutionShift() function).
Reimplement the reset() function to restore the state of the input method. Note that the default implementation calls the sendEvent() function with empty preedit and commit strings if the input method is in compose mode (i.e., if the input method is actively composing a preedit string).
To receive replies to an input method query (sent using the sendQuery() function), you must reimplement the queryResponse() function, while the mouseHandler() function must be reimplemented if you want to handle mouse events within the preedit text. Reimplement the updateHandler() function to handle update events including resets and focus changes. The UpdateType enum describes the various types of update events recognized by the input method.
In addition to the filter(), reset(), queryResponse(), mouseHandler() and updateHandler() function mentioned in the previous section, the QWSInputMethod provides several other functions helping the window system to manage the installed input methods.
The sendEvent() function sends the given event to the focus widget, while the sendPreeditString() function sends the given preedit text (encapsulated by an event). QWSInputMethod also provides the sendCommitString() convenience function which sends an event encapsulating the given commit string to the current focus widget, and the sendMouseEvent() function which sends the given mouse event.
Finally, the QWSInputMethod class provides the sendQuery() function for sending input method queries. This function encapsulates the event with a QWSEvent instance of the QWSEvent::IMQuery type.
Definition at line 371 of file qwindowsystem_qws.h.
This enum describes the various types of update events recognized by the input method.
Enumerator | |
---|---|
Update | |
FocusIn | |
FocusOut | |
Reset | |
Destroyed |
Definition at line 378 of file qwindowsystem_qws.h.
QWSInputMethod::QWSInputMethod | ( | ) |
Constructs a new input method.
Use the QWSServer::setCurrentInputMethod() function to install it.
Definition at line 4672 of file qwindowsystem_qws.cpp.
|
virtual |
Destroys this input method, uninstalling it if it is installed.
Definition at line 4680 of file qwindowsystem_qws.cpp.
|
virtual |
Filters the key input identified by the given unicode, keycode, modifiers, isPress and autoRepeat parameters.
Note that the default implementation does nothing; reimplement this function to handle input from both physical and virtual devices.
The keycode is a Qt::Key value, and the modifiers is an OR combination of Qt::KeyboardModifiers. The isPress parameter is telling whether the input is a key press or key release, and the autoRepeat parameter determines whether the input is autorepeated ( i.e., in which case the QWSKeyboardHandler::beginAutoRepeat() function has been called).
To block the event from further processing, return true when reimplementing this function; the default implementation returns false.
Definition at line 4707 of file qwindowsystem_qws.cpp.
Referenced by QWSServer::sendKeyEvent(), and QWSServer::sendMouseEvent().
|
virtual |
Filters the mouse input identified by the given position, state, and wheel parameters.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 4726 of file qwindowsystem_qws.cpp.
|
protected |
Returns the number of bits shifted to go from pointer resolution to screen resolution when filtering mouse input.
Definition at line 5002 of file qwindowsystem_qws.cpp.
|
virtual |
Handles mouse events within the preedit text.
Note that the default implementation resets the input method on all mouse presses; reimplement this function to alter this behavior.
The offset parameter specifies the position of the mouse event within the string, and state specifies the type of the mouse event as described by the QWSServer::IMMouse enum. If state is less than 0, the mouse event is inside the associated widget, but outside the preedit text. When clicking in a different widget, the state is QWSServer::MouseOutside.
Definition at line 4836 of file qwindowsystem_qws.cpp.
Referenced by QWSServerPrivate::doClient(), QWSServerPrivate::send_im_mouse(), and QWSServerPrivate::sendMouseEventUnfiltered().
|
virtual |
Receive replies to an input method query.
Note that the default implementation does nothing; reimplement this function to receive such replies.
Internally, an input method query is passed encapsulated by an QWSEvent::IMQuery event generated by the sendQuery() function. The queried property and the result is passed in the property and result parameters.
Definition at line 4807 of file qwindowsystem_qws.cpp.
Referenced by QWSServerPrivate::invokeIMResponse().
|
virtual |
Resets the state of the input method.
If the input method is in compose mode, i.e., the input method is actively composing a preedit string, the default implementation calls sendEvent() with empty preedit and commit strings; otherwise it does nothing. Reimplement this function to alter this behavior.
Definition at line 4744 of file qwindowsystem_qws.cpp.
Referenced by QWSServer::resetInputMethod(), and QWSServer::setCurrentInputMethod().
|
protected |
Sends an event encapsulating the given commitString, to the focus widget.
Note that this will cause the input method to leave compose mode, i.e., the input method will no longer be actively composing the preedit string.
If the specified replaceLength is greater than 0, the commit string will replace the given number of characters of the receiving widget's previous text, starting at the given replaceFromPosition relative to the start of the current preedit string.
Internally, the event is represented by a QWSEvent object of the QWSEvent::IMEvent{IMEvent} type.
Definition at line 4923 of file qwindowsystem_qws.cpp.
|
inlineprotected |
Sends the given event to the focus widget.
The QInputMethodEvent
class is derived from QWSEvent, i.e., the given event is a QWSEvent object of the QWSEvent::IMEvent type.
Definition at line 408 of file qwindowsystem_qws.h.
|
protected |
Sends a mouse event specified by the given position, state and wheel parameters.
The given position will be transformed if the screen coordinates do not match the pointer device coordinates.
Note that the event will be not be tested by the active input method, but calling the QWSServer::sendMouseEvent() function will make the current input method filter the event.
Definition at line 5025 of file qwindowsystem_qws.cpp.
|
protected |
Sends an event encapsulating the given preeditString, to the focus widget.
The specified selectionLength is the number of characters to be marked as selected (starting at the given cursorPosition). If selectionLength is negative, the text before cursorPosition is marked.
The preedit string is marked with QInputContext::PreeditFormat, and the selected part is marked with QInputContext::SelectionFormat.
Sending an input method event with a non-empty preedit string will cause the input method to enter compose mode. Sending an input method event with an empty preedit string will cause the input method to leave compose mode, i.e., the input method will no longer be actively composing the preedit string.
Internally, the event is represented by a QWSEvent object of the QWSEvent::IMEvent{IMEvent} type.
Definition at line 4868 of file qwindowsystem_qws.cpp.
|
inlineprotected |
Sends an input method query (internally encapsulated by a QWSEvent of the QWSEvent::IMQuery{IMQuery} type) for the specified property.
To receive responses to input method queries, the virtual queryResponse() function must be reimplemented.
Definition at line 419 of file qwindowsystem_qws.h.
|
protected |
Sets and returns the number of bits shifted to go from pointer resolution to screen resolution when filtering mouse input.
If isHigh is true and the device has a pointer device resolution twice or more of the screen resolution, the positions passed to the filter() function will be presented at the higher resolution; otherwise the resolution will be equal to that of the screen resolution.
Definition at line 4990 of file qwindowsystem_qws.cpp.
|
virtual |
Handles update events including resets and focus changes.
The update events are specified by the given type which is one of the UpdateType enum values.
Note that reimplementations of this function must call the base implementation for all cases that it does not handle itself.
Definition at line 4781 of file qwindowsystem_qws.cpp.
Referenced by QWSServerPrivate::invokeIMUpdate(), and QWSServerPrivate::setFocus().
|
private |
Definition at line 405 of file qwindowsystem_qws.h.