v0.74.1: the version in the status bar follows light/dark mode
It read its color from its own palette, which its stylesheet pins, so the color it got at launch survived every theme switch — pale on pale after going from dark to light.
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
"""LinTunes — iTunes-style music library manager and player for Linux."""
|
"""LinTunes — iTunes-style music library manager and player for Linux."""
|
||||||
|
|
||||||
__version__ = "0.74.0"
|
__version__ = "0.74.1"
|
||||||
|
|||||||
@@ -7,10 +7,9 @@ git pull → the main window restarts the app on `update_applied`.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from PyQt6.QtCore import Qt, QTimer, pyqtSignal
|
from PyQt6.QtCore import Qt, QTimer, pyqtSignal
|
||||||
from PyQt6.QtGui import QPalette
|
|
||||||
from PyQt6.QtWidgets import QMessageBox, QPushButton
|
from PyQt6.QtWidgets import QMessageBox, QPushButton
|
||||||
|
|
||||||
from lintunes import __version__
|
from lintunes import __version__, theme
|
||||||
|
|
||||||
|
|
||||||
class VersionButton(QPushButton):
|
class VersionButton(QPushButton):
|
||||||
@@ -45,7 +44,9 @@ class VersionButton(QPushButton):
|
|||||||
def refresh_theme(self):
|
def refresh_theme(self):
|
||||||
# Subtle but readable: the theme's text color at ~55% opacity
|
# Subtle but readable: the theme's text color at ~55% opacity
|
||||||
# (palette(mid) is too close to the light backgrounds to read).
|
# (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(
|
self.setStyleSheet(
|
||||||
"QPushButton { border: none; padding: 0 6px; "
|
"QPushButton { border: none; padding: 0 6px; "
|
||||||
f"color: rgba({text.red()}, {text.green()}, {text.blue()}, 140); }}")
|
f"color: rgba({text.red()}, {text.green()}, {text.blue()}, 140); }}")
|
||||||
|
|||||||
@@ -90,3 +90,25 @@ class TestDialogFitsTheScreen:
|
|||||||
dialog = self._dialog(tmp_path)
|
dialog = self._dialog(tmp_path)
|
||||||
dialog.pages_list.setCurrentRow(1)
|
dialog.pages_list.setCurrentRow(1)
|
||||||
assert dialog.friend_pages["a"].selector is not None
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user