summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-06-19 18:49:59 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-07-30 20:52:41 +0200
commitd71f9d8c05d70053f2ce46dbb2203309addc0f93 (patch)
tree6edffca89fc49f0cc0bcfac21998c450fc1f235c /src
parentd448725403fea283a586aae5a23860c866597752 (diff)
Accessibility: Top level widgets should only be in the hierarchy once
On Linux for example Orca gets confused when showing a dialog that is a child of another widget since it would show up twice in the hierarchy. Task-number: QTBUG-39444 Change-Id: I84773ecc3d6774a652dbeb29ad201779f5b3191c Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/accessible/qaccessiblewidget.cpp14
-rw-r--r--src/widgets/accessible/qaccessiblewidgets.cpp12
-rw-r--r--src/widgets/accessible/simplewidgets.cpp2
3 files changed, 12 insertions, 16 deletions
diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp
index 73425b9acd..48f99f4d35 100644
--- a/src/widgets/accessible/qaccessiblewidget.cpp
+++ b/src/widgets/accessible/qaccessiblewidget.cpp
@@ -240,10 +240,10 @@ QWidget *QAccessibleWidget::widget() const
*/
QObject *QAccessibleWidget::parentObject() const
{
- QObject *parent = object()->parent();
- if (!parent)
- parent = qApp;
- return parent;
+ QWidget *w = widget();
+ if (!w || w->isWindow() || !w->parentWidget())
+ return qApp;
+ return w->parent();
}
/*! \reimp */
@@ -353,11 +353,7 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel
/*! \reimp */
QAccessibleInterface *QAccessibleWidget::parent() const
{
- Q_ASSERT(widget());
- QObject *parentWidget= widget()->parentWidget();
- if (!parentWidget)
- parentWidget = qApp;
- return QAccessible::queryAccessibleInterface(parentWidget);
+ return QAccessible::queryAccessibleInterface(parentObject());
}
/*! \reimp */
diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp
index da57d4657d..cc6310d591 100644
--- a/src/widgets/accessible/qaccessiblewidgets.cpp
+++ b/src/widgets/accessible/qaccessiblewidgets.cpp
@@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE
QString qt_accStripAmp(const QString &text);
-QList<QWidget*> childWidgets(const QWidget *widget, bool includeTopLevel)
+QList<QWidget*> childWidgets(const QWidget *widget)
{
if (widget == 0)
return QList<QWidget*>();
@@ -85,7 +85,7 @@ QList<QWidget*> childWidgets(const QWidget *widget, bool includeTopLevel)
if (!w)
continue;
QString objectName = w->objectName();
- if ((includeTopLevel || !w->isWindow())
+ if (!w->isWindow()
&& !qobject_cast<QFocusFrame*>(w)
&& !qobject_cast<QMenu*>(w)
&& objectName != QLatin1String("qt_rubberband")
@@ -970,7 +970,7 @@ QAccessibleMainWindow::QAccessibleMainWindow(QWidget *widget)
QAccessibleInterface *QAccessibleMainWindow::child(int index) const
{
- QList<QWidget*> kids = childWidgets(mainWindow(), true);
+ QList<QWidget*> kids = childWidgets(mainWindow());
if (index >= 0 && index < kids.count()) {
return QAccessible::queryAccessibleInterface(kids.at(index));
}
@@ -979,13 +979,13 @@ QAccessibleInterface *QAccessibleMainWindow::child(int index) const
int QAccessibleMainWindow::childCount() const
{
- QList<QWidget*> kids = childWidgets(mainWindow(), true);
+ QList<QWidget*> kids = childWidgets(mainWindow());
return kids.count();
}
int QAccessibleMainWindow::indexOfChild(const QAccessibleInterface *iface) const
{
- QList<QWidget*> kids = childWidgets(mainWindow(), true);
+ QList<QWidget*> kids = childWidgets(mainWindow());
return kids.indexOf(static_cast<QWidget*>(iface->object()));
}
@@ -998,7 +998,7 @@ QAccessibleInterface *QAccessibleMainWindow::childAt(int x, int y) const
if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y))
return 0;
- QWidgetList kids = childWidgets(mainWindow(), true);
+ QWidgetList kids = childWidgets(mainWindow());
QPoint rp = mainWindow()->mapFromGlobal(QPoint(x, y));
for (int i = 0; i < kids.size(); ++i) {
QWidget *child = kids.at(i);
diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp
index 6160b37a0f..88d3981391 100644
--- a/src/widgets/accessible/simplewidgets.cpp
+++ b/src/widgets/accessible/simplewidgets.cpp
@@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_ACCESSIBILITY
-extern QList<QWidget*> childWidgets(const QWidget *widget, bool includeTopLevel = false);
+extern QList<QWidget*> childWidgets(const QWidget *widget);
QString qt_accStripAmp(const QString &text);
QString qt_accHotKey(const QString &text);