diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2015-11-11 15:32:29 +0100 |
---|---|---|
committer | Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> | 2015-11-13 15:05:12 +0000 |
commit | d6b45853f5d45b5922c93f947d8909855f19a8b9 (patch) | |
tree | 91416c841af7681c550a87a1b47d5569c43f1430 /src/gui/image | |
parent | 45be40540801bc760b09d731958ba646e4eb946c (diff) |
Make qt_findAtNxFile return the source device pixel ratio
QTextImageHandler needs it.
And QQuickImageBase will also need it.
Change-Id: Ica5d17519c4c6c06e25bab7d2b1d3733f4058425
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qicon.cpp | 11 | ||||
-rw-r--r-- | src/gui/image/qicon.h | 3 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index af3af516db..b2d9ed18f5 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -1378,8 +1378,12 @@ QDebug operator<<(QDebug dbg, const QIcon &i) Given base foo.png and a target dpr of 2.5, this function will look for foo@3x.png, then foo@2x, then fall back to foo.png if not found. + + \a sourceDevicePixelRatio will be set to the value of N if the argument is + a non-null pointer */ -QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio) +QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio, + qreal *sourceDevicePixelRatio) { if (targetDevicePixelRatio <= 1.0) return baseFileName; @@ -1397,8 +1401,11 @@ QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRati for (int n = qCeil(targetDevicePixelRatio); n > 1; --n) { QString atNxfileName = baseFileName; atNxfileName.insert(dotIndex, atNx.arg(n)); - if (QFile::exists(atNxfileName)) + if (QFile::exists(atNxfileName)) { + if (sourceDevicePixelRatio) + *sourceDevicePixelRatio = n; return atNxfileName; + } } return baseFileName; diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h index 8c72f54629..9ed7336502 100644 --- a/src/gui/image/qicon.h +++ b/src/gui/image/qicon.h @@ -139,7 +139,8 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &); Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QIcon &); #endif -Q_GUI_EXPORT QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio); +Q_GUI_EXPORT QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio, + qreal *sourceDevicePixelRatio = Q_NULLPTR); QT_END_NAMESPACE |