Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add accessibility updates.
Re-add all accessibility updates with new api.

Change-Id: Iec91c41a0137911ccf6e9f4fa907a378d9dd335a
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
  • Loading branch information
Frederik Gladhorn authored and Qt by Nokia committed Mar 23, 2012
1 parent 91f9f12 commit 3d8f103
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/quick/items/qquickaccessibleattached.cpp
Expand Up @@ -144,6 +144,10 @@ QQuickAccessibleAttached::QQuickAccessibleAttached(QObject *parent)
// Enable accessibility for items with accessible content. This also
// enables accessibility for the ancestors of souch items.
item->d_func()->setAccessibleFlagAndListener();
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent ev(item, QAccessible::ObjectCreated);
QAccessible::updateAccessibility(&ev);
#endif
}

QQuickAccessibleAttached::~QQuickAccessibleAttached()
Expand Down
8 changes: 8 additions & 0 deletions src/quick/items/qquickaccessibleattached_p.h
Expand Up @@ -85,6 +85,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAccessibleAttached : public QObject
if (name != m_name) {
m_name = name;
emit nameChanged();
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent ev(parent(), QAccessible::NameChanged);
QAccessible::updateAccessibility(&ev);
#endif
}
}

Expand All @@ -94,6 +98,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAccessibleAttached : public QObject
if (m_description != description) {
m_description = description;
emit descriptionChanged();
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent ev(parent(), QAccessible::DescriptionChanged);
QAccessible::updateAccessibility(&ev);
#endif
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/quick/items/qquickitem.cpp
Expand Up @@ -3122,6 +3122,10 @@ void QQuickItem::inputMethodEvent(QInputMethodEvent *event)

void QQuickItem::focusInEvent(QFocusEvent *)
{
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent ev(this, QAccessible::Focus);
QAccessible::updateAccessibility(&ev);
#endif
}

void QQuickItem::focusOutEvent(QFocusEvent *)
Expand Down Expand Up @@ -4085,7 +4089,12 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
childVisibilityChanged |= QQuickItemPrivate::get(childItems.at(ii))->setEffectiveVisibleRecur(newEffectiveVisible);

itemChange(QQuickItem::ItemVisibleHasChanged, effectiveVisible);

#ifndef QT_NO_ACCESSIBILITY
if (isAccessible) {
QAccessibleEvent ev(q, effectiveVisible ? QAccessible::ObjectShow : QAccessible::ObjectHide);
QAccessible::updateAccessibility(&ev);
}
#endif
emit q->visibleChanged();
if (childVisibilityChanged)
emit q->visibleChildrenChanged();
Expand Down
16 changes: 15 additions & 1 deletion src/quick/items/qquicktextinput.cpp
Expand Up @@ -3302,6 +3302,7 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo
*/
void QQuickTextInputPrivate::internalSetText(const QString &txt, int pos, bool edited)
{
Q_Q(QQuickTextInput);
internalDeselect();
QString oldText = m_text;
if (m_maskData) {
Expand All @@ -3315,7 +3316,15 @@ void QQuickTextInputPrivate::internalSetText(const QString &txt, int pos, bool e
m_cursor = (pos < 0 || pos > m_text.length()) ? m_text.length() : pos;
m_textDirty = (oldText != m_text);

finishChange(-1, true, edited);
bool changed = finishChange(-1, true, edited);
#ifdef QT_NO_ACCESSIBILITY
Q_UNUSED(changed)
#else
if (changed) {
QAccessibleTextUpdateEvent ev(q, 0, oldText, m_text);
QAccessible::updateAccessibility(&ev);
}
#endif
}


Expand Down Expand Up @@ -3939,6 +3948,11 @@ bool QQuickTextInputPrivate::emitCursorPositionChanged()
}
}

#ifndef QT_NO_ACCESSIBILITY
QAccessibleTextCursorEvent ev(q, m_cursor);
QAccessible::updateAccessibility(&ev);
#endif

return true;
}
return false;
Expand Down

0 comments on commit 3d8f103

Please sign in to comment.