diff options
author | Pekka Vuorela <pekka.ta.vuorela@nokia.com> | 2012-01-20 17:57:21 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-27 13:27:54 +0100 |
commit | dd565d2d4c7e9b766bc9f575d803ebaad71b33b7 (patch) | |
tree | b81f8b84e26c8b433759e6f97cdcacd0c5419dd0 /src/gui/kernel/qguiapplication.cpp | |
parent | e7d0d54084aa04387ebfb8cee292248df5355021 (diff) |
QGuiApplication::focusObject() to replace QInputPanel::inputItem()
* Deprecated QInputPanel::inputWindow() which is already
just returning QGuiApplication::activeWindow()
* Deprecated QInputPanel::inputItem() and introduced
QGuiApplication::focusObject(). Input methods can check
input method support by Qt::ImEnabled query.
Change-Id: I70a9c1c3f79aadb75c839d0489a9428f7a221df5
Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index b3adcfcbaf..0be0927d46 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -196,6 +196,24 @@ QWindow *QGuiApplication::focusWindow() return QGuiApplicationPrivate::focus_window; } +/*! + \fn QGuiApplication::focusObjectChanged(QObject *focusObject) + + This signal is emitted when final receiver of events tied to focus is changed. + \sa focusObject() +*/ + +/*! + Returns the QObject in currently active window that will be final receiver of events + tied focus, such as key events. + */ +QObject *QGuiApplication::focusObject() +{ + if (focusWindow()) + return focusWindow()->focusObject(); + return 0; +} + QWindowList QGuiApplication::topLevelWindows() { return QGuiApplicationPrivate::window_list; @@ -792,9 +810,13 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate if (previous == QGuiApplicationPrivate::focus_window) return; + QObject *previousFocusObject = previous ? previous->focusObject() : 0; + if (previous) { QFocusEvent focusOut(QEvent::FocusOut); QCoreApplication::sendSpontaneousEvent(previous, &focusOut); + QObject::disconnect(previous, SIGNAL(focusObjectChanged(QObject*)), + qApp, SIGNAL(focusObjectChanged(QObject*))); } else { QEvent appActivate(QEvent::ApplicationActivate); qApp->sendSpontaneousEvent(qApp, &appActivate); @@ -803,6 +825,8 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate if (QGuiApplicationPrivate::focus_window) { QFocusEvent focusIn(QEvent::FocusIn); QCoreApplication::sendSpontaneousEvent(QGuiApplicationPrivate::focus_window, &focusIn); + QObject::connect(QGuiApplicationPrivate::focus_window, SIGNAL(focusObjectChanged(QObject*)), + qApp, SIGNAL(focusObjectChanged(QObject*))); } else { QEvent appActivate(QEvent::ApplicationDeactivate); qApp->sendSpontaneousEvent(qApp, &appActivate); @@ -810,6 +834,9 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate if (self) self->notifyActiveWindowChange(previous); + + if (previousFocusObject != qApp->focusObject()) + emit qApp->focusObjectChanged(qApp->focusObject()); } void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse) |