summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas McGuire <thomas.mcguire.qnx@kdab.com>2012-10-01 09:57:06 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-02 08:41:53 (GMT)
commita6717650711b107c96caf757f3aa91190a8bb52e (patch)
treea4a395f8ee4f57e32c70c4d775c689c3ef05e391
parentc3473c89fe66e32a36815e969f81480562d8ce12 (diff)
downloadQt-a6717650711b107c96caf757f3aa91190a8bb52e.zip
Qt-a6717650711b107c96caf757f3aa91190a8bb52e.tar.gz
Qt-a6717650711b107c96caf757f3aa91190a8bb52e.tar.bz2
Blackberry: Support input method hints
This is a backport of qtbase commit d162f276714f04b07827dfd525deea45dc55a5f1 Change-Id: I3ae3994d305eebd61773e175332cecfa1d9cde51 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/plugins/platforms/blackberry/qbbabstractvirtualkeyboard.cpp21
-rw-r--r--src/plugins/platforms/blackberry/qbbabstractvirtualkeyboard.h1
-rw-r--r--src/plugins/platforms/blackberry/qbbinputcontext_noimf.cpp5
3 files changed, 23 insertions, 4 deletions
diff --git a/src/plugins/platforms/blackberry/qbbabstractvirtualkeyboard.cpp b/src/plugins/platforms/blackberry/qbbabstractvirtualkeyboard.cpp
index 331ec7c..5da7c1a 100644
--- a/src/plugins/platforms/blackberry/qbbabstractvirtualkeyboard.cpp
+++ b/src/plugins/platforms/blackberry/qbbabstractvirtualkeyboard.cpp
@@ -41,6 +41,8 @@
#include "qbbabstractvirtualkeyboard.h"
+#include <QWidget>
+
QT_BEGIN_NAMESPACE
QBBAbstractVirtualKeyboard::QBBAbstractVirtualKeyboard(QObject *parent)
@@ -63,6 +65,25 @@ void QBBAbstractVirtualKeyboard::setKeyboardMode(KeyboardMode mode)
applyKeyboardMode(mode);
}
+void QBBAbstractVirtualKeyboard::setInputHintsFromWidget(QWidget *focusWidget)
+{
+ if (focusWidget) {
+ const Qt::InputMethodHints hints = focusWidget->inputMethodHints();
+ if (hints & Qt::ImhEmailCharactersOnly)
+ setKeyboardMode(QBBAbstractVirtualKeyboard::Email);
+ else if (hints & Qt::ImhDialableCharactersOnly)
+ setKeyboardMode(QBBAbstractVirtualKeyboard::Phone);
+ else if (hints & Qt::ImhUrlCharactersOnly)
+ setKeyboardMode(QBBAbstractVirtualKeyboard::Web);
+ else if (hints & Qt::ImhFormattedNumbersOnly || hints & Qt::ImhDigitsOnly)
+ setKeyboardMode(QBBAbstractVirtualKeyboard::NumPunc);
+ else
+ setKeyboardMode(QBBAbstractVirtualKeyboard::Default);
+ } else {
+ setKeyboardMode(QBBAbstractVirtualKeyboard::Default);
+ }
+}
+
void QBBAbstractVirtualKeyboard::setVisible(bool visible)
{
if (visible == mVisible)
diff --git a/src/plugins/platforms/blackberry/qbbabstractvirtualkeyboard.h b/src/plugins/platforms/blackberry/qbbabstractvirtualkeyboard.h
index 072648d..d0d3109 100644
--- a/src/plugins/platforms/blackberry/qbbabstractvirtualkeyboard.h
+++ b/src/plugins/platforms/blackberry/qbbabstractvirtualkeyboard.h
@@ -71,6 +71,7 @@ public:
int getHeight() const { return mVisible ? mHeight : 0; }
void setKeyboardMode(KeyboardMode mode);
+ void setInputHintsFromWidget(QWidget *focusWidget);
KeyboardMode keyboardMode() const { return mKeyboardMode; }
bool isVisible() const { return mVisible; }
diff --git a/src/plugins/platforms/blackberry/qbbinputcontext_noimf.cpp b/src/plugins/platforms/blackberry/qbbinputcontext_noimf.cpp
index 96cde22..2e35bff 100644
--- a/src/plugins/platforms/blackberry/qbbinputcontext_noimf.cpp
+++ b/src/plugins/platforms/blackberry/qbbinputcontext_noimf.cpp
@@ -118,10 +118,7 @@ void QBBInputContext::setFocusWidget(QWidget *w)
if (qobject_cast<QAbstractItemView*>(w))
return;
- if (qobject_cast<QAbstractSpinBox*>(w))
- mVirtualKeyboard.setKeyboardMode(QBBAbstractVirtualKeyboard::Phone);
- else
- mVirtualKeyboard.setKeyboardMode(QBBAbstractVirtualKeyboard::Default);
+ mVirtualKeyboard.setInputHintsFromWidget(w);
mVirtualKeyboard.showKeyboard();
} else {
mVirtualKeyboard.hideKeyboard();