diff options
author | Andras Becsi <andras.becsi@digia.com> | 2013-10-24 18:06:14 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-25 20:50:57 +0200 |
commit | 44383cc1e34b6fae069af35579c5267221d90ad4 (patch) | |
tree | 547779842f7e83e3412873f3e04c125c3b6c4335 /lib/widgets | |
parent | 01d4d6964665957ba1440f763545f6fbde73c2e5 (diff) |
Implement inputMethodQuery
This makes it possible on touch devices to use a simple
virtual keyboard input method that synthesizes key events.
This is the minimal requirement to make the the boot2Qt
Keyboard component functional.
For more advanced input methods and the widget tests we will
need to override inputMethodEvent as well.
Change-Id: If9228ee6b1730d72e7424bdb33a9a9c46654507f
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'lib/widgets')
-rw-r--r-- | lib/widgets/render_widget_host_view_qt_delegate_widget.cpp | 16 | ||||
-rw-r--r-- | lib/widgets/render_widget_host_view_qt_delegate_widget.h | 2 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp b/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp index 5d0a7960b..d8abd18ff 100644 --- a/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp @@ -49,6 +49,7 @@ #include <QPainter> #include <QPaintEvent> #include <QWindow> +#include <QtWidgets/QApplication> RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(WebContentsAdapterClient::CompositingMode mode, QWidget *parent) : QWidget(parent) @@ -139,6 +140,21 @@ void RenderWidgetHostViewQtDelegateWidget::resize(int width, int height) QWidget::resize(width, height); } +void RenderWidgetHostViewQtDelegateWidget::inputMethodStateChanged(bool editorVisible) +{ + if (qApp->inputMethod()->isVisible() == editorVisible) + return; + + QWidget::setAttribute(Qt::WA_InputMethodEnabled, editorVisible); + qApp->inputMethod()->update(Qt::ImQueryInput | Qt::ImEnabled | Qt::ImHints); + qApp->inputMethod()->setVisible(editorVisible); +} + +QVariant RenderWidgetHostViewQtDelegateWidget::inputMethodQuery(Qt::InputMethodQuery query) const +{ + return forwardInputMethodQuery(query); +} + void RenderWidgetHostViewQtDelegateWidget::paintEvent(QPaintEvent * event) { QPainter painter(this); diff --git a/lib/widgets/render_widget_host_view_qt_delegate_widget.h b/lib/widgets/render_widget_host_view_qt_delegate_widget.h index 264f8f4af..29e697d1b 100644 --- a/lib/widgets/render_widget_host_view_qt_delegate_widget.h +++ b/lib/widgets/render_widget_host_view_qt_delegate_widget.h @@ -70,12 +70,14 @@ public: virtual void update(const QRect& rect = QRect()); virtual void updateCursor(const QCursor &); virtual void resize(int width, int height); + virtual void inputMethodStateChanged(bool editorVisible); protected: void paintEvent(QPaintEvent * event); bool event(QEvent *event); void resizeEvent(QResizeEvent *resizeEvent); + QVariant inputMethodQuery(Qt::InputMethodQuery query) const; }; #endif |