aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2013-03-05 08:55:34 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-05 09:31:09 +0100
commit707bbe5dea9d7398b205124a54422f2fafb6f151 (patch)
treea39cdcc66e964caa6a59e5ea37c2a9e529e323eb /src/quick
parente65a7e2f9955bb873c569fcb7e40dd645d9846c2 (diff)
Load "@2x" images on high-dpi "retina" systems.
Check for the existence of a "@2x" file when loading an image from a local file url. For example, Image { source = "foo.png" } will load "foo@2x.png" if that file exists. Change-Id: I37688d035bc9eb412d54be0eb758dd52ebfa5d90 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/util/qquickpixmapcache.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index 0033be82be..d5ef4b767f 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -1020,6 +1020,17 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
if (localFile.isEmpty())
return 0;
+ // check for "retina" high-dpi and use @2x file if it exixts
+ if (qApp->devicePixelRatio() > 1) {
+ int dotIndex = localFile.lastIndexOf(QStringLiteral("."));
+ if (dotIndex != -1) {
+ QString retinaFile = localFile;
+ retinaFile.insert(dotIndex, "@2x");
+ if (QFile(retinaFile).exists())
+ localFile = retinaFile;
+ }
+ }
+
QFile f(localFile);
QSize readSize;
QString errorString;