v0.91.0: rounded, softly embossed windows with no line under the title or menu bar; blank main title bar; seek times centred on the timeline

This commit is contained in:
2026-11-08 00:35:24 -08:00
parent 15f1ed5c96
commit 435a082dc5
8 changed files with 274 additions and 50 deletions
+113
View File
@@ -0,0 +1,113 @@
"""Round 126: the house window (design.html#window, after routine-widget).
Every window is a rounded tile with a soft emboss round its edge and no
line between the title bar and the rest; the main window's title bar is
blank (the song is right under it). And the seek row's times sit at the
timeline's ends, centred on its line.
"""
import pytest
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QApplication, QDialog, QLabel, QVBoxLayout
from lintunes.gui import titlebar
from lintunes.gui.titlebar import parse_button_layout, title_bar
@pytest.fixture
def installed(qapp, monkeypatch):
monkeypatch.setattr(titlebar, "_layout_cache",
parse_button_layout("close,minimize:appmenu"))
installer = titlebar.install(qapp)
yield installer
qapp.removeEventFilter(installer)
def _dialog(title="Preferences", **props):
dialog = QDialog()
dialog.setWindowTitle(title)
for key, value in props.items():
dialog.setProperty(key, value)
QVBoxLayout(dialog).addWidget(QLabel("A label in a dialog"))
dialog.resize(300, 160)
dialog.show()
QApplication.processEvents()
return dialog
def test_corners_are_round_and_see_through(installed):
dialog = _dialog()
image = dialog.grab().toImage()
w, h = image.width(), image.height()
for x, y in ((0, 0), (w - 1, 0), (0, h - 1), (w - 1, h - 1)):
assert image.pixelColor(x, y).alpha() == 0
assert image.pixelColor(w // 2, h // 2).alpha() == 255
dialog.close()
def test_no_line_under_the_title_bar(installed):
dialog = _dialog()
bar = title_bar(dialog).grab().toImage()
x = bar.width() // 2
assert bar.pixelColor(x, bar.height() - 1) == bar.pixelColor(x, 3)
dialog.close()
def test_maximized_corners_are_square(installed):
dialog = _dialog()
dialog.setWindowState(Qt.WindowState.WindowMaximized)
QApplication.processEvents()
assert not title_bar(dialog)._frame.isVisible()
dialog.close()
def test_square_window_stays_opaque(installed):
dialog = _dialog(**{titlebar.SQUARE: True})
assert not dialog.testAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground)
assert dialog.grab().toImage().pixelColor(0, 0).alpha() == 255
dialog.close()
def test_blank_title_keeps_the_window_title(installed):
dialog = _dialog("LinTunes", **{titlebar.BLANK_TITLE: True})
assert title_bar(dialog).title() == ""
assert dialog.windowTitle() == "LinTunes"
dialog.close()
def test_main_window_title_bar_is_blank(qapp, tmp_path):
from lintunes.gui.main_window import MainWindow
from lintunes.library_manager import LibraryManager
from lintunes.models.library import Library
from lintunes.preferences import Preferences
window = MainWindow(LibraryManager(Library(), tmp_path),
Preferences(tmp_path))
assert window.property(titlebar.BLANK_TITLE)
window.close()
def test_times_are_centred_on_the_timeline(qapp, tmp_path):
from lintunes.gui.main_window import MainWindow
from lintunes.library_manager import LibraryManager
from lintunes.models.library import Library
from lintunes.preferences import Preferences
window = MainWindow(LibraryManager(Library(), tmp_path),
Preferences(tmp_path))
window.resize(1280, 500)
window.show()
qapp.processEvents()
bar = window._transport
slider = bar._slider
def mid_y(widget):
r = widget.geometry()
return widget.parentWidget().mapTo(window, r.center()).y()
for label in (bar._elapsed_label, bar._remaining_label):
assert abs(mid_y(label) - mid_y(slider)) <= 1
assert label.alignment() & Qt.AlignmentFlag.AlignVCenter
left = bar._elapsed_label.mapTo(window, bar._elapsed_label.rect().topRight())
right = bar._remaining_label.mapTo(window, bar._remaining_label.rect().topLeft())
s = slider.mapTo(window, slider.rect().topLeft())
assert left.x() <= s.x() and right.x() >= s.x() + slider.width() - 1
window.close()