From 805e088aa9179c253f848fc9153f4bac2b829971 Mon Sep 17 00:00:00 2001 From: Hugh Sorby Date: Tue, 30 Jul 2024 13:35:07 +1200 Subject: [PATCH] Play with spash screen improvements. --- src/mapclient/splashscreen.py | 40 ++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/mapclient/splashscreen.py b/src/mapclient/splashscreen.py index a2733096..157ea8a2 100644 --- a/src/mapclient/splashscreen.py +++ b/src/mapclient/splashscreen.py @@ -2,34 +2,40 @@ from PySide6 import QtCore, QtGui, QtWidgets +from mapclient.settings.version import __version__ as version + class SplashScreen(QtWidgets.QSplashScreen): def __init__(self): super(SplashScreen, self).__init__() + self._message = '' pixmap = QtGui.QPixmap(":/mapclient/splash.png") self.setPixmap(pixmap) - self._font = QtGui.QFont() - self._font.setPixelSize(20) + # self._font = QtGui.QFont() + # self._font.setPixelSize(24) self._progress_bar = QtWidgets.QProgressBar() self._progress_bar.setRange(0, 100) - self._progress_bar.setGeometry(0, 0, pixmap.width() - 0, 8) -# self.setStyleSheet(""" -# QProgressBar { -# border: 2px solid grey; -# border-radius: 5px; -# } -# -# QProgressBar::chunk { -# background-color: #05B8CC; -# width: 20px; -# } """) + self._progress_bar.setGeometry(0, 0, pixmap.width() - int(6 * self.devicePixelRatioF()), 8) self._pixmap_height = pixmap.height() - self.setFont(self._font) + # self.setFont(self._font) def drawContents(self, painter): - self._progress_bar.render(painter, QtCore.QPoint(0, self._pixmap_height - 8)) + vertical_offset = int(3 * self.devicePixelRatioF()) + self._progress_bar.render(painter, QtCore.QPoint(vertical_offset, self._pixmap_height - 8 - vertical_offset)) super(SplashScreen, self).drawContents(painter) + font = QtGui.QFont() + font.setFamily('Arial') + font.setPointSize(24) + painter.setFont(font) + pen = QtGui.QPen() + colour = QtGui.QColor("black") + colour.setRgb(44, 45, 43) + pen.setColor(colour) + painter.setPen(pen) + painter.drawText(550, 320, 120, 40, QtCore.Qt.AlignmentFlag.AlignHCenter, f"v{version}") + painter.drawText(8, 320, 500, 40, QtCore.Qt.AlignmentFlag.AlignLeft, self._message) - def showMessage(self, message, progress=0): + def showMessage(self, message, progress=0, alignment=QtCore.Qt.AlignmentFlag.AlignLeft, color=QtCore.Qt.GlobalColor.black): self._progress_bar.setValue(progress) - super(SplashScreen, self).showMessage(' ' + message, QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom) + self._message = message + super(SplashScreen, self).showMessage(' ', QtCore.Qt.AlignmentFlag.AlignLeft | QtCore.Qt.AlignmentFlag.AlignBottom)