qqnxvirtualkeyboard.cpp \
qqnxclipboard.cpp \
qqnxrootwindow.cpp \
- qqnxscreeneventhandler.cpp
+ qqnxscreeneventhandler.cpp \
+ qqnxabstractvirtualkeyboard.cpp
HEADERS = qqnxbuffer.h \
qqnxvirtualkeyboard.h \
qqnxclipboard.h \
qqnxrootwindow.h \
- qqnxscreeneventhandler.h
+ qqnxscreeneventhandler.h \
+ qqnxabstractvirtualkeyboard.h
CONFIG(blackberry) {
SOURCES += qqnxservices.cpp
--- /dev/null
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqnxabstractvirtualkeyboard.h"
+
+QT_BEGIN_NAMESPACE
+
+QQnxAbstractVirtualKeyboard::QQnxAbstractVirtualKeyboard(QObject *parent)
+ : QObject(parent)
+ , m_height(0)
+ , m_visible(false)
+ , m_locale(QLocale::system())
+ , m_keyboardMode(Default)
+{
+}
+
+void QQnxAbstractVirtualKeyboard::setKeyboardMode(KeyboardMode mode)
+{
+ if (mode == m_keyboardMode)
+ return;
+
+ m_keyboardMode = mode;
+
+ applyKeyboardMode(mode);
+}
+
+void QQnxAbstractVirtualKeyboard::setHeight(int height)
+{
+ if (height == m_height)
+ return;
+
+ const int effectiveHeight = this->height();
+
+ m_height = height;
+
+ if (effectiveHeight != this->height())
+ emit heightChanged(this->height());
+}
+
+void QQnxAbstractVirtualKeyboard::setVisible(bool visible)
+{
+ if (visible == m_visible)
+ return;
+
+ const int effectiveHeight = height();
+
+ m_visible = visible;
+
+ emit visibilityChanged(visible);
+
+ if (effectiveHeight != height())
+ emit heightChanged(height());
+}
+
+void QQnxAbstractVirtualKeyboard::setLocale(const QLocale &locale)
+{
+ if (locale == m_locale)
+ return;
+
+ m_locale = locale;
+
+ emit localeChanged(locale);
+}
+
+QT_END_NAMESPACE
--- /dev/null
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQNXABSTRACTVIRTUALKEYBOARD_H
+#define QQNXABSTRACTVIRTUALKEYBOARD_H
+
+#include <QLocale>
+#include <QObject>
+
+QT_BEGIN_NAMESPACE
+
+class QQnxAbstractVirtualKeyboard : public QObject
+{
+ Q_OBJECT
+public:
+ // NOTE: Not all the following keyboard modes are currently used.
+ // Default - Regular Keyboard
+ // Url/Email - Enhanced keys for each types.
+ // Web - Regular keyboard with two blank keys, currently unused.
+ // NumPunc - Numbers & Punctionation, alternate to Symbol
+ // Symbol - All symbols, alternate to NumPunc, currently unused.
+ // Phone - Phone enhanced keyboard - currently unused as no alternate keyboard available to access a-zA-Z
+ // Pin - Keyboard for entering Pins (Hex values) currently unused.
+ //
+ // SPECIAL NOTE: Usage of NumPunc may have to be removed, ABC button is non-functional.
+ //
+ enum KeyboardMode { Default, Url, Email, Web, NumPunc, Symbol, Phone, Pin };
+
+ explicit QQnxAbstractVirtualKeyboard(QObject *parent = 0);
+
+ virtual bool showKeyboard() = 0;
+ virtual bool hideKeyboard() = 0;
+
+ int height() { return m_visible ? m_height : 0; }
+ bool isVisible() const { return m_visible; }
+ QLocale locale() const { return m_locale; }
+
+ void setKeyboardMode(KeyboardMode mode);
+ KeyboardMode keyboardMode() const { return m_keyboardMode; }
+
+Q_SIGNALS:
+ void heightChanged(int height);
+ void visibilityChanged(bool visible);
+ void localeChanged(const QLocale &locale);
+
+protected:
+ virtual void applyKeyboardMode(KeyboardMode mode) = 0;
+
+ void setHeight(int height);
+ void setVisible(bool visible);
+ void setLocale(const QLocale &locale);
+
+private:
+ int m_height;
+ bool m_visible;
+ QLocale m_locale;
+ KeyboardMode m_keyboardMode;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQNXABSTRACTVIRTUALKEYBOARD_H
#include "qqnxinputcontext_imf.h"
#include "qqnxeventthread.h"
-#include "qqnxvirtualkeyboard.h"
+#include "qqnxabstractvirtualkeyboard.h"
#include <QtWidgets/QAbstractSpinBox>
#include <QtWidgets/QAction>
QT_BEGIN_NAMESPACE
-QQnxInputContext::QQnxInputContext(QQnxVirtualKeyboard &keyboard):
+QQnxInputContext::QQnxInputContext(QQnxAbstractVirtualKeyboard &keyboard):
QPlatformInputContext(),
m_lastCaretPos(0),
m_isComposing(false),
hideInputPanel();
} else {
if (qobject_cast<QAbstractSpinBox*>(inputItem))
- m_virtualKeyboard.setKeyboardMode(QQnxVirtualKeyboard::Phone);
+ m_virtualKeyboard.setKeyboardMode(QQnxAbstractVirtualKeyboard::Phone);
else
- m_virtualKeyboard.setKeyboardMode(QQnxVirtualKeyboard::Default);
+ m_virtualKeyboard.setKeyboardMode(QQnxAbstractVirtualKeyboard::Default);
if (!m_inputPanelVisible)
showInputPanel();
QT_BEGIN_NAMESPACE
-class QQnxVirtualKeyboard;
+class QQnxAbstractVirtualKeyboard;
class QQnxInputContext : public QPlatformInputContext
{
Q_OBJECT
public:
- QQnxInputContext(QQnxVirtualKeyboard &keyboard);
+ explicit QQnxInputContext(QQnxAbstractVirtualKeyboard &keyboard);
~QQnxInputContext();
bool isValid() const;
QString m_composingText;
bool m_inputPanelVisible;
QLocale m_inputPanelLocale;
- QQnxVirtualKeyboard &m_virtualKeyboad;
+ QQnxAbstractVirtualKeyboard &m_virtualKeyboad;
};
Q_DECLARE_METATYPE(extracted_text_t*)
****************************************************************************/
#include "qqnxinputcontext_noimf.h"
-#include "qqnxvirtualkeyboard.h"
+#include "qqnxabstractvirtualkeyboard.h"
#include <QtCore/QDebug>
#include <QtGui/QGuiApplication>
QT_BEGIN_NAMESPACE
-QQnxInputContext::QQnxInputContext(QQnxVirtualKeyboard &keyboard) :
+QQnxInputContext::QQnxInputContext(QQnxAbstractVirtualKeyboard &keyboard) :
QPlatformInputContext(),
m_inputPanelVisible(false),
m_inputPanelLocale(QLocale::c()),
hideInputPanel();
} else {
if (qobject_cast<QAbstractSpinBox*>(inputItem))
- m_virtualKeyboard.setKeyboardMode(QQnxVirtualKeyboard::Phone);
+ m_virtualKeyboard.setKeyboardMode(QQnxAbstractVirtualKeyboard::Phone);
else
- m_virtualKeyboard.setKeyboardMode(QQnxVirtualKeyboard::Default);
+ m_virtualKeyboard.setKeyboardMode(QQnxAbstractVirtualKeyboard::Default);
if (!m_inputPanelVisible)
showInputPanel();
QT_BEGIN_NAMESPACE
-class QQnxVirtualKeyboard;
+class QQnxAbstractVirtualKeyboard;
class QQnxInputContext : public QPlatformInputContext
{
Q_OBJECT
public:
- explicit QQnxInputContext(QQnxVirtualKeyboard &keyboard);
+ explicit QQnxInputContext(QQnxAbstractVirtualKeyboard &keyboard);
~QQnxInputContext();
bool isValid() const;
bool m_inputPanelVisible;
QLocale m_inputPanelLocale;
- QQnxVirtualKeyboard &m_virtualKeyboard;
+ QQnxAbstractVirtualKeyboard &m_virtualKeyboard;
};
QT_END_NAMESPACE
class QQnxEventThread;
class QQnxInputContext;
class QQnxNavigatorEventHandler;
-class QQnxVirtualKeyboard;
+class QQnxAbstractVirtualKeyboard;
class QQnxWindow;
class QQnxServices;
screen_context_t m_screenContext;
QQnxEventThread *m_eventThread;
QQnxNavigatorEventHandler *m_navigatorEventHandler;
- QQnxVirtualKeyboard *m_virtualKeyboard;
+ QQnxAbstractVirtualKeyboard *m_virtualKeyboard;
QQnxInputContext *m_inputContext;
QPlatformFontDatabase *m_fontDatabase;
bool m_paintUsingOpenGL;
: m_encoder(0),
m_decoder(0),
m_buffer(0),
- m_height(0),
m_fd(-1),
- m_keyboardMode(Default),
- m_visible(false),
- m_locale(QLatin1String("en_US")),
m_readNotifier(0)
{
}
return;
}
+void QQnxVirtualKeyboard::applyKeyboardMode(KeyboardMode mode)
+{
+ applyKeyboardModeOptions(mode);
+}
+
void QQnxVirtualKeyboard::close()
{
delete m_readNotifier;
return true;
}
-void QQnxVirtualKeyboard::notifyClientActiveStateChange(bool active)
-{
- if (!active)
- hideKeyboard();
-}
-
void QQnxVirtualKeyboard::ppsDataReady()
{
ssize_t nread = qt_safe_read(m_fd, m_buffer, ms_bufferSize - 1);
if (pps_decoder_get_string(m_decoder, "msg", &value) == PPS_DECODER_OK) {
if (strcmp(value, "show") == 0) {
- const bool oldVisible = m_visible;
- m_visible = true;
- handleKeyboardStateChangeMessage(true);
- if (oldVisible != m_visible)
- emit visibilityChanged(m_visible);
+ setVisible(true);
} else if (strcmp(value, "hide") == 0) {
- const bool oldVisible = m_visible;
- m_visible = false;
- handleKeyboardStateChangeMessage(false);
- if (oldVisible != m_visible)
- emit visibilityChanged(m_visible);
+ setVisible(false);
} else if (strcmp(value, "info") == 0)
handleKeyboardInfoMessage();
else if (strcmp(value, "connect") == 0) { }
// HUGE hack, should be removed ASAP.
newHeight -= KEYBOARD_SHADOW_HEIGHT; // We want to ignore the 8 pixel shadow above the keyboard. (PR 88400)
- if (newHeight != m_height) {
- m_height = newHeight;
- if (m_visible)
- emit heightChanged(m_height);
- }
+ setHeight(newHeight);
const QLocale locale = QLocale(languageId + QLatin1Char('_') + countryId);
- if (locale != m_locale) {
- m_locale = locale;
- emit localeChanged(locale);
- }
+ setLocale(locale);
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
qDebug() << "QQNX: handleKeyboardInfoMessage size=" << m_height << "locale=" << m_locale;
#endif
}
-void QQnxVirtualKeyboard::handleKeyboardStateChangeMessage(bool visible)
-{
-
-#ifdef QQNXVIRTUALKEYBOARD_DEBUG
- qDebug() << "QQNX: handleKeyboardStateChangeMessage " << visible;
-#endif
- if (visible != m_visible)
- emit heightChanged(height());
-
- if (visible)
- showKeyboard();
- else
- hideKeyboard();
-}
-
bool QQnxVirtualKeyboard::showKeyboard()
{
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
// NOTE: This must be done everytime the keyboard is shown even if there is no change because
// hiding the keyboard wipes the setting.
- applyKeyboardModeOptions();
+ applyKeyboardModeOptions(keyboardMode());
- if (m_visible)
+ if (isVisible())
return true;
pps_encoder_reset(m_encoder);
return true;
}
-void QQnxVirtualKeyboard::setKeyboardMode(KeyboardMode mode)
-{
- if (m_keyboardMode == mode)
- return;
-
- m_keyboardMode = mode;
- if (m_visible)
- applyKeyboardModeOptions();
-}
-
-void QQnxVirtualKeyboard::applyKeyboardModeOptions()
+void QQnxVirtualKeyboard::applyKeyboardModeOptions(KeyboardMode mode)
{
// Try to connect.
if (m_fd == -1 && !connect())
pps_encoder_add_string(m_encoder, "msg", "options");
pps_encoder_start_object(m_encoder, "dat");
- switch (m_keyboardMode) {
+ switch (mode) {
case Url:
addUrlModeOptions();
break;
#ifndef VIRTUALKEYBOARD_H_
#define VIRTUALKEYBOARD_H_
-#include <QtCore/QObject>
-#include <QtCore/QLocale>
-#include <QtGui/QPlatformScreen>
+#include "qqnxabstractvirtualkeyboard.h"
-#include <stddef.h>
-#include <vector>
-#include <string>
#include <sys/pps.h>
QT_BEGIN_NAMESPACE
class QSocketNotifier;
/* Shamelessly copied from the browser - this should be rewritten once we have a proper PPS wrapper class */
-class QQnxVirtualKeyboard : public QObject
+class QQnxVirtualKeyboard : public QQnxAbstractVirtualKeyboard
{
Q_OBJECT
public:
- // NOTE: Not all the following keyboard modes are currently used.
- // Default - Regular Keyboard
- // Url/Email - Enhanced keys for each types.
- // Web - Regular keyboard with two blank keys, currently unused.
- // NumPunc - Numbers & Punctionation, alternate to Symbol
- // Symbol - All symbols, alternate to NumPunc, currently unused.
- // Phone - Phone enhanced keyboard - currently unused as no alternate keyboard available to access a-zA-Z
- // Pin - Keyboard for entering Pins (Hex values) currently unused.
- //
- // SPECIAL NOTE: Usage of NumPunc may have to be removed, ABC button is non-functional.
- //
- enum KeyboardMode { Default, Url, Email, Web, NumPunc, Symbol, Phone, Pin };
-
QQnxVirtualKeyboard();
~QQnxVirtualKeyboard();
bool showKeyboard();
bool hideKeyboard();
- int height() { return m_visible ? m_height : 0; }
- void setKeyboardMode(KeyboardMode);
- void notifyClientActiveStateChange(bool);
- bool isVisible() const { return m_visible; }
- QLocale locale() const { return m_locale; }
public Q_SLOTS:
void start();
-Q_SIGNALS:
- void localeChanged(const QLocale &locale);
- void visibilityChanged(bool visible);
- void heightChanged(int height);
+protected:
+ void applyKeyboardMode(KeyboardMode mode);
private Q_SLOTS:
void ppsDataReady();
void close();
bool queryPPSInfo();
void handleKeyboardInfoMessage();
- void handleKeyboardStateChangeMessage(bool visible);
- void applyKeyboardModeOptions();
+ void applyKeyboardModeOptions(KeyboardMode mode);
void addDefaultModeOptions();
void addUrlModeOptions();
void addEmailModeOptions();
pps_encoder_t *m_encoder;
pps_decoder_t *m_decoder;
char *m_buffer;
- int m_height;
int m_fd;
- KeyboardMode m_keyboardMode;
- bool m_visible;
- QLocale m_locale;
QSocketNotifier *m_readNotifier;
// Path to keyboardManager in PPS.