feat: pagination, back/forward nav, context menu, artist fav, image fix

**Artist portrait**
- Fix CDN URL: images.portrait.{hash,format} →
  https://static.qobuz.com/images/artists/covers/large/{hash}.{format}

**Section alignment**
- Qt::ToolButtonTextOnly on all section toggles so text is truly left-aligned

**Auth 401 race condition**
- qobuz_backend_set_token now uses blocking_lock() instead of spawning an
  async task, guaranteeing the token is set before any subsequent API call

**Pagination (infinite scroll)**
- Release sections load 50 at a time (was 500)
- ArtistSection tracks has_more + loaded count; scrolling to the bottom
  emits loadMoreRequested → ArtistView calls getArtistReleases(offset=N)
- AlbumListView gains addAlbums() for append; setReleases routes to
  setAlbums (offset=0) or appendAlbums (offset>0)

**Back/Forward navigation**
- MainToolBar exposes Back/Forward QActions (go-previous/go-next icons)
- MainWindow keeps a NavPage vector + index; pushNav() on every album/artist
  navigation; goBack/goForward re-navigate without pushing history

**Context menu on now-playing label**
- Right-click on track label in toolbar → "Go to Album" / "Go to Artist"
- MainToolBar stores current track; emits albumRequested/artistRequested
  signals wired to MainWindow's existing handlers

**Artist favourites button**
- ♡ Favourite / ♥ Favourited toggle in artist header
- Calls new addFavArtist / removeFavArtist (Rust + Qt backend wiring)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
joren
2026-03-25 18:25:12 +01:00
parent 963c9ad232
commit 3e96b6d7a8
157 changed files with 64124 additions and 84 deletions

View File

@@ -98,6 +98,8 @@ void qobuz_backend_add_fav_track(QobuzBackendOpaque *backend, int64_t track_id);
void qobuz_backend_remove_fav_track(QobuzBackendOpaque *backend, int64_t track_id);
void qobuz_backend_add_fav_album(QobuzBackendOpaque *backend, const char *album_id);
void qobuz_backend_remove_fav_album(QobuzBackendOpaque *backend, const char *album_id);
void qobuz_backend_add_fav_artist(QobuzBackendOpaque *backend, int64_t artist_id);
void qobuz_backend_remove_fav_artist(QobuzBackendOpaque *backend, int64_t artist_id);
#ifdef __cplusplus
}

View File

@@ -447,4 +447,24 @@ impl QobuzClient {
Self::check_response(resp).await?;
Ok(())
}
pub async fn add_fav_artist(&self, artist_id: i64) -> Result<()> {
let resp = self
.get_request("favorite/create")
.query(&[("type", "artists"), ("artist_ids", &artist_id.to_string())])
.send()
.await?;
Self::check_response(resp).await?;
Ok(())
}
pub async fn remove_fav_artist(&self, artist_id: i64) -> Result<()> {
let resp = self
.get_request("favorite/delete")
.query(&[("type", "artists"), ("artist_ids", &artist_id.to_string())])
.send()
.await?;
Self::check_response(resp).await?;
Ok(())
}
}

View File

@@ -189,11 +189,9 @@ pub unsafe extern "C" fn qobuz_backend_login(
pub unsafe extern "C" fn qobuz_backend_set_token(ptr: *mut Backend, token: *const c_char) {
let inner = &(*ptr).0;
let token = CStr::from_ptr(token).to_string_lossy().into_owned();
let client = inner.client.clone();
// blocking_lock is available on tokio::sync::Mutex when not in an async context
inner.rt.spawn(async move {
client.lock().await.set_auth_token(token);
});
// Use blocking_lock (called from Qt main thread, not a tokio thread) so the
// token is set before any subsequent getUser/library requests are spawned.
inner.client.blocking_lock().set_auth_token(token);
}
// ---------- Search ----------
@@ -604,6 +602,30 @@ pub unsafe extern "C" fn qobuz_backend_remove_fav_album(ptr: *mut Backend, album
});
}
#[no_mangle]
pub unsafe extern "C" fn qobuz_backend_add_fav_artist(ptr: *mut Backend, artist_id: i64) {
let inner = &(*ptr).0;
let client = inner.client.clone();
let cb = inner.cb; let ud = inner.ud;
spawn(inner, async move {
if let Err(e) = client.lock().await.add_fav_artist(artist_id).await {
call_cb(cb, ud, EV_GENERIC_ERR, &err_json(&e.to_string()));
}
});
}
#[no_mangle]
pub unsafe extern "C" fn qobuz_backend_remove_fav_artist(ptr: *mut Backend, artist_id: i64) {
let inner = &(*ptr).0;
let client = inner.client.clone();
let cb = inner.cb; let ud = inner.ud;
spawn(inner, async move {
if let Err(e) = client.lock().await.remove_fav_artist(artist_id).await {
call_cb(cb, ud, EV_GENERIC_ERR, &err_json(&e.to_string()));
}
});
}
// ---------- User ----------
pub const EV_USER_OK: c_int = 23;