diff options
author | Morten Johan Sørvig <morten.sorvig@digia.com> | 2013-03-07 13:10:49 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-28 22:21:07 +0100 |
commit | 04ebd8e56f0a5b07fe419548b0ecc8b7845ce49c (patch) | |
tree | 9b763a1d111712ab5038cd3265d7f99cf2f61d93 /src | |
parent | f4c8fb6b397744fde1581187b2c7cdb330e1e0f3 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/image/qicon.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 683fe51d2b..d73cd0aa57 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -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); + } + } } /*! |