Qt 4.8
Public Functions | Protected Functions | Private Functions | Properties | List of all members
QBBInputContext Class Reference

#include <qbbinputcontext_imf.h>

Inheritance diagram for QBBInputContext:
QInputContext QInputContext QObject QObject

Public Functions

virtual QList< QAction * > actions ()
 This is a preliminary interface for Qt 4. More...
 
virtual bool filterEvent (const QEvent *event)
 This function can be reimplemented in a subclass to filter input events. More...
 
virtual bool filterEvent (const QEvent *event)
 This function can be reimplemented in a subclass to filter input events. More...
 
virtual QFont font () const
 Returns the font of the current input widget. More...
 
bool handleKeyboardEvent (int flags, int sym, int mod, int scan, int cap)
 
bool handleKeyboardEvent (int flags, int sym, int mod, int scan, int cap)
 
QString identifierName ()
 This function must be implemented in any subclasses to return the identifier name of the input method. More...
 
virtual QString identifierName ()
 This function must be implemented in any subclasses to return the identifier name of the input method. More...
 
bool isComposing () const
 This function indicates whether InputMethodStart event had been sent to the current focus widget. More...
 
virtual bool isComposing () const
 This function indicates whether InputMethodStart event had been sent to the current focus widget. More...
 
QString language ()
 This function must be implemented in any subclasses to return a language code (e. More...
 
virtual QString language ()
 This function must be implemented in any subclasses to return a language code (e. More...
 
virtual void mouseHandler (int x, QMouseEvent *event)
 This function can be reimplemented in a subclass to handle mouse press, release, double-click, and move events within the preedit text. More...
 
 QBBInputContext (QBBAbstractVirtualKeyboard &keyboard, QObject *parent=0)
 
 QBBInputContext (QBBAbstractVirtualKeyboard &keyboard, QObject *parent=0)
 
void reset ()
 This function can be reimplemented in a subclass to reset the state of the input method. More...
 
virtual void reset ()
 This function can be reimplemented in a subclass to reset the state of the input method. More...
 
void setFocusWidget (QWidget *w)
 Sets the widget that has an input focus for this input context. More...
 
virtual void setFocusWidget (QWidget *widget)
 Sets the widget that has an input focus for this input context. More...
 
virtual void update ()
 This virtual function is called when a state in the focus widget has changed. More...
 
virtual void widgetDestroyed (QWidget *widget)
 This virtual function is called when the specified widget is destroyed. More...
 
 ~QBBInputContext ()
 
 ~QBBInputContext ()
 
- Public Functions inherited from QInputContext
QWidgetfocusWidget () const
 Returns the widget that has an input focus for this input context. More...
 
 QInputContext (QObject *parent=0)
 Constructs an input context with the given parent. More...
 
void sendEvent (const QInputMethodEvent &event)
 Sends an input method event specified by event to the current focus widget. More...
 
QTextFormat standardFormat (StandardFormat s) const
 Returns a QTextFormat object that specifies the format for component s. More...
 
virtual bool x11FilterEvent (QWidget *keywidget, XEvent *event)
 This function may be overridden only if input method is depending on X11 and you need raw XEvent. More...
 
virtual ~QInputContext ()
 Destroys the input context. 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...
 
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

bool eventFilter (QObject *obj, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object. 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...
 

Private Functions

void closeSession ()
 
bool dispatchCloseSoftwareInputPanel ()
 
bool dispatchFocusEvent (FocusEventId id, int hints=Qt::ImhNone)
 
bool dispatchRequestSoftwareInputPanel ()
 
void endComposition ()
 
bool hasPhysicalKeyboard ()
 
bool hasSelectedText ()
 
bool hasSession ()
 
int32_t onBeginBatchEdit (input_session_t *ic)
 
int32_t onClearMetaKeyStates (input_session_t *ic, int32_t states)
 
int32_t onCommitText (input_session_t *ic, spannable_string_t *text, int32_t new_cursor_position)
 
int32_t onDeleteSurroundingText (input_session_t *ic, int32_t left_length, int32_t right_length)
 
int32_t onEndBatchEdit (input_session_t *ic)
 
int32_t onFinishComposingText (input_session_t *ic)
 
int32_t onForceUpdate ()
 
int32_t onGetCursorCapsMode (input_session_t *ic, int32_t req_modes)
 
int32_t onGetCursorPosition (input_session_t *ic)
 
extracted_text_t * onGetExtractedText (input_session_t *ic, extracted_text_request_t *request, int32_t flags)
 
spannable_string_t * onGetSelectedText (input_session_t *ic, int32_t flags)
 
spannable_string_t * onGetTextAfterCursor (input_session_t *ic, int32_t n, int32_t flags)
 
spannable_string_t * onGetTextBeforeCursor (input_session_t *ic, int32_t n, int32_t flags)
 
int32_t onPerformEditorAction (input_session_t *ic, int32_t editor_action)
 
int32_t onReportFullscreenMode (input_session_t *ic, int32_t enabled)
 
int32_t onSendAsyncEvent (input_session_t *ic, event_t *event)
 
int32_t onSendEvent (input_session_t *ic, event_t *event)
 
int32_t onSetComposingRegion (input_session_t *ic, int32_t start, int32_t end)
 
int32_t onSetComposingText (input_session_t *ic, spannable_string_t *text, int32_t new_cursor_position)
 
int32_t onSetSelection (input_session_t *ic, int32_t start, int32_t end)
 
void openSession ()
 
int32_t processEvent (event_t *event)
 
void setComposingText (QString const &composingText)
 

Properties

QString mComposingText
 
bool mIsComposing
 
int mLastCaretPos
 
QBBAbstractVirtualKeyboardmVirtualKeyboard
 

Additional Inherited Members

- Public Types inherited from QInputContext
enum  StandardFormat { PreeditFormat, SelectionFormat }
 
- 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

Definition at line 55 of file qbbinputcontext_imf.h.

Constructors and Destructors

◆ QBBInputContext() [1/2]

QBBInputContext::QBBInputContext ( QBBAbstractVirtualKeyboard keyboard,
QObject parent = 0 
)
explicit

Definition at line 683 of file qbbinputcontext_imf.cpp.

683  :
684  QInputContext(parent),
685  mLastCaretPos(0),
686  mIsComposing(false),
687  mVirtualKeyboard(keyboard)
688 {
689 #if defined(QBBINPUTCONTEXT_DEBUG)
690  qDebug() << TAG;
691 #endif
692 
693  if (!imfAvailable())
694  return;
695 
696  if ( p_imf_client_init() != 0 ) {
697  s_imfInitFailed = true;
698  qCritical("imf_client_init failed - IMF services will be unavailable");
699  }
700 
702 
703  // p_vkb_init_selection_service();
704 }
#define TAG
QBBAbstractVirtualKeyboard & mVirtualKeyboard
QInputContext(QObject *parent=0)
Constructs an input context with the given parent.
static bool imfAvailable()
Q_CORE_EXPORT void qDebug(const char *,...)
static bool s_imfInitFailed
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
Definition: qobject.cpp:2070
static int32_t(* p_imf_client_init)()=0
Q_CORE_EXPORT void qCritical(const char *,...)

◆ ~QBBInputContext() [1/2]

QBBInputContext::~QBBInputContext ( )

Definition at line 706 of file qbbinputcontext_imf.cpp.

707 {
708 #if defined(QBBINPUTCONTEXT_DEBUG)
709  qDebug() << TAG;
710 #endif
711 
712  if (!imfAvailable())
713  return;
714 
717 }
static void(* p_imf_client_disconnect)()=0
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
#define TAG
static bool imfAvailable()
Q_CORE_EXPORT void qDebug(const char *,...)
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.

◆ QBBInputContext() [2/2]

QBBInputContext::QBBInputContext ( QBBAbstractVirtualKeyboard keyboard,
QObject parent = 0 
)
explicit

◆ ~QBBInputContext() [2/2]

QBBInputContext::~QBBInputContext ( )

Functions

◆ actions()

QList< QAction * > QBBInputContext::actions ( )
virtual

This is a preliminary interface for Qt 4.

Reimplemented from QInputContext.

Definition at line 919 of file qbbinputcontext_imf.cpp.

920 {
921 #if defined(QBBINPUTCONTEXT_DEBUG)
922  qDebug() << TAG;
923 #endif
924  return QInputContext::actions();
925 }
#define TAG
virtual QList< QAction * > actions()
This is a preliminary interface for Qt 4.
Q_CORE_EXPORT void qDebug(const char *,...)

◆ closeSession()

void QBBInputContext::closeSession ( )
private

Definition at line 1006 of file qbbinputcontext_imf.cpp.

Referenced by openSession(), and setFocusWidget().

1007 {
1008 #if defined(QBBINPUTCONTEXT_DEBUG)
1009  qDebug() << TAG;;
1010 #endif
1011 
1012  if (!imfAvailable())
1013  return;
1014 
1015  if (sInputSession) {
1016  p_ictrl_close_session((input_session_t *)sInputSession);
1017  sInputSession = 0;
1018  }
1019 }
#define TAG
static bool imfAvailable()
Q_CORE_EXPORT void qDebug(const char *,...)
static void(* p_ictrl_close_session)(input_session_t *)=0

◆ dispatchCloseSoftwareInputPanel()

bool QBBInputContext::dispatchCloseSoftwareInputPanel ( )
private

Definition at line 1071 of file qbbinputcontext_imf.cpp.

Referenced by filterEvent().

1072 {
1074 #if defined(QBBINPUTCONTEXT_DEBUG)
1075  qDebug() << "QBB: hiding virtual keyboard";
1076 #endif
1077 
1078  // This also means we are stopping composition, but we should already have done that.
1079  return true;
1080 }
virtual bool hideKeyboard()=0
QBBAbstractVirtualKeyboard & mVirtualKeyboard
Q_CORE_EXPORT void qDebug(const char *,...)

◆ dispatchFocusEvent()

bool QBBInputContext::dispatchFocusEvent ( FocusEventId  id,
int  hints = Qt::ImhNone 
)
private

Definition at line 1085 of file qbbinputcontext_imf.cpp.

Referenced by setFocusWidget().

1086 {
1087 #if defined(QBBINPUTCONTEXT_DEBUG)
1088  qDebug() << TAG;
1089 #endif
1090 
1091  if (!sInputSession) {
1092  qWarning() << TAG << "Attempt to dispatch a focus event with no input session.";
1093  return false;
1094  }
1095 
1096  if (!imfAvailable())
1097  return false;
1098 
1099  // Set the last caret position to 0 since we don't really have one and we don't
1100  // want to have the old one.
1101  mLastCaretPos = 0;
1102 
1103  focus_event_t focusEvent;
1104  memset(&focusEvent, 0, sizeof(focusEvent));
1105  initEvent(&focusEvent.event, sInputSession, EVENT_FOCUS, id);
1106  focusEvent.style = DEFAULT_STYLE;
1107 
1108  if (hints && Qt::ImhNoPredictiveText)
1109  focusEvent.style |= NO_PREDICTION | NO_AUTO_CORRECTION;
1110  if (hints && Qt::ImhNoAutoUppercase)
1111  focusEvent.style |= NO_AUTO_TEXT;
1112 
1113  p_ictrl_dispatch_event((event_t *)&focusEvent);
1114 
1115  return true;
1116 }
#define TAG
static bool imfAvailable()
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT void qWarning(const char *,...)
static int32_t(* p_ictrl_dispatch_event)(event_t *)=0

◆ dispatchRequestSoftwareInputPanel()

bool QBBInputContext::dispatchRequestSoftwareInputPanel ( )
private

Definition at line 1050 of file qbbinputcontext_imf.cpp.

Referenced by filterEvent().

1051 {
1053 #if defined(QBBINPUTCONTEXT_DEBUG)
1054  qDebug() << "QBB: requesting virtual keyboard";
1055 #endif
1056 
1057  if (!imfAvailable() || !focusWidget())
1058  return true;
1059 
1060  // This also means that the caret position has moved
1062  caret_event_t caretEvent;
1063  memset(&caretEvent, 0, sizeof(caret_event_t));
1064  initEvent(&caretEvent.event, sInputSession, EVENT_CARET, CARET_POS_CHANGED);
1065  caretEvent.old_pos = mLastCaretPos;
1066  mLastCaretPos = caretEvent.new_pos = caretPos;
1067  p_ictrl_dispatch_event((event_t *)&caretEvent);
1068  return true;
1069 }
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
QBBAbstractVirtualKeyboard & mVirtualKeyboard
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
static bool imfAvailable()
Q_CORE_EXPORT void qDebug(const char *,...)
static int32_t(* p_ictrl_dispatch_event)(event_t *)=0
virtual bool showKeyboard()=0

◆ endComposition()

void QBBInputContext::endComposition ( )
private

Definition at line 1220 of file qbbinputcontext_imf.cpp.

Referenced by reset(), and setFocusWidget().

1221 {
1222  if (!imfAvailable())
1223  return;
1224 
1225  if (!isComposing())
1226  return;
1227 
1229  QInputMethodEvent event(QLatin1String(""), attributes);
1230  event.setCommitString(mComposingText);
1231  mComposingText = QString();
1232  mIsComposing = false;
1233  sendEvent(event);
1234 
1235  action_event_t actionEvent;
1236  memset(&actionEvent, 0, sizeof(actionEvent));
1237  initEvent(&actionEvent.event, sInputSession, EVENT_ACTION, ACTION_END_COMPOSITION);
1238  p_ictrl_dispatch_event(&actionEvent.event);
1239 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
static bool imfAvailable()
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
void sendEvent(const QInputMethodEvent &event)
Sends an input method event specified by event to the current focus widget.
virtual bool isComposing() const
This function indicates whether InputMethodStart event had been sent to the current focus widget...
static int32_t(* p_ictrl_dispatch_event)(event_t *)=0

◆ eventFilter()

bool QBBInputContext::eventFilter ( QObject ,
QEvent  
)
protectedvirtual

Filters events if this object has been installed as an event filter for the watched object.

In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.

Example:

class MainWindow : public QMainWindow
{
public:
MainWindow();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
private:
QTextEdit *textEdit;
};
MainWindow::MainWindow()
{
textEdit = new QTextEdit;
setCentralWidget(textEdit);
textEdit->installEventFilter(this);
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if (obj == textEdit) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
qDebug() << "Ate key press" << keyEvent->key();
return true;
} else {
return false;
}
} else {
// pass the event on to the parent class
return QMainWindow::eventFilter(obj, event);
}
}

Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.

Warning
If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash.
See also
installEventFilter()

Reimplemented from QObject.

Definition at line 722 of file qbbinputcontext_imf.cpp.

723 {
724 
725  if (event->type() == ImfEvent::sUserEventType) {
726  // Forward the event to our real handler.
727  ImfEvent* imfEvent = static_cast<ImfEvent*>(event);
728  switch (imfEvent->mImfType) {
729  case ImfBeginBatchEdit:
730  {
731  int32_t ret = onBeginBatchEdit(imfEvent->mSession);
732  imfEvent->mResult->setResult(QVariant::fromValue(ret));
733  break;
734  }
735 
736  case ImfClearMetaKeyStates:
737  {
738  getarg(int32_t, states);
739  int32_t ret = onClearMetaKeyStates(imfEvent->mSession, states);
740  imfEvent->mResult->setResult(QVariant::fromValue(ret));
741  break;
742  }
743 
744  case ImfCommitText:
745  {
746  getparg(spannable_string_t*, text);
747  getarg(int32_t, new_cursor_position);
748  int32_t ret = onCommitText(imfEvent->mSession, text, new_cursor_position);
749  imfEvent->mResult->setResult(QVariant::fromValue(ret));
750  break;
751  }
752 
753  case ImfDeleteSurroundingText:
754  {
755  getarg(int32_t, left_length);
756  getarg(int32_t, right_length);
757  int32_t ret = onDeleteSurroundingText(imfEvent->mSession, left_length, right_length);
758  imfEvent->mResult->setResult(QVariant::fromValue(ret));
759  break;
760  }
761 
762  case ImfEndBatchEdit:
763  {
764  int32_t ret = onEndBatchEdit(imfEvent->mSession);
765  imfEvent->mResult->setResult(QVariant::fromValue(ret));
766  break;
767  }
768 
769  case ImfFinishComposingText:
770  {
771  int32_t ret = onFinishComposingText(imfEvent->mSession);
772  imfEvent->mResult->setResult(QVariant::fromValue(ret));
773  break;
774  }
775 
776  case ImfGetCursorCapsMode:
777  {
778  getarg(int32_t, req_modes);
779  int32_t ret = onGetCursorCapsMode(imfEvent->mSession, req_modes);
780  imfEvent->mResult->setResult(QVariant::fromValue(ret));
781  break;
782  }
783 
784  case ImfGetCursorPosition:
785  {
786  int32_t ret = onGetCursorPosition(imfEvent->mSession);
787  imfEvent->mResult->setResult(QVariant::fromValue(ret));
788  break;
789  }
790 
791  case ImfGetExtractedText:
792  {
793  getparg(extracted_text_request_t*, request);
794  getarg(int32_t, flags);
795  extracted_text_t* ret = onGetExtractedText(imfEvent->mSession, request, flags);
796  imfEvent->mResult->setResult(QVariant::fromValue((void*)ret));
797  break;
798  }
799 
800  case ImfGetSelectedText:
801  {
802  getarg(int32_t, flags);
803  spannable_string_t* ret = onGetSelectedText(imfEvent->mSession, flags);
804  imfEvent->mResult->setResult(QVariant::fromValue((void*)ret));
805  break;
806  }
807 
808  case ImfGetTextAfterCursor:
809  {
810  getarg(int32_t, n);
811  getarg(int32_t, flags);
812  spannable_string_t* ret = onGetTextAfterCursor(imfEvent->mSession, n, flags);
813  imfEvent->mResult->setResult(QVariant::fromValue((void*)ret));
814  break;
815  }
816 
817  case ImfGetTextBeforeCursor:
818  {
819  getarg(int32_t, n);
820  getarg(int32_t, flags);
821  spannable_string_t* ret = onGetTextBeforeCursor(imfEvent->mSession, n, flags);
822  imfEvent->mResult->setResult(QVariant::fromValue((void*)ret));
823  break;
824  }
825 
826  case ImfPerformEditorAction:
827  {
828  getarg(int32_t, editor_action);
829  int32_t ret = onPerformEditorAction(imfEvent->mSession, editor_action);
830  imfEvent->mResult->setResult(QVariant::fromValue(ret));
831  break;
832  }
833 
834  case ImfReportFullscreenMode:
835  {
836  getarg(int32_t, enabled);
837  int32_t ret = onReportFullscreenMode(imfEvent->mSession, enabled);
838  imfEvent->mResult->setResult(QVariant::fromValue(ret));
839  break;
840  }
841 
842  case ImfSendEvent:
843  {
844  getparg(event_t*, event);
845  onSendEvent(imfEvent->mSession, event);
846  break;
847  }
848 
849  case ImfSendAsyncEvent:
850  {
851  getparg(event_t*, event);
852  onSendAsyncEvent(imfEvent->mSession, event);
853  break;
854  }
855 
856  case ImfSetComposingRegion:
857  {
858  getarg(int32_t, start);
859  getarg(int32_t, end);
860  int32_t ret = onSetComposingRegion(imfEvent->mSession, start, end);
861  imfEvent->mResult->setResult(QVariant::fromValue(ret));
862  break;
863  }
864 
865  case ImfSetComposingText:
866  {
867  getparg(spannable_string_t*, text);
868  getarg(int32_t, new_cursor_position);
869  int32_t ret = onSetComposingText(imfEvent->mSession, text, new_cursor_position);
870  imfEvent->mResult->setResult(QVariant::fromValue(ret));
871  break;
872  }
873 
874  case ImfSetSelection:
875  {
876  getarg(int32_t, start);
877  getarg(int32_t, end);
878  int32_t ret = onSetSelection(imfEvent->mSession, start, end);
879  imfEvent->mResult->setResult(QVariant::fromValue(ret));
880  break;
881  }
882  }; //switch
883 
884  return true;
885  } else {
886  // standard event processing
887  return QObject::eventFilter(obj, event);
888  }
889 }
extracted_text_t * onGetExtractedText(input_session_t *ic, extracted_text_request_t *request, int32_t flags)
#define getparg(type, name)
int32_t onFinishComposingText(input_session_t *ic)
int32_t onSetSelection(input_session_t *ic, int32_t start, int32_t end)
int32_t onSendAsyncEvent(input_session_t *ic, event_t *event)
int32_t onPerformEditorAction(input_session_t *ic, int32_t editor_action)
int32_t onSetComposingText(input_session_t *ic, spannable_string_t *text, int32_t new_cursor_position)
int32_t onGetCursorCapsMode(input_session_t *ic, int32_t req_modes)
spannable_string_t * onGetTextBeforeCursor(input_session_t *ic, int32_t n, int32_t flags)
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
int32_t onGetCursorPosition(input_session_t *ic)
int32_t onBeginBatchEdit(input_session_t *ic)
int32_t onEndBatchEdit(input_session_t *ic)
int32_t onReportFullscreenMode(input_session_t *ic, int32_t enabled)
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
int32_t onSendEvent(input_session_t *ic, event_t *event)
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
int32_t onDeleteSurroundingText(input_session_t *ic, int32_t left_length, int32_t right_length)
int32_t onClearMetaKeyStates(input_session_t *ic, int32_t states)
#define getarg(type, name)
int32_t onCommitText(input_session_t *ic, spannable_string_t *text, int32_t new_cursor_position)
int32_t onSetComposingRegion(input_session_t *ic, int32_t start, int32_t end)
spannable_string_t * onGetTextAfterCursor(input_session_t *ic, int32_t n, int32_t flags)
static const KeyPair *const end
#define enabled
spannable_string_t * onGetSelectedText(input_session_t *ic, int32_t flags)
#define text
Definition: qobjectdefs.h:80

◆ filterEvent() [1/2]

bool QBBInputContext::filterEvent ( const QEvent event)
virtual

This function can be reimplemented in a subclass to filter input events.

Return true if the event has been consumed. Otherwise, the unfiltered event will be forwarded to widgets as ordinary way. Although the input events have accept() and ignore() methods, leave it untouched.

event is currently restricted to events of these types:

  • CloseSoftwareInputPanel
  • KeyPress
  • KeyRelease
  • MouseButtonDblClick
  • MouseButtonPress
  • MouseButtonRelease
  • MouseMove
  • RequestSoftwareInputPanel

But some input method related events such as QWheelEvent or QTabletEvent may be added in future.

The filtering opportunity is always given to the input context as soon as possible. It has to be taken place before any other key event consumers such as eventfilters and accelerators because some input methods require quite various key combination and sequences. It often conflicts with accelerators and so on, so we must give the input context the filtering opportunity first to ensure all input methods work properly regardless of application design.

Ordinary input methods require discrete key events to work properly, so Qt's key compression is always disabled for any input contexts.

See also
QKeyEvent, x11FilterEvent()

Reimplemented from QInputContext.

Definition at line 901 of file qbbinputcontext_imf.cpp.

Referenced by hasPhysicalKeyboard(), and isComposing().

902 {
903 #if defined(QBBINPUTCONTEXT_DEBUG)
904  qDebug() << TAG << event;
905 #endif
906 
907  switch (event->type()) {
910  }
913  }
914  default:
915  return false;
916  }
917 }
#define TAG
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
Q_CORE_EXPORT void qDebug(const char *,...)
bool dispatchRequestSoftwareInputPanel()

