Fix TextInput and TextEdit software input panel on qtquick1
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>
Thu, 8 Sep 2011 12:12:45 +0000 (15:12 +0300)
committerLars Knoll <lars.knoll@nokia.com>
Thu, 8 Sep 2011 13:23:54 +0000 (15:23 +0200)
Change-Id: I39da7a877cef546da69bccfcf7ee1ae2ba92b208
Reviewed-on: http://codereview.qt-project.org/4455
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
src/qtquick1/graphicsitems/qdeclarativetextedit.cpp
src/qtquick1/graphicsitems/qdeclarativetextinput.cpp

index 3610515..777d964 100644 (file)
@@ -56,6 +56,7 @@
 #include <QGraphicsSceneMouseEvent>
 #include <QDebug>
 #include <QPainter>
+#include <QtGui/QInputPanel>
 
 #include <private/qtextcontrol_p.h>
 
@@ -1807,11 +1808,10 @@ void QDeclarative1TextEditPrivate::updateDefaultTextOption()
 */
 void QDeclarative1TextEdit::openSoftwareInputPanel()
 {
-    QEvent event(QEvent::RequestSoftwareInputPanel);
     if (qApp) {
         if (QGraphicsView * view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
             if (view->scene() && view->scene() == scene()) {
-                QApplication::sendEvent(view, &event);
+                qApp->inputPanel()->show();
             }
         }
     }
@@ -1858,11 +1858,10 @@ void QDeclarative1TextEdit::openSoftwareInputPanel()
 */
 void QDeclarative1TextEdit::closeSoftwareInputPanel()
 {
-    QEvent event(QEvent::CloseSoftwareInputPanel);
     if (qApp) {
         if (QGraphicsView * view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
             if (view->scene() && view->scene() == scene()) {
-                QApplication::sendEvent(view, &event);
+                qApp->inputPanel()->hide();
             }
         }
     }
index 271595a..544e35d 100644 (file)
@@ -48,6 +48,7 @@
 #include <QValidator>
 #include <QTextCursor>
 #include <QApplication>
+#include <QtGui/QInputPanel>
 #include <QFontMetrics>
 #include <QPainter>
 #include <QTextBoundaryFinder>
@@ -1277,7 +1278,6 @@ bool QDeclarative1TextInput::event(QEvent* ev)
 void QDeclarative1TextInput::geometryChanged(const QRectF &newGeometry,
                                   const QRectF &oldGeometry)
 {
-    Q_D(QDeclarative1TextInput);
     if (newGeometry.width() != oldGeometry.width()) {
         updateSize();
         updateCursorRectangle();
@@ -1763,11 +1763,10 @@ void QDeclarative1TextInput::moveCursorSelection(int pos, SelectionMode mode)
 */
 void QDeclarative1TextInput::openSoftwareInputPanel()
 {
-    QEvent event(QEvent::RequestSoftwareInputPanel);
     if (qApp) {
         if (QGraphicsView * view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
             if (view->scene() && view->scene() == scene()) {
-                QApplication::sendEvent(view, &event);
+                qApp->inputPanel()->show();
             }
         }
     }
@@ -1814,12 +1813,10 @@ void QDeclarative1TextInput::openSoftwareInputPanel()
 */
 void QDeclarative1TextInput::closeSoftwareInputPanel()
 {
-    QEvent event(QEvent::CloseSoftwareInputPanel);
     if (qApp) {
-        QEvent event(QEvent::CloseSoftwareInputPanel);
         if (QGraphicsView * view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
             if (view->scene() && view->scene() == scene()) {
-                QApplication::sendEvent(view, &event);
+                qApp->inputPanel()->hide();
             }
         }
     }