summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2014-05-19 22:56:13 +0200
committerMorten Johan Sørvig <morten.sorvig@digia.com>2014-07-03 09:15:42 +0200
commit5f3ec26d90c239420d7865cba91e625283f08ba1 (patch)
tree33899ce5dfa98114ace1dac16665063825cf94cd /src/gui/image
parent19d289ab1b5bde3e136765e5432b5c7d004df3a4 (diff)
Add opt-out environment variable for @2x images
There are cases where @2x images are in use but where you don't want the associated behavior: - You are implementing an image editor - You are inheriting a resource set which has @2x images, but don't want that behavior with Qt. Add support for disabling @2x behavior with QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING. Change-Id: I206e050b6241f8935b4404c7a28b024a9e00d46c Task-id: QTBUG-38485 Reviewed-by: Jake Petroules <jake.petroules@petroules.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qicon.cpp3
-rw-r--r--src/gui/image/qimagereader.cpp5
2 files changed, 5 insertions, 3 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 8172ecbb48..681e7e3f79 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1026,7 +1026,8 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
d->engine->addFile(fileName, size, mode, state);
// Check if a "@2x" file exists and add it.
- if (qApp->devicePixelRatio() > 1.0) {
+ static bool disable2xImageLoading = !qgetenv("QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING").isEmpty();
+ if (!disable2xImageLoading && qApp->devicePixelRatio() > 1.0) {
int dotIndex = fileName.lastIndexOf(QLatin1Char('.'));
if (dotIndex != -1) {
QString at2xfileName = fileName;
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index 091837b8b4..a10198a006 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -1247,8 +1247,9 @@ bool QImageReader::read(QImage *image)
}
// successful read; check for "@2x" file name suffix and set device pixel ratio.
- if (QFileInfo(fileName()).baseName().endsWith(QLatin1String("@2x"))) {
- image->setDevicePixelRatio(2.0);
+ static bool disable2xImageLoading = !qgetenv("QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING").isEmpty();
+ if (!disable2xImageLoading && QFileInfo(fileName()).baseName().endsWith(QLatin1String("@2x"))) {
+ image->setDevicePixelRatio(2.0);
}
return true;