diff options
Diffstat (limited to 'src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp')
-rw-r--r-- | src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp | 192 |
1 files changed, 73 insertions, 119 deletions
diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp index 20fce3da70..2b6ee3d1dc 100644 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp +++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp @@ -67,9 +67,6 @@ QT_BEGIN_NAMESPACE const char *QQnxVirtualKeyboardPps::ms_PPSPath = "/pps/services/input/control"; const size_t QQnxVirtualKeyboardPps::ms_bufferSize = 2048; -// Huge hack for keyboard shadow (see QNX PR 88400). Should be removed ASAP. -#define KEYBOARD_SHADOW_HEIGHT 8 - QQnxVirtualKeyboardPps::QQnxVirtualKeyboardPps() : m_encoder(0), m_decoder(0), @@ -91,11 +88,6 @@ void QQnxVirtualKeyboardPps::start() return; } -void QQnxVirtualKeyboardPps::applyKeyboardMode(KeyboardMode mode) -{ - applyKeyboardModeOptions(mode); -} - void QQnxVirtualKeyboardPps::close() { delete m_readNotifier; @@ -159,18 +151,14 @@ bool QQnxVirtualKeyboardPps::connect() bool QQnxVirtualKeyboardPps::queryPPSInfo() { + if (!prepareToSend()) + return false; + // Request info, requires id to regenerate res message. pps_encoder_add_string(m_encoder, "msg", "info"); pps_encoder_add_string(m_encoder, "id", "libWebView"); - if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { - close(); - return false; - } - - pps_encoder_reset(m_encoder); - - return true; + return writeCurrentPPSEncoder(); } void QQnxVirtualKeyboardPps::ppsDataReady() @@ -257,9 +245,6 @@ void QQnxVirtualKeyboardPps::handleKeyboardInfoMessage() } const QString countryId = QString::fromLatin1(value); - // HUGE hack, should be removed ASAP. - newHeight -= KEYBOARD_SHADOW_HEIGHT; // We want to ignore the 8 pixel shadow above the keyboard. (PR 88400) - setHeight(newHeight); const QLocale locale = QLocale(languageId + QLatin1Char('_') + countryId); @@ -272,13 +257,12 @@ bool QQnxVirtualKeyboardPps::showKeyboard() { qVirtualKeyboardDebug() << Q_FUNC_INFO; - // Try to connect. - if (m_fd == -1 && !connect()) + if (!prepareToSend()) return false; // NOTE: This must be done everytime the keyboard is shown even if there is no change because // hiding the keyboard wipes the setting. - applyKeyboardModeOptions(keyboardMode()); + applyKeyboardOptions(); if (isVisible()) return true; @@ -288,140 +272,110 @@ bool QQnxVirtualKeyboardPps::showKeyboard() // Send the show message. pps_encoder_add_string(m_encoder, "msg", "show"); - if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { - close(); - return false; - } - - pps_encoder_reset(m_encoder); - - // Return true if no error occurs. Sizing response will be triggered when confirmation of - // the change arrives. - return true; + return writeCurrentPPSEncoder(); } bool QQnxVirtualKeyboardPps::hideKeyboard() { qVirtualKeyboardDebug() << Q_FUNC_INFO; - if (m_fd == -1 && !connect()) + if (!prepareToSend()) return false; pps_encoder_add_string(m_encoder, "msg", "hide"); - if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { - close(); + return writeCurrentPPSEncoder(); +} - //Try again. - if (connect()) { - if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { - close(); - return false; - } - } - else - return false; - } +bool QQnxVirtualKeyboardPps::prepareToSend() +{ + if (m_fd == -1 && !connect()) + return false; pps_encoder_reset(m_encoder); + return true; +} - // Return true if no error occurs. Sizing response will be triggered when confirmation of - // the change arrives. +bool QQnxVirtualKeyboardPps::writeCurrentPPSEncoder() +{ + if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { + close(); + return false; + } return true; } -void QQnxVirtualKeyboardPps::applyKeyboardModeOptions(KeyboardMode mode) +void QQnxVirtualKeyboardPps::applyKeyboardOptions() { - // Try to connect. - if (m_fd == -1 && !connect()) + if (!prepareToSend()) return; // Send the options message. pps_encoder_add_string(m_encoder, "msg", "options"); - pps_encoder_start_object(m_encoder, "dat"); - switch (mode) { + + pps_encoder_add_string(m_encoder, "enter", enterKeyTypeStr()); + pps_encoder_add_string(m_encoder, "type", keyboardModeStr()); + + pps_encoder_end_object(m_encoder); + + writeCurrentPPSEncoder(); +} + +const char* QQnxVirtualKeyboardPps::keyboardModeStr() const +{ + switch (keyboardMode()) { case Url: - addUrlModeOptions(); - break; + return "url"; case Email: - addEmailModeOptions(); - break; + return "email"; case Web: - addWebModeOptions(); - break; + return "web"; case NumPunc: - addNumPuncModeOptions(); - break; + return "num_punc"; + case Number: + return "number"; case Symbol: - addSymbolModeOptions(); - break; + return "symbol"; case Phone: - addPhoneModeOptions(); - break; + return "phone"; case Pin: - addPinModeOptions(); - break; + return "pin"; + case Password: + return "password"; + case Alphanumeric: + return "alphanumeric"; case Default: - default: - addDefaultModeOptions(); - break; + return "default"; } - pps_encoder_end_object(m_encoder); - - if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) - close(); - - pps_encoder_reset(m_encoder); -} - -void QQnxVirtualKeyboardPps::addDefaultModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "default"); + return ""; } -void QQnxVirtualKeyboardPps::addUrlModeOptions() +const char* QQnxVirtualKeyboardPps::enterKeyTypeStr() const { - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "url"); -} - -void QQnxVirtualKeyboardPps::addEmailModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "email"); -} - -void QQnxVirtualKeyboardPps::addWebModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "web"); -} - -void QQnxVirtualKeyboardPps::addNumPuncModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "numPunc"); -} - -void QQnxVirtualKeyboardPps::addPhoneModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "phone"); -} - -void QQnxVirtualKeyboardPps::addPinModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "pin"); -} + switch (enterKeyType()) { + case DefaultReturn: + return "enter.default"; + case Connect: + return "enter.connect"; + case Done: + return "enter.done"; + case Go: + return "enter.go"; + case Join: + return "enter.join"; + case Next: + return "enter.next"; + case Search: + return "enter.search"; + case Send: + return "enter.send"; + case Submit: + return "enter.submit"; + } -void QQnxVirtualKeyboardPps::addSymbolModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "symbol"); + return ""; } QT_END_NAMESPACE |