summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2017-06-14 10:58:38 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-06-24 21:24:53 +0000
commit8dd8acf8bbfde548756ccde52cb14c848f2d8739 (patch)
treea9941d71d6439b14541f28cd0bc93bdc7f1cadb9 /src
parentd9206926d88b779495cc32c3cfec6bcc53021546 (diff)
qt_findAtNxFile(): account for .9 (9-patch image) extensions
Currently a file with a .9.png extension will only have its @2x variant found if it follows this format: foo.9@2x.png Since ".9" should be considered part of the file suffix, it should ideally be able to look like this and still be picked up: foo@2x.9.png This patch makes qt_findAtNxFile() account for .9.* extensions. This is needed for the image-based style support in Qt Quick Controls 2, which uses 9-patch images. qmlbench benchmark results using benchmarks\auto\creation\quick.image\delegates_image.qml with QT_SCALE_FACTOR=2 show no difference in performance after this patch is applied. [ChangeLog][QtGui] High DPI variants of 9-patch images can now be loaded using the following syntax: "foo@2x.9.png" Change-Id: I6d1384113bef21b4fe85a104ee6b16869c93b077 Reviewed-by: J-P Nurmi <jpnurmi@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/image/qicon.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index fa4b4e01af..9b2e96d4b0 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1469,8 +1469,13 @@ QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRati
return baseFileName;
int dotIndex = baseFileName.lastIndexOf(QLatin1Char('.'));
- if (dotIndex == -1) /* no dot */
+ if (dotIndex == -1) { /* no dot */
dotIndex = baseFileName.size(); /* append */
+ } else if (dotIndex >= 2 && baseFileName[dotIndex - 1] == QLatin1Char('9')
+ && baseFileName[dotIndex - 2] == QLatin1Char('.')) {
+ // If the file has a .9.* (9-patch image) extension, we must ensure that the @nx goes before it.
+ dotIndex -= 2;
+ }
QString atNxfileName = baseFileName;
atNxfileName.insert(dotIndex, QLatin1String("@2x"));