◆ filterEvent() [2/2]

virtual bool QBBInputContext::filterEvent ( const QEvent event)
virtual

This function can be reimplemented in a subclass to filter input events.

Return true if the event has been consumed. Otherwise, the unfiltered event will be forwarded to widgets as ordinary way. Although the input events have accept() and ignore() methods, leave it untouched.

event is currently restricted to events of these types:

  • CloseSoftwareInputPanel
  • KeyPress
  • KeyRelease
  • MouseButtonDblClick
  • MouseButtonPress
  • MouseButtonRelease
  • MouseMove
  • RequestSoftwareInputPanel

But some input method related events such as QWheelEvent or QTabletEvent may be added in future.

The filtering opportunity is always given to the input context as soon as possible. It has to be taken place before any other key event consumers such as eventfilters and accelerators because some input methods require quite various key combination and sequences. It often conflicts with accelerators and so on, so we must give the input context the filtering opportunity first to ensure all input methods work properly regardless of application design.

Ordinary input methods require discrete key events to work properly, so Qt's key compression is always disabled for any input contexts.

See also
QKeyEvent, x11FilterEvent()

Reimplemented from QInputContext.

◆ font()

QFont QBBInputContext::font ( ) const
virtual

Returns the font of the current input widget.

Reimplemented from QInputContext.

