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:
@@ -1309,6 +1309,16 @@ persistence) → GUI (Qt widgets that read the manager and connect to its signal
|
||||
into `contentsRect()` (`art_window.py`); one that needs the system frame
|
||||
sets the `titlebar.OPT_OUT` property. The bar must never be an event filter
|
||||
on its own window — that is called during the window's teardown and aborts.
|
||||
**The window is the house tile** (Round 126, design.html#window, after
|
||||
routine-widget): translucent with 10 px round corners (square when
|
||||
maximized), its gray filled by the installer on the window's `Paint`, and
|
||||
`titlebar._Frame` — a mouse-transparent overlay masked to the edge ring,
|
||||
on top of everything — clears outside the curve and paints the soft
|
||||
emboss and outline. No line under the title bar, nor under the menu bar
|
||||
(`ClickToJumpScrollStyle.drawControl` paints over Fusion's). The main
|
||||
window sets `BLANK_TITLE` (the song is in the panel right under it);
|
||||
`VisualizerWindow` sets `SQUARE` — Kaleidostrobe's GL clears to alpha 0,
|
||||
which would show the desktop through a translucent window.
|
||||
- **Music files are only touched deliberately:** tag edits via `tagging.py`,
|
||||
and — since Round 18 — artist/album_artist/album edits relocate the file
|
||||
inside `LibraryManager.organize_root()` (`<music_folder>/Music`) to keep the
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
"""LinTunes — iTunes-style music library manager and player for Linux."""
|
||||
|
||||
__version__ = "0.90.1"
|
||||
__version__ = "0.91.0"
|
||||
|
||||
@@ -31,7 +31,7 @@ from lintunes.gui.album_art_dialog import AlbumArtDialog
|
||||
from lintunes.gui.art_ops import embed_artwork
|
||||
from lintunes.gui.cast_dialog import AirPlayDialog, ChromecastDialog
|
||||
from lintunes.gui.cassette_ui import CassetteUi
|
||||
from lintunes.gui import menu_bar, sounds
|
||||
from lintunes.gui import menu_bar, sounds, titlebar
|
||||
from lintunes.gui.device_sync_dialog import (
|
||||
DeviceSyncSettingsDialog, resolve_sync_playlists,
|
||||
)
|
||||
@@ -152,6 +152,9 @@ class MainWindow(QMainWindow):
|
||||
self._cassette = CassetteUi(self, prefs, manager)
|
||||
|
||||
self.setWindowTitle("LinTunes")
|
||||
# The title bar stays blank: the song is in the now-playing panel
|
||||
# right under it (the title still names the window to the desktop).
|
||||
self.setProperty(titlebar.BLANK_TITLE, True)
|
||||
self.resize(1280, 800)
|
||||
# Keep the window's minimum well under typical sizes so the WM never
|
||||
# refuses an interactive shrink
|
||||
|
||||
+106
-28
@@ -18,21 +18,37 @@ Moving, snapping and resizing are still the compositor's, through
|
||||
|
||||
A top-level window that must keep the system frame sets the Qt property
|
||||
``OPT_OUT`` to ``True`` before it is first shown.
|
||||
|
||||
The window itself is the house's (shared-resources design.html#window,
|
||||
after routine-widget): translucent, so its corners can be round
|
||||
(``RADIUS``, square while maximized); its gray filled as that rounded
|
||||
shape; no line under the bar; and a soft emboss round the whole edge — a
|
||||
faint light rim along the top, a faint dark one along the bottom, then the
|
||||
outline — painted by ``_Frame``, a mouse-transparent child on top of
|
||||
everything that also cuts whatever a child painted outside the curve.
|
||||
A window that must stay opaque (a GL child that writes alpha 0) sets
|
||||
``SQUARE``. A window whose title is shown just below anyway sets ``BLANK_TITLE``: the
|
||||
bar shows only its buttons, and the window keeps its title for the task
|
||||
switcher.
|
||||
"""
|
||||
import subprocess
|
||||
|
||||
from PyQt6.QtCore import QEvent, QObject, QPoint, QRect, QSize, Qt
|
||||
from PyQt6.QtGui import QColor, QPainter, QPalette, QPen
|
||||
from PyQt6.QtCore import QEvent, QObject, QPoint, QRect, QRectF, QSize, Qt
|
||||
from PyQt6.QtGui import (QBrush, QColor, QLinearGradient, QPainter,
|
||||
QPainterPath, QPalette, QPen, QRegion)
|
||||
from PyQt6.QtWidgets import QAbstractButton, QLayout, QWidget
|
||||
|
||||
OPT_OUT = "lintunes_system_frame"
|
||||
BLANK_TITLE = "lintunes_blank_title"
|
||||
SQUARE = "lintunes_square_corners" # stays opaque: square corners, same rim
|
||||
_DONE = "_lintunes_titlebar"
|
||||
|
||||
RESIZE_MARGIN = 4 # the strip along each edge that resizes
|
||||
CORNER = 14 # how far along an edge a corner reaches
|
||||
BUTTON = 24 # the round button's diameter
|
||||
SPACING = 8 # between buttons, and from the bar's ends
|
||||
BORDER_ALPHA = 70 # the 1 px outline standing in for the missing shadow
|
||||
RADIUS = 10 # the window's corners
|
||||
RIM = 3 # how far in from the edge the frame paints
|
||||
|
||||
_BUTTONS = ("close", "minimize", "maximize")
|
||||
_FALLBACK_LAYOUT = ":minimize,close"
|
||||
@@ -119,8 +135,77 @@ def _framed(window: QWidget) -> bool:
|
||||
| Qt.WindowState.WindowFullScreen))
|
||||
|
||||
|
||||
def _border_color(window: QWidget) -> QColor:
|
||||
return QColor(0, 0, 0, BORDER_ALPHA)
|
||||
def _radius(window: QWidget) -> int:
|
||||
see_through = window.testAttribute(
|
||||
Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
return RADIUS if see_through and _framed(window) else 0
|
||||
|
||||
|
||||
def _outline(rect: QRect, radius: int) -> QPainterPath:
|
||||
path = QPainterPath()
|
||||
path.addRoundedRect(QRectF(rect).adjusted(0.5, 0.5, -0.5, -0.5),
|
||||
radius, radius)
|
||||
return path
|
||||
|
||||
|
||||
def paint_window_background(window: QWidget):
|
||||
"""The window's gray as a rounded tile (its corners stay see-through)."""
|
||||
painter = QPainter(window)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
painter.fillPath(_outline(window.rect(), _radius(window)),
|
||||
window.palette().color(QPalette.ColorRole.Window))
|
||||
painter.end()
|
||||
|
||||
|
||||
class _Frame(QWidget):
|
||||
"""The window's edge, over everything in it: clears what lies outside
|
||||
the rounded corners, then the soft emboss and the outline. Masked to a
|
||||
ring along the edge, so an update inside the window never reaches it."""
|
||||
|
||||
def __init__(self, window: QWidget):
|
||||
super().__init__(window)
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents)
|
||||
self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||
|
||||
def place(self):
|
||||
window = self.window()
|
||||
rect = window.rect()
|
||||
self.setGeometry(rect)
|
||||
ring = QRegion(rect).subtracted(
|
||||
QRegion(rect.adjusted(RIM, RIM, -RIM, -RIM)))
|
||||
k = _radius(window) + 1
|
||||
w, h = rect.width(), rect.height()
|
||||
for x, y in ((0, 0), (w - k, 0), (0, h - k), (w - k, h - k)):
|
||||
ring = ring.united(QRegion(x, y, k, k))
|
||||
self.setMask(ring)
|
||||
self.setVisible(_framed(window))
|
||||
self.raise_()
|
||||
|
||||
def paintEvent(self, _event):
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
r = _radius(self.window())
|
||||
path = _outline(self.rect(), r)
|
||||
outside = QPainterPath()
|
||||
outside.addRect(QRectF(self.rect()))
|
||||
painter.setCompositionMode(QPainter.CompositionMode.CompositionMode_Clear)
|
||||
painter.fillPath(outside.subtracted(path), Qt.GlobalColor.transparent)
|
||||
painter.setCompositionMode(
|
||||
QPainter.CompositionMode.CompositionMode_SourceOver)
|
||||
bg = self.palette().color(QPalette.ColorRole.Window)
|
||||
rims = QLinearGradient(0, 0, 0, self.height())
|
||||
rims.setColorAt(0, bg.lighter(112))
|
||||
rims.setColorAt(0.06, QColor(255, 255, 255, 0))
|
||||
rims.setColorAt(0.94, QColor(0, 0, 0, 0))
|
||||
rims.setColorAt(1, bg.darker(112))
|
||||
inner = QPainterPath()
|
||||
inner.addRoundedRect(QRectF(self.rect()).adjusted(1.5, 1.5, -1.5, -1.5),
|
||||
max(0, r - 1), max(0, r - 1))
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.setPen(QPen(QBrush(rims), 1.5))
|
||||
painter.drawPath(inner)
|
||||
painter.setPen(QPen(bg.darker(128), 1))
|
||||
painter.drawPath(path)
|
||||
|
||||
|
||||
class _Button(QAbstractButton):
|
||||
@@ -176,8 +261,8 @@ class _Button(QAbstractButton):
|
||||
|
||||
|
||||
class _Grip(QWidget):
|
||||
"""A thin resize strip along the left, right or bottom edge. It also
|
||||
paints that edge's outline, since a frameless window has no shadow."""
|
||||
"""A thin resize strip along the left, right or bottom edge (the top
|
||||
edge is the bar's). The frame over it paints the edge."""
|
||||
|
||||
def __init__(self, side: str, window: QWidget):
|
||||
super().__init__(window)
|
||||
@@ -203,18 +288,6 @@ class _Grip(QWidget):
|
||||
return
|
||||
event.ignore()
|
||||
|
||||
def paintEvent(self, _event):
|
||||
painter = QPainter(self)
|
||||
painter.setPen(_border_color(self.window()))
|
||||
if self.side == "left":
|
||||
painter.drawLine(0, 0, 0, self.height())
|
||||
elif self.side == "right":
|
||||
painter.drawLine(self.width() - 1, 0, self.width() - 1,
|
||||
self.height())
|
||||
else:
|
||||
painter.drawLine(0, self.height() - 1, self.width(),
|
||||
self.height() - 1)
|
||||
|
||||
|
||||
class TitleBar(QWidget):
|
||||
"""The bar itself: a child of the window, placed by hand above the
|
||||
@@ -234,6 +307,7 @@ class TitleBar(QWidget):
|
||||
lambda _=False, k=button.kind: self._on_button(k))
|
||||
self._grips = [_Grip(side, window)
|
||||
for side in ("left", "right", "bottom")]
|
||||
self._frame = _Frame(window)
|
||||
window.windowTitleChanged.connect(lambda _t: self.update())
|
||||
self._apply_height()
|
||||
self._place()
|
||||
@@ -281,6 +355,7 @@ class TitleBar(QWidget):
|
||||
grip.setVisible(framed)
|
||||
grip.raise_()
|
||||
self.raise_()
|
||||
self._frame.place()
|
||||
|
||||
# -- events --------------------------------------------------------
|
||||
|
||||
@@ -292,6 +367,7 @@ class TitleBar(QWidget):
|
||||
self._place()
|
||||
else:
|
||||
self.update()
|
||||
self._frame.update()
|
||||
for button in self._left + self._right:
|
||||
button.update()
|
||||
|
||||
@@ -345,16 +421,8 @@ class TitleBar(QWidget):
|
||||
def paintEvent(self, _event):
|
||||
painter = QPainter(self)
|
||||
palette = self.palette()
|
||||
# No line under it: the bar is the top of the window, not a zone.
|
||||
painter.fillRect(self.rect(), palette.color(QPalette.ColorRole.Window))
|
||||
painter.setPen(palette.color(QPalette.ColorRole.Window).darker(118))
|
||||
painter.drawLine(0, self.height() - 1, self.width(),
|
||||
self.height() - 1)
|
||||
if _framed(self._window):
|
||||
painter.setPen(_border_color(self._window))
|
||||
painter.drawLine(0, 0, self.width(), 0)
|
||||
painter.drawLine(0, 0, 0, self.height())
|
||||
painter.drawLine(self.width() - 1, 0, self.width() - 1,
|
||||
self.height())
|
||||
|
||||
# The title is centered on the whole bar, kept clear of both button
|
||||
# groups by the wider of the two.
|
||||
@@ -374,6 +442,8 @@ class TitleBar(QWidget):
|
||||
painter.drawText(room, Qt.AlignmentFlag.AlignCenter, title)
|
||||
|
||||
def title(self) -> str:
|
||||
if self._window.property(BLANK_TITLE):
|
||||
return ""
|
||||
# Qt's "[*]" modified placeholder, as the system bar would show it.
|
||||
title = self._window.windowTitle()
|
||||
return title.replace("[*]", "*" if self._window.isWindowModified()
|
||||
@@ -411,6 +481,10 @@ class TitleBarInstaller(QObject):
|
||||
bar = title_bar(obj)
|
||||
if bar is not None:
|
||||
bar.window_event(kind)
|
||||
elif kind == QEvent.Type.Paint:
|
||||
if (isinstance(obj, QWidget) and obj.isWindow()
|
||||
and obj.property(_DONE)):
|
||||
paint_window_background(obj)
|
||||
elif kind == QEvent.Type.Polish:
|
||||
if wants_bar(obj) and not obj.property(_DONE) and not (
|
||||
obj.windowFlags() & Qt.WindowType.FramelessWindowHint):
|
||||
@@ -423,6 +497,10 @@ class TitleBarInstaller(QObject):
|
||||
@staticmethod
|
||||
def make_frameless(window: QWidget):
|
||||
window.setProperty(_DONE, "frameless")
|
||||
# Before the flag, which recreates the native window: an alpha
|
||||
# channel is what lets the corners be round.
|
||||
if not window.property(SQUARE):
|
||||
window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
window.setWindowFlag(Qt.WindowType.FramelessWindowHint, True)
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -131,6 +131,20 @@ class ClickToJumpScrollStyle(QProxyStyle):
|
||||
return QRect(rect)
|
||||
return QRect() # SubLine / AddLine / First / Last: no arrows
|
||||
|
||||
def drawControl(self, element, option, painter, widget=None):
|
||||
if element == QStyle.ControlElement.CE_MenuBarEmptyArea:
|
||||
# Fusion rules a line under a main window's menu bar; the top
|
||||
# of the window is one zone (design.html#window), so no line.
|
||||
painter.fillRect(option.rect, option.palette.color(
|
||||
QPalette.ColorRole.Window))
|
||||
return
|
||||
super().drawControl(element, option, painter, widget)
|
||||
if element == QStyle.ControlElement.CE_MenuBarItem:
|
||||
# And under each item; its highlight stops 3 px above that row.
|
||||
r = option.rect
|
||||
painter.fillRect(QRect(r.left(), r.bottom(), r.width(), 1),
|
||||
option.palette.color(QPalette.ColorRole.Window))
|
||||
|
||||
def drawComplexControl(self, control, option, painter, widget=None):
|
||||
if control != QStyle.ComplexControl.CC_ScrollBar:
|
||||
return super().drawComplexControl(control, option, painter, widget)
|
||||
|
||||
+22
-20
@@ -445,7 +445,7 @@ class HeaderRow(ToolRow):
|
||||
floor = self.height() - self.BOTTOM
|
||||
box_h = max(0, floor - self.TOP_PAD)
|
||||
if widget is self.seek:
|
||||
# The playhead's knob and the times' baselines stand on the floor.
|
||||
# The playhead's knob stands on the floor, the times beside it.
|
||||
drop = self._drop(self.seek)
|
||||
self.seek.drop.changeSize(0, drop, QSizePolicy.Policy.Minimum,
|
||||
QSizePolicy.Policy.Fixed)
|
||||
@@ -585,37 +585,39 @@ class TransportBar(QWidget):
|
||||
self._apply_now_playing_font()
|
||||
|
||||
seek = QWidget()
|
||||
seek_row = QHBoxLayout(seek)
|
||||
seek_row.setContentsMargins(0, 0, 0, 0)
|
||||
self._elapsed_label = QLabel("")
|
||||
self._elapsed_label.setFixedWidth(50)
|
||||
self._remaining_label = QLabel("")
|
||||
self._remaining_label.setFixedWidth(50)
|
||||
# Both stand on the header row's floor, like the playlist name.
|
||||
# The times sit at the timeline's two ends, centred on its line.
|
||||
self._elapsed_label.setAlignment(Qt.AlignmentFlag.AlignLeft
|
||||
| Qt.AlignmentFlag.AlignBottom)
|
||||
| Qt.AlignmentFlag.AlignVCenter)
|
||||
self._remaining_label.setAlignment(Qt.AlignmentFlag.AlignRight
|
||||
| Qt.AlignmentFlag.AlignBottom)
|
||||
| Qt.AlignmentFlag.AlignVCenter)
|
||||
self._slider = SeekSlider()
|
||||
self._slider.setProperty("tall", True) # twice Fusion's height
|
||||
self._slider.setRange(0, 0)
|
||||
self._slider.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||
# The row reaches below the floor by the text's descent (so the
|
||||
# times' baselines stand on it); the slider is held up by the same
|
||||
# amount, so its knob does too. HeaderRow.place sets both.
|
||||
slider_col = QVBoxLayout()
|
||||
slider_col.setSpacing(0)
|
||||
slider_col.addStretch(1)
|
||||
slider_col.addWidget(self._slider)
|
||||
seek.drop = QSpacerItem(0, 0, QSizePolicy.Policy.Minimum,
|
||||
QSizePolicy.Policy.Fixed)
|
||||
slider_col.addSpacerItem(seek.drop)
|
||||
# The slider sets the line's height; the times centre on it.
|
||||
for label in (self._elapsed_label, self._remaining_label):
|
||||
label.setSizePolicy(QSizePolicy.Policy.Fixed,
|
||||
QSizePolicy.Policy.Expanding)
|
||||
seek_row.addWidget(self._elapsed_label)
|
||||
seek_row.addLayout(slider_col)
|
||||
seek_row.addWidget(self._remaining_label)
|
||||
QSizePolicy.Policy.Ignored)
|
||||
line = QHBoxLayout()
|
||||
line.setContentsMargins(0, 0, 0, 0)
|
||||
line.addWidget(self._elapsed_label)
|
||||
line.addWidget(self._slider, 1)
|
||||
line.addWidget(self._remaining_label)
|
||||
# The playhead's knob stands on the header row's floor: the row
|
||||
# reaches below it by the text's descent and the line is held up by
|
||||
# the same amount. HeaderRow.place sets both.
|
||||
seek_col = QVBoxLayout(seek)
|
||||
seek_col.setContentsMargins(0, 0, 0, 0)
|
||||
seek_col.setSpacing(0)
|
||||
seek_col.addStretch(1)
|
||||
seek_col.addLayout(line)
|
||||
seek.drop = QSpacerItem(0, 0, QSizePolicy.Policy.Minimum,
|
||||
QSizePolicy.Policy.Fixed)
|
||||
seek_col.addSpacerItem(seek.drop)
|
||||
|
||||
# The now-playing panel is exactly as tall as the boxes and shares
|
||||
# their top edge, so boxes, visualizer, panel and bpm read as one row;
|
||||
|
||||
@@ -2,6 +2,7 @@ from PyQt6.QtWidgets import QWidget, QApplication
|
||||
from PyQt6.QtCore import Qt, QSize, QRectF
|
||||
from PyQt6.QtGui import QPainter
|
||||
|
||||
from lintunes.gui import titlebar
|
||||
from lintunes.gui.art_window import fit_size
|
||||
|
||||
# The window takes a projection screen's shape.
|
||||
@@ -17,6 +18,9 @@ class VisualizerWindow(QWidget):
|
||||
super().__init__(visualizer, Qt.WindowType.Window)
|
||||
self._visualizer = visualizer
|
||||
self.setWindowTitle("Visualizer")
|
||||
# Kaleidostrobe's GL clears to alpha 0: in a see-through window the
|
||||
# desktop would show through it, so this one keeps square corners.
|
||||
self.setProperty(titlebar.SQUARE, True)
|
||||
self.setMinimumSize(160, 100)
|
||||
self.setToolTip("Click to close")
|
||||
# An OpenGL canvas over the contents, for a style that draws with
|
||||
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user