forked from qt-creator/qt-creator
Utils: StyleHelper::dpiSpecificPixmap > ::dpiSpecificImageFile
Letting that helper function return a file name is more flexible than returning a QPixmap. Change-Id: I4634e4e795eec029608c8e65c1a0e8afff870a91 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
This commit is contained in:
@@ -522,25 +522,17 @@ QLinearGradient StyleHelper::statusBarGradient(const QRect &statusBarRect)
|
||||
return grad;
|
||||
}
|
||||
|
||||
QPixmap StyleHelper::dpiSpecificPixmap(const QString &fileName)
|
||||
QString StyleHelper::dpiSpecificImageFile(const QString &fileName)
|
||||
{
|
||||
QString pixmapFileName = fileName;
|
||||
qreal pixmapDevicePixelRatio = 1.0;
|
||||
|
||||
// See QIcon::addFile()
|
||||
if (qApp->devicePixelRatio() > 1.0) {
|
||||
const QFileInfo fi(fileName);
|
||||
const QString at2xfileName = fi.path() + QLatin1Char('/')
|
||||
+ fi.completeBaseName() + QStringLiteral("@2x.") + fi.suffix();
|
||||
if (QFile::exists(at2xfileName)) {
|
||||
pixmapFileName = at2xfileName;
|
||||
pixmapDevicePixelRatio = 2.0;
|
||||
}
|
||||
if (QFile::exists(at2xfileName))
|
||||
return at2xfileName;
|
||||
}
|
||||
|
||||
QPixmap result(pixmapFileName);
|
||||
result.setDevicePixelRatio(pixmapDevicePixelRatio);
|
||||
return result;
|
||||
return fileName;
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
Reference in New Issue
Block a user