GUI: Preliminary support for HiDPI splashscreen

This commit is contained in:
Chris Hennes
2022-06-12 20:10:06 -05:00
committed by Uwe
parent 4b1004b33a
commit 5219718eb0
3 changed files with 12 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 KiB

View File

@@ -1,6 +1,7 @@
<RCC>
<qresource prefix="/icons">
<file>freecadsplash.png</file>
<file>freecadsplash2x.png</file>
<file>freecadabout.png</file>
<file>background.png</file>
<file>mouse_pointer.svg</file>

View File

@@ -1525,7 +1525,15 @@ QPixmap MainWindow::splashImage() const
// now try the icon paths
if (splash_image.isNull()) {
splash_image = Gui::BitmapFactory().pixmap(splash_path.c_str());
if (qApp->devicePixelRatio() > 1.0) {
// For HiDPI screens, we have a double-resolution version of the splash image
splash_path += "2x";
splash_image = Gui::BitmapFactory().pixmap(splash_path.c_str());
splash_image.setDevicePixelRatio(2.0);
}
else {
splash_image = Gui::BitmapFactory().pixmap(splash_path.c_str());
}
}
// include application name and version number
@@ -1559,14 +1567,14 @@ QPixmap MainWindow::splashImage() const
}
QFont fontExe = painter.font();
fontExe.setPointSize(20);
fontExe.setPointSizeF(20.0);
QFontMetrics metricExe(fontExe);
int l = QtTools::horizontalAdvance(metricExe, title);
int w = splash_image.width();
int h = splash_image.height();
QFont fontVer = painter.font();
fontVer.setPointSize(12);
fontVer.setPointSizeF(12.0);
QFontMetrics metricVer(fontVer);
int v = QtTools::horizontalAdvance(metricVer, version);