Hover previous track to see list

Fixes #205
This commit is contained in:
Keith Edmunds 2024-04-28 17:07:02 +01:00
parent f898e4645b
commit dfc51e1399
2 changed files with 22 additions and 0 deletions

View File

@ -161,6 +161,19 @@ class Playdates(dbtables.PlaydatesTable):
# last_played value
return Config.EPOCH # pragma: no cover
@staticmethod
def last_played_tracks(session: Session, limit=5) -> Sequence["Playdates"]:
"""
Return a list of the last limit tracks played, sorted
earliest to latest.
"""
return session.scalars(
Playdates.select()
.order_by(Playdates.lastplayed.desc())
.limit(limit)
).all()
@staticmethod
def played_after(session: Session, since: dt.datetime) -> Sequence["Playdates"]:
"""Return a list of Playdates objects since passed time"""

View File

@ -1178,6 +1178,15 @@ class Window(QMainWindow, Ui_MainWindow):
# Update headers
log.debug("update headers")
self.update_headers()
with db.Session() as session:
last_played = Playdates.last_played_tracks(session)
tracklist = []
for lp in last_played:
track = session.get(Tracks, lp.track_id)
tracklist.append(f"{track.title} ({track.artist})")
tt = "<br>".join(reversed(tracklist))
self.hdrPreviousTrack.setToolTip(tt)
def preview(self) -> None:
"""