Skip to content

Commit 35c5b6f

Browse files
committed
fix: correct splash logo path (media/ subdir) and add Restarting... text to Qt splash screen
1 parent e2ccc9a commit 35c5b6f

1 file changed

Lines changed: 31 additions & 6 deletions

File tree

BlocksScreen/BlocksScreen.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@
1515

1616
_SPLASH_CACHE = Path("/home/blocks/.cache/blockscreen/splash.raw")
1717
_FB0 = Path("/dev/fb0")
18-
_LOGO = Path(__file__).parent / "lib/ui/resources/logoblocks.png"
18+
_LOGO: Path | None = next(
19+
(
20+
p
21+
for p in [
22+
Path(__file__).parent / "lib/ui/resources/media/logoblocks400x300.png",
23+
Path(__file__).parent / "lib/ui/resources/media/logoblocks.png",
24+
Path(__file__).parent / "lib/ui/resources/media/graphics/logo_blocks.png",
25+
]
26+
if p.exists()
27+
),
28+
None,
29+
)
1930

2031

2132
class BlocksScreenApp(QtWidgets.QApplication):
@@ -63,18 +74,32 @@ def _write_splash_to_fb0() -> None:
6374
def show_splash() -> QtWidgets.QSplashScreen:
6475
"""Show a fullscreen splash immediately after QApplication is created.
6576
66-
Centres the logo on a black background matching the current screen geometry.
77+
Centres the logo on a dark background matching the current screen geometry,
78+
with a 'Restarting ...' message below the logo.
6779
Returns the QSplashScreen so the caller can call splash.finish(main_window).
6880
"""
69-
logo = QtGui.QPixmap(str(_LOGO))
81+
logo = QtGui.QPixmap(str(_LOGO)) if _LOGO is not None else QtGui.QPixmap()
7082
screen = QtWidgets.QApplication.primaryScreen()
7183
if screen is not None:
7284
geom = screen.geometry()
7385
bg = QtGui.QPixmap(geom.size())
74-
bg.fill(QtGui.QColor(0, 0, 0))
86+
bg.fill(QtGui.QColor(20, 20, 20))
7587
painter = QtGui.QPainter(bg)
76-
painter.drawPixmap(
77-
(bg.width() - logo.width()) // 2, (bg.height() - logo.height()) // 2, logo
88+
lx = (bg.width() - logo.width()) // 2
89+
ly = (bg.height() - logo.height()) // 2
90+
if not logo.isNull():
91+
painter.drawPixmap(lx, ly, logo)
92+
font = painter.font()
93+
font.setPointSize(14)
94+
painter.setFont(font)
95+
painter.setPen(QtGui.QColor(180, 180, 180))
96+
painter.drawText(
97+
0,
98+
ly + logo.height() + 24,
99+
bg.width(),
100+
32,
101+
QtCore.Qt.AlignmentFlag.AlignHCenter,
102+
"Restarting ...",
78103
)
79104
painter.end()
80105
splash = QtWidgets.QSplashScreen(bg, QtCore.Qt.WindowType.WindowStaysOnTopHint)

0 commit comments

Comments
 (0)