Definition at line 927 of file qbbinputcontext_imf.cpp.

928 {
929 #if defined(QBBINPUTCONTEXT_DEBUG)
930  qDebug() << TAG;
931 #endif
932  return QInputContext::font();
933 }
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)
virtual QFont font() const
Returns the font of the current input widget.

◆ handleKeyboardEvent() [1/2]

bool QBBInputContext::handleKeyboardEvent ( int  flags,
int  sym,
int  mod,
int  scan,
int  cap 
)

◆ handleKeyboardEvent() [2/2]

bool QBBInputContext::handleKeyboardEvent ( int  flags,
int  sym,
int  mod,
int  scan,
int  cap 
)

Definition at line 1118 of file qbbinputcontext_imf.cpp.

Referenced by QBBScreenEventHandler::handleKeyboardEvent(), hasPhysicalKeyboard(), and isComposing().

1119 {
1120  if (!imfAvailable())
1121  return false;
1122 
1123  int key = (flags & KEY_SYM_VALID) ? sym : cap;
1124  bool navKey = false;
1125  switch ( key ) {
1126  case KEYCODE_RETURN:
1127  /* In a single line edit we should end composition because enter might be used by something.
1128  endComposition();
1129  return false;*/
1130  break;
1131 
1132  case KEYCODE_BACKSPACE:
1133  case KEYCODE_DELETE:
1134  // If there is a selection range, then we want a delete key to operate on that (by
1135  // deleting the contents of the select range) rather than operating on the composition
1136  // range.
1137  if (hasSelectedText())
1138  return false;
1139  break;
1140  case KEYCODE_LEFT:
1141  key = NAVIGATE_LEFT;
1142  navKey = true;
1143  break;
1144  case KEYCODE_RIGHT:
1145  key = NAVIGATE_RIGHT;
1146  navKey = true;
1147  break;
1148  case KEYCODE_UP:
1149  key = NAVIGATE_UP;
1150  navKey = true;
1151  break;
1152  case KEYCODE_DOWN:
1153  key = NAVIGATE_DOWN;
1154  navKey = true;
1155  break;
1156  case KEYCODE_CAPS_LOCK:
1157  case KEYCODE_LEFT_SHIFT:
1158  case KEYCODE_RIGHT_SHIFT:
1159  case KEYCODE_LEFT_CTRL:
1160  case KEYCODE_RIGHT_CTRL:
1161  case KEYCODE_LEFT_ALT:
1162  case KEYCODE_RIGHT_ALT:
1163  case KEYCODE_MENU:
1164  case KEYCODE_LEFT_HYPER:
1165  case KEYCODE_RIGHT_HYPER:
1166  case KEYCODE_INSERT:
1167  case KEYCODE_HOME:
1168  case KEYCODE_PG_UP:
1169  case KEYCODE_END:
1170  case KEYCODE_PG_DOWN:
1171  // Don't send these
1172  key = 0;
1173  break;
1174  }
1175 
1176  if ( mod & KEYMOD_CTRL ) {
1177  // If CTRL is pressed, just let AIR handle it. But terminate any composition first
1178  //endComposition();
1179  return false;
1180  }
1181 
1182  // Pass the keys we don't know about on through
1183  if ( key == 0 )
1184  return false;
1185 
1186  // IMF doesn't need key releases so just swallow them.
1187  if (!(flags & KEY_DOWN))
1188  return true;
1189 
1190  if ( navKey ) {
1191  // Even if we're forwarding up events, we can't do this for
1192  // navigation keys.
1193  if ( flags & KEY_DOWN ) {
1194  navigation_event_t navEvent;
1195  initEvent(&navEvent.event, sInputSession, EVENT_NAVIGATION, key);
1196  navEvent.magnitude = 1;
1197 #if defined(QBBINPUTCONTEXT_DEBUG)
1198  qDebug() << TAG << "dispatch navigation event " << key;
1199 #endif
1200  p_ictrl_dispatch_event(&navEvent.event);
1201  }
1202  }
1203  else {
1204  key_event_t keyEvent;
1205  initEvent(&keyEvent.event, sInputSession, EVENT_KEY, flags & KEY_DOWN ? IMF_KEY_DOWN : IMF_KEY_UP);
1206  keyEvent.key_code = key;
1207  keyEvent.character = 0;
1208  keyEvent.meta_key_state = 0;
1209 
1210  p_ictrl_dispatch_event(&keyEvent.event);
1211 #if defined(QBBINPUTCONTEXT_DEBUG)
1212  qDebug() << TAG << "dispatch key event " << key;
1213 #endif
1214  }
1215 
1216  scan = 0;
1217  return true;
1218 }
static void keyEvent(KeyAction action, QWidget *widget, char ascii, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
#define TAG
static bool imfAvailable()
Q_CORE_EXPORT void qDebug(const char *,...)
int key
static int32_t(* p_ictrl_dispatch_event)(event_t *)=0

◆ hasPhysicalKeyboard()

bool QBBInputContext::hasPhysicalKeyboard ( )
private

Definition at line 69 of file qbbinputcontext_noimf.cpp.

Referenced by isComposing().

70 {
71  // TODO: This should query the system to check if a USB keyboard is connected.
72  return false;
73 }

◆ hasSelectedText()

bool QBBInputContext::hasSelectedText ( )
private

Definition at line 1039 of file qbbinputcontext_imf.cpp.

Referenced by handleKeyboardEvent(), and onDeleteSurroundingText().

1040 {
1041  if (focusWidget()) {
1043  }
1044  else
1045  {
1046  return false;
1047  }
1048 }
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625

◆ hasSession()

bool QBBInputContext::hasSession ( )
private

Definition at line 1034 of file qbbinputcontext_imf.cpp.

Referenced by setFocusWidget().

1035 {
1036  return sInputSession != 0;
1037 }

◆ identifierName() [1/2]

QString QBBInputContext::identifierName ( )
inlinevirtual

This function must be implemented in any subclasses to return the identifier name of the input method.

Return value is the name to identify and specify input methods for the input method switching mechanism and so on. The name has to be consistent with QInputContextPlugin::keys(). The name has to consist of ASCII characters only.

There are two different names with different responsibility in the input method domain. This function returns one of them. Another name is called 'display name' that stands for the name for endusers appeared in a menu and so on.

See also
QInputContextPlugin::keys(), QInputContextPlugin::displayName()

Implements QInputContext.

Definition at line 57 of file qbbinputcontext_noimf.h.

57 { return QString("BlackBerry IMF"); }
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ identifierName() [2/2]

QString QBBInputContext::identifierName ( )
virtual

This function must be implemented in any subclasses to return the identifier name of the input method.

Return value is the name to identify and specify input methods for the input method switching mechanism and so on. The name has to be consistent with QInputContextPlugin::keys(). The name has to consist of ASCII characters only.

There are two different names with different responsibility in the input method domain. This function returns one of them. Another name is called 'display name' that stands for the name for endusers appeared in a menu and so on.

See also
QInputContextPlugin::keys(), QInputContextPlugin::displayName()

Implements QInputContext.

Definition at line 891 of file qbbinputcontext_imf.cpp.

892 {
893  return tr("PlayBook IMF");
894 }
static QString tr(const char *sourceText, const char *comment=0, int n=-1)

◆ isComposing() [1/2]

bool QBBInputContext::isComposing ( ) const
inlinevirtual

This function indicates whether InputMethodStart event had been sent to the current focus widget.

It is ensured that an input context can send InputMethodCompose or InputMethodEnd event safely if this function returned true.

The state is automatically being tracked through sendEvent().

See also
sendEvent()

Implements QInputContext.

Definition at line 61 of file qbbinputcontext_noimf.h.

61 { return false; }

◆ isComposing() [2/2]

bool QBBInputContext::isComposing ( ) const
virtual

This function indicates whether InputMethodStart event had been sent to the current focus widget.

It is ensured that an input context can send InputMethodCompose or InputMethodEnd event safely if this function returned true.

The state is automatically being tracked through sendEvent().

See also
sendEvent()

Implements QInputContext.

Definition at line 935 of file qbbinputcontext_imf.cpp.

Referenced by endComposition().

936 {
937 #if defined(QBBINPUTCONTEXT_DEBUG)
938  qDebug() << TAG;
939 #endif
940  return mIsComposing;
941 }
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)

