Fix PyQt6 drawText overload in the startup splash
The splash passed two alignment flags to QPainter.drawText, which has no matching PyQt6 overload. Combine them into one int flags value and cast the remaining painted labels for safety. Adds splash and full-page render coverage. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Code
parent
b262b1e664
commit
ffe95020bc
+7
-8
@@ -50,20 +50,19 @@ def _splash_pixmap() -> QPixmap:
|
||||
brand.paint_mark(painter, QRectF(34, 34, 72, 72))
|
||||
painter.setPen(QColor(theme.TEXT))
|
||||
painter.setFont(theme.display_font(26, QFont.Weight.DemiBold))
|
||||
painter.drawText(QRectF(124, 36, 300, 40), Qt.AlignmentFlag.AlignLeft,
|
||||
Qt.AlignmentFlag.AlignVCenter, "BoltClam")
|
||||
left_center = int(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
|
||||
painter.drawText(QRectF(124, 36, 300, 40), left_center, "BoltClam")
|
||||
painter.setPen(QColor(theme.MUTED))
|
||||
painter.setFont(theme.body_font(10.0))
|
||||
painter.drawText(QRectF(126, 76, 300, 24), Qt.AlignmentFlag.AlignLeft,
|
||||
Qt.AlignmentFlag.AlignVCenter, "ClamAV protection, without the noise.")
|
||||
painter.drawText(QRectF(126, 76, 300, 24), left_center,
|
||||
"ClamAV protection, without the noise.")
|
||||
painter.setPen(QColor(theme.TEXT_SOFT))
|
||||
painter.setFont(theme.body_font(10.5))
|
||||
painter.drawText(QRectF(36, 154, 390, 26), Qt.AlignmentFlag.AlignLeft,
|
||||
Qt.AlignmentFlag.AlignVCenter, "Starting protection…")
|
||||
painter.drawText(QRectF(36, 154, 390, 26), left_center, "Starting protection…")
|
||||
painter.setPen(QColor(theme.DIM))
|
||||
painter.setFont(theme.mono_font(8.0))
|
||||
painter.drawText(QRectF(36, 206, 390, 20), Qt.AlignmentFlag.AlignLeft,
|
||||
Qt.AlignmentFlag.AlignVCenter, f"Version {__version__} · {__build_date__}")
|
||||
painter.drawText(QRectF(36, 206, 390, 20), left_center,
|
||||
f"Version {__version__} · {__build_date__}")
|
||||
painter.end()
|
||||
return image
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ class Avatar(QWidget):
|
||||
painter.setPen(QColor(theme.AMBER_BRIGHT))
|
||||
font = theme.display_font(self._size * 0.30, QFont.Weight.DemiBold)
|
||||
painter.setFont(font)
|
||||
painter.drawText(rect, Qt.AlignmentFlag.AlignCenter, self.initials())
|
||||
painter.drawText(rect, int(Qt.AlignmentFlag.AlignCenter), self.initials())
|
||||
|
||||
|
||||
class ProtectionDial(QWidget):
|
||||
@@ -331,9 +331,10 @@ class NavButton(QAbstractButton):
|
||||
painter.setPen(QColor(theme.TEXT if checked else theme.TEXT_SOFT))
|
||||
font = theme.body_font(10.4, QFont.Weight.DemiBold if checked else QFont.Weight.Normal)
|
||||
painter.setFont(font)
|
||||
painter.drawText(QRectF(46, 0, self.width() - 52, self.height()),
|
||||
Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignLeft,
|
||||
self.text())
|
||||
painter.drawText(
|
||||
QRectF(46, 0, self.width() - 52, self.height()),
|
||||
int(Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignLeft),
|
||||
self.text())
|
||||
|
||||
|
||||
def _draw_nav_icon(painter: QPainter, name: str, rect: QRectF, color: QColor) -> None:
|
||||
@@ -529,9 +530,10 @@ class ScanButton(QAbstractButton):
|
||||
|
||||
painter.setPen(QColor("#241704" if self.isEnabled() else "#807A68"))
|
||||
painter.setFont(theme.body_font(11.2, QFont.Weight.Bold))
|
||||
painter.drawText(QRectF(core.left(), core.center().y() + 20, core.width(), 24),
|
||||
Qt.AlignmentFlag.AlignCenter,
|
||||
"Scanning…" if self._scanning else "Start scan")
|
||||
painter.drawText(
|
||||
QRectF(core.left(), core.center().y() + 20, core.width(), 24),
|
||||
int(Qt.AlignmentFlag.AlignCenter),
|
||||
"Scanning…" if self._scanning else "Start scan")
|
||||
|
||||
|
||||
class StatTile(QFrame):
|
||||
|
||||
@@ -66,12 +66,24 @@ def test_main_window_builds_four_pages_and_switches_tabs(qapp, isolated_env):
|
||||
assert window.stack.currentIndex() == 3
|
||||
assert window.settings_page.channel_combo.currentData() == "release"
|
||||
assert window.about_page.rows["account"].value_label.text() == "Aaron"
|
||||
for index in range(4):
|
||||
window.stack.setCurrentIndex(index)
|
||||
qapp.processEvents()
|
||||
assert not window.stack.currentWidget().grab().isNull()
|
||||
finally:
|
||||
window._allow_close = True
|
||||
window.close()
|
||||
qapp.processEvents()
|
||||
|
||||
|
||||
def test_splash_pixmap_renders(qapp):
|
||||
from boltclam.app import _splash_pixmap
|
||||
|
||||
pixmap = _splash_pixmap()
|
||||
assert not pixmap.isNull()
|
||||
assert pixmap.width() == 460 and pixmap.height() == 250
|
||||
|
||||
|
||||
def test_login_dialog_builds_without_starting_a_worker(qapp, isolated_env):
|
||||
auth = AuthService(
|
||||
"http://127.0.0.1:9", install_id="test",
|
||||
|
||||
Reference in New Issue
Block a user