summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2020-12-11 14:45:12 +0200
committerKatja Marttila <katja.marttila@qt.io>2020-12-21 09:15:33 +0200
commitb7df5571e0707f53716fa51d426d5ec31d36af43 (patch)
tree273923e5d6350ea82469d537adf663af6bfeebb8 /src
parent2e29ed1ec128e5d31c8294c77c215f4649c44140 (diff)
Add high dpi image support for Logo and ProductImages
Task-number: QTIFW-2061 Task-number: QTIFW-2060 Change-Id: Idaabb6a08f5e52aa7808de4b3ad541ae47dc4dd8 Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/libs/ifwtools/binarycreator.cpp1
-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
6 files changed, 30 insertions, 6 deletions
diff --git a/src/libs/ifwtools/binarycreator.cpp b/src/libs/ifwtools/binarycreator.cpp
index e8d1c3cd4..8fcc14ca3 100644
--- a/src/libs/ifwtools/binarycreator.cpp
+++ b/src/libs/ifwtools/binarycreator.cpp
@@ -60,7 +60,6 @@
using namespace QInstaller;
using namespace QInstallerTools;
-static const QLatin1String scHighDpi("@2x.");
#ifndef Q_OS_WIN
static void chmod755(const QString &absolutFilePath)
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;