r24309 by jghali - #16379 : Adjustments for splash screen : scale smoothly if device pixel ratio is not an integer value
scribus-commit
scribus-commit at lists.scribus.net
Mon Dec 7 19:00:21 UTC 2020
Author: jghali
Date: Mon Dec 7 19:00:21 2020
New Revision: 24309
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24309
Log:
#16379 : Adjustments for splash screen : scale smoothly if device pixel ratio is not an integer value
Modified:
trunk/Scribus/scribus/scribuscore.cpp
trunk/Scribus/scribus/ui/about.cpp
Modified: trunk/Scribus/scribus/scribuscore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24309&path=/trunk/Scribus/scribus/scribuscore.cpp
==============================================================================
--- trunk/Scribus/scribus/scribuscore.cpp (original)
+++ trunk/Scribus/scribus/scribuscore.cpp Mon Dec 7 19:00:21 2020
@@ -23,10 +23,12 @@
#include <cassert>
#include <iostream>
+
#include <QByteArray>
#include <QDebug>
#include <QGlobalStatic>
#include <QMessageBox>
+#include <QScreen>
#include "colormgmt/sccolormgmtenginefactory.h"
#include "commonstrings.h"
@@ -208,7 +210,20 @@
m_SplashScreen = nullptr;
if (!showSplash)
return;
+
+ QScreen* primaryScreeen = qApp->primaryScreen();
+ double pixelRatio = primaryScreeen ? primaryScreeen->devicePixelRatio() : 1.0;
QPixmap pix = IconManager::instance().loadPixmap("scribus_splash.png", true);
+ if (pixelRatio != 1.0)
+ {
+ int w = qRound(pix.width() * pixelRatio);
+ int h = qRound(pix.height() * pixelRatio);
+ double integralPart = 0;
+ bool isIntegerRatio = (modf(pixelRatio, &integralPart) == 0.0);
+ pix = pix.scaled(w, h, Qt::IgnoreAspectRatio, isIntegerRatio ? Qt::FastTransformation : Qt::SmoothTransformation);
+ pix.setDevicePixelRatio(pixelRatio);
+ }
+
m_SplashScreen = new ScSplashScreen(pix, Qt::WindowStaysOnTopHint);
if (m_SplashScreen != nullptr)
{
Modified: trunk/Scribus/scribus/ui/about.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24309&path=/trunk/Scribus/scribus/ui/about.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/about.cpp (original)
+++ trunk/Scribus/scribus/ui/about.cpp Mon Dec 7 19:00:21 2020
@@ -106,9 +106,24 @@
tabLayout1 = new QVBoxLayout( tab );
tabLayout1->setSpacing( 6 );
tabLayout1->setMargin( 15 );
+
+ double pixelRatio = devicePixelRatioF();
+ QPixmap splashPixmap = IconManager::instance().loadPixmap("scribus_splash.png", true);
+ double splashPixmapW = splashPixmap.width();
+ double splashPixmapH = splashPixmap.height();
+ if (pixelRatio != 1.0)
+ {
+ int w = qRound(splashPixmap.width() * pixelRatio);
+ int h = qRound(splashPixmap.height() * pixelRatio);
+ double integralPart = 0;
+ bool isIntegerRatio = (modf(pixelRatio, &integralPart) == 0.0);
+ splashPixmap = splashPixmap.scaled(w, h, Qt::IgnoreAspectRatio, isIntegerRatio ? Qt::FastTransformation : Qt::SmoothTransformation);
+ splashPixmap.setDevicePixelRatio(pixelRatio);
+ }
+
pixmapLabel1 = new QLabel( tab );
- pixmapLabel1->setPixmap(IconManager::instance().loadPixmap("scribus_splash.png", true));
- pixmapLabel1->setFixedSize(QSize(pixmapLabel1->pixmap()->width(), pixmapLabel1->pixmap()->height()));
+ pixmapLabel1->setPixmap(splashPixmap);
+ pixmapLabel1->setFixedSize(QSize(splashPixmapW, splashPixmapH));
pixmapLabel1->setAlignment(Qt::AlignCenter);
tabLayout1->addWidget( pixmapLabel1 );
buildID = new QLabel( tab );
More information about the scribus-commit
mailing list