qqnxinputcontext: Add support for EnterKeyType

Change-Id: I03b9d70b9bb05cd28fdcbb076764a2e1d9e3e0e3
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
This commit is contained in:
Kai Uwe Broulik 2015-06-02 17:13:38 +02:00
parent 49f7281d36
commit 287e944def
4 changed files with 33 additions and 2 deletions

View File

@ -124,4 +124,25 @@ void QQnxAbstractVirtualKeyboard::setLocale(const QLocale &locale)
emit localeChanged(locale);
}
QQnxAbstractVirtualKeyboard::EnterKeyType
QQnxAbstractVirtualKeyboard::qtEnterKeyTypeToQnx(Qt::EnterKeyType type)
{
switch (type) {
case Qt::EnterKeyDone:
return Done;
case Qt::EnterKeyGo:
return Go;
case Qt::EnterKeyNext:
return Next;
case Qt::EnterKeySearch:
return Search;
case Qt::EnterKeySend:
return Send;
case Qt::EnterKeyDefault:
case Qt::EnterKeyReturn:
case Qt::EnterKeyPrevious: // unsupported
return DefaultReturn;
}
}
QT_END_NAMESPACE

View File

@ -74,6 +74,8 @@ public:
KeyboardMode keyboardMode() const { return m_keyboardMode; }
EnterKeyType enterKeyType() const { return m_enterKeyType; }
static EnterKeyType qtEnterKeyTypeToQnx(Qt::EnterKeyType type);
Q_SIGNALS:
void heightChanged(int height);
void visibilityChanged(bool visible);

View File

@ -1384,13 +1384,17 @@ void QQnxInputContext::setFocusObject(QObject *object)
if (hasSession())
dispatchFocusLossEvent();
} else {
QInputMethodQueryEvent query(Qt::ImHints);
QInputMethodQueryEvent query(Qt::ImHints | Qt::ImEnterKeyType);
QCoreApplication::sendEvent(object, &query);
int inputHints = query.value(Qt::ImHints).toInt();
Qt::EnterKeyType qtEnterKeyType = Qt::EnterKeyType(query.value(Qt::ImEnterKeyType).toInt());
dispatchFocusGainEvent(inputHints);
m_virtualKeyboard.setInputHints(inputHints);
m_virtualKeyboard.setEnterKeyType(
QQnxAbstractVirtualKeyboard::qtEnterKeyTypeToQnx(qtEnterKeyType)
);
if (!m_inputPanelVisible)
showInputPanel();

View File

@ -172,11 +172,15 @@ void QQnxInputContext::setFocusObject(QObject *object)
if (m_inputPanelVisible)
hideInputPanel();
} else {
QInputMethodQueryEvent query(Qt::ImHints);
QInputMethodQueryEvent query(Qt::ImHints | Qt::ImEnterKeyType);
QCoreApplication::sendEvent(object, &query);
int inputHints = query.value(Qt::ImHints).toInt();
Qt::EnterKeyType qtEnterKeyType = Qt::EnterKeyType(query.value(Qt::ImEnterKeyType).toInt());
m_virtualKeyboard.setInputHints(inputHints);
m_virtualKeyboard.setEnterKeyType(
QQnxAbstractVirtualKeyboard::qtEnterKeyTypeToQnx(qtEnterKeyType)
);
if (!m_inputPanelVisible)
showInputPanel();