summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/blackberry/qbbvirtualkeyboard.cpp
diff options
context:
space:
mode:
authorKevin Krammer <kevin.krammer.qnx@kdab.com>2012-03-23 16:35:33 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-03-30 12:40:19 (GMT)
commitacbdd48f4401f2cc9b48eb3bd79d957b1c4e2949 (patch)
tree1ba3d566175d22dd00f67d200e2c1ad0751b460a /src/plugins/platforms/blackberry/qbbvirtualkeyboard.cpp
parent69a50ee68bb870b3ba0d95a35ab8b6bc4e1a461f (diff)
downloadQt-acbdd48f4401f2cc9b48eb3bd79d957b1c4e2949.zip
Qt-acbdd48f4401f2cc9b48eb3bd79d957b1c4e2949.tar.gz
Qt-acbdd48f4401f2cc9b48eb3bd79d957b1c4e2949.tar.bz2
Refactoring virtual keyboard class into non-singleton
Getting rid of the singleton gives us better control over when the virtual keyboard handling class is instantiated and configured. Also notify screens about keyboard height changes and let them notify through QWindowSystemInterface instead of "guessing" the screen in QQnxVirtualKeyboard. Backport of 5d117fd427e3e727df5d3f417a2b91366f2a31c1 Change-Id: I49c1a6af5decca47a5ab3ba382430a2b25578d40 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Diffstat (limited to 'src/plugins/platforms/blackberry/qbbvirtualkeyboard.cpp')
-rw-r--r--src/plugins/platforms/blackberry/qbbvirtualkeyboard.cpp46
1 files changed, 15 insertions, 31 deletions
diff --git a/src/plugins/platforms/blackberry/qbbvirtualkeyboard.cpp b/src/plugins/platforms/blackberry/qbbvirtualkeyboard.cpp
index 3022dc8..0f1a16e 100644
--- a/src/plugins/platforms/blackberry/qbbvirtualkeyboard.cpp
+++ b/src/plugins/platforms/blackberry/qbbvirtualkeyboard.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-//#define QBBVIRTUALKEYBOARD_DEBUG
+#define QBBVIRTUALKEYBOARD_DEBUG
#include "qbbvirtualkeyboard.h"
@@ -58,11 +58,12 @@
#include <sys/types.h>
#include <unistd.h>
+
+QT_BEGIN_NAMESPACE
+
const char *QBBVirtualKeyboard::sPPSPath = "/pps/services/input/control?wait";
const size_t QBBVirtualKeyboard::sBufferSize = 2048;
-static QBBVirtualKeyboard* s_instance = NULL;
-
// Huge hack for keyboard shadow (see QNX PR 88400). Should be removed ASAP.
#define KEYBOARD_SHADOW_HEIGHT 8
@@ -85,20 +86,6 @@ QBBVirtualKeyboard::~QBBVirtualKeyboard()
close();
}
-/* static */
-QBBVirtualKeyboard& QBBVirtualKeyboard::instance()
-{
- if (!s_instance) {
- s_instance = new QBBVirtualKeyboard();
-
- // delay invocation of start() to the time the event loop is up and running
- // needed to have the QThread internals of the main thread properly initialized
- QMetaObject::invokeMethod(s_instance, "start", Qt::QueuedConnection);
- }
-
- return *s_instance;
-}
-
void QBBVirtualKeyboard::start()
{
#ifdef QBBVIRTUALKEYBOARD_DEBUG
@@ -109,15 +96,6 @@ void QBBVirtualKeyboard::start()
return;
}
-/* static */
-void QBBVirtualKeyboard::destroy()
-{
- if (s_instance) {
- delete s_instance;
- s_instance = 0;
- }
-}
-
void QBBVirtualKeyboard::close()
{
delete mReadNotifier;
@@ -289,7 +267,8 @@ void QBBVirtualKeyboard::handleKeyboardInfoMessage()
if (newHeight != mHeight) {
mHeight = newHeight;
- handleKeyboardStateChangeMessage(true);
+ if (mVisible)
+ emit heightChanged(mHeight);
}
#ifdef QBBVIRTUALKEYBOARD_DEBUG
@@ -304,10 +283,8 @@ void QBBVirtualKeyboard::handleKeyboardStateChangeMessage(bool visible)
qDebug() << "QBB: handleKeyboardStateChangeMessage " << visible;
#endif
- // TODO: What screen index should be used? I assume 0 here because it works, and
- // we do it for handleScreenGeometryChange elsewhere but since we have support
- // for more than one screen, that's not going to always work.
- QWindowSystemInterface::handleScreenAvailableGeometryChange(0);
+ if (mVisible != visible)
+ emit heightChanged(getHeight());
}
bool QBBVirtualKeyboard::showKeyboard()
@@ -375,7 +352,12 @@ bool QBBVirtualKeyboard::hideKeyboard()
void QBBVirtualKeyboard::setKeyboardMode(KeyboardMode mode)
{
+ if (mKeyboardMode == mode)
+ return;
+
mKeyboardMode = mode;
+ if (mVisible)
+ applyKeyboardModeOptions();
}
void QBBVirtualKeyboard::applyKeyboardModeOptions()
@@ -472,3 +454,5 @@ void QBBVirtualKeyboard::addSymbolModeOptions()
pps_encoder_add_string(mEncoder, "enter", "enter.default");
pps_encoder_add_string(mEncoder, "type", "symbol");
}
+
+QT_END_NAMESPACE