summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qapplication.cpp
diff options
context:
space:
mode:
authorRobin Burchell <robin+qt@viroteck.net>2013-12-13 12:36:45 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-13 13:45:27 +0100
commit9b621f38619d8d9b3e61723f4cd4e821f909697a (patch)
treeb908566e07eb5ce1ea8f0b601a596e37630d9b16 /src/widgets/kernel/qapplication.cpp
parentb7cb0613f0dc92a5abfd7eedc44ba9f0ee310cae (diff)
Partially revert "Move notification of layout change up from QApplication to QGuiApplication."
We can't rely on QGuiApplication::topLevelWindows containing top level QWidgets, because they only exist as actual windows once QWidgetPrivate::create_sys is called. Thus, make sure to send notifications to all top level widgets, if a QApplication is being used. This reverts commit f82ed5b3e30282bb8dc1da321a0d04ad4d463e59. Task-number: QTBUG-35589 Change-Id: Iac517089af1c22f20094ba6e185d5ed44ebe3d6f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/widgets/kernel/qapplication.cpp')
-rw-r--r--src/widgets/kernel/qapplication.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index d8c37d6ca0..c9d6593662 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -1888,6 +1888,31 @@ bool QApplication::event(QEvent *e)
\obsolete
*/
+// ### FIXME: topLevelWindows does not contain QWidgets without a parent
+// until create_sys is called. So we have to override the
+// QGuiApplication::notifyLayoutDirectionChange
+// to do the right thing.
+void QApplicationPrivate::notifyLayoutDirectionChange()
+{
+ const QWidgetList list = QApplication::topLevelWidgets();
+ QWindowList windowList = QGuiApplication::topLevelWindows();
+
+ // send to all top-level QWidgets
+ for (int i = 0; i < list.size(); ++i) {
+ QWidget *w = list.at(i);
+ windowList.removeAll(w->windowHandle());
+ QEvent ev(QEvent::ApplicationLayoutDirectionChange);
+ QCoreApplication::sendEvent(w, &ev);
+ }
+
+ // in case there are any plain QWindows in this QApplication-using
+ // application, also send the notification to them
+ for (int i = 0; i < windowList.size(); ++i) {
+ QEvent ev(QEvent::ApplicationLayoutDirectionChange);
+ QCoreApplication::sendEvent(windowList.at(i), &ev);
+ }
+}
+
/*!
\fn void QApplication::setActiveWindow(QWidget* active)