Qt 4.8
Public Types | Public Functions | Protected Functions | Properties | List of all members
QWSInputMethod Class Reference

The QWSInputMethod class provides international input methods in Qt for Embedded Linux. More...

#include <qwindowsystem_qws.h>

Inheritance diagram for QWSInputMethod:
QObject

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 QObjectListchildren () 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< QByteArraydynamicPropertyNames () 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 >
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 QMetaObjectmetaObject () 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
 
QObjectparent () 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...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (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...
 
QObjectsender () 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< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

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.

Creating Custom Input Methods

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.

Using Input Methods

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.

See also
QWSServer, {Qt for Embedded Linux Architecture}

Definition at line 371 of file qwindowsystem_qws.h.

Enumerations

◆ UpdateType

This enum describes the various types of update events recognized by the input method.

  • Update The input widget is updated in some way; use sendQuery() with Qt::ImMicroFocus as an argument for more information.
  • FocusIn A new input widget receives focus.
  • FocusOut The input widget loses focus.
  • Reset The input method should be reset.
  • Destroyed The input widget is destroyed.
See also
updateHandler()
Enumerator
Update 
FocusIn 
FocusOut 
Reset 
Destroyed 

Definition at line 378 of file qwindowsystem_qws.h.

Constructors and Destructors

◆ QWSInputMethod()

QWSInputMethod::QWSInputMethod ( )

Constructs a new input method.

Use the QWSServer::setCurrentInputMethod() function to install it.

Definition at line 4672 of file qwindowsystem_qws.cpp.

4673 {
4674 
4675 }

◆ ~QWSInputMethod()

QWSInputMethod::~QWSInputMethod ( )
virtual

Destroys this input method, uninstalling it if it is installed.

Definition at line 4680 of file qwindowsystem_qws.cpp.

4681 {
4682  if (current_IM == this)
4683  current_IM = 0;
4684 }
static QWSInputMethod * current_IM

Functions

◆ filter() [1/2]

bool QWSInputMethod::filter ( int  unicode,
int  keycode,
int  modifiers,
bool  isPress,
bool  autoRepeat 
)
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.

See also
setInputResolution(), inputResolutionShift()

Definition at line 4707 of file qwindowsystem_qws.cpp.

Referenced by QWSServer::sendKeyEvent(), and QWSServer::sendMouseEvent().

4708 {
4709  Q_UNUSED(unicode);
4710  Q_UNUSED(keycode);
4711  Q_UNUSED(modifiers);
4712  Q_UNUSED(isPress);
4713  Q_UNUSED(autoRepeat);
4714  return false;
4715 }
int keycode
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ filter() [2/2]

bool QWSInputMethod::filter ( const QPoint position,
int  state,
int  wheel 
)
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.

4727 {
4728  Q_UNUSED(position);
4729  Q_UNUSED(state);
4730  Q_UNUSED(wheel);
4731  return false;
4732 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ inputResolutionShift()

uint QWSInputMethod::inputResolutionShift ( ) const
protected

Returns the number of bits shifted to go from pointer resolution to screen resolution when filtering mouse input.

See also
setInputResolution(), filter()

Definition at line 5002 of file qwindowsystem_qws.cpp.

5003 {
5004  return 0; // default for devices with single resolution.
5005 }

◆ mouseHandler()

void QWSInputMethod::mouseHandler ( int  offset,
int  state 
)
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.

See also
sendPreeditString(), reset()

Definition at line 4836 of file qwindowsystem_qws.cpp.

Referenced by QWSServerPrivate::doClient(), QWSServerPrivate::send_im_mouse(), and QWSServerPrivate::sendMouseEventUnfiltered().

4837 {
4838  if (state == QWSServer::MousePress || state == QWSServer::MouseOutside)
4839  reset();
4840 }
virtual void reset()
Resets the state of the input method.

◆ queryResponse()

void QWSInputMethod::queryResponse ( int  property,
const QVariant result 
)
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.

See also
sendQuery(), QWSServer::sendIMQuery()

Definition at line 4807 of file qwindowsystem_qws.cpp.

Referenced by QWSServerPrivate::invokeIMResponse().

4808 {
4809  Q_UNUSED(property);
4810  Q_UNUSED(result);
4811 }
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ reset()

void QWSInputMethod::reset ( )
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.

See also
sendEvent()

Definition at line 4744 of file qwindowsystem_qws.cpp.

Referenced by QWSServer::resetInputMethod(), and QWSServer::setCurrentInputMethod().

4745 {
4747  QInputMethodEvent ime;
4748  sendEvent(&ime);
4749  }
4750 }
void sendEvent(const QInputMethodEvent *)
Sends the given event to the focus widget.
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
static QWSWindow * current_IM_composing_win

◆ sendCommitString()

void QWSInputMethod::sendCommitString ( const QString commitString,
int  replaceFromPosition = 0,
int  replaceLength = 0 
)
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.

See also
sendEvent(), sendPreeditString()

Definition at line 4923 of file qwindowsystem_qws.cpp.

4924 {
4925  QInputMethodEvent ime;
4926  ime.setCommitString(commitString, replaceFrom, replaceLength);
4927  qwsServer->sendIMEvent(&ime);
4928 }
void setCommitString(const QString &commitString, int replaceFrom=0, int replaceLength=0)
Sets the commit string to commitString.
Definition: qevent.cpp:2042
void sendIMEvent(const QInputMethodEvent *)
Sends the given input method event.
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
QWSServer Q_GUI_EXPORT * qwsServer

◆ sendEvent()

void QWSInputMethod::sendEvent ( const QInputMethodEvent event)
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.

See also
sendPreeditString(), sendCommitString(), reset()

Definition at line 408 of file qwindowsystem_qws.h.

409 {
410  qwsServer->sendIMEvent(ime);
411 }
void sendIMEvent(const QInputMethodEvent *)
Sends the given input method event.
Q_GUI_EXPORT QWSServer * qwsServer

◆ sendMouseEvent()

void QWSInputMethod::sendMouseEvent ( const QPoint position,
int  state,
int  wheel 
)
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.

See also
mouseHandler(), sendEvent()

Definition at line 5025 of file qwindowsystem_qws.cpp.

5026 {
5027  if (qt_last_x) {
5028  *qt_last_x = pos.x();
5029  *qt_last_y = pos.y();
5030  }
5032  qwsServerPrivate->mouseState = state;
5033  QWSServerPrivate::sendMouseEventUnfiltered(pos, state, wheel);
5034 }
static void sendMouseEventUnfiltered(const QPoint &pos, int state, int wheel=0)
int * qt_last_x
int * qt_last_y
static QWSServerPrivate * qwsServerPrivate
static QPoint mousePosition

◆ sendPreeditString()

void QWSInputMethod::sendPreeditString ( const QString preeditString,
int  cursorPosition,
int  selectionLength = 0 
)
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.

See also
sendEvent(), sendCommitString()

Definition at line 4868 of file qwindowsystem_qws.cpp.

4869 {
4871 
4872  int selPos = cursorPosition;
4873  if (selectionLength == 0) {
4874  selPos = 0;
4875  } else if (selectionLength < 0) {
4876  selPos += selectionLength;
4877  selectionLength = -selectionLength;
4878  }
4879  if (selPos > 0)
4882 
4883  if (selectionLength)
4884  attributes += QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, selPos, selectionLength,
4886 
4887  if (selPos + selectionLength < preeditString.length())
4889  selPos + selectionLength,
4890  preeditString.length() - selPos - selectionLength,
4892 
4893  attributes += QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursorPosition, 0, QVariant());
4894 
4895  QInputMethodEvent ime(preeditString, attributes);
4896  qwsServer->sendIMEvent(&ime);
4897 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QInputMethodEvent::Attribute class stores an input method attribute.
Definition: qevent.h:441
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
void sendIMEvent(const QInputMethodEvent *)
Sends the given input method event.
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
QWSServer Q_GUI_EXPORT * qwsServer

◆ sendQuery()

void QWSInputMethod::sendQuery ( int  property)
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.

See also
queryResponse(), QWSServer::sendIMQuery()

Definition at line 419 of file qwindowsystem_qws.h.

420 {
422 }
void sendIMQuery(int property)
Sends an input method query for the given property.
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
Q_GUI_EXPORT QWSServer * qwsServer

◆ setInputResolution()

uint QWSInputMethod::setInputResolution ( bool  isHigh)
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.

See also
inputResolutionShift(), filter()

Definition at line 4990 of file qwindowsystem_qws.cpp.

4991 {
4992  mIResolution = isHigh;
4993  return inputResolutionShift();
4994 }
uint inputResolutionShift() const
Returns the number of bits shifted to go from pointer resolution to screen resolution when filtering ...

◆ updateHandler()

void QWSInputMethod::updateHandler ( int  type)
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.

See also
UpdateType

Definition at line 4781 of file qwindowsystem_qws.cpp.

Referenced by QWSServerPrivate::invokeIMUpdate(), and QWSServerPrivate::setFocus().

4782 {
4783  switch (type) {
4784  case FocusOut:
4785  case Reset:
4786  reset();
4787  break;
4788 
4789  default:
4790  break;
4791  }
4792 }
int type
Definition: qmetatype.cpp:239
virtual void reset()
Resets the state of the input method.

Properties

◆ mIResolution

bool QWSInputMethod::mIResolution
private

Definition at line 405 of file qwindowsystem_qws.h.


The documentation for this class was generated from the following files: