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>
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;