Skip to content

Commit

Permalink
Play with spash screen improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
hsorby committed Jul 30, 2024
1 parent b6a5ef2 commit 805e088
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/mapclient/splashscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 805e088

Please sign in to comment.