◆ language() [1/2]

QString QBBInputContext::language ( )
virtual

This function must be implemented in any subclasses to return a language code (e.

g. "zh_CN", "zh_TW", "zh_HK", "ja", "ko", ...) of the input context. If the input context can handle multiple languages, return the currently used one. The name has to be consistent with QInputContextPlugin::language().

This information will be used by language tagging feature in QInputMethodEvent. It is required to distinguish unified han characters correctly. It enables proper font and character code handling. Suppose CJK-awared multilingual web browser (that automatically modifies fonts in CJK-mixed text) and XML editor (that automatically inserts lang attr).

Implements QInputContext.

◆ language() [2/2]

QString QBBInputContext::language ( )
virtual

This function must be implemented in any subclasses to return a language code (e.

g. "zh_CN", "zh_TW", "zh_HK", "ja", "ko", ...) of the input context. If the input context can handle multiple languages, return the currently used one. The name has to be consistent with QInputContextPlugin::language().

This information will be used by language tagging feature in QInputMethodEvent. It is required to distinguish unified han characters correctly. It enables proper font and character code handling. Suppose CJK-awared multilingual web browser (that automatically modifies fonts in CJK-mixed text) and XML editor (that automatically inserts lang attr).

Implements QInputContext.

Definition at line 896 of file qbbinputcontext_imf.cpp.

