diff options
author | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-01-26 16:22:48 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-02-06 06:32:34 +0000 |
commit | 4805714b0f5d5584fd390067b6c092ca5ee7f482 (patch) | |
tree | 604139ba76064fd138c91cc8d20cb3467ac84095 | |
parent | 6246e142a48dd66a8cba4ac2846276db5da952ed (diff) |
QIcon: Fix that HiDPI image was not found with QRC alias
When using images in QRC and giving the 1x and 2x image files
respective aliases but without any file extension
(for example 'myimage' and 'myimage@2x'),
then QIcon would fail to find the 2x variant.
Task-number: QTBUG-44049
Change-Id: I400bf6d22aeefe0aa351c68e473bf24ac2a36471
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
-rw-r--r-- | src/gui/image/qicon.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 6f6bf158c8..86d9c02c6e 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -1026,13 +1026,13 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State // Check if a "@2x" file exists and add it. static bool disable2xImageLoading = !qgetenv("QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING").isEmpty(); if (!disable2xImageLoading && qApp->devicePixelRatio() > 1.0) { + QString at2xfileName = fileName; int dotIndex = fileName.lastIndexOf(QLatin1Char('.')); - if (dotIndex != -1) { - QString at2xfileName = fileName; - at2xfileName.insert(dotIndex, QStringLiteral("@2x")); - if (QFile::exists(at2xfileName)) - d->engine->addFile(at2xfileName, size, mode, state); - } + if (dotIndex == -1) /* no dot */ + dotIndex = fileName.size(); /* append */ + at2xfileName.insert(dotIndex, QStringLiteral("@2x")); + if (QFile::exists(at2xfileName)) + d->engine->addFile(at2xfileName, size, mode, state); } } |