Fix splashscreen size on HiDPI (windows) screens

This commit is contained in:
fieldOfView 2015-12-16 13:42:13 +01:00
parent 4bf4a20d44
commit fa9f4ca0ba

View File

@ -1,8 +1,8 @@
# Copyright (c) 2015 Ultimaker B.V. # Copyright (c) 2015 Ultimaker B.V.
# Uranium is released under the terms of the AGPLv3 or higher. # Uranium is released under the terms of the AGPLv3 or higher.
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt, QCoreApplication
from PyQt5.QtGui import QPixmap, QColor, QFont from PyQt5.QtGui import QPixmap, QColor, QFont, QFontMetrics
from PyQt5.QtWidgets import QSplashScreen from PyQt5.QtWidgets import QSplashScreen
from UM.Resources import Resources from UM.Resources import Resources
@ -11,7 +11,10 @@ from UM.Application import Application
class CuraSplashScreen(QSplashScreen): class CuraSplashScreen(QSplashScreen):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.setPixmap(QPixmap(Resources.getPath(Resources.Images, "cura.png"))) self._scale = round(QFontMetrics(QCoreApplication.instance().font()).ascent() / 12)
splash_image = QPixmap(Resources.getPath(Resources.Images, "cura.png"))
self.setPixmap(splash_image.scaled(splash_image.size() * self._scale))
def drawContents(self, painter): def drawContents(self, painter):
painter.save() painter.save()
@ -19,11 +22,11 @@ class CuraSplashScreen(QSplashScreen):
version = Application.getInstance().getVersion().split("-") version = Application.getInstance().getVersion().split("-")
painter.setFont(QFont("Proxima Nova Rg", 20)) painter.setFont(QFont("Proxima Nova Rg", 20 ))
painter.drawText(0, 0, 203, 230, Qt.AlignRight | Qt.AlignBottom, version[0]) painter.drawText(0, 0, 330 * self._scale, 230 * self._scale, Qt.AlignHCenter | Qt.AlignBottom, version[0])
if len(version) > 1: if len(version) > 1:
painter.setFont(QFont("Proxima Nova Rg", 12)) painter.setFont(QFont("Proxima Nova Rg", 12 ))
painter.drawText(0, 0, 203, 255, Qt.AlignRight | Qt.AlignBottom, version[1]) painter.drawText(0, 0, 330 * self._scale, 255 * self._scale, Qt.AlignHCenter | Qt.AlignBottom, version[1])
painter.restore() painter.restore()
super().drawContents(painter) super().drawContents(painter)