diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-09-03 12:23:15 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-09-20 17:46:52 +0200 |
commit | deb238586a4420f6848fb60b3356ec6220b86b17 (patch) | |
tree | 7dd66f4416782ae07e1ebd01e04035e58dba6b73 /src/quickcontrols2impl | |
parent | 88aea5173f5bb7d900a4a3220ba44a2632262624 (diff) |
QQuickIcon: Resolve URL relative to current element
If a user passes a relative URL to icon, they probably expect the URL to
be handled relative to the current file (like in Qt 5). We restore this
behavior by doing the URL resolution in the current QML context.
Unfortunately, as a gadget, QQuickIcon does not have its own context.
Thus, we need to store (and set) a pointer to its "owner", so that we can
retrieve the context for the binding that causes the URL to be set.
We adjust the three classes which currently use QQuickIcon to set the
owner in their setIcon methods.
Task-number: QTBUG-95587
Pick-to: 6.2
Change-Id: Icd1f2ddf65ae7d09ff787a50a01f1db78c571abf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quickcontrols2impl')
-rw-r--r-- | src/quickcontrols2impl/qquickiconlabel.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/quickcontrols2impl/qquickiconlabel.cpp b/src/quickcontrols2impl/qquickiconlabel.cpp index d76da28f93..111c68cc98 100644 --- a/src/quickcontrols2impl/qquickiconlabel.cpp +++ b/src/quickcontrols2impl/qquickiconlabel.cpp @@ -78,7 +78,7 @@ bool QQuickIconLabelPrivate::createImage() beginClass(image); image->setObjectName(QStringLiteral("image")); image->setName(icon.name()); - image->setSource(icon.source()); + image->setSource(icon.resolvedSource()); image->setSourceSize(QSize(icon.width(), icon.height())); image->setColor(icon.color()); image->setCache(icon.cache()); @@ -112,7 +112,7 @@ void QQuickIconLabelPrivate::syncImage() return; image->setName(icon.name()); - image->setSource(icon.source()); + image->setSource(icon.resolvedSource()); image->setSourceSize(QSize(icon.width(), icon.height())); image->setColor(icon.color()); image->setCache(icon.cache()); @@ -399,6 +399,7 @@ void QQuickIconLabel::setIcon(const QQuickIcon &icon) return; d->icon = icon; + d->icon.setOwner(this); d->updateOrSyncImage(); } |