Пример #1
0
void MozQWidget::hideVKB()
{
    if (gPendingVKBOpen) {
        // do not really open
        gPendingVKBOpen = false;
    }

    if (!gKeyboardOpen) {
        return;
    }

#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
    QInputContext *inputContext = qApp->inputContext();
    if (!inputContext) {
        NS_WARNING("Closing SIP: but no input context");
        return;
    }

    QEvent request(QEvent::CloseSoftwareInputPanel);
    inputContext->filterEvent(&request);
    inputContext->reset();
    gKeyboardOpen = false;
#else
    LOG(("VKB not supported in Qt < 4.6\n"));
#endif
}
bool NSRInputDialog::eventFilter (QObject *obj, QEvent *ev)
{
	if (obj != ui->inputEdit)
		return QWidget::eventFilter (obj, ev);

	if (ev->type () != QEvent::FocusIn &&
	    ev->type () != QEvent::FocusOut &&
	    ev->type () != QEvent::KeyPress)
		return false;

	QInputContext *inputContext = qApp->inputContext ();

	if (inputContext == NULL)
		return false;

	if (ev->type () == QEvent::FocusIn) {
		QEvent request (QEvent::RequestSoftwareInputPanel);

		inputContext->filterEvent (&request);
		ui->inputEdit->setAttribute (Qt::WA_InputMethodEnabled, true);
		inputContext->setFocusWidget (ui->inputEdit);
	} else if (ev->type () == QEvent::FocusOut) {
		QEvent request (QEvent::CloseSoftwareInputPanel);

		inputContext->filterEvent (&request);
		inputContext->reset ();
	} else {
		QKeyEvent *keyEv = (QKeyEvent *) ev;

		if (keyEv->key () == Qt::Key_Return)
			on_okButton_clicked ();
	}

	return false;
}
Пример #3
0
/*!
    Creates and returns a QInputContext object for the input context
    specified by \a key with the given \a parent. Keys are case
    sensitive.

    \sa keys()
*/
QInputContext *QInputContextFactory::create( const QString& key, QObject *parent )
{
    QInputContext *result = 0;
#if defined(Q_WS_X11) && !defined(QT_NO_XIM)
    if (key == QLatin1String("xim")) {
        result = new QXIMInputContext;
    }
#endif
#if defined(Q_WS_WIN)
    if (key == QLatin1String("win")) {
        result = new QWinInputContext;
    }
#endif
#if defined(Q_WS_MAC)
    if (key == QLatin1String("mac")) {
        result = new QMacInputContext;
    }
#endif
#if defined(Q_WS_S60)
    if (key == QLatin1String("coefep")) {
        result = new QCoeFepInputContext;
    }
#endif
#ifdef QT_NO_LIBRARY
    Q_UNUSED(key);
#else
    if (QInputContextFactoryInterface *factory =
        qobject_cast<QInputContextFactoryInterface*>(loader()->instance(key))) {
        result = factory->create(key);
    }
#endif
    if (result)
        result->setParent(parent);
    return result;
}
Пример #4
0
void QtFallbackWebPopupCombo::hidePopup()
{
#ifndef QT_NO_IM
    QWidget* activeFocus = QApplication::focusWidget();
    if (activeFocus && activeFocus == QComboBox::view()
        && activeFocus->testAttribute(Qt::WA_InputMethodEnabled)) {
        QInputContext* qic = activeFocus->inputContext();
        if (qic) {
            qic->reset();
            qic->setFocusWidget(0);
        }
    }
#endif // QT_NO_IM

    QComboBox::hidePopup();

    if (QGraphicsProxyWidget* proxy = graphicsProxyWidget())
        proxy->setVisible(false);

    if (!m_ownerPopup.m_popupVisible)
        return;

    m_ownerPopup.m_popupVisible = false;
    m_ownerPopup.popupDidHide();
}
static PyObject *meth_QInputContext_identifierName(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;
    PyObject *sipOrigSelf = sipSelf;

    {
        QInputContext *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QInputContext, &sipCpp))
        {
            QString *sipRes;

            if (!sipOrigSelf)
            {
                sipAbstractMethod(sipName_QInputContext, sipName_identifierName);
                return NULL;
            }

            Py_BEGIN_ALLOW_THREADS
            sipRes = new QString(sipCpp->identifierName());
            Py_END_ALLOW_THREADS

            return sipConvertFromNewType(sipRes,sipType_QString,NULL);
        }
    }
