v0.98.1: a playlist's Imported from link can be typed in Get Info, for playlists imported before it was kept

This commit is contained in:
2026-11-17 23:27:54 -08:00
parent 2964158281
commit f52dd7f567
6 changed files with 57 additions and 21 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
"""LinTunes — iTunes-style music library manager and player for Linux."""
__version__ = "0.98.0"
__version__ = "0.98.1"
+2
View File
@@ -1611,6 +1611,8 @@ class MainWindow(QMainWindow):
return
if dialog.new_name():
self._manager.rename_playlist(pid, dialog.new_name())
if dialog.source_change() is not None:
self._manager.set_playlist_source(pid, dialog.source_change())
change = dialog.art_change()
if change is not None:
try:
+27 -19
View File
@@ -10,7 +10,7 @@ paste, drop or choose an image, or remove it.
Passive, like the song Get Info: nothing is written until OK, and then by
the caller (``MainWindow._playlist_info``), which reads ``new_name()`` and
``art_change()``.
``source_change()`` and ``art_change()``.
"""
from datetime import datetime
@@ -107,25 +107,27 @@ class PlaylistInfoDialog(QDialog):
form.addRow("Songs changed:",
self._label(when_text(playlist.date_modified)))
form.addRow("Last played:", self._label(when_text(last_played)))
# Editable, so a playlist imported before Round 130 (or made by hand
# from a list somewhere) can be given its link.
source = playlist.source_url
if source:
row = QHBoxLayout()
self._source = QLineEdit(source)
self._source.setReadOnly(True)
self._source.setCursorPosition(0)
copy = QPushButton("Copy")
copy.clicked.connect(
lambda: QApplication.clipboard().setText(source))
open_link = QPushButton("Open")
open_link.clicked.connect(
lambda: QDesktopServices.openUrl(QUrl(source)))
row.addWidget(self._source, 1)
row.addWidget(copy)
row.addWidget(open_link)
form.addRow("Imported from:", row)
else:
form.addRow("Imported from:", self._label("—"))
self._source_label = source
row = QHBoxLayout()
self._source = QLineEdit(source)
self._source.setPlaceholderText("a link (https://…)")
self._source.setCursorPosition(0)
copy = QPushButton("Copy")
copy.clicked.connect(lambda: QApplication.clipboard().setText(
self._source.text().strip()))
open_link = QPushButton("Open")
open_link.clicked.connect(lambda: QDesktopServices.openUrl(
QUrl(self._source.text().strip())))
for button in (copy, open_link):
button.setEnabled(bool(source))
self._source.textChanged.connect(
lambda text, b=button: b.setEnabled(bool(text.strip())))
row.addWidget(self._source, 1)
row.addWidget(copy)
row.addWidget(open_link)
form.addRow("Imported from:", row)
box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok
| QDialogButtonBox.StandardButton.Cancel)
@@ -161,6 +163,12 @@ class PlaylistInfoDialog(QDialog):
name = self._name.text().strip()
return name if name and name != self._playlist.name else ""
def source_change(self) -> str | None:
"""The new "Imported from" link ("" clears it), or None to leave
it."""
text = self._source.text().strip()
return None if text == self._playlist.source_url else text
def art_change(self) -> bytes | None:
"""None: leave the cover; b"": remove it; else the new image."""
return self._art_change
+16
View File
@@ -224,6 +224,22 @@ class LibraryManager(QObject):
def playlist_last_played(self, pid: str) -> str | None:
return self.playlist_plays.last_played(pid)
def set_playlist_source(self, pid: str, url: str):
"""Where the playlist was imported from (Get Info), undoable. Not a
change to its songs, so it moves no ``date_modified``."""
playlist = self.library.playlists.get(pid)
if playlist is None or playlist.source_url == url:
return
old = playlist.source_url
def apply(value):
playlist.source_url = value
self._mark_playlist(pid)
apply(url)
self.undo_stack.push(Command("Edit Playlist Info",
undo=lambda: apply(old),
redo=lambda: apply(url)))
def rename_playlist(self, pid: str, name: str):
playlist = self.library.playlists.get(pid)
if playlist and name and playlist.name != name: