Adapt QGraphicsView from QInputContext to QInputPanel
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>
Fri, 23 Sep 2011 11:29:07 +0000 (14:29 +0300)
committerQt by Nokia <qt-info@nokia.com>
Wed, 28 Sep 2011 12:02:08 +0000 (14:02 +0200)
Change-Id: Icbb458af7914f0af3e37ac012aa7c1cbd5f3a023
Reviewed-on: http://codereview.qt-project.org/5631
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
src/widgets/graphicsview/qgraphicsitem.cpp
src/widgets/graphicsview/qgraphicsscene.cpp
src/widgets/graphicsview/qgraphicsview.cpp

index c0f6339..180643d 100644 (file)
 #include <QtGui/qpixmapcache.h>
 #include <QtWidgets/qstyleoption.h>
 #include <QtGui/qevent.h>
-#include <QtWidgets/qinputcontext.h>
+#include <QtGui/qinputpanel.h>
 #include <QtWidgets/qgraphicseffect.h>
 #ifndef QT_NO_ACCESSIBILITY
 # include "qaccessible.h"
@@ -7373,15 +7373,10 @@ void QGraphicsItem::setInputMethodHints(Qt::InputMethodHints hints)
     if (!hasFocus())
         return;
     d->scene->d_func()->updateInputMethodSensitivityInViews();
-#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
     QWidget *fw = QApplication::focusWidget();
     if (!fw)
         return;
-    for (int i = 0 ; i < scene()->views().count() ; ++i)
-        if (scene()->views().at(i) == fw)
-            if (QInputContext *inputContext = fw->inputContext())
-                inputContext->update();
-#endif
+    qApp->inputPanel()->update(Qt::ImHints);
 }
 
 /*!
@@ -7398,14 +7393,15 @@ void QGraphicsItem::updateMicroFocus()
         if (scene()) {
             for (int i = 0 ; i < scene()->views().count() ; ++i) {
                 if (scene()->views().at(i) == fw) {
-                    if (QInputContext *inputContext = fw->inputContext()) {
-                        inputContext->update();
+                    if (qApp)
+                        qApp->inputPanel()->update(Qt::ImQueryAll);
+
 #ifndef QT_NO_ACCESSIBILITY
-                        // ##### is this correct
-                        if (toGraphicsObject())
-                            QAccessible::updateAccessibility(toGraphicsObject(), 0, QAccessible::StateChanged);
+                    // ##### is this correct
+                    if (toGraphicsObject())
+                        QAccessible::updateAccessibility(toGraphicsObject(), 0, QAccessible::StateChanged);
 #endif
-                        break;
+                    break;
                     }
                 }
             }
@@ -10206,15 +10202,12 @@ bool QGraphicsTextItem::sceneEvent(QEvent *event)
     case QEvent::KeyRelease:
         // Reset the focus widget's input context, regardless
         // of how this item gained or lost focus.
-        if (QWidget *fw = qApp->focusWidget()) {
-#ifndef QT_NO_IM
-            if (QInputContext *qic = fw->inputContext()) {
-                if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut)
-                    qic->reset();
-                else
-                    qic->update();
-            }
-#endif //QT_NO_IM
+        if (event->type() == QEvent::FocusIn) {
+            qApp->inputPanel()->reset();
+        } else if (event->type() == QEvent::FocusOut) {
+            qApp->inputPanel()->commit();
+        } else {
+            qApp->inputPanel()->update(Qt::ImQueryInput);
         }
         break;
     case QEvent::ShortcutOverride:
index 1650966..2c2acc8 100644 (file)
 #include <QtWidgets/qstyleoption.h>
 #include <QtWidgets/qtooltip.h>
 #include <QtGui/qtransform.h>
-#include <QtWidgets/qinputcontext.h>
+#include <QtGui/qinputpanel.h>
 #include <QtWidgets/qgraphicseffect.h>
 #ifndef QT_NO_ACCESSIBILITY
 # include <QtWidgets/qaccessible.h>
@@ -821,9 +821,8 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
             // automatically by removing WA_InputMethodEnabled on
             // the views, but if we are changing focus, we have to
             // do it ourselves.
-            for (int i = 0; i < views.size(); ++i)
-                if (views.at(i)->inputContext())
-                    views.at(i)->inputContext()->reset();
+            if (qApp)
+                qApp->inputPanel()->commit();
         }
 
         focusItem = 0;
index b5ec8a8..279dfce 100644 (file)
@@ -280,7 +280,6 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime <
 #include <QtGui/qpainter.h>
 #include <QtWidgets/qscrollbar.h>
 #include <QtWidgets/qstyleoption.h>
-#include <QtWidgets/qinputcontext.h>
 #ifdef Q_WS_X11
 #include <QtGui/qpaintengine.h>
 #include <private/qt_x11_p.h>