mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Calculate the height of the splash screen based on font rather than logo size
Should make it impossible for text overlap to happen
This commit is contained in:
parent
e16b3820e9
commit
1e12b6d64e
@ -15,7 +15,7 @@ from calibre.utils.monotonic import monotonic
|
||||
|
||||
class SplashScreen(QSplashScreen):
|
||||
|
||||
TITLE_SIZE = 18 # pt
|
||||
TITLE_SIZE = 20 # pt
|
||||
BODY_SIZE = 12 # pt
|
||||
FOOTER_SIZE = 9 # pt
|
||||
LOGO_SIZE = 96 # px
|
||||
@ -31,8 +31,9 @@ class SplashScreen(QSplashScreen):
|
||||
self.body_font = f = QFont()
|
||||
f.setPointSize(self.BODY_SIZE)
|
||||
self.line_height = QFontMetrics(f).lineSpacing()
|
||||
self.total_height = max(self.LOGO_SIZE, self.title_height + 3 * self.line_height)
|
||||
self.num_font = f = QFont()
|
||||
f.setPixelSize(self.LOGO_SIZE)
|
||||
f.setPixelSize(self.total_height)
|
||||
f.setItalic(True), f.setBold(True)
|
||||
f = QFontMetrics(f)
|
||||
self.num_ch = str(max(3, numeric_version[0]))
|
||||
@ -56,7 +57,8 @@ class SplashScreen(QSplashScreen):
|
||||
painter.save()
|
||||
painter.setRenderHint(painter.TextAntialiasing, True)
|
||||
painter.setRenderHint(painter.Antialiasing, True)
|
||||
pw = height = self.LOGO_SIZE
|
||||
pw = self.LOGO_SIZE
|
||||
height = max(pw, self.total_height)
|
||||
width = self.width()
|
||||
|
||||
# Draw frame
|
||||
@ -65,7 +67,8 @@ class SplashScreen(QSplashScreen):
|
||||
painter.fillRect(0, y, width, height, self.light_brush)
|
||||
painter.fillRect(0, y, width, self.title_height, self.dark_brush)
|
||||
painter.fillRect(0, y, pw, height, self.dark_brush)
|
||||
painter.drawPixmap(0, y, self.pmap)
|
||||
dy = (height - self.LOGO_SIZE) // 2
|
||||
painter.drawPixmap(0, y + dy, self.pmap)
|
||||
|
||||
# Draw number
|
||||
painter.setFont(self.num_font)
|
||||
|
Loading…
x
Reference in New Issue
Block a user