summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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();