fix: section alignment, pagination, fav state, playback error handling

**Section toggles left-aligned**
- Replace QToolButton with flat QPushButton for all section headers;
  QPushButton properly respects text-align: left in stylesheets

**Pagination via "Load More" button**
- QTreeWidget expands to fit all items so the scrollbar-based infinite
  scroll never triggered; replaced with an explicit "Load more…" button
  that appears when has_more is true and emits loadMoreRequested

**Favourite button reflects actual state**
- MainWindow preloads fav artist IDs on session restore (getFavArtists)
  and caches them in m_favArtistIds
- ArtistView receives the full set via setFavArtistIds() and checks
  it on every setArtist() call so the button starts gold if already faved
- Toggling updates the local cache immediately for back/forward nav

**Playback error → queue advances**
- player_loop now sets track_finished on Err (was only set on Ok(None)),
  so the toolbar's onTrackFinished handler advances to the next track
  instead of stalling on an unplayable track

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
joren
2026-03-25 23:22:30 +01:00
parent b3cc2e3def
commit 333a620be2
8 changed files with 98 additions and 52 deletions

View File

@@ -121,6 +121,7 @@ MainWindow::MainWindow(QobuzBackend *backend, QWidget *parent)
statusBar()->showMessage(tr("Loading favorite albums…"));
});
connect(m_library, &List::Library::favArtistsRequested, this, [this] {
m_showFavArtistsOnLoad = true;
m_backend->getFavArtists();
statusBar()->showMessage(tr("Loading favorite artists…"));
});
@@ -233,6 +234,8 @@ void MainWindow::tryRestoreSession()
m_backend->getUser(); // userLoaded will call m_library->refresh()
else
m_library->refresh();
// Preload fav artists so the artist page fav button works immediately
m_backend->getFavArtists();
const QString name = AppSettings::instance().displayName();
statusBar()->showMessage(tr("Signed in as %1").arg(
name.isEmpty() ? AppSettings::instance().userEmail() : name));
@@ -339,9 +342,22 @@ void MainWindow::onFavAlbumsLoaded(const QJsonObject &result)
void MainWindow::onFavArtistsLoaded(const QJsonObject &result)
{
m_content->showFavArtists(result);
statusBar()->showMessage(
tr("%1 favorite artists").arg(result["total"].toInt()), 4000);
// Always cache fav artist IDs (needed by the artist page fav button)
m_favArtistIds.clear();
const QJsonArray items = result["items"].toArray();
for (const QJsonValue &v : items) {
const qint64 id = static_cast<qint64>(v.toObject()["id"].toDouble());
if (id > 0) m_favArtistIds.insert(id);
}
m_content->setFavArtistIds(m_favArtistIds);
// Only navigate to the fav artists page if the user explicitly requested it
if (m_showFavArtistsOnLoad) {
m_showFavArtistsOnLoad = false;
m_content->showFavArtists(result);
statusBar()->showMessage(
tr("%1 favorite artists").arg(result["total"].toInt()), 4000);
}
}
void MainWindow::onAlbumLoaded(const QJsonObject &album)