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. Change-Id: I71a7f6b5e9d5455563404f6abe7a0daec567a12d Reviewed-by: Sean Harmer <sh@theharmers.co.uk> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
This commit is contained in:
parent
a80a2c6da2
commit
5d117fd427
@ -674,12 +674,15 @@ static bool imfAvailable()
|
|||||||
return s_imfReady;
|
return s_imfReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
QQnxInputContext::QQnxInputContext():
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
QQnxInputContext::QQnxInputContext(QQnxVirtualKeyboard &keyboard):
|
||||||
QPlatformInputContext(),
|
QPlatformInputContext(),
|
||||||
m_lastCaretPos(0),
|
m_lastCaretPos(0),
|
||||||
m_isComposing(false),
|
m_isComposing(false),
|
||||||
m_inputPanelVisible(false),
|
m_inputPanelVisible(false),
|
||||||
m_inputPanelLocale(QLocale::c())
|
m_inputPanelLocale(QLocale::c()),
|
||||||
|
m_virtualKeyboad(keyboard)
|
||||||
{
|
{
|
||||||
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
@ -697,7 +700,6 @@ QQnxInputContext::QQnxInputContext():
|
|||||||
|
|
||||||
// p_vkb_init_selection_service();
|
// p_vkb_init_selection_service();
|
||||||
|
|
||||||
QQnxVirtualKeyboard &keyboard = QQnxVirtualKeyboard::instance();
|
|
||||||
connect(&keyboard, SIGNAL(visibilityChanged(bool)), this, SLOT(keyboardVisibilityChanged(bool)));
|
connect(&keyboard, SIGNAL(visibilityChanged(bool)), this, SLOT(keyboardVisibilityChanged(bool)));
|
||||||
connect(&keyboard, SIGNAL(localeChanged(QLocale)), this, SLOT(keyboardLocaleChanged(QLocale)));
|
connect(&keyboard, SIGNAL(localeChanged(QLocale)), this, SLOT(keyboardLocaleChanged(QLocale)));
|
||||||
keyboardVisibilityChanged(keyboard.isVisible());
|
keyboardVisibilityChanged(keyboard.isVisible());
|
||||||
@ -959,7 +961,7 @@ bool QQnxInputContext::hasSelectedText()
|
|||||||
|
|
||||||
bool QQnxInputContext::dispatchRequestSoftwareInputPanel()
|
bool QQnxInputContext::dispatchRequestSoftwareInputPanel()
|
||||||
{
|
{
|
||||||
QQnxVirtualKeyboard::instance().showKeyboard();
|
m_virtualKeyboard.showKeyboard();
|
||||||
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
||||||
qDebug() << "QQNX: requesting virtual keyboard";
|
qDebug() << "QQNX: requesting virtual keyboard";
|
||||||
#endif
|
#endif
|
||||||
@ -986,7 +988,7 @@ bool QQnxInputContext::dispatchRequestSoftwareInputPanel()
|
|||||||
|
|
||||||
bool QQnxInputContext::dispatchCloseSoftwareInputPanel()
|
bool QQnxInputContext::dispatchCloseSoftwareInputPanel()
|
||||||
{
|
{
|
||||||
QQnxVirtualKeyboard::instance().hideKeyboard();
|
m_virtualKeyboard.hideKeyboard();
|
||||||
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
||||||
qDebug() << "QQNX: hiding virtual keyboard";
|
qDebug() << "QQNX: hiding virtual keyboard";
|
||||||
#endif
|
#endif
|
||||||
@ -1685,12 +1687,14 @@ void QQnxInputContext::inputItemChanged()
|
|||||||
if (m_inputPanelVisible)
|
if (m_inputPanelVisible)
|
||||||
hideInputPanel();
|
hideInputPanel();
|
||||||
} else {
|
} else {
|
||||||
if (qobject_cast<QAbstractSpinBox*>(inputItem)) {
|
if (qobject_cast<QAbstractSpinBox*>(inputItem))
|
||||||
QQnxVirtualKeyboard::instance().setKeyboardMode(QQnxVirtualKeyboard::NumPunc);
|
m_virtualKeyboard.setKeyboardMode(QQnxVirtualKeyboard::Phone);
|
||||||
} else {
|
else
|
||||||
QQnxVirtualKeyboard::instance().setKeyboardMode(QQnxVirtualKeyboard::Default);
|
m_virtualKeyboard.setKeyboardMode(QQnxVirtualKeyboard::Default);
|
||||||
}
|
|
||||||
if (!m_inputPanelVisible)
|
if (!m_inputPanelVisible)
|
||||||
showInputPanel();
|
showInputPanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
@ -53,11 +53,13 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QQnxVirtualKeyboard;
|
||||||
|
|
||||||
class QQnxInputContext : public QPlatformInputContext
|
class QQnxInputContext : public QPlatformInputContext
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QQnxInputContext();
|
QQnxInputContext(QQnxVirtualKeyboard &keyboard);
|
||||||
~QQnxInputContext();
|
~QQnxInputContext();
|
||||||
|
|
||||||
virtual bool isValid() const;
|
virtual bool isValid() const;
|
||||||
@ -123,6 +125,7 @@ private:
|
|||||||
QString m_composingText;
|
QString m_composingText;
|
||||||
bool m_inputPanelVisible;
|
bool m_inputPanelVisible;
|
||||||
QLocale m_inputPanelLocale;
|
QLocale m_inputPanelLocale;
|
||||||
|
QQnxVirtualKeyboard &m_virtualKeyboad;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(extracted_text_t*)
|
Q_DECLARE_METATYPE(extracted_text_t*)
|
||||||
|
@ -46,12 +46,14 @@
|
|||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
#include <QtWidgets/QAbstractSpinBox>
|
#include <QtWidgets/QAbstractSpinBox>
|
||||||
|
|
||||||
QQnxInputContext::QQnxInputContext() :
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
QQnxInputContext::QQnxInputContext(QQnxVirtualKeyboard &keyboard) :
|
||||||
QPlatformInputContext(),
|
QPlatformInputContext(),
|
||||||
m_inputPanelVisible(false),
|
m_inputPanelVisible(false),
|
||||||
m_inputPanelLocale(QLocale::c())
|
m_inputPanelLocale(QLocale::c()),
|
||||||
|
m_virtualKeyboard(keyboard)
|
||||||
{
|
{
|
||||||
QQnxVirtualKeyboard &keyboard = QQnxVirtualKeyboard::instance();
|
|
||||||
connect(&keyboard, SIGNAL(visibilityChanged(bool)), this, SLOT(keyboardVisibilityChanged(bool)));
|
connect(&keyboard, SIGNAL(visibilityChanged(bool)), this, SLOT(keyboardVisibilityChanged(bool)));
|
||||||
connect(&keyboard, SIGNAL(localeChanged(QLocale)), this, SLOT(keyboardLocaleChanged(QLocale)));
|
connect(&keyboard, SIGNAL(localeChanged(QLocale)), this, SLOT(keyboardLocaleChanged(QLocale)));
|
||||||
keyboardVisibilityChanged(keyboard.isVisible());
|
keyboardVisibilityChanged(keyboard.isVisible());
|
||||||
@ -86,7 +88,7 @@ bool QQnxInputContext::filterEvent( const QEvent *event )
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (event->type() == QEvent::CloseSoftwareInputPanel) {
|
if (event->type() == QEvent::CloseSoftwareInputPanel) {
|
||||||
QQnxVirtualKeyboard::instance().hideKeyboard();
|
m_virtualKeyboard.hideKeyboard();
|
||||||
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
||||||
qDebug() << "QQNX: hiding virtual keyboard";
|
qDebug() << "QQNX: hiding virtual keyboard";
|
||||||
#endif
|
#endif
|
||||||
@ -94,7 +96,7 @@ bool QQnxInputContext::filterEvent( const QEvent *event )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event->type() == QEvent::RequestSoftwareInputPanel) {
|
if (event->type() == QEvent::RequestSoftwareInputPanel) {
|
||||||
QQnxVirtualKeyboard::instance().showKeyboard();
|
m_virtualKeyboard.showKeyboard();
|
||||||
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
||||||
qDebug() << "QQNX: requesting virtual keyboard";
|
qDebug() << "QQNX: requesting virtual keyboard";
|
||||||
#endif
|
#endif
|
||||||
@ -120,7 +122,7 @@ void QQnxInputContext::showInputPanel()
|
|||||||
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
#endif
|
#endif
|
||||||
QQnxVirtualKeyboard::instance().showKeyboard();
|
m_virtualKeyboard.showKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QQnxInputContext::hideInputPanel()
|
void QQnxInputContext::hideInputPanel()
|
||||||
@ -128,7 +130,7 @@ void QQnxInputContext::hideInputPanel()
|
|||||||
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
#if defined(QQNXINPUTCONTEXT_DEBUG)
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
#endif
|
#endif
|
||||||
QQnxVirtualKeyboard::instance().hideKeyboard();
|
m_virtualKeyboard.hideKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QQnxInputContext::isInputPanelVisible() const
|
bool QQnxInputContext::isInputPanelVisible() const
|
||||||
@ -176,12 +178,14 @@ void QQnxInputContext::inputItemChanged()
|
|||||||
if (m_inputPanelVisible)
|
if (m_inputPanelVisible)
|
||||||
hideInputPanel();
|
hideInputPanel();
|
||||||
} else {
|
} else {
|
||||||
if (qobject_cast<QAbstractSpinBox*>(inputItem)) {
|
if (qobject_cast<QAbstractSpinBox*>(inputItem))
|
||||||
QQnxVirtualKeyboard::instance().setKeyboardMode(QQnxVirtualKeyboard::NumPunc);
|
m_virtualKeyboard.setKeyboardMode(QQnxVirtualKeyboard::Phone);
|
||||||
} else {
|
else
|
||||||
QQnxVirtualKeyboard::instance().setKeyboardMode(QQnxVirtualKeyboard::Default);
|
m_virtualKeyboard.setKeyboardMode(QQnxVirtualKeyboard::Default);
|
||||||
}
|
|
||||||
if (!m_inputPanelVisible)
|
if (!m_inputPanelVisible)
|
||||||
showInputPanel();
|
showInputPanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
@ -48,11 +48,13 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QQnxVirtualKeyboard;
|
||||||
|
|
||||||
class QQnxInputContext : public QPlatformInputContext
|
class QQnxInputContext : public QPlatformInputContext
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit QQnxInputContext();
|
explicit QQnxInputContext(QQnxVirtualKeyboard &keyboard);
|
||||||
~QQnxInputContext();
|
~QQnxInputContext();
|
||||||
|
|
||||||
virtual bool isValid() const;
|
virtual bool isValid() const;
|
||||||
@ -77,6 +79,7 @@ private:
|
|||||||
|
|
||||||
bool m_inputPanelVisible;
|
bool m_inputPanelVisible;
|
||||||
QLocale m_inputPanelLocale;
|
QLocale m_inputPanelLocale;
|
||||||
|
QQnxVirtualKeyboard &m_virtualKeyboard;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -79,6 +79,7 @@ QQnxIntegration::QQnxIntegration()
|
|||||||
: QPlatformIntegration()
|
: QPlatformIntegration()
|
||||||
, m_eventThread(0)
|
, m_eventThread(0)
|
||||||
, m_navigatorEventHandler(0)
|
, m_navigatorEventHandler(0)
|
||||||
|
, m_virtualKeyboard(0)
|
||||||
, m_inputContext(0)
|
, m_inputContext(0)
|
||||||
, m_fontDatabase(new QGenericUnixFontDatabase())
|
, m_fontDatabase(new QGenericUnixFontDatabase())
|
||||||
, m_paintUsingOpenGL(false)
|
, m_paintUsingOpenGL(false)
|
||||||
@ -122,10 +123,18 @@ QQnxIntegration::QQnxIntegration()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Create/start the keyboard class.
|
// Create/start the keyboard class.
|
||||||
QQnxVirtualKeyboard::instance();
|
m_virtualKeyboard = new QQnxVirtualKeyboard();
|
||||||
|
|
||||||
|
// 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(m_virtualKeyboard, "start", Qt::QueuedConnection);
|
||||||
|
|
||||||
|
// TODO check if we need to do this for all screens or only the primary one
|
||||||
|
QObject::connect(m_virtualKeyboard, SIGNAL(heightChanged(int)),
|
||||||
|
QQnxScreen::primaryDisplay(), SLOT(keyboardHeightChanged(int)));
|
||||||
|
|
||||||
// Set up the input context
|
// Set up the input context
|
||||||
m_inputContext = new QQnxInputContext;
|
m_inputContext = new QQnxInputContext(*m_virtualKeyboard);
|
||||||
|
|
||||||
// Create services handling class
|
// Create services handling class
|
||||||
#ifdef Q_OS_BLACKBERRY
|
#ifdef Q_OS_BLACKBERRY
|
||||||
@ -138,8 +147,12 @@ QQnxIntegration::~QQnxIntegration()
|
|||||||
#if defined(QQNXINTEGRATION_DEBUG)
|
#if defined(QQNXINTEGRATION_DEBUG)
|
||||||
qDebug() << "QQnx: platform plugin shutdown begin";
|
qDebug() << "QQnx: platform plugin shutdown begin";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Destroy input context
|
||||||
|
delete m_inputContext;
|
||||||
|
|
||||||
// Destroy the keyboard class.
|
// Destroy the keyboard class.
|
||||||
QQnxVirtualKeyboard::destroy();
|
delete m_virtualKeyboard;
|
||||||
|
|
||||||
#ifndef QT_NO_CLIPBOARD
|
#ifndef QT_NO_CLIPBOARD
|
||||||
// Delete the clipboard
|
// Delete the clipboard
|
||||||
|
@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QQnxEventThread;
|
class QQnxEventThread;
|
||||||
class QQnxInputContext;
|
class QQnxInputContext;
|
||||||
class QQnxNavigatorEventHandler;
|
class QQnxNavigatorEventHandler;
|
||||||
|
class QQnxVirtualKeyboard;
|
||||||
class QQnxWindow;
|
class QQnxWindow;
|
||||||
class QQnxServices;
|
class QQnxServices;
|
||||||
|
|
||||||
@ -103,6 +104,7 @@ private:
|
|||||||
screen_context_t m_screenContext;
|
screen_context_t m_screenContext;
|
||||||
QQnxEventThread *m_eventThread;
|
QQnxEventThread *m_eventThread;
|
||||||
QQnxNavigatorEventHandler *m_navigatorEventHandler;
|
QQnxNavigatorEventHandler *m_navigatorEventHandler;
|
||||||
|
QQnxVirtualKeyboard *m_virtualKeyboard;
|
||||||
QQnxInputContext *m_inputContext;
|
QQnxInputContext *m_inputContext;
|
||||||
QPlatformFontDatabase *m_fontDatabase;
|
QPlatformFontDatabase *m_fontDatabase;
|
||||||
bool m_paintUsingOpenGL;
|
bool m_paintUsingOpenGL;
|
||||||
|
@ -40,11 +40,11 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "qqnxscreen.h"
|
#include "qqnxscreen.h"
|
||||||
#include "qqnxvirtualkeyboard.h"
|
|
||||||
#include "qqnxwindow.h"
|
#include "qqnxwindow.h"
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QUuid>
|
#include <QtCore/QUuid>
|
||||||
|
#include <QtGui/QWindowSystemInterface>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
@ -59,6 +59,7 @@ QQnxScreen::QQnxScreen(screen_context_t screenContext, screen_display_t display,
|
|||||||
m_rootWindow(),
|
m_rootWindow(),
|
||||||
m_primaryScreen(primaryScreen),
|
m_primaryScreen(primaryScreen),
|
||||||
m_posted(false),
|
m_posted(false),
|
||||||
|
m_keyboardHeight(0),
|
||||||
m_platformContext(0)
|
m_platformContext(0)
|
||||||
{
|
{
|
||||||
#if defined(QQNXSCREEN_DEBUG)
|
#if defined(QQNXSCREEN_DEBUG)
|
||||||
@ -182,9 +183,8 @@ QRect QQnxScreen::availableGeometry() const
|
|||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
#endif
|
#endif
|
||||||
// available geometry = total geometry - keyboard
|
// available geometry = total geometry - keyboard
|
||||||
int keyboardHeight = QQnxVirtualKeyboard::instance().height();
|
|
||||||
return QRect(m_currentGeometry.x(), m_currentGeometry.y(),
|
return QRect(m_currentGeometry.x(), m_currentGeometry.y(),
|
||||||
m_currentGeometry.width(), m_currentGeometry.height() - keyboardHeight);
|
m_currentGeometry.width(), m_currentGeometry.height() - m_keyboardHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -312,4 +312,15 @@ void QQnxScreen::onWindowPost(QQnxWindow *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QQnxScreen::keyboardHeightChanged(int height)
|
||||||
|
{
|
||||||
|
if (height == m_keyboardHeight)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_keyboardHeight = height;
|
||||||
|
|
||||||
|
QWindowSystemInterface::handleScreenAvailableGeometryChange(screen(), availableGeometry());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
#include "qqnxrootwindow.h"
|
#include "qqnxrootwindow.h"
|
||||||
|
|
||||||
#include <QtCore/QByteArray>
|
#include <QtCore/QByteArray>
|
||||||
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QScopedPointer>
|
#include <QtCore/QScopedPointer>
|
||||||
|
|
||||||
#include <screen/screen.h>
|
#include <screen/screen.h>
|
||||||
@ -55,8 +56,9 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
class QQnxWindow;
|
class QQnxWindow;
|
||||||
|
|
||||||
class QQnxScreen : public QPlatformScreen
|
class QQnxScreen : public QObject, public QPlatformScreen
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static QList<QPlatformScreen *> screens() { return ms_screens; }
|
static QList<QPlatformScreen *> screens() { return ms_screens; }
|
||||||
static void createDisplays(screen_context_t context);
|
static void createDisplays(screen_context_t context);
|
||||||
@ -91,6 +93,9 @@ public:
|
|||||||
|
|
||||||
QSharedPointer<QQnxRootWindow> rootWindow() const { return m_rootWindow; }
|
QSharedPointer<QQnxRootWindow> rootWindow() const { return m_rootWindow; }
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void keyboardHeightChanged(int height);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QQnxScreen(screen_context_t context, screen_display_t display, bool primaryScreen);
|
QQnxScreen(screen_context_t context, screen_display_t display, bool primaryScreen);
|
||||||
virtual ~QQnxScreen();
|
virtual ~QQnxScreen();
|
||||||
@ -102,10 +107,10 @@ private:
|
|||||||
QSharedPointer<QQnxRootWindow> m_rootWindow;
|
QSharedPointer<QQnxRootWindow> m_rootWindow;
|
||||||
bool m_primaryScreen;
|
bool m_primaryScreen;
|
||||||
bool m_posted;
|
bool m_posted;
|
||||||
bool m_usingOpenGL;
|
|
||||||
|
|
||||||
int m_initialRotation;
|
int m_initialRotation;
|
||||||
int m_currentRotation;
|
int m_currentRotation;
|
||||||
|
int m_keyboardHeight;
|
||||||
QSize m_initialPhysicalSize;
|
QSize m_initialPhysicalSize;
|
||||||
QSize m_currentPhysicalSize;
|
QSize m_currentPhysicalSize;
|
||||||
QRect m_initialGeometry;
|
QRect m_initialGeometry;
|
||||||
|
@ -42,9 +42,6 @@
|
|||||||
#include "qqnxvirtualkeyboard.h"
|
#include "qqnxvirtualkeyboard.h"
|
||||||
#include "qqnxscreen.h"
|
#include "qqnxscreen.h"
|
||||||
|
|
||||||
#include <QtGui/QPlatformScreen>
|
|
||||||
#include <QtGui/QPlatformWindow>
|
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QSocketNotifier>
|
#include <QtCore/QSocketNotifier>
|
||||||
#include <QtCore/private/qcore_unix_p.h>
|
#include <QtCore/private/qcore_unix_p.h>
|
||||||
@ -59,11 +56,11 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
const char *QQnxVirtualKeyboard::ms_PPSPath = "/pps/services/input/control?wait";
|
const char *QQnxVirtualKeyboard::ms_PPSPath = "/pps/services/input/control?wait";
|
||||||
const size_t QQnxVirtualKeyboard::ms_bufferSize = 2048;
|
const size_t QQnxVirtualKeyboard::ms_bufferSize = 2048;
|
||||||
|
|
||||||
static QQnxVirtualKeyboard *s_instance = 0;
|
|
||||||
|
|
||||||
// Huge hack for keyboard shadow (see QNX PR 88400). Should be removed ASAP.
|
// Huge hack for keyboard shadow (see QNX PR 88400). Should be removed ASAP.
|
||||||
#define KEYBOARD_SHADOW_HEIGHT 8
|
#define KEYBOARD_SHADOW_HEIGHT 8
|
||||||
|
|
||||||
@ -85,20 +82,6 @@ QQnxVirtualKeyboard::~QQnxVirtualKeyboard()
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
|
||||||
QQnxVirtualKeyboard& QQnxVirtualKeyboard::instance()
|
|
||||||
{
|
|
||||||
if (!s_instance) {
|
|
||||||
s_instance = new QQnxVirtualKeyboard();
|
|
||||||
|
|
||||||
// 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 QQnxVirtualKeyboard::start()
|
void QQnxVirtualKeyboard::start()
|
||||||
{
|
{
|
||||||
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
|
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
|
||||||
@ -108,15 +91,6 @@ void QQnxVirtualKeyboard::start()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
|
||||||
void QQnxVirtualKeyboard::destroy()
|
|
||||||
{
|
|
||||||
if (s_instance) {
|
|
||||||
delete s_instance;
|
|
||||||
s_instance = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QQnxVirtualKeyboard::close()
|
void QQnxVirtualKeyboard::close()
|
||||||
{
|
{
|
||||||
delete m_readNotifier;
|
delete m_readNotifier;
|
||||||
@ -292,7 +266,8 @@ void QQnxVirtualKeyboard::handleKeyboardInfoMessage()
|
|||||||
|
|
||||||
if (newHeight != m_height) {
|
if (newHeight != m_height) {
|
||||||
m_height = newHeight;
|
m_height = newHeight;
|
||||||
updateAvailableScreenGeometry();
|
if (m_visible)
|
||||||
|
emit heightChanged(m_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QLocale locale = QLocale(languageId + QLatin1Char('_') + countryId);
|
const QLocale locale = QLocale(languageId + QLatin1Char('_') + countryId);
|
||||||
@ -312,7 +287,8 @@ void QQnxVirtualKeyboard::handleKeyboardStateChangeMessage(bool visible)
|
|||||||
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
|
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
|
||||||
qDebug() << "QQNX: handleKeyboardStateChangeMessage " << visible;
|
qDebug() << "QQNX: handleKeyboardStateChangeMessage " << visible;
|
||||||
#endif
|
#endif
|
||||||
updateAvailableScreenGeometry();
|
if (visible != m_visible)
|
||||||
|
emit heightChanged(height());
|
||||||
|
|
||||||
if (visible)
|
if (visible)
|
||||||
showKeyboard();
|
showKeyboard();
|
||||||
@ -320,19 +296,6 @@ void QQnxVirtualKeyboard::handleKeyboardStateChangeMessage(bool visible)
|
|||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QQnxVirtualKeyboard::updateAvailableScreenGeometry()
|
|
||||||
{
|
|
||||||
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
|
|
||||||
qDebug() << "QQNX: updateAvailableScreenGeometry: keyboard visible=" << m_visible << ", keyboard height=" << m_height;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TODO: What screen index should be used? I assume primaryScreen 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.
|
|
||||||
QQnxScreen *platformScreen = QQnxScreen::primaryDisplay();
|
|
||||||
QWindowSystemInterface::handleScreenAvailableGeometryChange(platformScreen->screen(), platformScreen->availableGeometry());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QQnxVirtualKeyboard::showKeyboard()
|
bool QQnxVirtualKeyboard::showKeyboard()
|
||||||
{
|
{
|
||||||
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
|
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
|
||||||
@ -347,6 +310,9 @@ bool QQnxVirtualKeyboard::showKeyboard()
|
|||||||
// hiding the keyboard wipes the setting.
|
// hiding the keyboard wipes the setting.
|
||||||
applyKeyboardModeOptions();
|
applyKeyboardModeOptions();
|
||||||
|
|
||||||
|
if (m_visible)
|
||||||
|
return true;
|
||||||
|
|
||||||
pps_encoder_reset(m_encoder);
|
pps_encoder_reset(m_encoder);
|
||||||
|
|
||||||
// Send the show message.
|
// Send the show message.
|
||||||
@ -398,7 +364,12 @@ bool QQnxVirtualKeyboard::hideKeyboard()
|
|||||||
|
|
||||||
void QQnxVirtualKeyboard::setKeyboardMode(KeyboardMode mode)
|
void QQnxVirtualKeyboard::setKeyboardMode(KeyboardMode mode)
|
||||||
{
|
{
|
||||||
|
if (m_keyboardMode == mode)
|
||||||
|
return;
|
||||||
|
|
||||||
m_keyboardMode = mode;
|
m_keyboardMode = mode;
|
||||||
|
if (m_visible)
|
||||||
|
applyKeyboardModeOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QQnxVirtualKeyboard::applyKeyboardModeOptions()
|
void QQnxVirtualKeyboard::applyKeyboardModeOptions()
|
||||||
@ -495,3 +466,5 @@ void QQnxVirtualKeyboard::addSymbolModeOptions()
|
|||||||
pps_encoder_add_string(m_encoder, "enter", "enter.default");
|
pps_encoder_add_string(m_encoder, "enter", "enter.default");
|
||||||
pps_encoder_add_string(m_encoder, "type", "symbol");
|
pps_encoder_add_string(m_encoder, "type", "symbol");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
@ -45,17 +45,16 @@
|
|||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QLocale>
|
#include <QtCore/QLocale>
|
||||||
#include <QtGui/QPlatformScreen>
|
#include <QtGui/QPlatformScreen>
|
||||||
#include <QtGui/QWindowSystemInterface>
|
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/pps.h>
|
#include <sys/pps.h>
|
||||||
|
|
||||||
class QSocketNotifier;
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QSocketNotifier;
|
||||||
|
|
||||||
/* Shamelessly copied from the browser - this should be rewritten once we have a proper PPS wrapper class */
|
/* Shamelessly copied from the browser - this should be rewritten once we have a proper PPS wrapper class */
|
||||||
class QQnxVirtualKeyboard : public QObject
|
class QQnxVirtualKeyboard : public QObject
|
||||||
{
|
{
|
||||||
@ -74,8 +73,8 @@ public:
|
|||||||
//
|
//
|
||||||
enum KeyboardMode { Default, Url, Email, Web, NumPunc, Symbol, Phone, Pin };
|
enum KeyboardMode { Default, Url, Email, Web, NumPunc, Symbol, Phone, Pin };
|
||||||
|
|
||||||
static QQnxVirtualKeyboard& instance();
|
QQnxVirtualKeyboard();
|
||||||
static void destroy();
|
~QQnxVirtualKeyboard();
|
||||||
|
|
||||||
bool showKeyboard();
|
bool showKeyboard();
|
||||||
bool hideKeyboard();
|
bool hideKeyboard();
|
||||||
@ -91,21 +90,18 @@ public Q_SLOTS:
|
|||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void localeChanged(const QLocale &locale);
|
void localeChanged(const QLocale &locale);
|
||||||
void visibilityChanged(bool visible);
|
void visibilityChanged(bool visible);
|
||||||
|
void heightChanged(int height);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void ppsDataReady();
|
void ppsDataReady();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QQnxVirtualKeyboard();
|
|
||||||
virtual ~QQnxVirtualKeyboard();
|
|
||||||
|
|
||||||
// Will be called internally if needed.
|
// Will be called internally if needed.
|
||||||
bool connect();
|
bool connect();
|
||||||
void close();
|
void close();
|
||||||
bool queryPPSInfo();
|
bool queryPPSInfo();
|
||||||
void handleKeyboardInfoMessage();
|
void handleKeyboardInfoMessage();
|
||||||
void handleKeyboardStateChangeMessage(bool visible);
|
void handleKeyboardStateChangeMessage(bool visible);
|
||||||
void updateAvailableScreenGeometry();
|
|
||||||
|
|
||||||
void applyKeyboardModeOptions();
|
void applyKeyboardModeOptions();
|
||||||
void addDefaultModeOptions();
|
void addDefaultModeOptions();
|
||||||
|
Loading…
Reference in New Issue
Block a user