Пример #1
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
        }
    }
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
 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);
 }
Пример #4
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
}
Пример #5
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
}