Fix a11y crash: dock doesn't always have a widget.

Also return dock widget title.

Reviewed-by: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
(cherry picked from commit 276d16583b80da2838f9af47e15fe3a83cdb0485)

Change-Id: I8d66bec4212cc2b1df8c9b041375d7455c6a76a3
Reviewed-on: http://codereview.qt.nokia.com/3023
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
This commit is contained in:
Frederik Gladhorn 2011-06-28 14:37:10 +02:00 committed by Qt by Nokia
parent 910e1bf415
commit 90fd142c93

View File

@ -73,6 +73,9 @@ QT_BEGIN_NAMESPACE
using namespace QAccessible2;
QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
QString Q_GUI_EXPORT qt_accHotKey(const QString &text);
QList<QWidget*> childWidgets(const QWidget *widget, bool includeTopLevel)
{
if (widget == 0)
@ -1139,8 +1142,8 @@ int QAccessibleTitleBar::childCount() const
QString QAccessibleTitleBar::text(Text t, int child) const
{
if (!child) {
if (t == Value) {
return dockWidget()->windowTitle();
if (t == Name || t == Value) {
return qt_accStripAmp(dockWidget()->windowTitle());
}
}
return QString();
@ -1171,17 +1174,19 @@ QAccessible::State QAccessibleTitleBar::state(int child) const
return state;
}
QRect QAccessibleTitleBar::rect (int child ) const
QRect QAccessibleTitleBar::rect(int child) const
{
bool mapToGlobal = true;
QRect rect;
if (child == 0) {
if (dockWidget()->isFloating()) {
rect = dockWidget()->frameGeometry();
QPoint globalPos = dockWidget()->mapToGlobal( dockWidget()->widget()->rect().topLeft() );
globalPos.ry()--;
rect.setBottom(globalPos.y());
mapToGlobal = false;
if (dockWidget()->widget()) {
QPoint globalPos = dockWidget()->mapToGlobal(dockWidget()->widget()->rect().topLeft());
globalPos.ry()--;
rect.setBottom(globalPos.y());
mapToGlobal = false;
}
} else {
QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(dockWidget()->layout());
rect = layout->titleArea();