fix: art scaling on shrink + skip unavailable tracks in queue

- Now-playing art: use setFixedHeight (not setFixedSize) so the dock
  width constraint is removed and can shrink freely; use event->size()
  in resizeEvent to get the correct new width without layout lag
- PlayQueue: filter non-streamable tracks out of setContext and
  reorderContext so unavailable tracks are never in the queue and
  pressing Next always lands on a playable track

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
joren
2026-03-24 17:15:49 +01:00
parent 9ca17b4406
commit 9327147021
2 changed files with 32 additions and 13 deletions

View File

@@ -25,14 +25,27 @@ public:
{ {
m_queue.clear(); m_queue.clear();
m_playNext.clear(); m_playNext.clear();
for (const auto &v : tracks)
m_queue.append(v.toObject()); // Only queue streamable tracks; find the filtered index for startIndex
if (m_shuffle) { int filteredStart = 0;
shuffleQueue(startIndex); int filteredIdx = 0;
// shuffleQueue moves the start track to index 0 and sets m_index = 0 bool found = false;
} else { for (int orig = 0; orig < tracks.size(); ++orig) {
m_index = qBound(0, startIndex, m_queue.size() - 1); const QJsonObject t = tracks[orig].toObject();
if (!t["streamable"].toBool(true))
continue;
if (!found && orig >= startIndex) {
filteredStart = filteredIdx;
found = true;
} }
m_queue.append(t);
++filteredIdx;
}
m_index = qBound(0, filteredStart, qMax(0, m_queue.size() - 1));
if (m_shuffle)
shuffleQueue(m_index);
emit queueChanged(); emit queueChanged();
} }
@@ -41,8 +54,11 @@ public:
void reorderContext(const QJsonArray &tracks, qint64 currentId) void reorderContext(const QJsonArray &tracks, qint64 currentId)
{ {
m_queue.clear(); m_queue.clear();
for (const auto &v : tracks) for (const auto &v : tracks) {
m_queue.append(v.toObject()); const QJsonObject t = v.toObject();
if (t["streamable"].toBool(true))
m_queue.append(t);
}
m_index = 0; m_index = 0;
for (int i = 0; i < m_queue.size(); ++i) { for (int i = 0; i < m_queue.size(); ++i) {

View File

@@ -84,15 +84,18 @@ void View::onArtReady(QNetworkReply *reply)
void View::resizeEvent(QResizeEvent *event) void View::resizeEvent(QResizeEvent *event)
{ {
QDockWidget::resizeEvent(event); QDockWidget::resizeEvent(event);
scaleArtToWidth(); if (m_artPixmap.isNull()) return;
// Use the new dock width from the event so we don't lag behind the layout
const int side = qMax(32, event->size().width() - 16);
m_albumArt->setFixedHeight(side);
m_albumArt->setPixmap(m_artPixmap.scaled(side, side, Qt::KeepAspectRatio, Qt::SmoothTransformation));
} }
void View::scaleArtToWidth() void View::scaleArtToWidth()
{ {
if (m_artPixmap.isNull()) return; if (m_artPixmap.isNull()) return;
// Available width = dock width minus the 8px margins on each side const int side = qMax(32, width() - 16);
const int side = qMax(32, widget() ? widget()->width() - 16 : width() - 16); m_albumArt->setFixedHeight(side);
m_albumArt->setFixedSize(side, side);
m_albumArt->setPixmap(m_artPixmap.scaled(side, side, Qt::KeepAspectRatio, Qt::SmoothTransformation)); m_albumArt->setPixmap(m_artPixmap.scaled(side, side, Qt::KeepAspectRatio, Qt::SmoothTransformation));
} }