aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickpopupitem.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-12-30 11:44:50 +0100
committerLiang Qi <liang.qi@qt.io>2019-12-30 11:44:50 +0100
commitec686af14f817cc51323cfb01186f036905789c3 (patch)
tree29d229c8df8f37db56b9f6f5f3997bcd732689d4 /src/quicktemplates2/qquickpopupitem.cpp
parent0425562e14e41b62dc7631c7c02768b8294454d0 (diff)
parent090eab86b05478572485b3086c087a846fbae7fd (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts: .qmake.conf tests/auto/controls/data/tst_combobox.qml Change-Id: I8471cdac4397f77a8e58140d58c6b50d3c437928
Diffstat (limited to 'src/quicktemplates2/qquickpopupitem.cpp')
-rw-r--r--src/quicktemplates2/qquickpopupitem.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp
index 28ddde66..8e169b0b 100644
--- a/src/quicktemplates2/qquickpopupitem.cpp
+++ b/src/quicktemplates2/qquickpopupitem.cpp
@@ -47,6 +47,10 @@
#endif
#include <QtGui/private/qguiapplication_p.h>
+#if QT_CONFIG(accessibility)
+#include <QtQuick/private/qquickaccessibleattached_p.h>
+#endif
+
QT_BEGIN_NAMESPACE
class QQuickPopupItemPrivate : public QQuickPagePrivate
@@ -403,7 +407,28 @@ QAccessible::Role QQuickPopupItem::accessibleRole() const
void QQuickPopupItem::accessibilityActiveChanged(bool active)
{
Q_D(const QQuickPopupItem);
+ // Can't just use d->popup->accessibleName() here, because that refers to the accessible
+ // name of us, the popup item, which is not what we want.
+ const QQuickAccessibleAttached *popupAccessibleAttached = QQuickControlPrivate::accessibleAttached(d->popup);
+ const QString oldPopupName = popupAccessibleAttached ? popupAccessibleAttached->name() : QString();
+ const bool wasNameExplicitlySetOnPopup = popupAccessibleAttached && popupAccessibleAttached->wasNameExplicitlySet();
+
QQuickPage::accessibilityActiveChanged(active);
+
+ QQuickAccessibleAttached *accessibleAttached = QQuickControlPrivate::accessibleAttached(this);
+ const QString ourName = accessibleAttached ? accessibleAttached->name() : QString();
+ if (wasNameExplicitlySetOnPopup && accessibleAttached && ourName != oldPopupName) {
+ // The user set Accessible.name on the Popup. Since the Popup and its popup item
+ // have different accessible attached properties, the popup item doesn't know that
+ // a name was set on the Popup by the user, and that it should use that, rather than
+ // whatever QQuickPage sets. That's why we need to do it here.
+ // To avoid it being overridden by the call to accessibilityActiveChanged() below,
+ // we set it explicitly. It's safe to do this as the popup item is an internal implementation detail.
+ accessibleAttached->setName(oldPopupName);
+ }
+
+ // This allows the different popup types to set a name on their popup item accordingly.
+ // For example: Dialog uses its title and ToolTip uses its text.
d->popup->accessibilityActiveChanged(active);
}
#endif