aboutsummaryrefslogtreecommitdiffstats
path: root/src/controls/qquicklabel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/controls/qquicklabel.cpp')
-rw-r--r--src/controls/qquicklabel.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/controls/qquicklabel.cpp b/src/controls/qquicklabel.cpp
index f70179c1..2175fc33 100644
--- a/src/controls/qquicklabel.cpp
+++ b/src/controls/qquicklabel.cpp
@@ -43,11 +43,18 @@
#include <QtQuick/private/qquicktext_p.h>
#include <QtQuick/private/qquickclipnode_p.h>
+#ifndef QT_NO_ACCESSIBILITY
+#include <QtQuick/private/qquickaccessibleattached_p.h>
+#endif
+
QT_BEGIN_NAMESPACE
QQuickLabel::QQuickLabel(QQuickItem *parent) :
QQuickText(*(new QQuickLabelPrivate), parent)
{
+ Q_D(const QQuickLabel);
+ QObjectPrivate::connect(this, &QQuickText::textChanged,
+ d, &QQuickLabelPrivate::_q_textChanged);
}
QQuickLabel::~QQuickLabel()
@@ -70,6 +77,16 @@ void QQuickLabelPrivate::resolveFont()
setFont_helper(resolvedFont);
}
+void QQuickLabelPrivate::_q_textChanged(const QString &text)
+{
+#ifndef QT_NO_ACCESSIBILITY
+ if (accessibleAttached)
+ accessibleAttached->setName(text);
+#else
+ Q_UNUSED(text)
+#endif
+}
+
QFont QQuickLabel::font() const
{
Q_D(const QQuickLabel);
@@ -95,6 +112,19 @@ void QQuickLabel::setFont(const QFont &font)
emit fontChanged();
}
+void QQuickLabel::classBegin()
+{
+ QQuickText::classBegin();
+#ifndef QT_NO_ACCESSIBILITY
+ Q_D(QQuickLabel);
+ d->accessibleAttached = qobject_cast<QQuickAccessibleAttached *>(qmlAttachedPropertiesObject<QQuickAccessibleAttached>(this, true));
+ if (d->accessibleAttached)
+ d->accessibleAttached->setRole((QAccessible::Role)0x00000029); // Accessible.StaticText
+ else
+ qWarning() << "QQuickLabel: QQuickAccessibleAttached object creation failed!";
+#endif
+}
+
QQuickItem *QQuickLabel::background() const
{
Q_D(const QQuickLabel);