diff --git a/lintunes/__init__.py b/lintunes/__init__.py index bb19c21..aa567c7 100644 --- a/lintunes/__init__.py +++ b/lintunes/__init__.py @@ -1,3 +1,3 @@ """LinTunes — iTunes-style music library manager and player for Linux.""" -__version__ = "0.74.0" +__version__ = "0.74.1" diff --git a/lintunes/gui/version_button.py b/lintunes/gui/version_button.py index b183e05..544a407 100644 --- a/lintunes/gui/version_button.py +++ b/lintunes/gui/version_button.py @@ -7,10 +7,9 @@ git pull → the main window restarts the app on `update_applied`. """ from PyQt6.QtCore import Qt, QTimer, pyqtSignal -from PyQt6.QtGui import QPalette from PyQt6.QtWidgets import QMessageBox, QPushButton -from lintunes import __version__ +from lintunes import __version__, theme class VersionButton(QPushButton): @@ -45,7 +44,9 @@ class VersionButton(QPushButton): def refresh_theme(self): # Subtle but readable: the theme's text color at ~55% opacity # (palette(mid) is too close to the light backgrounds to read). - text = self.palette().color(QPalette.ColorRole.WindowText) + # From the theme, never self.palette(): this stylesheet pins that, + # so the color it gave at launch survived every light/dark switch. + text = theme.text_color() self.setStyleSheet( "QPushButton { border: none; padding: 0 6px; " f"color: rgba({text.red()}, {text.green()}, {text.blue()}, 140); }}") diff --git a/tests/test_round105.py b/tests/test_round105.py index 2e5447b..3c93faf 100644 --- a/tests/test_round105.py +++ b/tests/test_round105.py @@ -90,3 +90,25 @@ class TestDialogFitsTheScreen: dialog = self._dialog(tmp_path) dialog.pages_list.setCurrentRow(1) assert dialog.friend_pages["a"].selector is not None + + +def test_version_label_follows_light_and_dark(qapp): + """It read its color from its own palette, which its stylesheet had + pinned — so a launch in one mode left it unreadable in the other.""" + from unittest.mock import MagicMock + from lintunes import theme + from lintunes.gui.version_button import VersionButton + updater = MagicMock() + updater.short_hash.return_value = "" + button = VersionButton(updater) + old = theme._mode + try: + for mode in ("dark", "light"): + theme._mode = mode + button.refresh_theme() + color = theme.text_color() + assert f"rgba({color.red()}, {color.green()}, {color.blue()}, 140)" \ + in button.styleSheet() + assert theme.text_color("dark") != theme.text_color("light") + finally: + theme._mode = old