summaryrefslogtreecommitdiffstats
path: root/src/libs/installer
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/installer')
-rw-r--r--src/libs/installer/constants.h1
-rw-r--r--src/libs/installer/fileutils.cpp17
-rw-r--r--src/libs/installer/fileutils.h1
-rw-r--r--src/libs/installer/packagemanagergui.cpp5
-rw-r--r--src/libs/installer/settings.cpp11
5 files changed, 30 insertions, 5 deletions
diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h
index 35fcb9c89..711aaa66b 100644
--- a/src/libs/installer/constants.h
+++ b/src/libs/installer/constants.h
@@ -98,6 +98,7 @@ static const QLatin1String scSupportsModify("SupportsModify");
static const QLatin1String scAllowUnstableComponents("AllowUnstableComponents");
static const QLatin1String scSaveDefaultRepositories("SaveDefaultRepositories");
static const QLatin1String scRepositoryCategoryDisplayName("RepositoryCategoryDisplayName");
+static const QLatin1String scHighDpi("@2x.");
const char scRelocatable[] = "@RELOCATABLE_PATH@";
}
diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp
index 76e5e3cd8..273901267 100644
--- a/src/libs/installer/fileutils.cpp
+++ b/src/libs/installer/fileutils.cpp
@@ -28,6 +28,7 @@
#include "fileutils.h"
#include "globals.h"
+#include "constants.h"
#include <errors.h>
#include <QtCore/QDateTime>
@@ -40,6 +41,8 @@
#include <QtCore/QCoreApplication>
#include <QImageReader>
#include <QRandomGenerator>
+#include <QGuiApplication>
+#include <QScreen>
#include <errno.h>
@@ -707,3 +710,17 @@ QString QInstaller::replacePath(const QString &path, const QString &before, cons
return QDir::cleanPath(after) + pathToPatch.mid(pathToReplace.size());
return path;
}
+
+/*!
+ Replaces \a imagePath with high dpi image. If high dpi image is not provided or
+ high dpi screen is not in use, the original value is returned.
+*/
+void QInstaller::replaceHighDpiImage(QString &imagePath)
+{
+ if (QGuiApplication::primaryScreen()->devicePixelRatio() >= 2 ) {
+ QFileInfo fi(imagePath);
+ QString highdpiPixmap = fi.absolutePath() + QLatin1Char('/') + fi.baseName() + scHighDpi + fi.suffix();
+ if (QFileInfo::exists(highdpiPixmap))
+ imagePath = highdpiPixmap;
+ }
+}
diff --git a/src/libs/installer/fileutils.h b/src/libs/installer/fileutils.h
index 78241d3ce..101a6a1cc 100644
--- a/src/libs/installer/fileutils.h
+++ b/src/libs/installer/fileutils.h
@@ -92,6 +92,7 @@ private:
bool INSTALLER_EXPORT isInBundle(const QString &path, QString *bundlePath = 0);
QString replacePath(const QString &path, const QString &pathBefore, const QString &pathAfter);
+ void replaceHighDpiImage(QString &imagePath);
#ifdef Q_OS_WIN
QString INSTALLER_EXPORT getLongPathName(const QString &name);
diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp
index 339079b10..4a454e781 100644
--- a/src/libs/installer/packagemanagergui.cpp
+++ b/src/libs/installer/packagemanagergui.cpp
@@ -1238,10 +1238,13 @@ QPixmap PackageManagerPage::bannerPixmap() const
/*!
Returns the logo pixmap specified in the \c <Logo> element of the package information file.
+ If @2x image is provided, returns that instead for high DPI displays.
*/
QPixmap PackageManagerPage::logoPixmap() const
{
- return QPixmap(m_core->value(QLatin1String("LogoPixmap")));
+ QString logoPixmap = m_core->value(QLatin1String("LogoPixmap"));
+ QInstaller::replaceHighDpiImage(logoPixmap);
+ return QPixmap(logoPixmap);
}
/*!
diff --git a/src/libs/installer/settings.cpp b/src/libs/installer/settings.cpp
index aeacf7a8e..8b921213b 100644
--- a/src/libs/installer/settings.cpp
+++ b/src/libs/installer/settings.cpp
@@ -32,6 +32,7 @@
#include "repository.h"
#include "repositorycategory.h"
#include "globals.h"
+#include "fileutils.h"
#include <QtCore/QFileInfo>
#include <QtCore/QStringList>
@@ -497,10 +498,12 @@ QStringList Settings::productImages() const
const QVariant variant = d->m_data.value(scProductImages);
QStringList imagePaths;
if (variant.canConvert<QStringList>()) {
- foreach (const QString &imagePath, variant.value<QStringList>()) {
- QFileInfo(imagePath).isAbsolute()
- ? imagePaths.append(imagePath)
- : imagePaths.append(d->m_data.value(scPrefix).toString() + QLatin1Char('/') + imagePath);
+ foreach (auto image, variant.value<QStringList>()) {
+ QString imagePath = QFileInfo(image).isAbsolute()
+ ? image
+ : d->m_data.value(scPrefix).toString() + QLatin1Char('/') + image;
+ QInstaller::replaceHighDpiImage(imagePath);
+ imagePaths.append(imagePath);
}
}
return imagePaths;