v0.85.0: every slider tall and click-to-jump, Light | Dark as folder tabs, album art shows it's clickable (finger, tooltip, keyboard focus)

This commit is contained in:
2026-10-30 16:41:04 -07:00
parent 4be4d60da2
commit b1c8a704e7
7 changed files with 321 additions and 31 deletions
+14 -6
View File
@@ -239,12 +239,20 @@ persistence) → GUI (Qt widgets that read the manager and connect to its signal
Go to Current Song button while a song is on (not in DJ mode): raised Go to Current Song button while a song is on (not in DJ mode): raised
in the hover face under the cursor, sunk and darker while held. Its in the hover face under the cursor, sunk and darker while held. Its
face is a `face` property, since a QFrame has no `:pressed`. face is a `face` property, since a QFrame has no `:pressed`.
**No pointing-hand (finger) cursor anywhere** (trav's call, Round 110): **The look is `~/Documents/shared-resources/design.html`** (canonical
most of the app is clickable, so a finger on a few things misleads. He since Round 118; read it before UI work). **No pointing-hand (finger)
may want it on *every* button later — all or nothing. So a thing that's cursor** (Round 110), with one exception (Round 118): a clickable
clickable must *look* it: the version button is flat until an update is *picture* — the sidebar art — can't wear a button face without altering
ready, then shows the button face on hover; the status bar's cancel ✕ and the picture, so it gets the finger, a tooltip and Tab focus (Enter/Space,
the DJ deck's cancel-split ✕ are always drawn as buttons. a 2 px highlight ring). Everything else that's clickable must *look* it:
the version button is flat until an update is ready, then shows the
button face on hover; the status bar's cancel ✕ and the DJ deck's
cancel-split ✕ are always drawn as buttons. **Every slider is tall and
click-to-jump** (Round 118, app-wide in `ClickToJumpScrollStyle`: the
`tall` property defaults on, `SH_Slider_AbsoluteSetButtons`); a slider
with its own style sheet (the DJ shelf's) draws itself. A choice that
changes the page under it is **folder tabs** (`gui/mac_tabs.py`, shared
with wave) — Preferences › Colors' Light | Dark.
The playlist list's frame is a `sidebar.RoundedFrame` (Round 91): the The playlist list's frame is a `sidebar.RoundedFrame` (Round 91): the
panels' 8 px corners, painted *over* the list by a mouse-transparent panels' 8 px corners, painted *over* the list by a mouse-transparent
overlay (window color outside the curve, then Fusion's own frame line, overlay (window color outside the curve, then Fusion's own frame line,
+1 -1
View File
@@ -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.84.1" __version__ = "0.85.0"
+167
View File
@@ -0,0 +1,167 @@
"""Folder tabs after classic Mac OS (the Platinum look of OS 8 and 9), in
the house style (shared-resources' design page, #tabs): slanted sides with
8 px top corners, the tabs behind are buttons (embossed in the button
gray, darker on hover, sunk while held), and the open tab in front is the
page's own color with only the top rim, open at the foot so it runs into
the page. All stand on one baseline, overlapping a little.
Each tab is a checkable QToolButton that paints itself, so the window's
QButtonGroup logic is unchanged; `TabStrip` holds them, overlapping a little
the way the real ones did, and draws the baseline they stand on. The tab
in front is raised above its neighbours, so its feet cover theirs."""
from __future__ import annotations
from PyQt6.QtCore import QPointF, QSize, Qt
from PyQt6.QtGui import QLinearGradient, QPainter, QPainterPath, QPalette, QPen
from PyQt6.QtWidgets import QToolButton, QWidget
from lintunes import theme
OVERLAP = 9 # px adjacent tabs overlap at their slanted feet
RADIUS = 8 # the top corners: the big buttons' radius
SLANT = 0.28 # each side's run, as a share of the height
OUTLINE = 135 # the buttons' outline, darker(135)
def _slant(h: int) -> float:
return h * SLANT
def baseline_color(palette):
return palette.color(QPalette.ColorRole.Window).darker(OUTLINE)
class MacTab(QToolButton):
def __init__(self, text: str, parent=None):
super().__init__(parent)
self.setText(text)
self.setCheckable(True)
self.toggled.connect(lambda on: on and self.raise_())
def sizeHint(self) -> QSize:
fm = self.fontMetrics()
h = fm.height() + 12
return QSize(int(fm.horizontalAdvance(self.text()) + 2 * _slant(h) + 18), h)
def minimumSizeHint(self) -> QSize:
return self.sizeHint()
def _outline(self) -> QPainterPath:
"""Up the left slope, round the top corners, down the right slope;
open along the foot."""
w, h, s = self.width(), self.height(), _slant(self.height())
top, foot = 0.5, float(h)
side = ((s - 0.5) ** 2 + (foot - top) ** 2) ** 0.5
r = min(RADIUS, side / 2)
# where the curve starts, back down each slope
dx, dy = (s - 0.5) * r / side, (foot - top) * r / side
p = QPainterPath()
p.moveTo(0.5, foot)
p.lineTo(s - dx, top + dy)
p.quadTo(s, top, s + r, top)
p.lineTo(w - s - r, top)
p.quadTo(w - s, top, w - s + dx, top + dy)
p.lineTo(w - 0.5, foot)
return p
def _fill(self, color, front: bool) -> QLinearGradient:
"""A button's emboss, or (front) only its top rim, then the page."""
g = QLinearGradient(QPointF(0, 0), QPointF(0, self.height()))
stops = theme.emboss_stops(color, pressed=self.isDown() and not front)
for pos, c in (stops[:3] if front else stops):
g.setColorAt(pos, c)
if front:
g.setColorAt(1, color)
return g
def paintEvent(self, _) -> None:
front = self.isChecked()
pal = self.palette()
if front:
color = pal.color(QPalette.ColorRole.Window)
else:
color = pal.color(QPalette.ColorRole.Button)
if self.isDown():
color = color.darker(theme.PRESSED_DARKER)
elif self.underMouse():
color = color.darker(theme.HOVER_DARKER)
w, h = self.width(), self.height()
p = QPainter(self)
p.setRenderHint(QPainter.RenderHint.Antialiasing)
shape = self._outline()
p.fillPath(shape, self._fill(color, front))
p.setPen(QPen(color.darker(OUTLINE), 1))
p.drawPath(shape)
if not front: # behind: the baseline runs across its foot
p.setPen(QPen(baseline_color(pal), 1))
p.drawLine(QPointF(0, h - 0.5), QPointF(w, h - 0.5))
p.setPen(pal.color(QPalette.ColorRole.WindowText if front
else QPalette.ColorRole.ButtonText))
f = self.font()
f.setBold(front)
p.setFont(f)
p.drawText(self.rect().adjusted(0, 2, 0, 0), Qt.AlignmentFlag.AlignCenter, self.text())
p.end()
def enterEvent(self, e) -> None:
self.update()
super().enterEvent(e)
def leaveEvent(self, e) -> None:
self.update()
super().leaveEvent(e)
class TabStrip(QWidget):
"""A row of MacTabs (None in `add` = a gap) on a baseline across the
width. Placed by hand: a layout can't overlap its widgets."""
def __init__(self, parent=None):
super().__init__(parent)
self._items: list[MacTab | int] = [] # a tab, or a gap's width
def add(self, tab: MacTab | None, gap: int = 24) -> None:
if tab is None:
self._items.append(gap)
else:
tab.setParent(self)
self._items.append(tab)
def finish(self) -> None:
for t in self._tabs():
if t.isChecked():
t.raise_()
self._place()
def _tabs(self) -> list[MacTab]:
return [t for t in self._items if isinstance(t, MacTab)]
def sizeHint(self) -> QSize:
tabs = self._tabs()
h = max((t.sizeHint().height() for t in tabs), default=24)
w = 4 + sum(t.sizeHint().width() - OVERLAP if isinstance(t, MacTab) else t
for t in self._items) + OVERLAP
return QSize(w, h)
def minimumSizeHint(self) -> QSize:
return self.sizeHint()
def _place(self) -> None:
x, h = 4, self.height()
for item in self._items:
if isinstance(item, MacTab):
hint = item.sizeHint()
item.setGeometry(x, h - hint.height(), hint.width(), hint.height())
x += hint.width() - OVERLAP
else:
x += item
def resizeEvent(self, e) -> None:
self._place()
super().resizeEvent(e)
def paintEvent(self, _) -> None:
p = QPainter(self)
p.setPen(QPen(baseline_color(self.palette()), 1))
p.drawLine(0, self.height() - 1, self.width(), self.height() - 1)
p.end()
+12 -12
View File
@@ -19,6 +19,7 @@ from lintunes.gui import visualizer_styles
from lintunes.gui.range_slider import RangeSlider from lintunes.gui.range_slider import RangeSlider
from lintunes.gui.scope_drawing import ScopeDrawing from lintunes.gui.scope_drawing import ScopeDrawing
from lintunes.gui.transport import ClickJumpSlider from lintunes.gui.transport import ClickJumpSlider
from lintunes.gui.mac_tabs import MacTab, TabStrip
from lintunes.gui import visualizer_presets as presets from lintunes.gui import visualizer_presets as presets
from lintunes.gui import sounds from lintunes.gui import sounds
from lintunes.theme import HIGHLIGHT_COLORS from lintunes.theme import HIGHLIGHT_COLORS
@@ -1137,7 +1138,7 @@ class PreferencesDialog(QDialog):
def _build_colors_group(self) -> QGroupBox: def _build_colors_group(self) -> QGroupBox:
"""Light and dark each have a tint and a full set of grays; the """Light and dark each have a tint and a full set of grays; the
Light | Dark switch picks which set the controls show and edit, and Light | Dark tabs pick which set the controls show and edit, and
every control moves to that set's saved values.""" every control moves to that set's saved values."""
group = QGroupBox("Colors") group = QGroupBox("Colors")
form = QFormLayout(group) form = QFormLayout(group)
@@ -1146,21 +1147,19 @@ class PreferencesDialog(QDialog):
note.setWordWrap(True) note.setWordWrap(True)
form.addRow(note) form.addRow(note)
switch = QHBoxLayout() # Which set the controls below show: folder tabs, since picking one
switch.setSpacing(0) # changes the page under it (shared design #tabs).
strip = TabStrip()
self._color_mode_group = QButtonGroup(self) self._color_mode_group = QButtonGroup(self)
self._color_mode_buttons = {} self._color_mode_buttons = {}
for which in theme.MODES: for which in theme.MODES:
button = QPushButton(which.capitalize()) tab = MacTab(which.capitalize())
button.setCheckable(True) self._color_mode_group.addButton(tab)
button.setProperty("tile", "first" if which == "light" else "last") self._color_mode_buttons[which] = tab
self._color_mode_group.addButton(button) strip.add(tab)
self._color_mode_buttons[which] = button tab.toggled.connect(
switch.addWidget(button)
button.toggled.connect(
lambda on, w=which: on and self._edit_colors_of(w)) lambda on, w=which: on and self._edit_colors_of(w))
switch.addStretch() form.addRow(strip)
form.addRow("Editing:", switch)
self._editing = theme.mode(self._prefs) self._editing = theme.mode(self._prefs)
tint_row = QHBoxLayout() tint_row = QHBoxLayout()
@@ -1187,6 +1186,7 @@ class PreferencesDialog(QDialog):
self._color_sliders[key] = slider self._color_sliders[key] = slider
form.addRow(label, slider) form.addRow(label, slider)
self._color_mode_buttons[self._editing].setChecked(True) self._color_mode_buttons[self._editing].setChecked(True)
strip.finish()
self._show_color_values() self._show_color_values()
return group return group
+53 -8
View File
@@ -329,6 +329,10 @@ class SidebarArt(QWidget):
self._art_window = ArtWindow() self._art_window = ArtWindow()
self._hovered = False self._hovered = False
self._held = False self._held = False
# A clickable picture can't wear a button face without changing the
# picture, so it says so the shared way (design #clickable-images):
# the finger over it, a tooltip, and a place in the Tab order.
self.setFocusPolicy(Qt.FocusPolicy.TabFocus)
player.track_changed.connect(self.set_track) player.track_changed.connect(self.set_track)
def set_track(self, track): def set_track(self, track):
@@ -340,6 +344,7 @@ class SidebarArt(QWidget):
pixmap = QPixmap() pixmap = QPixmap()
if pixmap.loadFromData(data): if pixmap.loadFromData(data):
self._pixmap = pixmap self._pixmap = pixmap
self._update_cursor()
if self._pixmap is not None: if self._pixmap is not None:
self.setToolTip("Click to view full size") self.setToolTip("Click to view full size")
elif track is not None: elif track is not None:
@@ -354,6 +359,14 @@ class SidebarArt(QWidget):
self._had_art = self.has_art() self._had_art = self.has_art()
self.has_art_changed.emit(self._had_art) self.has_art_changed.emit(self._had_art)
def _update_cursor(self):
"""The finger only over a picture: an empty panel shows it's a
button by its face instead."""
if self.has_art():
self.setCursor(Qt.CursorShape.PointingHandCursor)
else:
self.unsetCursor()
def has_art(self) -> bool: def has_art(self) -> bool:
return self._pixmap is not None and not self._pixmap.isNull() return self._pixmap is not None and not self._pixmap.isNull()
@@ -415,21 +428,53 @@ class SidebarArt(QWidget):
# also fire when a drag merely starts here. # also fire when a drag merely starts here.
if (event.button() == Qt.MouseButton.LeftButton if (event.button() == Qt.MouseButton.LeftButton
and self.rect().contains(event.position().toPoint())): and self.rect().contains(event.position().toPoint())):
if self._pixmap is not None: self._activate()
self._art_window.show_artwork(self._pixmap, self._title(),
self.screen())
elif self._track is not None:
self.download_art_requested.emit(self._track.track_id)
super().mouseReleaseEvent(event) super().mouseReleaseEvent(event)
def keyPressEvent(self, event):
if event.key() in (Qt.Key.Key_Return, Qt.Key.Key_Enter, Qt.Key.Key_Space):
self._activate()
event.accept()
return
super().keyPressEvent(event)
def focusInEvent(self, event):
self.update()
super().focusInEvent(event)
def focusOutEvent(self, event):
self.update()
super().focusOutEvent(event)
def _activate(self):
if self._pixmap is not None:
self._art_window.show_artwork(self._pixmap, self._title(),
self.screen())
elif self._track is not None:
self.download_art_requested.emit(self._track.track_id)
def _paint_focus(self, painter, rect):
"""The keyboard focus ring: 2 px of the highlight over the edge."""
if not self.hasFocus():
return
from PyQt6.QtGui import QPainterPath, QPen
ring = QPainterPath()
ring.addRoundedRect(rect, NO_ART_RADIUS, NO_ART_RADIUS)
painter.setPen(QPen(self.palette().highlight().color(), 2))
painter.drawPath(ring)
def paintEvent(self, event): def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
rect = QRectF(self.rect()).adjusted(0.5, NO_ART_GAP + 0.5, -0.5, -0.5)
self._paint_panel(painter, rect)
self._paint_focus(painter, rect)
def _paint_panel(self, painter, rect):
# Straight onto the window, a panel debossed in the visualizer's # Straight onto the window, a panel debossed in the visualizer's
# color and shaded at its edges as the visualizer is. # color and shaded at its edges as the visualizer is.
from lintunes.gui.transport import CONTROL_HEIGHT from lintunes.gui.transport import CONTROL_HEIGHT
from PyQt6.QtGui import QPainterPath from PyQt6.QtGui import QPainterPath
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
rect = QRectF(self.rect()).adjusted(0.5, NO_ART_GAP + 0.5, -0.5, -0.5)
if self._is_button() and self._hovered: if self._is_button() and self._hovered:
# Pops up as a plain button under the cursor (no glyph): the # Pops up as a plain button under the cursor (no glyph): the
# Library button's face, hover-darkened, and sunk while held. # Library button's face, hover-darkened, and sunk while held.
+10 -4
View File
@@ -3,7 +3,7 @@ import os
from PyQt6.QtWidgets import ( from PyQt6.QtWidgets import (
QTableView, QAbstractItemView, QMenu, QApplication, QProxyStyle, QStyle, QTableView, QAbstractItemView, QMenu, QApplication, QProxyStyle, QStyle,
QStyledItemDelegate, QStyleOptionViewItem, QWidget, QStyledItemDelegate, QStyleOptionViewItem, QWidget, QSlider,
) )
from PyQt6.QtCore import ( from PyQt6.QtCore import (
Qt, QAbstractTableModel, QModelIndex, QPersistentModelIndex, Qt, QAbstractTableModel, QModelIndex, QPersistentModelIndex,
@@ -50,17 +50,23 @@ class ClickToJumpScrollStyle(QProxyStyle):
extent = 14 extent = 14
# A slider whose `tall` property is set (the seek bar) has its groove # Every slider is tall (shared design #sliders): groove and handle this
# and handle this many times Fusion's height; the handle keeps its width. # many times Fusion's height, the handle keeping its width. A slider
# opts out with the `tall` property set False, or by having a style
# sheet of its own (the DJ shelf's), which draws it instead.
TALL = 2 TALL = 2
@staticmethod @staticmethod
def _tall(widget) -> bool: def _tall(widget) -> bool:
return widget is not None and bool(widget.property("tall")) return (isinstance(widget, QSlider) and widget.property("tall") is not False
and not widget.styleSheet())
def styleHint(self, hint, option=None, widget=None, returnData=None): def styleHint(self, hint, option=None, widget=None, returnData=None):
if hint == QStyle.StyleHint.SH_ScrollBar_LeftClickAbsolutePosition: if hint == QStyle.StyleHint.SH_ScrollBar_LeftClickAbsolutePosition:
return 1 return 1
if hint == QStyle.StyleHint.SH_Slider_AbsoluteSetButtons:
# a left click puts the handle's centre where it lands
return Qt.MouseButton.LeftButton.value
return super().styleHint(hint, option, widget, returnData) return super().styleHint(hint, option, widget, returnData)
def pixelMetric(self, metric, option=None, widget=None): def pixelMetric(self, metric, option=None, widget=None):
+64
View File
@@ -0,0 +1,64 @@
"""Round 118: brought in line with the shared design page — every slider
tall and click-to-jump, the Colors page's Light | Dark as folder tabs, and
the album art saying it's clickable (finger, tooltip, keyboard focus)."""
from PyQt6.QtCore import QPointF, Qt
from PyQt6.QtGui import QMouseEvent
from PyQt6.QtWidgets import QSlider, QStyle
from lintunes.gui.mac_tabs import MacTab
from lintunes.gui.track_table import ClickToJumpScrollStyle
from tests.test_round101 import _dialog
def _press(slider, x):
y = slider.height() / 2
for kind in (QMouseEvent.Type.MouseButtonPress, QMouseEvent.Type.MouseButtonRelease):
event = QMouseEvent(kind, QPointF(x, y), slider.mapToGlobal(QPointF(x, y)),
Qt.MouseButton.LeftButton, Qt.MouseButton.LeftButton,
Qt.KeyboardModifier.NoModifier)
(slider.mousePressEvent if kind == QMouseEvent.Type.MouseButtonPress
else slider.mouseReleaseEvent)(event)
def test_a_plain_slider_is_tall_and_jumps(qapp):
style = ClickToJumpScrollStyle()
plain, opted_out = QSlider(Qt.Orientation.Horizontal), QSlider(Qt.Orientation.Horizontal)
opted_out.setProperty("tall", False)
for s in (plain, opted_out):
s.setStyle(style)
metric = QStyle.PixelMetric.PM_SliderThickness
assert style.pixelMetric(metric, None, plain) == \
2 * style.pixelMetric(metric, None, opted_out)
plain.setRange(0, 100)
plain.resize(300, plain.sizeHint().height())
plain.show()
_press(plain, 290) # far right, in one click
assert plain.value() > 90
plain.close()
def test_light_and_dark_are_folder_tabs(qapp, tmp_path):
prefs, dialog = _dialog(tmp_path)
tabs = dialog._color_mode_buttons
assert all(isinstance(t, MacTab) for t in tabs.values())
tabs["dark"].setChecked(True)
assert not tabs["light"].isChecked()
dialog.deleteLater()
def test_album_art_says_it_is_clickable(qapp):
from PyQt6.QtGui import QKeyEvent, QPixmap
from tests.test_round61 import _art, _track
art, requested = _art()
assert art.focusPolicy() == Qt.FocusPolicy.TabFocus
art.set_track(_track(42)) # no art: a button, no finger
assert art.cursor().shape() == Qt.CursorShape.ArrowCursor
art.keyPressEvent(QKeyEvent(QKeyEvent.Type.KeyPress, Qt.Key.Key_Space,
Qt.KeyboardModifier.NoModifier))
assert requested == [42] # the keyboard reaches it too
pixmap = QPixmap(8, 8)
pixmap.fill(Qt.GlobalColor.red)
art._pixmap = pixmap
art._update_cursor()
assert art.cursor().shape() == Qt.CursorShape.PointingHandCursor