Пример #6
0
    virtual void IMENotification(int aIstate, bool aOpen, int aCause, int aFocusChange)
    {
        LOGT("imeState:%i", aIstate);
        q->setInputMethodHints(aIstate == 2 ? Qt::ImhHiddenText : Qt::ImhPreferLowercase);
        QWidget* focusWidget = qApp->focusWidget();
        if (focusWidget && aFocusChange) {
#if (QT_VERSION <= QT_VERSION_CHECK(5, 0, 0))
            QInputContext *inputContext = qApp->inputContext();
            if (!inputContext) {
                LOGT("Requesting SIP: but no input context");
                return;
            }
            if (aIstate) {
                QEvent request(QEvent::RequestSoftwareInputPanel);
                inputContext->filterEvent(&request);
                focusWidget->setAttribute(Qt::WA_InputMethodEnabled, true);
                inputContext->setFocusWidget(focusWidget);
            } else {
                QEvent request(QEvent::CloseSoftwareInputPanel);
                inputContext->filterEvent(&request);
                inputContext->reset();
            }
#else
            LOGT("Fixme IME for Qt5");
#endif
        }
    }
Пример #7
0
/*!
  This function is not intended as polymorphic usage. Just a shared code
  fragment that calls QInputContext::mouseHandler for this
  class.
*/
bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e )
{
#if !defined QT_NO_IM
    Q_Q(QLineEdit);
    if ( control->composeMode() ) {
	int tmp_cursor = xToPos(e->pos().x());
	int mousePos = tmp_cursor - control->cursor();
	if ( mousePos < 0 || mousePos > control->preeditAreaText().length() ) {
            mousePos = -1;
	    // don't send move events outside the preedit area
            if ( e->type() == QEvent::MouseMove )
                return true;
        }

        QInputContext *qic = q->inputContext();
        if ( qic )
            // may be causing reset() in some input methods
            qic->mouseHandler(mousePos, e);
        if (!control->preeditAreaText().isEmpty())
            return true;
    }
#else
    Q_UNUSED(e);
#endif

    return false;
}
Пример #8
0
void MozQWidget::showVKB()
{
    // skip showing of keyboard if not pending
    if (!gPendingVKBOpen) {
        return;
    }

    gPendingVKBOpen = false;

#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
    QWidget* focusWidget = qApp->focusWidget();

    if (focusWidget) {
        QInputContext *inputContext = qApp->inputContext();
        if (!inputContext) {
            NS_WARNING("Requesting SIP: but no input context");
            return;
        }

        QEvent request(QEvent::RequestSoftwareInputPanel);
        inputContext->filterEvent(&request);
        focusWidget->setAttribute(Qt::WA_InputMethodEnabled, true);
        inputContext->setFocusWidget(focusWidget);
        gKeyboardOpen = true;
        gFailedOpenKeyboard = false;
    }
    else
    {
        // No focused widget yet, so we have to open the VKB later on.
        gFailedOpenKeyboard = true;
    }
#else
    LOG(("VKB not supported in Qt < 4.6\n"));
#endif
}
void MWidgetController::updateMicroFocus()
{
    QInputContext *ic = qApp->inputContext();

    if (ic != 0) {
        ic->update();
    }
}
Пример #10
0
void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
{
    Q_D(QWidget);
    d->aboutToDestroy();
    if (!isWindow() && parentWidget())
        parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));

    d->deactivateWidgetCleanup();
    if (testAttribute(Qt::WA_WState_Created)) {
        setAttribute(Qt::WA_WState_Created, false);
        QObjectList childObjects =  children();
        for (int i = 0; i < childObjects.size(); ++i) {
            QObject *obj = childObjects.at(i);
            if (obj->isWidgetType())
                static_cast<QWidget*>(obj)->destroy(destroySubWindows,
                                                     destroySubWindows);
        }
        releaseMouse();
        if (qt_pressGrab == this)
          qt_pressGrab = 0;

        if (keyboardGrb == this)
            releaseKeyboard();
        if (testAttribute(Qt::WA_ShowModal))                // just be sure we leave modal
            QApplicationPrivate::leaveModal(this);
        else if ((windowType() == Qt::Popup))
            qApp->d_func()->closePopup(this);
#ifndef QT_NO_IM
        if (d->ic) {
            delete d->ic;
            d->ic =0;
        } else {
            // release previous focus information participating with
            // preedit preservation of qic -- while we still have a winId
            QInputContext *qic = QApplicationPrivate::inputContext;
            if (qic)
                qic->widgetDestroyed(this);
        }
#endif //QT_NO_IM

        if ((windowType() == Qt::Desktop)) {
        } else {
            if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) {
                d->hide_sys();
            }
            if (destroyWindow && isWindow()) {
                if (d->extra && d->extra->topextra && d->extra->topextra->backingStore)
                    d->extra->topextra->backingStore->windowSurface->setGeometry(QRect());
                qwsDisplay()->destroyRegion(internalWinId());
            }
        }
        QT_TRY {
            d->setWinId(0);
        } QT_CATCH (const std::bad_alloc &) {
            // swallow - destructors must not throw
        }
    }
}
Пример #11
0
bool QWSInputContext::translateIMEvent(QWidget *w, const QWSIMEvent *e)
{
    QDataStream stream(e->streamingData);
    QString preedit;
    QString commit;

    stream >> preedit;
    stream >> commit;

    if (preedit.isEmpty() && QT_PREPEND_NAMESPACE(activeWidget))
        w = QT_PREPEND_NAMESPACE(activeWidget);

    QInputContext *qic = w->inputContext();
    if (!qic)
        return false;

    QList<QInputMethodEvent::Attribute> attrs;


    while (!stream.atEnd()) {
        int type = -1;
        int start = -1;
        int length = -1;
        QVariant data;
        stream >> type >> start >> length >> data;
        if (stream.status() != QDataStream::Ok) {
            qWarning("corrupted QWSIMEvent");
            //qic->reset(); //???
            return false;
        }
        if (type == QInputMethodEvent::TextFormat)
            data = qic->standardFormat(static_cast<QInputContext::StandardFormat>(data.toInt()));
        attrs << QInputMethodEvent::Attribute(static_cast<QInputMethodEvent::AttributeType>(type), start, length, data);
    }
#ifdef EXTRA_DEBUG
    qDebug() << "preedit" << preedit << "len" << preedit.length() <<"commit" << commit << "len" << commit.length()
             << "n attr" << attrs.count();
#endif

    if (preedit.isEmpty())
        QT_PREPEND_NAMESPACE(activeWidget) = 0;
    else
        QT_PREPEND_NAMESPACE(activeWidget) = w;


    QInputMethodEvent ime(preedit, attrs);
    if (!commit.isEmpty() || e->simpleData.replaceLength > 0)
        ime.setCommitString(commit, e->simpleData.replaceFrom, e->simpleData.replaceLength);


    extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); //qapplication_qws.cpp
    qt_sendSpontaneousEvent(w, &ime);

    return true;
}
Пример #12
0
void QtopiaInputDialogPrivate::_q_preedit(QString text)
{
    QList<QInputMethodEvent::Attribute> attributes;
    QInputContext *qic = m_widget->inputContext();
    QVariant data = qic->standardFormat(QInputContext::PreeditFormat);
    attributes << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, text.length(), data);
    //QInputMethodEvent *ime = new QInputMethodEvent(text, attributes);
    //QApplication::postEvent(m_widget, ime);
    QInputMethodEvent ime(text, attributes);
    QApplication::sendEvent(m_widget, &ime);
}
Пример #13
0
void QGraphicsWebViewPrivate::_q_updateMicroFocus()
{
    // Ideally, this should be handled by a common call to an updateMicroFocus function
    // in QGraphicsItem. See http://bugreports.qt.nokia.com/browse/QTBUG-7578.
    QList<QGraphicsView*> views = q->scene()->views();
    for (int c = 0; c < views.size(); ++c) {
        QInputContext* ic = views.at(c)->inputContext();
        if (ic)
            ic->update();
    }
}
Пример #14
0
void MDeclarativeScreen::sendClicked(int x, int y, int position) const
{
    QInputContext *ic = qApp->inputContext();

    if (ic != NULL) {
        QEvent::Type mouseEventType(QEvent::MouseButtonRelease);
        QPoint mousePoint(x,y);
        QMouseEvent mouseEvent(mouseEventType, mousePoint, Qt::LeftButton,
                               Qt::LeftButton, Qt::NoModifier);
        int preeditOffset = 0;
        ic->mouseHandler(preeditOffset, &mouseEvent);
    }
}
Пример #15
0
void QGraphicsWebViewPrivate::_q_updateMicroFocus()
{
#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
    // Ideally, this should be handled by a common call to an updateMicroFocus function
    // in QGraphicsItem. See http://bugreports.qt.nokia.com/browse/QTBUG-7578.
    QList<QGraphicsView*> views = q->scene()->views();
    for (int c = 0; c < views.size(); ++c) {
        QInputContext* ic = views.at(c)->inputContext();
        if (ic)
            ic->update();
    }
#endif
}
Пример #16
0
/*!
  Sends an input method event specified by \a event to the current focus
  widget. Implementations of QInputContext should call this method to
  send the generated input method events and not
  QApplication::sendEvent(), as the events might have to get dispatched
  to a different application on some platforms.

  Some complex input methods route the handling to several child
  contexts (e.g. to enable language switching). To account for this,
  QInputContext will check if the parent object is a QInputContext. If
  yes, it will call the parents sendEvent() implementation instead of
  sending the event directly.

  \sa QInputMethodEvent
*/
void QInputContext::sendEvent(const QInputMethodEvent &event)
{
    // route events over input context parents to make chaining possible.
    QInputContext *p = qobject_cast<QInputContext *>(parent());
    if (p) {
        p->sendEvent(event);
        return;
    }

    QWidget *focus = focusWidget();
    if (!focus)
	return;

    QInputMethodEvent e(event);
    qApp->sendEvent(focus, &e);
}
Пример #17
0
void QMultiInputContext::changeSlave(QAction *a)
{
    for (int i = 0; i < slaves.size(); ++i) {
        if (keys.at(i) == a->data().toString()) {
            if (slaves.at(i) == 0)
                slaves.replace(i, QInputContextFactory::create(keys.at(i), this));
            QInputContext *qic = slaves.at(current);
            QWidget *oldWidget = qic->focusWidget();
            qic->reset();
            qic->setFocusWidget(0);
            current = i;
            qic = slaves.at(current);
            qic->setFocusWidget(oldWidget);
            return;
        }
    }
}
void HbInputAbstractMethod::focusReceived()
{
    bool isVannilaApp = false;
    QInputContext* context = qApp->inputContext();
    if (context && context->focusWidget()) {
        QWidget *focusedWidget = context->focusWidget();
        if (!focusedWidget->inherits("HbMainWindow")) {
            isVannilaApp = true;
        }
    }
    
    if(isVannilaApp && focusObject() ) {
        QList<HbAction*> customActions= focusObject()->editorInterface().actions();
        if(!customActions.contains(mVanillQwertySwitch)) {
            disconnect(mVanillQwertySwitch, SIGNAL(triggered(bool)));
            connect(mVanillQwertySwitch, SIGNAL(triggered(bool)), this, SLOT(switchKeypad(bool)));
            focusObject()->editorInterface().addAction(mVanillQwertySwitch);
        }
bool MDeclarativeIMObserver::sceneEventFilter(QGraphicsItem * watched, QEvent * event)
{
    if (event->type()==QEvent::InputMethod) {        
        if (m_omitInputMethodEvents) {
            return true;
        }

        QInputMethodEvent *ime = static_cast<QInputMethodEvent*>(event);
		QString newPreedit = ime->preeditString();
		
        QGraphicsObject *g = parentObject();
        if (g != 0 && g->property("maximumLength").isValid()) {
            int maximumTextLength = g->property("maximumLength").toInt();
            int textLength = g->property("text").toString().length();
            int selectedTextLength = g->property("selectedText").toString().length();
            if (textLength == maximumTextLength &&
                newPreedit.length() - ime->replacementLength() > 0 &&
                selectedTextLength == 0) {
                    m_omitInputMethodEvents = true;
                    QInputContext *ic = qApp->inputContext();
                    ic->reset();
                    m_omitInputMethodEvents = false;
                    return true;
            }				
        }

        if (newPreedit!=m_preedit) {
            m_preedit = newPreedit;
            emit preeditChanged();
        }
        
        QList<QInputMethodEvent::Attribute> attributes = ime->attributes();
        QList<QInputMethodEvent::Attribute>::iterator i;
        for (i = attributes.begin(); i != attributes.end(); ++i) {
            QInputMethodEvent::Attribute attribute = *i;
            if (attribute.type == QInputMethodEvent::Cursor) {
                m_preeditCursorPosition = attribute.start;
                emit preeditCursorPositionChanged();
            }
        }
    }

    return QDeclarativeItem::sceneEventFilter(watched,event);
}
Пример #20
0
void QWebPopup::hidePopup()
{
    QWidget* activeFocus = QApplication::focusWidget();
    if (activeFocus && activeFocus == view()
        && activeFocus->testAttribute(Qt::WA_InputMethodEnabled)) {
        QInputContext* qic = activeFocus->inputContext();
        if (qic) {
            qic->reset();
            qic->setFocusWidget(0);
        }
    }

    QComboBox::hidePopup();
    if (!m_popupVisible)
        return;

    m_popupVisible = false;
    m_client->popupDidHide();
}
Пример #21
0
 bool eventFilter(QObject *obj, QEvent *event) {
     QInputContext *ic = qApp->inputContext();
     if (ic) {
         if (ic->focusWidget() == 0 && prevFocusWidget) {
             QEvent closeSIPEvent(QEvent::CloseSoftwareInputPanel);
             ic->filterEvent(&closeSIPEvent);
         } else if (prevFocusWidget == 0 && ic->focusWidget()) {
             QEvent openSIPEvent(QEvent::RequestSoftwareInputPanel);
             ic->filterEvent(&openSIPEvent);
         }
         prevFocusWidget = ic->focusWidget();
     }
     return QObject::eventFilter(obj,event);
 }