summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAnselmo L. S. Melo <anselmo.melo@openbossa.org>2012-01-27 07:49:34 -0300
committerQt by Nokia <qt-info@nokia.com>2012-01-31 07:05:09 +0100
commit8839a0a001c7017a1acf1d7460c4c19893c74967 (patch)
treeb85e72ac6e15314799e45ccf5a0bb42d9a5aa0ac /src
parente8105e4783f3932885695353eefa1a60937929a1 (diff)
Fix QGuiApplication::topLevelWindows(), introducing allWindows()
As discussed on the development mailing list, the window list returned by QGuiApplication::topLevellWindows() included all QWindows, even the non top-level ones. This commit introduces the new method allWindows(), which returns the list of all QWindows, fixes the list returned by topLevelWindows() and also introduces tests for both methods. Change-Id: I761f0fcdec79f83949012c628655ed12cd18572c Reviewed-by: Jonas Gastal <jgastal@profusion.mobi> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qguiapplication.cpp29
-rw-r--r--src/gui/kernel/qguiapplication.h1
2 files changed, 29 insertions, 1 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index cc6ef36963..ea562c75b8 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -214,11 +214,38 @@ QObject *QGuiApplication::focusObject()
return 0;
}
-QWindowList QGuiApplication::topLevelWindows()
+/*!
+ \fn QGuiApplication::allWindows()
+
+ Returns a list of all the windows in the application.
+
+ The list is empty if there are no windows.
+
+ \sa topLevelWindows()
+ */
+QWindowList QGuiApplication::allWindows()
{
return QGuiApplicationPrivate::window_list;
}
+/*!
+ \fn QGuiApplication::topLevelWindows()
+
+ Returns a list of the top-level windows in the application.
+
+ \sa allWindows()
+ */
+QWindowList QGuiApplication::topLevelWindows()
+{
+ const QWindowList &list = QGuiApplicationPrivate::window_list;
+ QWindowList topLevelWindows;
+ for (int i = 0; i < list.size(); i++) {
+ if (!list.at(i)->parent())
+ topLevelWindows.prepend(list.at(i));
+ }
+ return topLevelWindows;
+}
+
QScreen *QGuiApplication::primaryScreen()
{
if (QGuiApplicationPrivate::screen_list.isEmpty())
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index 90061ed338..9bf6a69c45 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -81,6 +81,7 @@ public:
QGuiApplication(int &argc, char **argv, int = ApplicationFlags);
virtual ~QGuiApplication();
+ static QWindowList allWindows();
static QWindowList topLevelWindows();
static QWindow *topLevelAt(const QPoint &pos);