v0.6.0: delete songs from the library

Right-click a track (or a multi-selection) for "Remove from Library" or
"Remove from Library and Delete File". The second moves the file to the
desktop trash rather than unlinking it, so it stays recoverable by Ctrl+Z
in-app and by "Restore" from the file manager afterwards.

The trash is per-filesystem: music lives on a mounted volume, so the file
belongs in <topdir>/.Trash-<uid> with a topdir-relative, percent-encoded
Path. Using ~/.local/share/Trash would be a cross-device copy recording an
original path "Restore" can't reach. lintunes/trash.py implements the
freedesktop spec directly rather than adding a dependency that would need
a manual reinstall on the other machine.

Playlist cleanup is synchronous with the removal: playlist edits address
tracks by row index into track_ids while the view skips ids missing from
the library, so a dangling id would desync the two and make a later
"Remove from Playlist" hit the wrong track.

A file that can't be trashed keeps its track — better a song to delete
again than a library entry orphaned from a file still on disk. Player
gains drop_tracks() so deleting the playing track stops cleanly instead
of erroring out when the queue walk later reaches a dead id.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-14 11:21:50 -04:00
co-authored by Claude Opus 5
parent 01996d5fe2
commit 6fad0247ee
10 changed files with 878 additions and 5 deletions
+22
View File
@@ -400,6 +400,28 @@ class Player(QObject):
self._index = self._queue.index(current_id)
self._reshuffle()
def drop_tracks(self, track_ids):
"""Forget tracks that no longer exist in the library.
Stops if one of them is playing; otherwise the current track keeps its
place in the shortened queue. Without this the queue keeps dead ids and
``_load_current`` stops the whole thing with an error dialog when the
walk eventually reaches one.
"""
doomed = set(track_ids)
if not doomed:
return
if self._current_track is not None and self._current_track.track_id in doomed:
self.stop()
current_id = None
else:
current_id = (self._queue[self._index]
if 0 <= self._index < len(self._queue) else None)
self._queue = [tid for tid in self._queue if tid not in doomed]
self._index = (self._queue.index(current_id)
if current_id is not None and current_id in self._queue else -1)
self._reshuffle()
# ---- shuffle ----
def is_shuffle(self) -> bool: