Load "@2x" images on high-dpi "retina" systems.
Check for the existence of a "@2x" file when adding an image to QIcon. For example, adding "foo.png" will also add "foo@2x.png" if that file exists. Change-Id: If32a3446cf56ca0828de17f6a361091e4c874f26 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
parent
f4c8fb6b39
commit
04ebd8e56f
@ -958,6 +958,17 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
|
||||
detach();
|
||||
}
|
||||
d->engine->addFile(fileName, size, mode, state);
|
||||
|
||||
// Check if a "@2x" file exists and add it.
|
||||
if (qApp->devicePixelRatio() > 1.0) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user