Referenced by identifierName().

897 {
898  return mVirtualKeyboard.languageId();
899 }
QBBAbstractVirtualKeyboard & mVirtualKeyboard

◆ mouseHandler()

void QBBInputContext::mouseHandler ( int  x,
QMouseEvent event 
)
virtual

This function can be reimplemented in a subclass to handle mouse press, release, double-click, and move events within the preedit text.

You can use the function to implement mouse-oriented user interface such as text selection or popup menu for candidate selection.

The x parameter is the offset within the string that was sent with the InputMethodCompose event. The alteration boundary of x is ensured as character boundary of preedit string accurately.

The event parameter is the event that was sent to the editor widget. The event type is QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick or QEvent::MouseMove. The event's button and state indicate the kind of operation that was performed.

Reimplemented from QInputContext.

Definition at line 943 of file qbbinputcontext_imf.cpp.

944 {
945 #if defined(QBBINPUTCONTEXT_DEBUG)
946  qDebug() << TAG;
947 #endif
948  return QInputContext::mouseHandler(x, event);
949 }
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)
virtual void mouseHandler(int x, QMouseEvent *event)
This function can be reimplemented in a subclass to handle mouse press, release, double-click, and move events within the preedit text.

◆ onBeginBatchEdit()

int32_t QBBInputContext::onBeginBatchEdit ( input_session_t *  ic)
private

Definition at line 1319 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1320 {
1321 #if defined(QBBINPUTCONTEXT_DEBUG)
1322  qDebug() << TAG;
1323 #endif
1324 
1325  if (!isSessionOkay(ic))
1326  return 0;
1327 
1328  // We don't care.
1329  return 0;
1330 }
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)

◆ onClearMetaKeyStates()

int32_t QBBInputContext::onClearMetaKeyStates ( input_session_t *  ic,
int32_t  states 
)
private

Definition at line 1332 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1333 {
1334  Q_UNUSED(states);
1335 #if defined(QBBINPUTCONTEXT_DEBUG)
1336  qDebug() << TAG;
1337 #endif
1338 
1339  if (!isSessionOkay(ic))
1340  return 0;
1341 
1342  // Should never get called.
1343  qCritical() << TAG << "onClearMetaKeyStates is unsupported.";
1344  return 0;
1345 }
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)
#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
Q_CORE_EXPORT void qCritical(const char *,...)

◆ onCommitText()

int32_t QBBInputContext::onCommitText ( input_session_t *  ic,
spannable_string_t *  text,
int32_t  new_cursor_position 
)
private

