From 932714702107801b23f0ff07057ad641ba48d143 Mon Sep 17 00:00:00 2001 From: joren Date: Tue, 24 Mar 2026 17:15:49 +0100 Subject: [PATCH] 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 --- src/playqueue.hpp | 34 +++++++++++++++++++++++++--------- src/view/context/view.cpp | 11 +++++++---- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/playqueue.hpp b/src/playqueue.hpp index 0bdb84b..e960f68 100644 --- a/src/playqueue.hpp +++ b/src/playqueue.hpp @@ -25,14 +25,27 @@ public: { m_queue.clear(); m_playNext.clear(); - for (const auto &v : tracks) - m_queue.append(v.toObject()); - if (m_shuffle) { - shuffleQueue(startIndex); - // shuffleQueue moves the start track to index 0 and sets m_index = 0 - } else { - m_index = qBound(0, startIndex, m_queue.size() - 1); + + // Only queue streamable tracks; find the filtered index for startIndex + int filteredStart = 0; + int filteredIdx = 0; + bool found = false; + for (int orig = 0; orig < tracks.size(); ++orig) { + 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(); } @@ -41,8 +54,11 @@ public: void reorderContext(const QJsonArray &tracks, qint64 currentId) { m_queue.clear(); - for (const auto &v : tracks) - m_queue.append(v.toObject()); + for (const auto &v : tracks) { + const QJsonObject t = v.toObject(); + if (t["streamable"].toBool(true)) + m_queue.append(t); + } m_index = 0; for (int i = 0; i < m_queue.size(); ++i) { diff --git a/src/view/context/view.cpp b/src/view/context/view.cpp index 62a2809..381b653 100644 --- a/src/view/context/view.cpp +++ b/src/view/context/view.cpp @@ -84,15 +84,18 @@ void View::onArtReady(QNetworkReply *reply) void View::resizeEvent(QResizeEvent *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() { if (m_artPixmap.isNull()) return; - // Available width = dock width minus the 8px margins on each side - const int side = qMax(32, widget() ? widget()->width() - 16 : width() - 16); - m_albumArt->setFixedSize(side, side); + const int side = qMax(32, width() - 16); + m_albumArt->setFixedHeight(side); m_albumArt->setPixmap(m_artPixmap.scaled(side, side, Qt::KeepAspectRatio, Qt::SmoothTransformation)); }