summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/qgroupbox.cpp3
-rw-r--r--src/plugins/accessible/widgets/main.cpp4
-rw-r--r--src/plugins/accessible/widgets/simplewidgets.cpp129
-rw-r--r--src/plugins/accessible/widgets/simplewidgets.h29
4 files changed, 147 insertions, 18 deletions
diff --git a/src/gui/widgets/qgroupbox.cpp b/src/gui/widgets/qgroupbox.cpp
index 236f308..03275e7 100644
--- a/src/gui/widgets/qgroupbox.cpp
+++ b/src/gui/widgets/qgroupbox.cpp
@@ -641,6 +641,9 @@ void QGroupBox::setChecked(bool b)
update();
d->checked = b;
d->_q_setChildrenEnabled(b);
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::updateAccessibility(this, 0, QAccessible::StateChanged);
+#endif
emit toggled(b);
}
}
diff --git a/src/plugins/accessible/widgets/main.cpp b/src/plugins/accessible/widgets/main.cpp
index aa0e096..d947d08 100644
--- a/src/plugins/accessible/widgets/main.cpp
+++ b/src/plugins/accessible/widgets/main.cpp
@@ -233,8 +233,10 @@ QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObjec
#endif
} else if (classname == QLatin1String("QLabel") || classname == QLatin1String("QLCDNumber")) {
iface = new QAccessibleDisplay(widget);
+#ifndef QT_NO_GROUPBOX
} else if (classname == QLatin1String("QGroupBox")) {
- iface = new QAccessibleDisplay(widget, Grouping);
+ iface = new QAccessibleGroupBox(widget);
+#endif
} else if (classname == QLatin1String("QStatusBar")) {
iface = new QAccessibleWidgetEx(widget, StatusBar);
#ifndef QT_NO_PROGRESSBAR
diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp
index 5f59133..e47cfad 100644
--- a/src/plugins/accessible/widgets/simplewidgets.cpp
+++ b/src/plugins/accessible/widgets/simplewidgets.cpp
@@ -537,10 +537,6 @@ QString QAccessibleDisplay::text(Text t, int child) const
if (str.isEmpty()) {
if (qobject_cast<QLabel*>(object())) {
str = qobject_cast<QLabel*>(object())->text();
-#ifndef QT_NO_GROUPBOX
- } else if (qobject_cast<QGroupBox*>(object())) {
- str = qobject_cast<QGroupBox*>(object())->title();
-#endif
#ifndef QT_NO_LCDNUMBER
} else if (qobject_cast<QLCDNumber*>(object())) {
QLCDNumber *l = qobject_cast<QLCDNumber*>(object());
@@ -581,13 +577,6 @@ QAccessible::Relation QAccessibleDisplay::relationTo(int child, const QAccessibl
if (o == label->buddy())
relation |= Label;
#endif
-#ifndef QT_NO_GROUPBOX
- } else {
- QGroupBox *groupbox = qobject_cast<QGroupBox*>(object());
- if (groupbox && !groupbox->title().isEmpty())
- if (groupbox->children().contains(o))
- relation |= Label;
-#endif
}
return relation;
}
@@ -604,12 +593,6 @@ int QAccessibleDisplay::navigate(RelationFlag rel, int entry, QAccessibleInterfa
if (entry == 1)
targetObject = label->buddy();
#endif
-#ifndef QT_NO_GROUPBOX
- } else {
- QGroupBox *groupbox = qobject_cast<QGroupBox*>(object());
- if (groupbox && !groupbox->title().isEmpty())
- rel = Child;
-#endif
}
*target = QAccessible::queryAccessibleInterface(targetObject);
if (*target)
@@ -660,6 +643,118 @@ QRect QAccessibleDisplay::imagePosition(QAccessible2::CoordinateType coordType)
return QRect();
}
+#ifndef QT_NO_GROUPBOX
+QAccessibleGroupBox::QAccessibleGroupBox(QWidget *w)
+ : QAccessibleWidgetEx(w, Grouping)
+{
+}
+
+QGroupBox* QAccessibleGroupBox::groupBox() const
+{
+ return static_cast<QGroupBox *>(widget());
+}
+
+QString QAccessibleGroupBox::text(QAccessible::Text t, int child) const
+{
+ QString txt = QAccessibleWidgetEx::text(t, child);
+
+ if (txt.isEmpty()) {
+ switch (t) {
+ case Name:
+ txt = qt_accStripAmp(groupBox()->title());
+ case Description:
+ txt = qt_accStripAmp(groupBox()->title());
+ default:
+ break;
+ }
+ }
+
+ return txt;
+}
+
+QAccessible::State QAccessibleGroupBox::state(int child) const
+{
+ QAccessible::State st = QAccessibleWidgetEx::state(child);
+
+ if (groupBox()->isChecked())
+ st |= QAccessible::Checked;
+
+ return st;
+}
+
+QAccessible::Role QAccessibleGroupBox::role(int child) const
+{
+ if (child)
+ return QAccessibleWidgetEx::role(child);
+
+ return groupBox()->isCheckable() ? QAccessible::CheckBox : QAccessible::Grouping;
+}
+
+int QAccessibleGroupBox::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const
+{
+ if ((rel == Labelled) && !groupBox()->title().isEmpty())
+ rel = Child;
+ return QAccessibleWidgetEx::navigate(rel, entry, target);
+}
+
+QAccessible::Relation QAccessibleGroupBox::relationTo(int child, const QAccessibleInterface* other, int otherChild) const
+{
+ QGroupBox *groupbox = this->groupBox();
+
+ QAccessible::Relation relation = QAccessibleWidgetEx::relationTo(child, other, otherChild);
+
+ if (!child && !otherChild && !groupbox->title().isEmpty()) {
+ QObject *o = other->object();
+ if (groupbox->children().contains(o))
+ relation |= Label;
+ }
+
+ return relation;
+}
+
+int QAccessibleGroupBox::actionCount()
+{
+ return groupBox()->isCheckable() ? 1 : 0;
+}
+
+void QAccessibleGroupBox::doAction(int actionIndex)
+{
+ if ((actionIndex == 0) && groupBox()->isCheckable()) {
+ groupBox()->setChecked(!groupBox()->isChecked());
+ }
+}
+
+QString QAccessibleGroupBox::description(int actionIndex)
+{
+ if ((actionIndex == 0) && (groupBox()->isCheckable())) {
+ return QLatin1String("Toggles the button.");
+ }
+ return QString();
+}
+
+QString QAccessibleGroupBox::name(int actionIndex)
+{
+ if (actionIndex || !groupBox()->isCheckable())
+ return QString();
+
+ return QLatin1String("Toggle");
+}
+
+QString QAccessibleGroupBox::localizedName(int actionIndex)
+{
+ if (actionIndex || !groupBox()->isCheckable())
+ return QString();
+
+ return QGroupBox::tr("Toggle");
+}
+
+QStringList QAccessibleGroupBox::keyBindings(int actionIndex)
+{
+ return QStringList();
+}
+
+#endif
+
#ifndef QT_NO_LINEEDIT
/*!
\class QAccessibleLineEdit
diff --git a/src/plugins/accessible/widgets/simplewidgets.h b/src/plugins/accessible/widgets/simplewidgets.h
index e1c99d2..32592ba 100644
--- a/src/plugins/accessible/widgets/simplewidgets.h
+++ b/src/plugins/accessible/widgets/simplewidgets.h
@@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE
class QAbstractButton;
class QLineEdit;
class QToolButton;
+class QGroupBox;
class QProgressBar;
class QAccessibleButton : public QAccessibleWidgetEx, public QAccessibleActionInterface
@@ -129,6 +130,34 @@ public:
QRect imagePosition(QAccessible2::CoordinateType coordType);
};
+#ifndef QT_NO_GROUPBOX
+class QAccessibleGroupBox : public QAccessibleWidgetEx,
+ public QAccessibleActionInterface
+{
+ Q_ACCESSIBLE_OBJECT
+public:
+ explicit QAccessibleGroupBox(QWidget *w);
+
+ State state(int child) const;
+ Role role(int child) const;
+ QString text(Text t, int child) const;
+
+ Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
+ int navigate(RelationFlag rel, int entry, QAccessibleInterface** target) const;
+
+ //QAccessibleActionInterface
+ int actionCount();
+ QString description(int actionIndex);
+ void doAction(int actionIndex);
+ QString name(int actionIndex);
+ QString localizedName(int actionIndex);
+ QStringList keyBindings(int actionIndex);
+
+private:
+ QGroupBox *groupBox() const;
+};
+#endif
+
#ifndef QT_NO_LINEEDIT
class QAccessibleLineEdit : public QAccessibleWidgetEx, public QAccessibleTextInterface,
public QAccessibleSimpleEditableTextInterface