Definition at line 1347 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1348 {
1349  Q_UNUSED(new_cursor_position); // TODO: How can we set the cursor position it's not part of the API.
1350  if (!isSessionOkay(ic))
1351  return 0;
1352 
1353  QString commitString = QString::fromWCharArray(text->str, text->length);
1354 
1355 #if defined(QBBINPUTCONTEXT_DEBUG)
1356  qDebug() << TAG << "Committing [" << commitString << "]";
1357 #endif
1358 
1360  QInputMethodEvent event(QLatin1String(""), attributes);
1361  event.setCommitString(commitString, 0, 0);
1362 
1363  sendEvent(event);
1364  mComposingText = QString();
1365 
1366  return 0;
1367 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define TAG
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
Q_CORE_EXPORT void qDebug(const char *,...)
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
void sendEvent(const QInputMethodEvent &event)
Sends an input method event specified by event to the current focus widget.
#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
#define text
Definition: qobjectdefs.h:80

◆ onDeleteSurroundingText()

int32_t QBBInputContext::onDeleteSurroundingText ( input_session_t *  ic,
int32_t  left_length,
int32_t  right_length 
)
private

Definition at line 1369 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1370 {
1371 #if defined(QBBINPUTCONTEXT_DEBUG)
1372  qDebug() << TAG << "L:" << left_length << " R:" << right_length;
1373 #endif
1374 
1375  if (!isSessionOkay(ic))
1376  return 0;
1377 
1378  if (hasSelectedText()) {
1379  QBBEventThread::injectKeyboardEvent(KEY_DOWN | KEY_CAP_VALID, KEYCODE_DELETE, 0, 0, 0);
1380  QBBEventThread::injectKeyboardEvent(KEY_CAP_VALID, KEYCODE_DELETE, 0, 0, 0);
1381  reset();
1382  return 0;
1383  }
1384 
1385  int replacementLength = left_length + right_length;
1386  int replacementStart = -left_length;
1387 
1389  QInputMethodEvent event(QLatin1String(""), attributes);
1390  event.setCommitString(QLatin1String(""), replacementStart, replacementLength);
1391  sendEvent(event);
1392 
1393  return 0;
1394 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual void reset()
This function can be reimplemented in a subclass to reset the state of the input method.
#define TAG
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
Q_CORE_EXPORT void qDebug(const char *,...)
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
void sendEvent(const QInputMethodEvent &event)
Sends an input method event specified by event to the current focus widget.

◆ onEndBatchEdit()

int32_t QBBInputContext::onEndBatchEdit ( input_session_t *  ic)
private

Definition at line 1396 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1397 {
1398 #if defined(QBBINPUTCONTEXT_DEBUG)
1399  qDebug() << TAG;
1400 #endif
1401 
1402  if (!isSessionOkay(ic))
1403  return 0;
1404 
1405  return 0;
1406 }
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)

◆ onFinishComposingText()

int32_t QBBInputContext::onFinishComposingText ( input_session_t *  ic)
private

Definition at line 1408 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1409 {
1410 #if defined(QBBINPUTCONTEXT_DEBUG)
1411  qDebug() << TAG;
1412 #endif
1413 
1414  if (!isSessionOkay(ic))
1415  return 0;
1416 
1417  // Only update the control, no need to send a message back to imf (don't call
1418  // end composition)
1420  QInputMethodEvent event(QLatin1String(""), attributes);
1421  event.setCommitString(mComposingText);
1422  mComposingText = QString();
1423  mIsComposing = false;
1424  sendEvent(event);
1425 
1426  return 0;
1427 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define TAG
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
Q_CORE_EXPORT void qDebug(const char *,...)
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
void sendEvent(const QInputMethodEvent &event)
Sends an input method event specified by event to the current focus widget.

◆ onForceUpdate()

int32_t QBBInputContext::onForceUpdate ( )
private

◆ onGetCursorCapsMode()

int32_t QBBInputContext::onGetCursorCapsMode ( input_session_t *  ic,
int32_t  req_modes 
)
private

Definition at line 1429 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1430 {
1431  Q_UNUSED(req_modes);
1432 #if defined(QBBINPUTCONTEXT_DEBUG)
1433  qDebug() << TAG;
1434 #endif
1435 
1436  if (!isSessionOkay(ic))
1437  return 0;
1438 
1439  // Should never get called.
1440  qCritical() << TAG << "onGetCursorCapsMode is unsupported.";
1441 
1442  return 0;
1443 }
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)
#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
Q_CORE_EXPORT void qCritical(const char *,...)

◆ onGetCursorPosition()

int32_t QBBInputContext::onGetCursorPosition ( input_session_t *  ic)
private

Definition at line 1445 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1446 {
1447 #if defined(QBBINPUTCONTEXT_DEBUG)
1448  qDebug() << TAG;
1449 #endif
1450 
1451  if (!isSessionOkay(ic))
1452  return 0;
1453 
1455  return mLastCaretPos;
1456 }
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
#define TAG
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
Q_CORE_EXPORT void qDebug(const char *,...)

◆ onGetExtractedText()

extracted_text_t * QBBInputContext::onGetExtractedText ( input_session_t *  ic,
extracted_text_request_t *  request,
int32_t  flags 
)
private

Definition at line 1458 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1459 {
1460  Q_UNUSED(flags);
1461  Q_UNUSED(request);
1462 #if defined(QBBINPUTCONTEXT_DEBUG)
1463  qDebug() << TAG;
1464 #endif
1465 
1466  if (!isSessionOkay(ic)) {
1467  extracted_text_t *et = (extracted_text_t *)calloc(sizeof(extracted_text_t),1);
1468  et->text = (spannable_string_t *)calloc(sizeof(spannable_string_t),1);
1469  return 0;
1470  }
1471 
1472  // Used to update dictionaries, but not supported right now.
1473  extracted_text_t *et = (extracted_text_t *)calloc(sizeof(extracted_text_t),1);
1474  et->text = (spannable_string_t *)calloc(sizeof(spannable_string_t),1);
1475 
1476  return et;
1477 }
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)
#define calloc(a, b)
#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

◆ onGetSelectedText()

spannable_string_t * QBBInputContext::onGetSelectedText ( input_session_t *  ic,
int32_t  flags 
)
private

Definition at line 1479 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1480 {
1481  Q_UNUSED(flags);
1482 #if defined(QBBINPUTCONTEXT_DEBUG)
1483  qDebug() << TAG;
1484 #endif
1485 
1486  if (!isSessionOkay(ic))
1487  return toSpannableString("");
1488 
1490  return toSpannableString(text);
1491 }
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
#define TAG
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_CORE_EXPORT void qDebug(const char *,...)
#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
#define text
Definition: qobjectdefs.h:80

◆ onGetTextAfterCursor()

spannable_string_t * QBBInputContext::onGetTextAfterCursor ( input_session_t *  ic,
int32_t  n,
int32_t  flags 
)
private

Definition at line 1493 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1494 {
1495  Q_UNUSED(flags);
1496 #if defined(QBBINPUTCONTEXT_DEBUG)
1497  qDebug() << TAG;
1498 #endif
1499 
1500  if (!isSessionOkay(ic))
1501  return toSpannableString("");
1502 
1505 
1506  return toSpannableString(text.mid(mLastCaretPos+1, n));
1507 }
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
#define TAG
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
The QString class provides a Unicode character string.
Definition: qstring.h:83
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
Q_CORE_EXPORT void qDebug(const char *,...)
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
#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
#define text
Definition: qobjectdefs.h:80

◆ onGetTextBeforeCursor()

spannable_string_t * QBBInputContext::onGetTextBeforeCursor ( input_session_t *  ic,
int32_t  n,
int32_t  flags 
)
private

Definition at line 1509 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1510 {
1511  Q_UNUSED(flags);
1512 #if defined(QBBINPUTCONTEXT_DEBUG)
1513  qDebug() << TAG;
1514 #endif
1515 
1516  if (!isSessionOkay(ic))
1517  return toSpannableString("");
1518 
1521 
1522  if (n < mLastCaretPos)
1523  {
1524  return toSpannableString(text.mid(mLastCaretPos - n, n));
1525  }
1526  else
1527  return toSpannableString(text.mid(0, mLastCaretPos));
1528 }
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
#define TAG
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
The QString class provides a Unicode character string.
Definition: qstring.h:83
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
Q_CORE_EXPORT void qDebug(const char *,...)
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
#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
#define text
Definition: qobjectdefs.h:80

◆ onPerformEditorAction()

int32_t QBBInputContext::onPerformEditorAction ( input_session_t *  ic,
int32_t  editor_action 
)
private

Definition at line 1530 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1531 {
1532  Q_UNUSED(editor_action);
1533 #if defined(QBBINPUTCONTEXT_DEBUG)
1534  qDebug() << TAG;
1535 #endif
1536 
1537  if (!isSessionOkay(ic))
1538  return 0;
1539 
1540  // Should never get called.
1541  qCritical() << TAG << "onPerformEditorAction is unsupported.";
1542 
1543  return 0;
1544 }
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)
#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
Q_CORE_EXPORT void qCritical(const char *,...)

◆ onReportFullscreenMode()

int32_t QBBInputContext::onReportFullscreenMode ( input_session_t *  ic,
int32_t  enabled 
)
private

Definition at line 1546 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1547 {
1548  Q_UNUSED(enabled);
1549 #if defined(QBBINPUTCONTEXT_DEBUG)
1550  qDebug() << TAG;
1551 #endif
1552 
1553  if (!isSessionOkay(ic))
1554  return 0;
1555 
1556  // Should never get called.
1557  qCritical() << TAG << "onReportFullscreenMode is unsupported.";
1558 
1559  return 0;
1560 }
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)
#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
#define enabled
Q_CORE_EXPORT void qCritical(const char *,...)

◆ onSendAsyncEvent()

int32_t QBBInputContext::onSendAsyncEvent ( input_session_t *  ic,
event_t *  event 
)
private

Definition at line 1574 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1575 {
1576 #if defined(QBBINPUTCONTEXT_DEBUG)
1577  qDebug() << TAG;
1578 #endif
1579 
1580  if (!isSessionOkay(ic))
1581  return 0;
1582 
1583  return processEvent(event);
1584 }
#define TAG
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
Q_CORE_EXPORT void qDebug(const char *,...)
int32_t processEvent(event_t *event)

◆ onSendEvent()

int32_t QBBInputContext::onSendEvent ( input_session_t *  ic,
event_t *  event 
)
private

Definition at line 1562 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1563 {
1564 #if defined(QBBINPUTCONTEXT_DEBUG)
1565  qDebug() << TAG;
1566 #endif
1567 
1568  if (!isSessionOkay(ic))
1569  return 0;
1570 
1571  return processEvent(event);
1572 }
#define TAG
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
Q_CORE_EXPORT void qDebug(const char *,...)
int32_t processEvent(event_t *event)

◆ onSetComposingRegion()

int32_t QBBInputContext::onSetComposingRegion ( input_session_t *  ic,
int32_t  start,
int32_t  end 
)
private

Definition at line 1586 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1587 {
1588 #if defined(QBBINPUTCONTEXT_DEBUG)
1589  qDebug() << TAG;
1590 #endif
1591 
1592  if (!isSessionOkay(ic))
1593  return 0;
1594 
1595  if (!focusWidget())
1596  {
1597  qCritical() << "No focus widget!";
1598  return 0;
1599  }
1600 
1602 
1605  QString empty = QString::fromLatin1("");
1606  text = text.mid(start, end - start);
1607 
1608  // Delete the current text.
1609  {
1610  QInputMethodEvent event(empty, attributes);
1611  event.setCommitString(empty, start - mLastCaretPos, end - start);
1612  sendEvent(event);
1613  }
1614 
1615  // Move the specified text into a preedit string.
1616  {
1617  setComposingText(text);
1618  }
1619 
1620  return 0;
1621 }
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
#define TAG
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
Q_CORE_EXPORT void qDebug(const char *,...)
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
void setComposingText(QString const &composingText)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
void sendEvent(const QInputMethodEvent &event)
Sends an input method event specified by event to the current focus widget.
static const KeyPair *const end
Q_CORE_EXPORT void qCritical(const char *,...)
#define text
Definition: qobjectdefs.h:80

◆ onSetComposingText()

int32_t QBBInputContext::onSetComposingText ( input_session_t *  ic,
spannable_string_t *  text,
int32_t  new_cursor_position 
)
private

Definition at line 1623 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1624 {
1625  Q_UNUSED(new_cursor_position);
1626 #if defined(QBBINPUTCONTEXT_DEBUG)
1627  qDebug() << TAG;
1628 #endif
1629 
1630  if (!isSessionOkay(ic))
1631  return 0;
1632 
1633  if (!focusWidget())
1634  {
1635  qCritical() << "No focus widget!";
1636  return 0;
1637  }
1638 
1639  mIsComposing = true;
1640 
1641  QString preeditString = QString::fromWCharArray(text->str, text->length);
1642  setComposingText(preeditString);
1643 
1644  return 0;
1645 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
#define TAG
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_CORE_EXPORT void qDebug(const char *,...)
void setComposingText(QString const &composingText)
#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
Q_CORE_EXPORT void qCritical(const char *,...)
#define text
Definition: qobjectdefs.h:80

◆ onSetSelection()

int32_t QBBInputContext::onSetSelection ( input_session_t *  ic,
int32_t  start,
int32_t  end 
)
private

Definition at line 1647 of file qbbinputcontext_imf.cpp.

Referenced by eventFilter().

1648 {
1649  Q_UNUSED(start);
1650  Q_UNUSED(end);
1651 #if defined(QBBINPUTCONTEXT_DEBUG)
1652  qDebug() << TAG;
1653 #endif
1654 
1655  if (!isSessionOkay(ic))
1656  return 0;
1657 
1658  // Should never get called.
1659  qCritical() << TAG << "onSetSelection is unsupported.";
1660 
1661  return 0;
1662 }
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)
static const KeyPair *const end
#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
Q_CORE_EXPORT void qCritical(const char *,...)

◆ openSession()

void QBBInputContext::openSession ( )
private

Definition at line 1021 of file qbbinputcontext_imf.cpp.

Referenced by setFocusWidget().

1022 {
1023 #if defined(QBBINPUTCONTEXT_DEBUG)
1024  qDebug() << TAG;;
1025 #endif
1026 
1027  if (!imfAvailable())
1028  return;
1029 
1030  closeSession();
1031  sInputSession = p_ictrl_open_session(&ic_funcs);
1032 }
static const input_session_t *(* p_ictrl_open_session)(connection_interface_t *)=0
#define TAG
static bool imfAvailable()
Q_CORE_EXPORT void qDebug(const char *,...)

◆ processEvent()

int32_t QBBInputContext::processEvent ( event_t *  event)
private

Definition at line 1256 of file qbbinputcontext_imf.cpp.

Referenced by onSendAsyncEvent(), and onSendEvent().

1257 {
1258  int32_t result = -1;
1259  switch (event->event_type) {
1260  case EVENT_SPELL_CHECK: {
1261  #if defined(QBBINPUTCONTEXT_DEBUG)
1262  qDebug() << TAG << "EVENT_SPELL_CHECK";
1263  #endif
1264  result = 0;
1265  break;
1266  }
1267 
1268  case EVENT_NAVIGATION: {
1269  #if defined(QBBINPUTCONTEXT_DEBUG)
1270  qDebug() << TAG << "EVENT_NAVIGATION";
1271  #endif
1272 
1273  int key = event->event_id == NAVIGATE_UP ? KEYCODE_UP :
1274  event->event_id == NAVIGATE_DOWN ? KEYCODE_DOWN :
1275  event->event_id == NAVIGATE_LEFT ? KEYCODE_LEFT :
1276  event->event_id == NAVIGATE_RIGHT ? KEYCODE_RIGHT : 0;
1277 
1278  QBBEventThread::injectKeyboardEvent(KEY_DOWN | KEY_CAP_VALID, key, 0, 0, 0);
1279  QBBEventThread::injectKeyboardEvent(KEY_CAP_VALID, key, 0, 0, 0);
1280  result = 0;
1281  break;
1282  }
1283 
1284  case EVENT_KEY: {
1285  #if defined(QBBINPUTCONTEXT_DEBUG)
1286  qDebug() << TAG << "EVENT_KEY";
1287  #endif
1288  key_event_t* kevent = (key_event_t*) event;
1289 
1290  QBBEventThread::injectKeyboardEvent(KEY_DOWN | KEY_SYM_VALID | KEY_CAP_VALID, kevent->key_code, 0, 0, kevent->key_code);
1291  QBBEventThread::injectKeyboardEvent(KEY_SYM_VALID | KEY_CAP_VALID, kevent->key_code, 0, 0, kevent->key_code);
1292 
1293  result = 0;
1294  break;
1295  }
1296 
1297  case EVENT_ACTION:
1298  // Don't care, indicates that IMF is done.
1299  break;
1300 
1301  case EVENT_CARET:
1302  case EVENT_NOTHING:
1303  case EVENT_FOCUS:
1304  case EVENT_USER_ACTION:
1305  case EVENT_STROKE:
1306  case EVENT_INVOKE_LATER:
1307  qCritical() << TAG << "Unsupported event type: " << event->event_type;
1308  break;
1309  default:
1310  qCritical() << TAG << "Unknown event type: " << event->event_type;
1311  }
1312  return result;
1313 }
#define TAG
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
Q_CORE_EXPORT void qDebug(const char *,...)
int key
Q_CORE_EXPORT void qCritical(const char *,...)

◆ reset() [1/2]

void QBBInputContext::reset ( )
virtual

This function can be reimplemented in a subclass to reset the state of the input method.

This function is called by several widgets to reset input state. For example, a text widget call this function before inserting a text to make widget ready to accept a text.

Default implementation is sufficient for simple input method. You can override this function to reset external input method engines in complex input method. In the case, call QInputContext::reset() to ensure proper termination of inputting.

In a reimplementation of reset(), you must not send any QInputMethodEvent containing preedit text. You can only commit string and attributes; otherwise, you risk breaking input state consistency.

Implements QInputContext.

◆ reset() [2/2]

void QBBInputContext::reset ( )
virtual

This function can be reimplemented in a subclass to reset the state of the input method.

This function is called by several widgets to reset input state. For example, a text widget call this function before inserting a text to make widget ready to accept a text.

Default implementation is sufficient for simple input method. You can override this function to reset external input method engines in complex input method. In the case, call QInputContext::reset() to ensure proper termination of inputting.

In a reimplementation of reset(), you must not send any QInputMethodEvent containing preedit text. You can only commit string and attributes; otherwise, you risk breaking input state consistency.

Implements QInputContext.

Definition at line 951 of file qbbinputcontext_imf.cpp.

Referenced by hasPhysicalKeyboard(), identifierName(), onDeleteSurroundingText(), and update().

952 {
953 #if defined(QBBINPUTCONTEXT_DEBUG)
954  qDebug() << TAG;
955 #endif
956 
957  endComposition();
958 }
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)

◆ setComposingText()

void QBBInputContext::setComposingText ( QString const &  composingText)
private

Definition at line 1241 of file qbbinputcontext_imf.cpp.

Referenced by onSetComposingRegion(), and onSetComposingText().

1242 {
1243  mComposingText = composingText;
1244  mIsComposing = true;
1245 
1248  format.setFontUnderline(true);
1249  attributes.push_back(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, composingText.length(), format));
1250 
1251  QInputMethodEvent event(composingText, attributes);
1252 
1253  sendEvent(event);
1254 }
void push_back(const T &t)
This function is provided for STL compatibility.
Definition: qlist.h:296
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
The QInputMethodEvent::Attribute class stores an input method attribute.
Definition: qevent.h:441
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
void sendEvent(const QInputMethodEvent &event)
Sends an input method event specified by event to the current focus widget.
void setFontUnderline(bool underline)
If underline is true, sets the text format&#39;s font to be underlined; otherwise it is displayed non-und...
Definition: qtextformat.h:432

◆ setFocusWidget() [1/2]

void QBBInputContext::setFocusWidget ( QWidget widget)
virtual

Sets the widget that has an input focus for this input context.

Warning
Ordinary input methods must not call this function directly.
See also
focusWidget()

Reimplemented from QInputContext.

◆ setFocusWidget() [2/2]

void QBBInputContext::setFocusWidget ( QWidget widget)
virtual

Sets the widget that has an input focus for this input context.

Warning
Ordinary input methods must not call this function directly.
See also
focusWidget()

Reimplemented from QInputContext.

Definition at line 960 of file qbbinputcontext_imf.cpp.

Referenced by hasPhysicalKeyboard(), and isComposing().

961 {
962 #if defined(QBBINPUTCONTEXT_DEBUG)
963  qDebug() << TAG;
964 #endif
965 
966  if (hasSession()) {
967  endComposition();
968  dispatchFocusEvent(FOCUS_LOST);
969  closeSession();
970  }
971 
972  // Update the widget before moving on.
974 
975  // If we have hidden text, or any flags that restrict input (exclusive flags), then we just disable
976  // imf for this field.
977  if (widget != 0 && !(widget->inputMethodHints() & Qt::ImhHiddenText) && !(widget->inputMethodHints() >= Qt::ImhDigitsOnly && widget->inputMethodHints() <= Qt::ImhUrlCharactersOnly))
978  {
979 #if defined(QBBINPUTCONTEXT_DEBUG)
980  qDebug() << TAG << "Starting input session for " << widget;
981 #endif
982  openSession();
983  dispatchFocusEvent(FOCUS_GAINED, widget->inputMethodHints());
984  }
985 }
QPointer< QWidget > widget
bool dispatchFocusEvent(FocusEventId id, int hints=Qt::ImhNone)
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)
Qt::InputMethodHints inputMethodHints
What input method specific hints the widget has.
Definition: qwidget.h:224
virtual void setFocusWidget(QWidget *w)
Sets the widget that has an input focus for this input context.

◆ update()

void QBBInputContext::update ( void  )
virtual

This virtual function is called when a state in the focus widget has changed.

QInputContext can then use QWidget::inputMethodQuery() to query the new state of the widget.

Reimplemented from QInputContext.

Definition at line 987 of file qbbinputcontext_imf.cpp.

988 {
989 #if defined(QBBINPUTCONTEXT_DEBUG)
990  qDebug() << TAG;
991 #endif
992 
993  reset();
994 
996 }
virtual void reset()
This function can be reimplemented in a subclass to reset the state of the input method.
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)
virtual void update()
This virtual function is called when a state in the focus widget has changed.

◆ widgetDestroyed()

void QBBInputContext::widgetDestroyed ( QWidget widget)
virtual

This virtual function is called when the specified widget is destroyed.

The widget is a widget on which this input context is installed.

Reimplemented from QInputContext.

Definition at line 998 of file qbbinputcontext_imf.cpp.

999 {
1000 #if defined(QBBINPUTCONTEXT_DEBUG)
1001  qDebug() << TAG;
1002 #endif
1004 }
#define TAG
Q_CORE_EXPORT void qDebug(const char *,...)
virtual void widgetDestroyed(QWidget *w)
This virtual function is called when the specified widget is destroyed.

Properties

◆ mComposingText

QString QBBInputContext::mComposingText
private

◆ mIsComposing

bool QBBInputContext::mIsComposing
private

◆ mLastCaretPos

int QBBInputContext::mLastCaretPos
private

◆ mVirtualKeyboard

QBBAbstractVirtualKeyboard & QBBInputContext::mVirtualKeyboard
private

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