Compare commits
19 Commits
feat/playl
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c8d032ce9 | ||
|
|
a21d0c8a33 | ||
|
|
333a620be2 | ||
|
|
b3cc2e3def | ||
|
|
3e96b6d7a8 | ||
|
|
963c9ad232 | ||
|
|
8310eceeb2 | ||
|
|
fb58c0ac8c | ||
|
|
e37de6d897 | ||
|
|
5ae18afa08 | ||
|
|
6f11b364aa | ||
|
|
4ba6d00748 | ||
|
|
e4c2694584 | ||
|
|
5d0011cb90 | ||
|
|
5bda2396d1 | ||
|
|
eb5c151d3a | ||
|
|
872fdecdce | ||
|
|
69fb818c38 | ||
|
|
56473cae6f |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,7 @@
|
|||||||
build/
|
build/
|
||||||
|
build-*/
|
||||||
target/
|
target/
|
||||||
|
src/visualizer/
|
||||||
.cache/
|
.cache/
|
||||||
*.user
|
*.user
|
||||||
*.autosave
|
*.autosave
|
||||||
|
|||||||
@@ -88,9 +88,18 @@ if (UNIX AND NOT APPLE)
|
|||||||
target_link_libraries(qobuz-qt PRIVATE asound)
|
target_link_libraries(qobuz-qt PRIVATE asound)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Compiler warnings
|
# Compiler warnings + hardening
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
target_compile_options(qobuz-qt PRIVATE -Wall -Wextra -Wno-unused-parameter)
|
target_compile_options(qobuz-qt PRIVATE
|
||||||
|
-Wall -Wextra -Wno-unused-parameter
|
||||||
|
-fstack-protector-strong
|
||||||
|
-D_FORTIFY_SOURCE=2
|
||||||
|
-fPIE
|
||||||
|
)
|
||||||
|
target_link_options(qobuz-qt PRIVATE
|
||||||
|
-pie
|
||||||
|
-Wl,-z,relro,-z,now
|
||||||
|
)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# D-Bus
|
# D-Bus
|
||||||
|
|||||||
@@ -31,3 +31,4 @@ toml = "0.8"
|
|||||||
[profile.release]
|
[profile.release]
|
||||||
lto = "thin"
|
lto = "thin"
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
overflow-checks = true
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ enum QobuzEvent {
|
|||||||
EV_PLAYLIST_CREATED = 20,
|
EV_PLAYLIST_CREATED = 20,
|
||||||
EV_PLAYLIST_DELETED = 21,
|
EV_PLAYLIST_DELETED = 21,
|
||||||
EV_PLAYLIST_TRACK_ADDED = 22,
|
EV_PLAYLIST_TRACK_ADDED = 22,
|
||||||
|
EV_USER_OK = 23,
|
||||||
|
EV_ARTIST_RELEASES_OK = 24,
|
||||||
|
EV_DEEP_SHUFFLE_OK = 25,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Callback signature
|
// Callback signature
|
||||||
@@ -46,6 +49,7 @@ void qobuz_backend_free(QobuzBackendOpaque *backend);
|
|||||||
// Auth
|
// Auth
|
||||||
void qobuz_backend_login(QobuzBackendOpaque *backend, const char *email, const char *password);
|
void qobuz_backend_login(QobuzBackendOpaque *backend, const char *email, const char *password);
|
||||||
void qobuz_backend_set_token(QobuzBackendOpaque *backend, const char *token);
|
void qobuz_backend_set_token(QobuzBackendOpaque *backend, const char *token);
|
||||||
|
void qobuz_backend_get_user(QobuzBackendOpaque *backend);
|
||||||
|
|
||||||
// Catalog
|
// Catalog
|
||||||
void qobuz_backend_search(QobuzBackendOpaque *backend, const char *query, uint32_t offset, uint32_t limit);
|
void qobuz_backend_search(QobuzBackendOpaque *backend, const char *query, uint32_t offset, uint32_t limit);
|
||||||
@@ -77,6 +81,17 @@ void qobuz_backend_set_replaygain(QobuzBackendOpaque *backend, bool enabled);
|
|||||||
void qobuz_backend_set_gapless(QobuzBackendOpaque *backend, bool enabled);
|
void qobuz_backend_set_gapless(QobuzBackendOpaque *backend, bool enabled);
|
||||||
void qobuz_backend_prefetch_track(QobuzBackendOpaque *backend, int64_t track_id, int32_t format_id);
|
void qobuz_backend_prefetch_track(QobuzBackendOpaque *backend, int64_t track_id, int32_t format_id);
|
||||||
|
|
||||||
|
// Visualizer PCM access
|
||||||
|
uint32_t qobuz_backend_viz_read(QobuzBackendOpaque *backend, float *buf, uint32_t max_samples);
|
||||||
|
uint32_t qobuz_backend_viz_sample_rate(const QobuzBackendOpaque *backend);
|
||||||
|
uint32_t qobuz_backend_viz_channels(const QobuzBackendOpaque *backend);
|
||||||
|
|
||||||
|
// Artist releases (auto-paginates to fetch all)
|
||||||
|
void qobuz_backend_get_artist_releases(QobuzBackendOpaque *backend, int64_t artist_id, const char *release_type, uint32_t limit, uint32_t offset);
|
||||||
|
|
||||||
|
// Deep shuffle: fetch tracks from multiple albums (album_ids_json is a JSON array of strings)
|
||||||
|
void qobuz_backend_get_albums_tracks(QobuzBackendOpaque *backend, const char *album_ids_json);
|
||||||
|
|
||||||
// Playlist management
|
// Playlist management
|
||||||
void qobuz_backend_create_playlist(QobuzBackendOpaque *backend, const char *name);
|
void qobuz_backend_create_playlist(QobuzBackendOpaque *backend, const char *name);
|
||||||
void qobuz_backend_delete_playlist(QobuzBackendOpaque *backend, int64_t playlist_id);
|
void qobuz_backend_delete_playlist(QobuzBackendOpaque *backend, int64_t playlist_id);
|
||||||
@@ -88,6 +103,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_remove_fav_track(QobuzBackendOpaque *backend, int64_t track_id);
|
||||||
void qobuz_backend_add_fav_album(QobuzBackendOpaque *backend, const char *album_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_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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ impl QobuzClient {
|
|||||||
.as_secs()
|
.as_secs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Compute the request signature required by the Qobuz API.
|
||||||
|
/// NOTE: MD5 is mandated by the Qobuz API protocol — not our choice.
|
||||||
fn request_sig(&self, method: &str, params: &mut Vec<(&str, String)>, ts: u64) -> String {
|
fn request_sig(&self, method: &str, params: &mut Vec<(&str, String)>, ts: u64) -> String {
|
||||||
params.sort_by_key(|(k, _)| *k);
|
params.sort_by_key(|(k, _)| *k);
|
||||||
let mut s = method.replace('/', "");
|
let mut s = method.replace('/', "");
|
||||||
@@ -116,6 +118,7 @@ impl QobuzClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// NOTE: Qobuz API requires credentials as GET query params — not our choice.
|
||||||
async fn oauth2_login(&mut self, email: &str, password: &str) -> Result<OAuthLoginResponse> {
|
async fn oauth2_login(&mut self, email: &str, password: &str) -> Result<OAuthLoginResponse> {
|
||||||
let ts = Self::ts();
|
let ts = Self::ts();
|
||||||
let mut sign_params: Vec<(&str, String)> = vec![
|
let mut sign_params: Vec<(&str, String)> = vec![
|
||||||
@@ -252,17 +255,35 @@ impl QobuzClient {
|
|||||||
|
|
||||||
// --- Artist ---
|
// --- Artist ---
|
||||||
|
|
||||||
pub async fn get_artist(&self, artist_id: i64) -> Result<ArtistDto> {
|
pub async fn get_artist_page(&self, artist_id: i64) -> Result<Value> {
|
||||||
let resp = self
|
let resp = self
|
||||||
.get_request("artist/get")
|
.get_request("artist/page")
|
||||||
|
.query(&[("artist_id", artist_id.to_string())])
|
||||||
|
.send()
|
||||||
|
.await?;
|
||||||
|
Self::check_response(resp).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_artist_releases_list(
|
||||||
|
&self,
|
||||||
|
artist_id: i64,
|
||||||
|
release_type: &str,
|
||||||
|
limit: u32,
|
||||||
|
offset: u32,
|
||||||
|
) -> Result<Value> {
|
||||||
|
let resp = self
|
||||||
|
.get_request("artist/getReleasesList")
|
||||||
.query(&[
|
.query(&[
|
||||||
("artist_id", artist_id.to_string()),
|
("artist_id", artist_id.to_string()),
|
||||||
("extra", "albums".to_string()),
|
("release_type", release_type.to_string()),
|
||||||
|
("sort", "release_date".to_string()),
|
||||||
|
("order", "desc".to_string()),
|
||||||
|
("limit", limit.to_string()),
|
||||||
|
("offset", offset.to_string()),
|
||||||
])
|
])
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
let body = Self::check_response(resp).await?;
|
Self::check_response(resp).await
|
||||||
Ok(serde_json::from_value(body)?)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Search ---
|
// --- Search ---
|
||||||
@@ -426,4 +447,24 @@ impl QobuzClient {
|
|||||||
Self::check_response(resp).await?;
|
Self::check_response(resp).await?;
|
||||||
Ok(())
|
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(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ pub struct SubscriptionDto {
|
|||||||
pub struct TrackDto {
|
pub struct TrackDto {
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
|
pub version: Option<String>,
|
||||||
pub duration: Option<i64>,
|
pub duration: Option<i64>,
|
||||||
pub track_number: Option<i32>,
|
pub track_number: Option<i32>,
|
||||||
pub playlist_track_id: Option<i64>,
|
pub playlist_track_id: Option<i64>,
|
||||||
@@ -98,6 +99,7 @@ pub struct AlbumDto {
|
|||||||
pub maximum_sampling_rate: Option<f64>,
|
pub maximum_sampling_rate: Option<f64>,
|
||||||
pub hires_streamable: Option<bool>,
|
pub hires_streamable: Option<bool>,
|
||||||
pub streamable: Option<bool>,
|
pub streamable: Option<bool>,
|
||||||
|
pub release_type: Option<String>,
|
||||||
pub tracks: Option<TracksWrapper>,
|
pub tracks: Option<TracksWrapper>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,6 +121,10 @@ pub struct ArtistDto {
|
|||||||
pub image: Option<ImageDto>,
|
pub image: Option<ImageDto>,
|
||||||
pub biography: Option<BiographyDto>,
|
pub biography: Option<BiographyDto>,
|
||||||
pub albums: Option<SearchResultItems<AlbumDto>>,
|
pub albums: Option<SearchResultItems<AlbumDto>>,
|
||||||
|
#[serde(rename = "epSingles")]
|
||||||
|
pub ep_singles: Option<SearchResultItems<AlbumDto>>,
|
||||||
|
#[serde(rename = "liveAlbums")]
|
||||||
|
pub live_albums: Option<SearchResultItems<AlbumDto>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, Serialize)]
|
#[derive(Debug, Deserialize, Clone, Serialize)]
|
||||||
@@ -238,30 +244,5 @@ impl Format {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn label(self) -> &'static str {
|
|
||||||
match self {
|
|
||||||
Format::Mp3 => "MP3 320",
|
|
||||||
Format::Cd => "CD 16-bit",
|
|
||||||
Format::HiRes96 => "Hi-Res 24-bit/96kHz",
|
|
||||||
Format::HiRes192 => "Hi-Res 24-bit/192kHz",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all() -> &'static [Format] {
|
|
||||||
&[Format::HiRes192, Format::HiRes96, Format::Cd, Format::Mp3]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- QWS ---
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, Serialize)]
|
|
||||||
pub struct QwsTokenResponse {
|
|
||||||
pub jwt_qws: Option<QwsToken>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, Serialize)]
|
|
||||||
pub struct QwsToken {
|
|
||||||
pub exp: Option<i64>,
|
|
||||||
pub jwt: Option<String>,
|
|
||||||
pub endpoint: Option<String>,
|
|
||||||
}
|
|
||||||
|
|||||||
202
rust/src/lib.rs
202
rust/src/lib.rs
@@ -68,6 +68,8 @@ pub const EV_POSITION: c_int = 16;
|
|||||||
pub const EV_TRACK_URL_OK: c_int = 17;
|
pub const EV_TRACK_URL_OK: c_int = 17;
|
||||||
pub const EV_TRACK_URL_ERR: c_int = 18;
|
pub const EV_TRACK_URL_ERR: c_int = 18;
|
||||||
pub const EV_GENERIC_ERR: c_int = 19;
|
pub const EV_GENERIC_ERR: c_int = 19;
|
||||||
|
pub const EV_ARTIST_RELEASES_OK: c_int = 24;
|
||||||
|
pub const EV_DEEP_SHUFFLE_OK: c_int = 25;
|
||||||
|
|
||||||
// ---------- Callback ----------
|
// ---------- Callback ----------
|
||||||
|
|
||||||
@@ -96,7 +98,9 @@ pub struct Backend(BackendInner);
|
|||||||
// ---------- Helpers ----------
|
// ---------- Helpers ----------
|
||||||
|
|
||||||
fn call_cb(cb: EventCallback, ud: SendPtr, ev: c_int, json: &str) {
|
fn call_cb(cb: EventCallback, ud: SendPtr, ev: c_int, json: &str) {
|
||||||
let cstr = CString::new(json).unwrap_or_else(|_| CString::new("{}").unwrap());
|
// Strip null bytes that would cause CString::new to fail
|
||||||
|
let safe = json.replace('\0', "");
|
||||||
|
let cstr = CString::new(safe).unwrap_or_else(|_| CString::new("{}").unwrap());
|
||||||
unsafe { cb(ud.0, ev, cstr.as_ptr()) };
|
unsafe { cb(ud.0, ev, cstr.as_ptr()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,8 +123,14 @@ pub unsafe extern "C" fn qobuz_backend_new(
|
|||||||
event_cb: EventCallback,
|
event_cb: EventCallback,
|
||||||
userdata: *mut c_void,
|
userdata: *mut c_void,
|
||||||
) -> *mut Backend {
|
) -> *mut Backend {
|
||||||
let rt = Runtime::new().expect("tokio runtime");
|
let rt = match Runtime::new() {
|
||||||
let client = Arc::new(Mutex::new(QobuzClient::new().expect("QobuzClient")));
|
Ok(r) => r,
|
||||||
|
Err(_) => return std::ptr::null_mut(),
|
||||||
|
};
|
||||||
|
let client = match QobuzClient::new() {
|
||||||
|
Ok(c) => Arc::new(Mutex::new(c)),
|
||||||
|
Err(_) => return std::ptr::null_mut(),
|
||||||
|
};
|
||||||
let player = Player::new();
|
let player = Player::new();
|
||||||
|
|
||||||
Box::into_raw(Box::new(Backend(BackendInner {
|
Box::into_raw(Box::new(Backend(BackendInner {
|
||||||
@@ -180,11 +190,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) {
|
pub unsafe extern "C" fn qobuz_backend_set_token(ptr: *mut Backend, token: *const c_char) {
|
||||||
let inner = &(*ptr).0;
|
let inner = &(*ptr).0;
|
||||||
let token = CStr::from_ptr(token).to_string_lossy().into_owned();
|
let token = CStr::from_ptr(token).to_string_lossy().into_owned();
|
||||||
let client = inner.client.clone();
|
// Use blocking_lock (called from Qt main thread, not a tokio thread) so the
|
||||||
// blocking_lock is available on tokio::sync::Mutex when not in an async context
|
// token is set before any subsequent getUser/library requests are spawned.
|
||||||
inner.rt.spawn(async move {
|
inner.client.blocking_lock().set_auth_token(token);
|
||||||
client.lock().await.set_auth_token(token);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- Search ----------
|
// ---------- Search ----------
|
||||||
@@ -239,7 +247,7 @@ pub unsafe extern "C" fn qobuz_backend_get_artist(ptr: *mut Backend, artist_id:
|
|||||||
let cb = inner.cb; let ud = inner.ud;
|
let cb = inner.cb; let ud = inner.ud;
|
||||||
|
|
||||||
spawn(inner, async move {
|
spawn(inner, async move {
|
||||||
let result = client.lock().await.get_artist(artist_id).await;
|
let result = client.lock().await.get_artist_page(artist_id).await;
|
||||||
let (ev, json) = match result {
|
let (ev, json) = match result {
|
||||||
Ok(r) => (EV_ARTIST_OK, serde_json::to_string(&r).unwrap_or_default()),
|
Ok(r) => (EV_ARTIST_OK, serde_json::to_string(&r).unwrap_or_default()),
|
||||||
Err(e) => (EV_ARTIST_ERR, err_json(&e.to_string())),
|
Err(e) => (EV_ARTIST_ERR, err_json(&e.to_string())),
|
||||||
@@ -248,6 +256,109 @@ pub unsafe extern "C" fn qobuz_backend_get_artist(ptr: *mut Backend, artist_id:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------- Artist releases ----------
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn qobuz_backend_get_artist_releases(
|
||||||
|
ptr: *mut Backend,
|
||||||
|
artist_id: i64,
|
||||||
|
release_type: *const c_char,
|
||||||
|
limit: u32,
|
||||||
|
_offset: u32,
|
||||||
|
) {
|
||||||
|
let inner = &(*ptr).0;
|
||||||
|
let client = inner.client.clone();
|
||||||
|
let cb = inner.cb; let ud = inner.ud;
|
||||||
|
let rtype = CStr::from_ptr(release_type).to_string_lossy().into_owned();
|
||||||
|
|
||||||
|
spawn(inner, async move {
|
||||||
|
// Auto-paginate: fetch all pages until has_more is false.
|
||||||
|
let mut all_items: Vec<serde_json::Value> = Vec::new();
|
||||||
|
let mut offset: u32 = 0;
|
||||||
|
loop {
|
||||||
|
let result = client.lock().await
|
||||||
|
.get_artist_releases_list(artist_id, &rtype, limit, offset)
|
||||||
|
.await;
|
||||||
|
match result {
|
||||||
|
Ok(r) => {
|
||||||
|
let obj = r.as_object().cloned().unwrap_or_default();
|
||||||
|
if let Some(items) = obj.get("items").and_then(|v| v.as_array()) {
|
||||||
|
all_items.extend(items.iter().cloned());
|
||||||
|
}
|
||||||
|
let has_more = obj.get("has_more").and_then(|v| v.as_bool()).unwrap_or(false);
|
||||||
|
if !has_more {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
offset += limit;
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
call_cb(cb, ud, EV_GENERIC_ERR, &err_json(&e.to_string()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let result = serde_json::json!({
|
||||||
|
"release_type": rtype,
|
||||||
|
"items": all_items,
|
||||||
|
"has_more": false,
|
||||||
|
"offset": 0
|
||||||
|
});
|
||||||
|
call_cb(cb, ud, EV_ARTIST_RELEASES_OK, &serde_json::to_string(&result).unwrap_or_default());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Deep shuffle (fetch tracks from multiple albums) ----------
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn qobuz_backend_get_albums_tracks(
|
||||||
|
ptr: *mut Backend,
|
||||||
|
album_ids_json: *const c_char,
|
||||||
|
) {
|
||||||
|
let inner = &(*ptr).0;
|
||||||
|
let client = inner.client.clone();
|
||||||
|
let cb = inner.cb; let ud = inner.ud;
|
||||||
|
let ids_str = CStr::from_ptr(album_ids_json).to_string_lossy().into_owned();
|
||||||
|
|
||||||
|
let album_ids: Vec<String> = match serde_json::from_str(&ids_str) {
|
||||||
|
Ok(v) => v,
|
||||||
|
Err(e) => {
|
||||||
|
call_cb(cb, ud, EV_GENERIC_ERR, &err_json(&e.to_string()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
spawn(inner, async move {
|
||||||
|
let mut all_tracks: Vec<serde_json::Value> = Vec::new();
|
||||||
|
for id in &album_ids {
|
||||||
|
let result = client.lock().await.get_album(id).await;
|
||||||
|
if let Ok(album) = result {
|
||||||
|
if let Some(tracks) = album.tracks.as_ref().and_then(|t| t.items.as_ref()) {
|
||||||
|
for t in tracks {
|
||||||
|
// Serialize track and inject album info for playback context
|
||||||
|
if let Ok(mut tv) = serde_json::to_value(t) {
|
||||||
|
if let Some(obj) = tv.as_object_mut() {
|
||||||
|
// Ensure album context is present on each track
|
||||||
|
if obj.get("album").is_none() || obj["album"].is_null() {
|
||||||
|
obj.insert("album".to_string(), serde_json::json!({
|
||||||
|
"id": album.id,
|
||||||
|
"title": album.title,
|
||||||
|
"artist": album.artist,
|
||||||
|
"image": album.image,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
all_tracks.push(tv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Skip albums that fail — don't abort the whole operation
|
||||||
|
}
|
||||||
|
let result = serde_json::json!({ "tracks": all_tracks });
|
||||||
|
call_cb(cb, ud, EV_DEEP_SHUFFLE_OK, &serde_json::to_string(&result).unwrap_or_default());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- Playlist ----------
|
// ---------- Playlist ----------
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@@ -402,7 +513,7 @@ pub unsafe extern "C" fn qobuz_backend_play_track(
|
|||||||
if let Some(dur) = track.duration {
|
if let Some(dur) = track.duration {
|
||||||
status.duration_secs.store(dur as u64, std::sync::atomic::Ordering::Relaxed);
|
status.duration_secs.store(dur as u64, std::sync::atomic::Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
let _ = cmd_tx.send(player::PlayerCommand::Play(player::TrackInfo { track, url, format, replaygain_db }));
|
let _ = cmd_tx.send(player::PlayerCommand::Play(player::TrackInfo { track, url, replaygain_db }));
|
||||||
|
|
||||||
// 5. State notification
|
// 5. State notification
|
||||||
call_cb(cb, ud, EV_STATE_CHANGED, r#"{"state":"playing"}"#);
|
call_cb(cb, ud, EV_STATE_CHANGED, r#"{"state":"playing"}"#);
|
||||||
@@ -563,6 +674,77 @@ 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;
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn qobuz_backend_get_user(ptr: *mut Backend) {
|
||||||
|
let inner = &(*ptr).0;
|
||||||
|
let client = inner.client.clone();
|
||||||
|
let cb = inner.cb; let ud = inner.ud;
|
||||||
|
spawn(inner, async move {
|
||||||
|
let result = client.lock().await.get_user().await;
|
||||||
|
let (ev, json) = match result {
|
||||||
|
Ok(r) => (EV_USER_OK, serde_json::to_string(&r).unwrap_or_default()),
|
||||||
|
Err(e) => (EV_GENERIC_ERR, err_json(&e.to_string())),
|
||||||
|
};
|
||||||
|
call_cb(cb, ud, ev, &json);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Visualizer PCM access ----------
|
||||||
|
|
||||||
|
/// Read up to `max_samples` f32 PCM values into `buf`.
|
||||||
|
/// Returns the number of samples actually read.
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn qobuz_backend_viz_read(
|
||||||
|
ptr: *mut Backend,
|
||||||
|
buf: *mut f32,
|
||||||
|
max_samples: u32,
|
||||||
|
) -> u32 {
|
||||||
|
let consumer = &(*ptr).0.player.status.viz_consumer;
|
||||||
|
let Ok(mut lock) = consumer.try_lock() else { return 0 };
|
||||||
|
let slice = std::slice::from_raw_parts_mut(buf, max_samples as usize);
|
||||||
|
rb::RbConsumer::read(&mut *lock, slice).unwrap_or(0) as u32
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns current sample rate of the audio stream (0 if idle).
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn qobuz_backend_viz_sample_rate(ptr: *const Backend) -> u32 {
|
||||||
|
(*ptr).0.player.status.viz_sample_rate.load(std::sync::atomic::Ordering::Relaxed)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns current channel count (0 if idle).
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn qobuz_backend_viz_channels(ptr: *const Backend) -> u32 {
|
||||||
|
(*ptr).0.player.status.viz_channels.load(std::sync::atomic::Ordering::Relaxed)
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- Playlist management ----------
|
// ---------- Playlist management ----------
|
||||||
|
|
||||||
pub const EV_PLAYLIST_CREATED: c_int = 20;
|
pub const EV_PLAYLIST_CREATED: c_int = 20;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use rb::RB;
|
||||||
use std::io::{self, Read, Seek, SeekFrom};
|
use std::io::{self, Read, Seek, SeekFrom};
|
||||||
use std::sync::{
|
use std::sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
@@ -176,8 +177,12 @@ pub fn play_track_inline(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if audio_output.is_none() {
|
if audio_output.is_none() {
|
||||||
*audio_output = Some(AudioOutput::try_open(sample_rate, channels)?);
|
let mut ao = AudioOutput::try_open(sample_rate, channels)?;
|
||||||
|
ao.set_viz_producer(status.viz_ring.producer());
|
||||||
|
*audio_output = Some(ao);
|
||||||
}
|
}
|
||||||
|
status.viz_sample_rate.store(sample_rate, Ordering::Relaxed);
|
||||||
|
status.viz_channels.store(channels as u32, Ordering::Relaxed);
|
||||||
let ao = audio_output.as_mut().unwrap();
|
let ao = audio_output.as_mut().unwrap();
|
||||||
|
|
||||||
let mut stopped = false;
|
let mut stopped = false;
|
||||||
@@ -195,11 +200,6 @@ pub fn play_track_inline(
|
|||||||
paused.store(false, Ordering::SeqCst);
|
paused.store(false, Ordering::SeqCst);
|
||||||
*status.state.lock().unwrap() = super::PlayerState::Playing;
|
*status.state.lock().unwrap() = super::PlayerState::Playing;
|
||||||
}
|
}
|
||||||
Ok(PlayerCommand::Seek(s)) => {
|
|
||||||
status.seek_target_secs.store(s, Ordering::Relaxed);
|
|
||||||
status.seek_requested.load(Ordering::SeqCst); // read-side fence
|
|
||||||
status.seek_requested.store(true, Ordering::SeqCst);
|
|
||||||
}
|
|
||||||
Ok(PlayerCommand::SetVolume(v)) => {
|
Ok(PlayerCommand::SetVolume(v)) => {
|
||||||
status.volume.store(v, Ordering::Relaxed);
|
status.volume.store(v, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
mod decoder;
|
mod decoder;
|
||||||
pub mod output;
|
pub mod output;
|
||||||
|
|
||||||
|
use rb::{SpscRb, RB};
|
||||||
use std::sync::{
|
use std::sync::{
|
||||||
atomic::{AtomicBool, AtomicU64, AtomicU8, Ordering},
|
atomic::{AtomicBool, AtomicU32, AtomicU64, AtomicU8, Ordering},
|
||||||
Arc,
|
Arc,
|
||||||
};
|
};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use crate::api::{Format, TrackDto};
|
use crate::api::TrackDto;
|
||||||
|
|
||||||
|
/// Size of the visualizer ring buffer in f32 samples (~180ms at 44.1kHz stereo).
|
||||||
|
const VIZ_RING_SIZE: usize = 16 * 1024;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum PlayerCommand {
|
pub enum PlayerCommand {
|
||||||
@@ -15,7 +19,6 @@ pub enum PlayerCommand {
|
|||||||
Pause,
|
Pause,
|
||||||
Resume,
|
Resume,
|
||||||
Stop,
|
Stop,
|
||||||
Seek(u64),
|
|
||||||
SetVolume(u8),
|
SetVolume(u8),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +26,6 @@ pub enum PlayerCommand {
|
|||||||
pub struct TrackInfo {
|
pub struct TrackInfo {
|
||||||
pub track: TrackDto,
|
pub track: TrackDto,
|
||||||
pub url: String,
|
pub url: String,
|
||||||
pub format: Format,
|
|
||||||
/// ReplayGain track gain in dB, if enabled and available.
|
/// ReplayGain track gain in dB, if enabled and available.
|
||||||
pub replaygain_db: Option<f64>,
|
pub replaygain_db: Option<f64>,
|
||||||
}
|
}
|
||||||
@@ -33,7 +35,6 @@ pub enum PlayerState {
|
|||||||
Idle,
|
Idle,
|
||||||
Playing,
|
Playing,
|
||||||
Paused,
|
Paused,
|
||||||
Stopped,
|
|
||||||
Error(String),
|
Error(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,10 +54,17 @@ pub struct PlayerStatus {
|
|||||||
pub replaygain_gain: Arc<std::sync::Mutex<f32>>,
|
pub replaygain_gain: Arc<std::sync::Mutex<f32>>,
|
||||||
/// When false the audio output is torn down after each track, producing a gap.
|
/// When false the audio output is torn down after each track, producing a gap.
|
||||||
pub gapless: Arc<AtomicBool>,
|
pub gapless: Arc<AtomicBool>,
|
||||||
|
/// Visualizer ring buffer (consumer side, read by FFI).
|
||||||
|
pub viz_ring: Arc<SpscRb<f32>>,
|
||||||
|
pub viz_consumer: Arc<std::sync::Mutex<rb::Consumer<f32>>>,
|
||||||
|
pub viz_sample_rate: Arc<AtomicU32>,
|
||||||
|
pub viz_channels: Arc<AtomicU32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PlayerStatus {
|
impl PlayerStatus {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
let viz_ring = Arc::new(SpscRb::new(VIZ_RING_SIZE));
|
||||||
|
let viz_consumer = Arc::new(std::sync::Mutex::new(viz_ring.consumer()));
|
||||||
Self {
|
Self {
|
||||||
state: Arc::new(std::sync::Mutex::new(PlayerState::Idle)),
|
state: Arc::new(std::sync::Mutex::new(PlayerState::Idle)),
|
||||||
position_secs: Arc::new(AtomicU64::new(0)),
|
position_secs: Arc::new(AtomicU64::new(0)),
|
||||||
@@ -68,6 +76,10 @@ impl PlayerStatus {
|
|||||||
seek_target_secs: Arc::new(AtomicU64::new(0)),
|
seek_target_secs: Arc::new(AtomicU64::new(0)),
|
||||||
replaygain_gain: Arc::new(std::sync::Mutex::new(1.0)),
|
replaygain_gain: Arc::new(std::sync::Mutex::new(1.0)),
|
||||||
gapless: Arc::new(AtomicBool::new(false)),
|
gapless: Arc::new(AtomicBool::new(false)),
|
||||||
|
viz_ring,
|
||||||
|
viz_consumer,
|
||||||
|
viz_sample_rate: Arc::new(AtomicU32::new(0)),
|
||||||
|
viz_channels: Arc::new(AtomicU32::new(0)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,9 +99,6 @@ impl PlayerStatus {
|
|||||||
self.volume.load(Ordering::Relaxed)
|
self.volume.load(Ordering::Relaxed)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_current_track(&self) -> Option<TrackDto> {
|
|
||||||
self.current_track.lock().unwrap().clone()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
@@ -169,10 +178,6 @@ fn player_loop(rx: std::sync::mpsc::Receiver<PlayerCommand>, status: PlayerStatu
|
|||||||
Ok(PlayerCommand::SetVolume(v)) => {
|
Ok(PlayerCommand::SetVolume(v)) => {
|
||||||
status.volume.store(v, Ordering::Relaxed);
|
status.volume.store(v, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
Ok(PlayerCommand::Seek(s)) => {
|
|
||||||
status.seek_target_secs.store(s, Ordering::Relaxed);
|
|
||||||
status.seek_requested.store(true, Ordering::SeqCst);
|
|
||||||
}
|
|
||||||
Ok(_) => {} // Pause/Resume ignored when idle
|
Ok(_) => {} // Pause/Resume ignored when idle
|
||||||
Err(RecvTimeoutError::Timeout) => {}
|
Err(RecvTimeoutError::Timeout) => {}
|
||||||
Err(RecvTimeoutError::Disconnected) => break 'outer,
|
Err(RecvTimeoutError::Disconnected) => break 'outer,
|
||||||
@@ -210,6 +215,9 @@ fn player_loop(rx: std::sync::mpsc::Receiver<PlayerCommand>, status: PlayerStatu
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("playback error: {e}");
|
eprintln!("playback error: {e}");
|
||||||
*status.state.lock().unwrap() = PlayerState::Error(e.to_string());
|
*status.state.lock().unwrap() = PlayerState::Error(e.to_string());
|
||||||
|
// Signal track end so the queue advances to the next track
|
||||||
|
// instead of stalling on an unplayable track.
|
||||||
|
status.track_finished.store(true, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const RING_BUFFER_SIZE: usize = 32 * 1024;
|
|||||||
|
|
||||||
pub struct AudioOutput {
|
pub struct AudioOutput {
|
||||||
ring_buf_producer: rb::Producer<f32>,
|
ring_buf_producer: rb::Producer<f32>,
|
||||||
|
viz_producer: Option<rb::Producer<f32>>,
|
||||||
_stream: cpal::Stream,
|
_stream: cpal::Stream,
|
||||||
pub sample_rate: u32,
|
pub sample_rate: u32,
|
||||||
pub channels: usize,
|
pub channels: usize,
|
||||||
@@ -51,12 +52,17 @@ impl AudioOutput {
|
|||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
ring_buf_producer: producer,
|
ring_buf_producer: producer,
|
||||||
|
viz_producer: None,
|
||||||
_stream: stream,
|
_stream: stream,
|
||||||
sample_rate,
|
sample_rate,
|
||||||
channels,
|
channels,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_viz_producer(&mut self, producer: rb::Producer<f32>) {
|
||||||
|
self.viz_producer = Some(producer);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn write(
|
pub fn write(
|
||||||
&mut self,
|
&mut self,
|
||||||
decoded: AudioBufferRef<'_>,
|
decoded: AudioBufferRef<'_>,
|
||||||
@@ -70,6 +76,11 @@ impl AudioOutput {
|
|||||||
sample_buf.copy_interleaved_ref(decoded);
|
sample_buf.copy_interleaved_ref(decoded);
|
||||||
let samples: Vec<f32> = sample_buf.samples().iter().map(|s| s * volume).collect();
|
let samples: Vec<f32> = sample_buf.samples().iter().map(|s| s * volume).collect();
|
||||||
|
|
||||||
|
// Best-effort copy for visualizer (non-blocking, ok to drop samples)
|
||||||
|
if let Some(ref mut viz) = self.viz_producer {
|
||||||
|
let _ = viz.write(&samples);
|
||||||
|
}
|
||||||
|
|
||||||
let mut remaining = &samples[..];
|
let mut remaining = &samples[..];
|
||||||
while !remaining.is_empty() {
|
while !remaining.is_empty() {
|
||||||
if stop.load(Ordering::SeqCst) {
|
if stop.load(Ordering::SeqCst) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ target_sources(qobuz-qt PRIVATE
|
|||||||
view/albumlistview.hpp
|
view/albumlistview.hpp
|
||||||
view/artistlistview.hpp
|
view/artistlistview.hpp
|
||||||
view/artistview.hpp
|
view/artistview.hpp
|
||||||
|
view/artistview.cpp
|
||||||
view/sidepanel/view.hpp
|
view/sidepanel/view.hpp
|
||||||
view/sidepanel/view.cpp
|
view/sidepanel/view.cpp
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ QobuzBackend::QobuzBackend(QObject *parent)
|
|||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
m_backend = qobuz_backend_new(&QobuzBackend::eventTrampoline, this);
|
m_backend = qobuz_backend_new(&QobuzBackend::eventTrampoline, this);
|
||||||
|
if (!m_backend) {
|
||||||
|
qCritical("Failed to initialize Qobuz backend");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_positionTimer = new QTimer(this);
|
m_positionTimer = new QTimer(this);
|
||||||
m_positionTimer->setInterval(50);
|
m_positionTimer->setInterval(50);
|
||||||
@@ -35,6 +39,11 @@ void QobuzBackend::setToken(const QString &token)
|
|||||||
qobuz_backend_set_token(m_backend, token.toUtf8().constData());
|
qobuz_backend_set_token(m_backend, token.toUtf8().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QobuzBackend::getUser()
|
||||||
|
{
|
||||||
|
qobuz_backend_get_user(m_backend);
|
||||||
|
}
|
||||||
|
|
||||||
// ---- catalog ----
|
// ---- catalog ----
|
||||||
|
|
||||||
void QobuzBackend::search(const QString &query, quint32 offset, quint32 limit)
|
void QobuzBackend::search(const QString &query, quint32 offset, quint32 limit)
|
||||||
@@ -52,6 +61,19 @@ void QobuzBackend::getArtist(qint64 artistId)
|
|||||||
qobuz_backend_get_artist(m_backend, artistId);
|
qobuz_backend_get_artist(m_backend, artistId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QobuzBackend::getArtistReleases(qint64 artistId, const QString &releaseType, quint32 limit, quint32 offset)
|
||||||
|
{
|
||||||
|
qobuz_backend_get_artist_releases(m_backend, artistId,
|
||||||
|
releaseType.toUtf8().constData(), limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QobuzBackend::getAlbumsTracks(const QStringList &albumIds)
|
||||||
|
{
|
||||||
|
const QJsonArray arr = QJsonArray::fromStringList(albumIds);
|
||||||
|
const QByteArray json = QJsonDocument(arr).toJson(QJsonDocument::Compact);
|
||||||
|
qobuz_backend_get_albums_tracks(m_backend, json.constData());
|
||||||
|
}
|
||||||
|
|
||||||
void QobuzBackend::getPlaylist(qint64 playlistId, quint32 offset, quint32 limit)
|
void QobuzBackend::getPlaylist(qint64 playlistId, quint32 offset, quint32 limit)
|
||||||
{
|
{
|
||||||
qobuz_backend_get_playlist(m_backend, playlistId, offset, limit);
|
qobuz_backend_get_playlist(m_backend, playlistId, offset, limit);
|
||||||
@@ -140,6 +162,16 @@ void QobuzBackend::removeFavAlbum(const QString &albumId)
|
|||||||
qobuz_backend_remove_fav_album(m_backend, albumId.toUtf8().constData());
|
qobuz_backend_remove_fav_album(m_backend, albumId.toUtf8().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QobuzBackend::addFavArtist(qint64 artistId)
|
||||||
|
{
|
||||||
|
qobuz_backend_add_fav_artist(m_backend, artistId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QobuzBackend::removeFavArtist(qint64 artistId)
|
||||||
|
{
|
||||||
|
qobuz_backend_remove_fav_artist(m_backend, artistId);
|
||||||
|
}
|
||||||
|
|
||||||
// ---- playback ----
|
// ---- playback ----
|
||||||
|
|
||||||
void QobuzBackend::playTrack(qint64 trackId, int formatId)
|
void QobuzBackend::playTrack(qint64 trackId, int formatId)
|
||||||
@@ -177,6 +209,21 @@ quint64 QobuzBackend::duration() const { return qobuz_backend_get_duration(m_bac
|
|||||||
int QobuzBackend::volume() const { return qobuz_backend_get_volume(m_backend); }
|
int QobuzBackend::volume() const { return qobuz_backend_get_volume(m_backend); }
|
||||||
int QobuzBackend::state() const { return qobuz_backend_get_state(m_backend); }
|
int QobuzBackend::state() const { return qobuz_backend_get_state(m_backend); }
|
||||||
|
|
||||||
|
quint32 QobuzBackend::vizRead(float *buf, quint32 maxSamples)
|
||||||
|
{
|
||||||
|
return qobuz_backend_viz_read(m_backend, buf, maxSamples);
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 QobuzBackend::vizSampleRate() const
|
||||||
|
{
|
||||||
|
return qobuz_backend_viz_sample_rate(m_backend);
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 QobuzBackend::vizChannels() const
|
||||||
|
{
|
||||||
|
return qobuz_backend_viz_channels(m_backend);
|
||||||
|
}
|
||||||
|
|
||||||
// ---- private slots ----
|
// ---- private slots ----
|
||||||
|
|
||||||
void QobuzBackend::onPositionTick()
|
void QobuzBackend::onPositionTick()
|
||||||
@@ -189,7 +236,12 @@ void QobuzBackend::onPositionTick()
|
|||||||
|
|
||||||
void QobuzBackend::onEvent(int eventType, const QString &json)
|
void QobuzBackend::onEvent(int eventType, const QString &json)
|
||||||
{
|
{
|
||||||
const QJsonObject obj = QJsonDocument::fromJson(json.toUtf8()).object();
|
const QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
||||||
|
if (!doc.isObject()) {
|
||||||
|
emit error(tr("Malformed response from backend"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const QJsonObject obj = doc.object();
|
||||||
|
|
||||||
switch (eventType) {
|
switch (eventType) {
|
||||||
case EV_LOGIN_OK:
|
case EV_LOGIN_OK:
|
||||||
@@ -213,6 +265,17 @@ void QobuzBackend::onEvent(int eventType, const QString &json)
|
|||||||
case EV_ARTIST_OK:
|
case EV_ARTIST_OK:
|
||||||
emit artistLoaded(obj);
|
emit artistLoaded(obj);
|
||||||
break;
|
break;
|
||||||
|
case 24: // EV_ARTIST_RELEASES_OK
|
||||||
|
emit artistReleasesLoaded(
|
||||||
|
obj["release_type"].toString(),
|
||||||
|
obj["items"].toArray(),
|
||||||
|
obj["has_more"].toBool(),
|
||||||
|
obj["offset"].toInt()
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 25: // EV_DEEP_SHUFFLE_OK
|
||||||
|
emit deepShuffleTracksLoaded(obj["tracks"].toArray());
|
||||||
|
break;
|
||||||
case EV_ARTIST_ERR:
|
case EV_ARTIST_ERR:
|
||||||
emit error(obj["error"].toString());
|
emit error(obj["error"].toString());
|
||||||
break;
|
break;
|
||||||
@@ -249,6 +312,9 @@ void QobuzBackend::onEvent(int eventType, const QString &json)
|
|||||||
case 22: // EV_PLAYLIST_TRACK_ADDED
|
case 22: // EV_PLAYLIST_TRACK_ADDED
|
||||||
emit playlistTrackAdded(static_cast<qint64>(obj["playlist_id"].toDouble()));
|
emit playlistTrackAdded(static_cast<qint64>(obj["playlist_id"].toDouble()));
|
||||||
break;
|
break;
|
||||||
|
case EV_USER_OK:
|
||||||
|
emit userLoaded(obj);
|
||||||
|
break;
|
||||||
case EV_GENERIC_ERR:
|
case EV_GENERIC_ERR:
|
||||||
case EV_TRACK_URL_ERR:
|
case EV_TRACK_URL_ERR:
|
||||||
emit error(obj["error"].toString());
|
emit error(obj["error"].toString());
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QJsonArray>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@@ -23,11 +24,14 @@ public:
|
|||||||
// --- auth ---
|
// --- auth ---
|
||||||
void login(const QString &email, const QString &password);
|
void login(const QString &email, const QString &password);
|
||||||
void setToken(const QString &token);
|
void setToken(const QString &token);
|
||||||
|
void getUser();
|
||||||
|
|
||||||
// --- catalog ---
|
// --- catalog ---
|
||||||
void search(const QString &query, quint32 offset = 0, quint32 limit = 20);
|
void search(const QString &query, quint32 offset = 0, quint32 limit = 20);
|
||||||
void getAlbum(const QString &albumId);
|
void getAlbum(const QString &albumId);
|
||||||
void getArtist(qint64 artistId);
|
void getArtist(qint64 artistId);
|
||||||
|
void getArtistReleases(qint64 artistId, const QString &releaseType, quint32 limit = 50, quint32 offset = 0);
|
||||||
|
void getAlbumsTracks(const QStringList &albumIds);
|
||||||
void getPlaylist(qint64 playlistId, quint32 offset = 0, quint32 limit = 500);
|
void getPlaylist(qint64 playlistId, quint32 offset = 0, quint32 limit = 500);
|
||||||
|
|
||||||
// --- favorites ---
|
// --- favorites ---
|
||||||
@@ -52,6 +56,8 @@ public:
|
|||||||
void removeFavTrack(qint64 trackId);
|
void removeFavTrack(qint64 trackId);
|
||||||
void addFavAlbum(const QString &albumId);
|
void addFavAlbum(const QString &albumId);
|
||||||
void removeFavAlbum(const QString &albumId);
|
void removeFavAlbum(const QString &albumId);
|
||||||
|
void addFavArtist(qint64 artistId);
|
||||||
|
void removeFavArtist(qint64 artistId);
|
||||||
|
|
||||||
// --- playback ---
|
// --- playback ---
|
||||||
void playTrack(qint64 trackId, int formatId = 6);
|
void playTrack(qint64 trackId, int formatId = 6);
|
||||||
@@ -67,15 +73,23 @@ public:
|
|||||||
/// 1 = playing, 2 = paused, 0 = idle
|
/// 1 = playing, 2 = paused, 0 = idle
|
||||||
int state() const;
|
int state() const;
|
||||||
|
|
||||||
|
// --- visualizer PCM ---
|
||||||
|
quint32 vizRead(float *buf, quint32 maxSamples);
|
||||||
|
quint32 vizSampleRate() const;
|
||||||
|
quint32 vizChannels() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// auth
|
// auth
|
||||||
void loginSuccess(const QString &token, const QJsonObject &user);
|
void loginSuccess(const QString &token, const QJsonObject &user);
|
||||||
void loginError(const QString &error);
|
void loginError(const QString &error);
|
||||||
|
void userLoaded(const QJsonObject &user);
|
||||||
|
|
||||||
// catalog
|
// catalog
|
||||||
void searchResult(const QJsonObject &result);
|
void searchResult(const QJsonObject &result);
|
||||||
void albumLoaded(const QJsonObject &album);
|
void albumLoaded(const QJsonObject &album);
|
||||||
void artistLoaded(const QJsonObject &artist);
|
void artistLoaded(const QJsonObject &artist);
|
||||||
|
void artistReleasesLoaded(const QString &releaseType, const QJsonArray &items, bool hasMore, int offset);
|
||||||
|
void deepShuffleTracksLoaded(const QJsonArray &tracks);
|
||||||
void playlistLoaded(const QJsonObject &playlist);
|
void playlistLoaded(const QJsonObject &playlist);
|
||||||
void playlistCreated(const QJsonObject &playlist);
|
void playlistCreated(const QJsonObject &playlist);
|
||||||
void playlistDeleted(const QJsonObject &result);
|
void playlistDeleted(const QJsonObject &result);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "tracks.hpp"
|
#include "tracks.hpp"
|
||||||
#include "../util/settings.hpp"
|
#include "../util/settings.hpp"
|
||||||
|
#include "../util/trackinfo.hpp"
|
||||||
|
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
@@ -35,24 +36,32 @@ Tracks::Tracks(QobuzBackend *backend, PlayQueue *queue, QWidget *parent)
|
|||||||
this, &Tracks::onDoubleClicked);
|
this, &Tracks::onDoubleClicked);
|
||||||
connect(this, &QTreeView::customContextMenuRequested,
|
connect(this, &QTreeView::customContextMenuRequested,
|
||||||
this, &Tracks::onContextMenu);
|
this, &Tracks::onContextMenu);
|
||||||
|
connect(m_model, &QAbstractItemModel::modelReset, this, [this] {
|
||||||
|
for (int row : m_model->discHeaderRows())
|
||||||
|
setFirstColumnSpanned(row, {}, true);
|
||||||
|
setSortingEnabled(!m_model->hasMultipleDiscs());
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tracks::loadTracks(const QJsonArray &tracks)
|
void Tracks::loadTracks(const QJsonArray &tracks)
|
||||||
{
|
{
|
||||||
setPlaylistContext(0);
|
setPlaylistContext(0);
|
||||||
|
setColumnHidden(TrackListModel::ColAlbum, false);
|
||||||
m_model->setTracks(tracks, false, /*useSequential=*/true);
|
m_model->setTracks(tracks, false, /*useSequential=*/true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tracks::loadAlbum(const QJsonObject &album)
|
void Tracks::loadAlbum(const QJsonObject &album)
|
||||||
{
|
{
|
||||||
setPlaylistContext(0);
|
setPlaylistContext(0);
|
||||||
|
setColumnHidden(TrackListModel::ColAlbum, true);
|
||||||
const QJsonArray items = album["tracks"].toObject()["items"].toArray();
|
const QJsonArray items = album["tracks"].toObject()["items"].toArray();
|
||||||
m_model->setTracks(items); // album: use track_number
|
m_model->setTracks(items); // album: use track_number
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tracks::loadPlaylist(const QJsonObject &playlist)
|
void Tracks::loadPlaylist(const QJsonObject &playlist)
|
||||||
{
|
{
|
||||||
|
setColumnHidden(TrackListModel::ColAlbum, false);
|
||||||
const qint64 id = static_cast<qint64>(playlist["id"].toDouble());
|
const qint64 id = static_cast<qint64>(playlist["id"].toDouble());
|
||||||
const qint64 ownId = static_cast<qint64>(playlist["owner"].toObject()["id"].toDouble());
|
const qint64 ownId = static_cast<qint64>(playlist["owner"].toObject()["id"].toDouble());
|
||||||
const qint64 myId = AppSettings::instance().userId();
|
const qint64 myId = AppSettings::instance().userId();
|
||||||
@@ -65,6 +74,7 @@ void Tracks::loadPlaylist(const QJsonObject &playlist)
|
|||||||
void Tracks::loadSearchTracks(const QJsonArray &tracks)
|
void Tracks::loadSearchTracks(const QJsonArray &tracks)
|
||||||
{
|
{
|
||||||
setPlaylistContext(0);
|
setPlaylistContext(0);
|
||||||
|
setColumnHidden(TrackListModel::ColAlbum, false);
|
||||||
m_model->setTracks(tracks, false, /*useSequential=*/true);
|
m_model->setTracks(tracks, false, /*useSequential=*/true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,12 +94,30 @@ void Tracks::setPlayingTrackId(qint64 id)
|
|||||||
m_model->setPlayingId(id);
|
m_model->setPlayingId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Tracks::setFavTrackIds(const QSet<qint64> &ids)
|
||||||
|
{
|
||||||
|
m_model->setFavIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tracks::addFavTrackId(qint64 id)
|
||||||
|
{
|
||||||
|
m_model->addFavId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tracks::removeFavTrackId(qint64 id)
|
||||||
|
{
|
||||||
|
m_model->removeFavId(id);
|
||||||
|
}
|
||||||
|
|
||||||
void Tracks::playAll(bool shuffle)
|
void Tracks::playAll(bool shuffle)
|
||||||
{
|
{
|
||||||
const QJsonArray tracks = m_model->currentTracksJson();
|
const QJsonArray tracks = m_model->currentTracksJson();
|
||||||
if (tracks.isEmpty()) return;
|
if (tracks.isEmpty()) return;
|
||||||
m_queue->setShuffle(shuffle);
|
|
||||||
m_queue->setContext(tracks, 0);
|
m_queue->setContext(tracks, 0);
|
||||||
|
// Shuffle once without touching the global shuffle flag — so a subsequent
|
||||||
|
// double-click on a track plays in normal order (unless global shuffle is on).
|
||||||
|
if (shuffle && !m_queue->shuffleEnabled())
|
||||||
|
m_queue->shuffleNow();
|
||||||
const qint64 firstId = static_cast<qint64>(m_queue->current()["id"].toDouble());
|
const qint64 firstId = static_cast<qint64>(m_queue->current()["id"].toDouble());
|
||||||
if (firstId > 0)
|
if (firstId > 0)
|
||||||
emit playTrackRequested(firstId);
|
emit playTrackRequested(firstId);
|
||||||
@@ -100,7 +128,11 @@ void Tracks::onDoubleClicked(const QModelIndex &index)
|
|||||||
{
|
{
|
||||||
const qint64 id = m_model->data(index, TrackListModel::TrackIdRole).toLongLong();
|
const qint64 id = m_model->data(index, TrackListModel::TrackIdRole).toLongLong();
|
||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
m_queue->setContext(m_model->currentTracksJson(), index.row());
|
// Compute filtered row (disc headers excluded from currentTracksJson)
|
||||||
|
int filteredRow = 0;
|
||||||
|
for (int r = 0; r < index.row(); ++r)
|
||||||
|
if (!m_model->trackAt(r).isDiscHeader) ++filteredRow;
|
||||||
|
m_queue->setContext(m_model->currentTracksJson(), filteredRow);
|
||||||
emit playTrackRequested(id);
|
emit playTrackRequested(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,6 +143,7 @@ void Tracks::onContextMenu(const QPoint &pos)
|
|||||||
if (!index.isValid()) return;
|
if (!index.isValid()) return;
|
||||||
|
|
||||||
const qint64 id = m_model->data(index, TrackListModel::TrackIdRole).toLongLong();
|
const qint64 id = m_model->data(index, TrackListModel::TrackIdRole).toLongLong();
|
||||||
|
if (id <= 0) return; // disc header row
|
||||||
const QJsonObject trackJson = m_model->data(index, TrackListModel::TrackJsonRole).toJsonObject();
|
const QJsonObject trackJson = m_model->data(index, TrackListModel::TrackJsonRole).toJsonObject();
|
||||||
|
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
@@ -119,12 +152,28 @@ void Tracks::onContextMenu(const QPoint &pos)
|
|||||||
auto *playNext = menu.addAction(QIcon(":/res/icons/media-skip-forward.svg"), tr("Play next"));
|
auto *playNext = menu.addAction(QIcon(":/res/icons/media-skip-forward.svg"), tr("Play next"));
|
||||||
auto *addQueue = menu.addAction(QIcon(":/res/icons/media-playlist-append.svg"), tr("Add to queue"));
|
auto *addQueue = menu.addAction(QIcon(":/res/icons/media-playlist-append.svg"), tr("Add to queue"));
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
auto *addFav = menu.addAction(QIcon(":/res/icons/starred-symbolic.svg"), tr("Add to favorites"));
|
|
||||||
auto *remFav = menu.addAction(QIcon(":/res/icons/non-starred-symbolic.svg"), tr("Remove from favorites"));
|
|
||||||
|
|
||||||
const int row = index.row();
|
const bool isFav = m_model->isFav(id);
|
||||||
connect(playNow, &QAction::triggered, this, [this, id, row] {
|
if (isFav) {
|
||||||
m_queue->setContext(m_model->currentTracksJson(), row);
|
auto *remFav = menu.addAction(QIcon(":/res/icons/non-starred-symbolic.svg"), tr("Remove from favorites"));
|
||||||
|
connect(remFav, &QAction::triggered, this, [this, id] {
|
||||||
|
m_backend->removeFavTrack(id);
|
||||||
|
m_model->removeFavId(id);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
auto *addFav = menu.addAction(QIcon(":/res/icons/starred-symbolic.svg"), tr("Add to favorites"));
|
||||||
|
connect(addFav, &QAction::triggered, this, [this, id] {
|
||||||
|
m_backend->addFavTrack(id);
|
||||||
|
m_model->addFavId(id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute filtered row for multi-disc albums (disc headers excluded from currentTracksJson)
|
||||||
|
int filteredRow = 0;
|
||||||
|
for (int r = 0; r < index.row(); ++r)
|
||||||
|
if (!m_model->trackAt(r).isDiscHeader) ++filteredRow;
|
||||||
|
connect(playNow, &QAction::triggered, this, [this, id, filteredRow] {
|
||||||
|
m_queue->setContext(m_model->currentTracksJson(), filteredRow);
|
||||||
emit playTrackRequested(id);
|
emit playTrackRequested(id);
|
||||||
});
|
});
|
||||||
connect(playNext, &QAction::triggered, this, [this, trackJson] {
|
connect(playNext, &QAction::triggered, this, [this, trackJson] {
|
||||||
@@ -133,12 +182,6 @@ void Tracks::onContextMenu(const QPoint &pos)
|
|||||||
connect(addQueue, &QAction::triggered, this, [this, trackJson] {
|
connect(addQueue, &QAction::triggered, this, [this, trackJson] {
|
||||||
m_queue->addToQueue(trackJson);
|
m_queue->addToQueue(trackJson);
|
||||||
});
|
});
|
||||||
connect(addFav, &QAction::triggered, this, [this, id] {
|
|
||||||
m_backend->addFavTrack(id);
|
|
||||||
});
|
|
||||||
connect(remFav, &QAction::triggered, this, [this, id] {
|
|
||||||
m_backend->removeFavTrack(id);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Open album
|
// Open album
|
||||||
const QString albumId = m_model->trackAt(index.row()).albumId;
|
const QString albumId = m_model->trackAt(index.row()).albumId;
|
||||||
@@ -195,6 +238,13 @@ void Tracks::onContextMenu(const QPoint &pos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Track info
|
||||||
|
menu.addSeparator();
|
||||||
|
auto *infoAction = menu.addAction(tr("Track info..."));
|
||||||
|
connect(infoAction, &QAction::triggered, this, [this, trackJson] {
|
||||||
|
TrackInfoDialog::show(trackJson, this);
|
||||||
|
});
|
||||||
|
|
||||||
menu.exec(viewport()->mapToGlobal(pos));
|
menu.exec(viewport()->mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
namespace List
|
namespace List
|
||||||
{
|
{
|
||||||
@@ -28,6 +29,11 @@ namespace List
|
|||||||
/// Called when the backend fires EV_TRACK_CHANGED so the playing row is highlighted.
|
/// Called when the backend fires EV_TRACK_CHANGED so the playing row is highlighted.
|
||||||
void setPlayingTrackId(qint64 id);
|
void setPlayingTrackId(qint64 id);
|
||||||
|
|
||||||
|
/// Populate favorite track IDs so the star indicator and context menu reflect fav status.
|
||||||
|
void setFavTrackIds(const QSet<qint64> &ids);
|
||||||
|
void addFavTrackId(qint64 id);
|
||||||
|
void removeFavTrackId(qint64 id);
|
||||||
|
|
||||||
/// Start playing all tracks in the current view from the beginning.
|
/// Start playing all tracks in the current view from the beginning.
|
||||||
/// If shuffle is true, enables shuffle mode before starting.
|
/// If shuffle is true, enables shuffle mode before starting.
|
||||||
void playAll(bool shuffle = false);
|
void playAll(bool shuffle = false);
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ MainWindow::MainWindow(QobuzBackend *backend, QWidget *parent)
|
|||||||
m_libraryDock->setObjectName(QStringLiteral("libraryDock"));
|
m_libraryDock->setObjectName(QStringLiteral("libraryDock"));
|
||||||
m_libraryDock->setFeatures(QDockWidget::DockWidgetMovable);
|
m_libraryDock->setFeatures(QDockWidget::DockWidgetMovable);
|
||||||
m_libraryDock->setWidget(m_library);
|
m_libraryDock->setWidget(m_library);
|
||||||
m_libraryDock->setMinimumWidth(200);
|
m_libraryDock->setMinimumWidth(180);
|
||||||
|
m_library->setFixedWidth(220);
|
||||||
addDockWidget(Qt::LeftDockWidgetArea, m_libraryDock);
|
addDockWidget(Qt::LeftDockWidgetArea, m_libraryDock);
|
||||||
|
|
||||||
// ---- Now-playing context dock (left, below library) ----
|
// ---- Now-playing context dock (left, below library) ----
|
||||||
@@ -53,7 +54,7 @@ MainWindow::MainWindow(QobuzBackend *backend, QWidget *parent)
|
|||||||
addDockWidget(Qt::RightDockWidgetArea, m_queuePanel);
|
addDockWidget(Qt::RightDockWidgetArea, m_queuePanel);
|
||||||
|
|
||||||
// ---- Search side panel (right) ----
|
// ---- Search side panel (right) ----
|
||||||
m_sidePanel = new SidePanel::View(m_backend, this);
|
m_sidePanel = new SidePanel::View(m_backend, m_queue, this);
|
||||||
m_sidePanel->hide();
|
m_sidePanel->hide();
|
||||||
addDockWidget(Qt::RightDockWidgetArea, m_sidePanel);
|
addDockWidget(Qt::RightDockWidgetArea, m_sidePanel);
|
||||||
|
|
||||||
@@ -72,11 +73,22 @@ MainWindow::MainWindow(QobuzBackend *backend, QWidget *parent)
|
|||||||
// ---- Backend signals ----
|
// ---- Backend signals ----
|
||||||
connect(m_backend, &QobuzBackend::loginSuccess, this, &MainWindow::onLoginSuccess);
|
connect(m_backend, &QobuzBackend::loginSuccess, this, &MainWindow::onLoginSuccess);
|
||||||
connect(m_backend, &QobuzBackend::loginError, this, &MainWindow::onLoginError);
|
connect(m_backend, &QobuzBackend::loginError, this, &MainWindow::onLoginError);
|
||||||
|
connect(m_backend, &QobuzBackend::userLoaded, this, [this](const QJsonObject &user) {
|
||||||
|
const qint64 id = static_cast<qint64>(user["id"].toDouble());
|
||||||
|
if (id > 0) {
|
||||||
|
AppSettings::instance().setUserId(id);
|
||||||
|
m_library->refresh(); // re-load playlists with correct ownership now
|
||||||
|
}
|
||||||
|
});
|
||||||
connect(m_backend, &QobuzBackend::favTracksLoaded, this, &MainWindow::onFavTracksLoaded);
|
connect(m_backend, &QobuzBackend::favTracksLoaded, this, &MainWindow::onFavTracksLoaded);
|
||||||
connect(m_backend, &QobuzBackend::favAlbumsLoaded, this, &MainWindow::onFavAlbumsLoaded);
|
connect(m_backend, &QobuzBackend::favAlbumsLoaded, this, &MainWindow::onFavAlbumsLoaded);
|
||||||
connect(m_backend, &QobuzBackend::favArtistsLoaded, this, &MainWindow::onFavArtistsLoaded);
|
connect(m_backend, &QobuzBackend::favArtistsLoaded, this, &MainWindow::onFavArtistsLoaded);
|
||||||
connect(m_backend, &QobuzBackend::albumLoaded, this, &MainWindow::onAlbumLoaded);
|
connect(m_backend, &QobuzBackend::albumLoaded, this, &MainWindow::onAlbumLoaded);
|
||||||
connect(m_backend, &QobuzBackend::artistLoaded, this, &MainWindow::onArtistLoaded);
|
connect(m_backend, &QobuzBackend::artistLoaded, this, &MainWindow::onArtistLoaded);
|
||||||
|
connect(m_backend, &QobuzBackend::artistReleasesLoaded,
|
||||||
|
m_content, &MainContent::updateArtistReleases);
|
||||||
|
connect(m_backend, &QobuzBackend::deepShuffleTracksLoaded,
|
||||||
|
m_content, &MainContent::onDeepShuffleTracks);
|
||||||
connect(m_backend, &QobuzBackend::playlistLoaded, this, &MainWindow::onPlaylistLoaded);
|
connect(m_backend, &QobuzBackend::playlistLoaded, this, &MainWindow::onPlaylistLoaded);
|
||||||
connect(m_backend, &QobuzBackend::playlistCreated, this, &MainWindow::onPlaylistCreated);
|
connect(m_backend, &QobuzBackend::playlistCreated, this, &MainWindow::onPlaylistCreated);
|
||||||
connect(m_backend, &QobuzBackend::playlistDeleted, this, [this](const QJsonObject &) {
|
connect(m_backend, &QobuzBackend::playlistDeleted, this, [this](const QJsonObject &) {
|
||||||
@@ -112,6 +124,7 @@ MainWindow::MainWindow(QobuzBackend *backend, QWidget *parent)
|
|||||||
statusBar()->showMessage(tr("Loading favorite albums…"));
|
statusBar()->showMessage(tr("Loading favorite albums…"));
|
||||||
});
|
});
|
||||||
connect(m_library, &List::Library::favArtistsRequested, this, [this] {
|
connect(m_library, &List::Library::favArtistsRequested, this, [this] {
|
||||||
|
m_showFavArtistsOnLoad = true;
|
||||||
m_backend->getFavArtists();
|
m_backend->getFavArtists();
|
||||||
statusBar()->showMessage(tr("Loading favorite artists…"));
|
statusBar()->showMessage(tr("Loading favorite artists…"));
|
||||||
});
|
});
|
||||||
@@ -142,12 +155,19 @@ MainWindow::MainWindow(QobuzBackend *backend, QWidget *parent)
|
|||||||
this, &MainWindow::onSearchArtistSelected);
|
this, &MainWindow::onSearchArtistSelected);
|
||||||
connect(m_sidePanel, &SidePanel::View::trackPlayRequested,
|
connect(m_sidePanel, &SidePanel::View::trackPlayRequested,
|
||||||
this, &MainWindow::onPlayTrackRequested);
|
this, &MainWindow::onPlayTrackRequested);
|
||||||
|
connect(m_sidePanel, &SidePanel::View::addToPlaylistRequested,
|
||||||
|
this, [this](qint64 trackId, qint64 playlistId) {
|
||||||
|
m_backend->addTrackToPlaylist(playlistId, trackId);
|
||||||
|
statusBar()->showMessage(tr("Adding track to playlist..."), 3000);
|
||||||
|
});
|
||||||
|
|
||||||
// ---- Album / artist navigation from content views ----
|
// ---- Album / artist navigation from content views ----
|
||||||
connect(m_content, &MainContent::albumRequested,
|
connect(m_content, &MainContent::albumRequested,
|
||||||
this, &MainWindow::onSearchAlbumSelected);
|
this, &MainWindow::onSearchAlbumSelected);
|
||||||
connect(m_content, &MainContent::artistRequested,
|
connect(m_content, &MainContent::artistRequested,
|
||||||
this, &MainWindow::onSearchArtistSelected);
|
this, &MainWindow::onSearchArtistSelected);
|
||||||
|
connect(m_content, &MainContent::playTrackRequested,
|
||||||
|
this, &MainWindow::onPlayTrackRequested);
|
||||||
|
|
||||||
// ---- Queue panel ----
|
// ---- Queue panel ----
|
||||||
connect(m_queuePanel, &QueuePanel::skipToTrackRequested,
|
connect(m_queuePanel, &QueuePanel::skipToTrackRequested,
|
||||||
@@ -158,6 +178,9 @@ MainWindow::MainWindow(QobuzBackend *backend, QWidget *parent)
|
|||||||
connect(m_toolBar, &MainToolBar::queueToggled,
|
connect(m_toolBar, &MainToolBar::queueToggled,
|
||||||
this, [this](bool v) { m_queuePanel->setVisible(v); });
|
this, [this](bool v) { m_queuePanel->setVisible(v); });
|
||||||
|
|
||||||
|
connect(m_toolBar, &MainToolBar::albumRequested, this, &MainWindow::onSearchAlbumSelected);
|
||||||
|
connect(m_toolBar, &MainToolBar::artistRequested, this, &MainWindow::onSearchArtistSelected);
|
||||||
|
|
||||||
// Apply playback options from saved settings
|
// Apply playback options from saved settings
|
||||||
m_backend->setReplayGain(AppSettings::instance().replayGainEnabled());
|
m_backend->setReplayGain(AppSettings::instance().replayGainEnabled());
|
||||||
m_backend->setGapless(AppSettings::instance().gaplessEnabled());
|
m_backend->setGapless(AppSettings::instance().gaplessEnabled());
|
||||||
@@ -199,7 +222,12 @@ void MainWindow::tryRestoreSession()
|
|||||||
const QString token = AppSettings::instance().authToken();
|
const QString token = AppSettings::instance().authToken();
|
||||||
if (!token.isEmpty()) {
|
if (!token.isEmpty()) {
|
||||||
m_backend->setToken(token);
|
m_backend->setToken(token);
|
||||||
|
if (AppSettings::instance().userId() == 0)
|
||||||
|
m_backend->getUser(); // userLoaded will call m_library->refresh()
|
||||||
|
else
|
||||||
m_library->refresh();
|
m_library->refresh();
|
||||||
|
// Preload fav artists so the artist page fav button works immediately
|
||||||
|
m_backend->getFavArtists();
|
||||||
const QString name = AppSettings::instance().displayName();
|
const QString name = AppSettings::instance().displayName();
|
||||||
statusBar()->showMessage(tr("Signed in as %1").arg(
|
statusBar()->showMessage(tr("Signed in as %1").arg(
|
||||||
name.isEmpty() ? AppSettings::instance().userEmail() : name));
|
name.isEmpty() ? AppSettings::instance().userEmail() : name));
|
||||||
@@ -283,6 +311,15 @@ void MainWindow::onTrackChanged(const QJsonObject &track)
|
|||||||
|
|
||||||
void MainWindow::onFavTracksLoaded(const QJsonObject &result)
|
void MainWindow::onFavTracksLoaded(const QJsonObject &result)
|
||||||
{
|
{
|
||||||
|
// Cache fav IDs so the star indicator and context menu stay in sync
|
||||||
|
QSet<qint64> ids;
|
||||||
|
const QJsonArray items = result["items"].toArray();
|
||||||
|
for (const QJsonValue &v : items) {
|
||||||
|
const qint64 id = static_cast<qint64>(v.toObject()["id"].toDouble());
|
||||||
|
if (id > 0) ids.insert(id);
|
||||||
|
}
|
||||||
|
m_content->tracksList()->setFavTrackIds(ids);
|
||||||
|
|
||||||
m_content->showFavTracks(result);
|
m_content->showFavTracks(result);
|
||||||
statusBar()->showMessage(
|
statusBar()->showMessage(
|
||||||
tr("%1 favorite tracks").arg(result["total"].toInt()), 4000);
|
tr("%1 favorite tracks").arg(result["total"].toInt()), 4000);
|
||||||
@@ -297,10 +334,23 @@ void MainWindow::onFavAlbumsLoaded(const QJsonObject &result)
|
|||||||
|
|
||||||
void MainWindow::onFavArtistsLoaded(const QJsonObject &result)
|
void MainWindow::onFavArtistsLoaded(const QJsonObject &result)
|
||||||
{
|
{
|
||||||
|
// 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);
|
m_content->showFavArtists(result);
|
||||||
statusBar()->showMessage(
|
statusBar()->showMessage(
|
||||||
tr("%1 favorite artists").arg(result["total"].toInt()), 4000);
|
tr("%1 favorite artists").arg(result["total"].toInt()), 4000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onAlbumLoaded(const QJsonObject &album)
|
void MainWindow::onAlbumLoaded(const QJsonObject &album)
|
||||||
{
|
{
|
||||||
@@ -312,8 +362,14 @@ void MainWindow::onAlbumLoaded(const QJsonObject &album)
|
|||||||
void MainWindow::onArtistLoaded(const QJsonObject &artist)
|
void MainWindow::onArtistLoaded(const QJsonObject &artist)
|
||||||
{
|
{
|
||||||
m_content->showArtist(artist);
|
m_content->showArtist(artist);
|
||||||
|
// Fire release requests only after the artist page is shown — avoids the
|
||||||
|
// race where a fast-responding release request arrives before setArtist()
|
||||||
|
// clears the sections, causing setArtist() to wipe out the data.
|
||||||
|
const qint64 artistId = static_cast<qint64>(artist["id"].toDouble());
|
||||||
|
for (const char *type : {"album", "epSingle", "live", "compilation"})
|
||||||
|
m_backend->getArtistReleases(artistId, QString::fromLatin1(type));
|
||||||
statusBar()->showMessage(
|
statusBar()->showMessage(
|
||||||
tr("Artist: %1").arg(artist["name"].toString()), 4000);
|
tr("Artist: %1").arg(artist["name"].toObject()["display"].toString()), 4000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onPlaylistLoaded(const QJsonObject &playlist)
|
void MainWindow::onPlaylistLoaded(const QJsonObject &playlist)
|
||||||
@@ -359,4 +415,6 @@ void MainWindow::onUserPlaylistsChanged(const QVector<QPair<qint64, QString>> &p
|
|||||||
{
|
{
|
||||||
m_userPlaylists = playlists;
|
m_userPlaylists = playlists;
|
||||||
m_content->tracksList()->setUserPlaylists(playlists);
|
m_content->tracksList()->setUserPlaylists(playlists);
|
||||||
|
m_sidePanel->searchTab()->setUserPlaylists(playlists);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,9 @@
|
|||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QJsonArray>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QSet>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@@ -51,6 +53,8 @@ private:
|
|||||||
QobuzBackend *m_backend = nullptr;
|
QobuzBackend *m_backend = nullptr;
|
||||||
PlayQueue *m_queue = nullptr;
|
PlayQueue *m_queue = nullptr;
|
||||||
QVector<QPair<qint64, QString>> m_userPlaylists;
|
QVector<QPair<qint64, QString>> m_userPlaylists;
|
||||||
|
QSet<qint64> m_favArtistIds;
|
||||||
|
bool m_showFavArtistsOnLoad = false;
|
||||||
MainToolBar *m_toolBar = nullptr;
|
MainToolBar *m_toolBar = nullptr;
|
||||||
MainContent *m_content = nullptr;
|
MainContent *m_content = nullptr;
|
||||||
List::Library *m_library = nullptr;
|
List::Library *m_library = nullptr;
|
||||||
|
|||||||
@@ -17,18 +17,28 @@ void TrackListModel::setTracks(const QJsonArray &tracks,
|
|||||||
m_tracks.clear();
|
m_tracks.clear();
|
||||||
m_tracks.reserve(tracks.size());
|
m_tracks.reserve(tracks.size());
|
||||||
|
|
||||||
|
// Parse into a temporary list first so we can detect multi-disc
|
||||||
|
QVector<TrackItem> parsed;
|
||||||
|
parsed.reserve(tracks.size());
|
||||||
|
|
||||||
int seq = 1;
|
int seq = 1;
|
||||||
for (const QJsonValue &v : tracks) {
|
for (const QJsonValue &v : tracks) {
|
||||||
const QJsonObject t = v.toObject();
|
const QJsonObject t = v.toObject();
|
||||||
TrackItem item;
|
TrackItem item;
|
||||||
item.id = static_cast<qint64>(t["id"].toDouble());
|
item.id = static_cast<qint64>(t["id"].toDouble());
|
||||||
item.playlistTrackId = static_cast<qint64>(t["playlist_track_id"].toDouble());
|
item.playlistTrackId = static_cast<qint64>(t["playlist_track_id"].toDouble());
|
||||||
item.title = t["title"].toString();
|
item.discNumber = t["media_number"].toInt(1);
|
||||||
item.duration = static_cast<qint64>(t["duration"].toDouble());
|
item.duration = static_cast<qint64>(t["duration"].toDouble());
|
||||||
item.hiRes = t["hires_streamable"].toBool();
|
|
||||||
item.streamable = t["streamable"].toBool(true);
|
item.streamable = t["streamable"].toBool(true);
|
||||||
|
item.hiRes = t["hires_streamable"].toBool();
|
||||||
item.raw = t;
|
item.raw = t;
|
||||||
|
|
||||||
|
// Combine title + version ("Melody" + "Vocal Remix" → "Melody (Vocal Remix)")
|
||||||
|
const QString base = t["title"].toString();
|
||||||
|
const QString version = t["version"].toString().trimmed();
|
||||||
|
item.title = version.isEmpty() ? base
|
||||||
|
: base + QStringLiteral(" (") + version + QLatin1Char(')');
|
||||||
|
|
||||||
if (useSequential) {
|
if (useSequential) {
|
||||||
item.number = seq++;
|
item.number = seq++;
|
||||||
} else if (usePosition) {
|
} else if (usePosition) {
|
||||||
@@ -41,24 +51,61 @@ void TrackListModel::setTracks(const QJsonArray &tracks,
|
|||||||
|
|
||||||
const QJsonObject performer = t["performer"].toObject();
|
const QJsonObject performer = t["performer"].toObject();
|
||||||
item.artist = performer["name"].toString();
|
item.artist = performer["name"].toString();
|
||||||
if (item.artist.isEmpty())
|
if (item.artist.isEmpty()) {
|
||||||
item.artist = t["album"].toObject()["artist"].toObject()["name"].toString();
|
// album.artist.name may be a plain string or {display:"..."} object
|
||||||
|
const QJsonValue n = t["album"].toObject()["artist"].toObject()["name"];
|
||||||
|
item.artist = n.isObject() ? n.toObject()["display"].toString() : n.toString();
|
||||||
|
}
|
||||||
|
if (item.artist.isEmpty()) {
|
||||||
|
// top_tracks format: artist.name.display
|
||||||
|
const QJsonValue n = t["artist"].toObject()["name"];
|
||||||
|
item.artist = n.isObject() ? n.toObject()["display"].toString() : n.toString();
|
||||||
|
}
|
||||||
|
|
||||||
const QJsonObject album = t["album"].toObject();
|
const QJsonObject album = t["album"].toObject();
|
||||||
item.album = album["title"].toString();
|
item.album = album["title"].toString();
|
||||||
item.albumId = album["id"].toString();
|
item.albumId = album["id"].toString();
|
||||||
|
|
||||||
m_tracks.append(item);
|
parsed.append(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-apply sort silently inside the reset (no layout signals needed here)
|
// Multi-disc only makes sense for album context (not playlists / fav / search)
|
||||||
|
int maxDisc = 1;
|
||||||
|
if (!usePosition && !useSequential) {
|
||||||
|
for (const TrackItem &t : parsed)
|
||||||
|
maxDisc = qMax(maxDisc, t.discNumber);
|
||||||
|
}
|
||||||
|
m_hasMultipleDiscs = (maxDisc > 1);
|
||||||
|
|
||||||
|
if (m_hasMultipleDiscs) {
|
||||||
|
// Sort by disc then track number
|
||||||
|
std::stable_sort(parsed.begin(), parsed.end(), [](const TrackItem &a, const TrackItem &b) {
|
||||||
|
return a.discNumber != b.discNumber ? a.discNumber < b.discNumber
|
||||||
|
: a.number < b.number;
|
||||||
|
});
|
||||||
|
// Interleave disc header items
|
||||||
|
int currentDisc = -1;
|
||||||
|
for (const TrackItem &t : parsed) {
|
||||||
|
if (t.discNumber != currentDisc) {
|
||||||
|
TrackItem header;
|
||||||
|
header.isDiscHeader = true;
|
||||||
|
header.discNumber = t.discNumber;
|
||||||
|
header.title = tr("Disc %1").arg(t.discNumber);
|
||||||
|
m_tracks.append(header);
|
||||||
|
currentDisc = t.discNumber;
|
||||||
|
}
|
||||||
|
m_tracks.append(t);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_tracks = parsed;
|
||||||
|
// Re-apply sort silently inside the reset
|
||||||
if (m_sortColumn >= 0)
|
if (m_sortColumn >= 0)
|
||||||
sortData(m_sortColumn, m_sortOrder);
|
sortData(m_sortColumn, m_sortOrder);
|
||||||
|
}
|
||||||
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
|
||||||
// Tell external listeners the sorted order is ready (e.g. PlayQueue sync)
|
if (!m_hasMultipleDiscs && m_sortColumn >= 0)
|
||||||
if (m_sortColumn >= 0)
|
|
||||||
emit sortApplied();
|
emit sortApplied();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +124,36 @@ void TrackListModel::removeTrack(int row)
|
|||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackListModel::setFavIds(const QSet<qint64> &ids)
|
||||||
|
{
|
||||||
|
m_favIds = ids;
|
||||||
|
if (!m_tracks.isEmpty())
|
||||||
|
emit dataChanged(index(0, ColTitle), index(rowCount() - 1, ColTitle),
|
||||||
|
{Qt::DecorationRole});
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackListModel::addFavId(qint64 id)
|
||||||
|
{
|
||||||
|
m_favIds.insert(id);
|
||||||
|
for (int r = 0; r < m_tracks.size(); ++r) {
|
||||||
|
if (m_tracks[r].id == id) {
|
||||||
|
const auto idx = index(r, ColTitle);
|
||||||
|
emit dataChanged(idx, idx, {Qt::DecorationRole});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackListModel::removeFavId(qint64 id)
|
||||||
|
{
|
||||||
|
m_favIds.remove(id);
|
||||||
|
for (int r = 0; r < m_tracks.size(); ++r) {
|
||||||
|
if (m_tracks[r].id == id) {
|
||||||
|
const auto idx = index(r, ColTitle);
|
||||||
|
emit dataChanged(idx, idx, {Qt::DecorationRole});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TrackListModel::setPlayingId(qint64 id)
|
void TrackListModel::setPlayingId(qint64 id)
|
||||||
{
|
{
|
||||||
m_playingId = id;
|
m_playingId = id;
|
||||||
@@ -85,6 +162,23 @@ void TrackListModel::setPlayingId(qint64 id)
|
|||||||
{Qt::FontRole, Qt::DecorationRole});
|
{Qt::FontRole, Qt::DecorationRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags TrackListModel::flags(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (!index.isValid() || index.row() >= m_tracks.size())
|
||||||
|
return Qt::NoItemFlags;
|
||||||
|
if (m_tracks.at(index.row()).isDiscHeader)
|
||||||
|
return Qt::ItemIsEnabled;
|
||||||
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<int> TrackListModel::discHeaderRows() const
|
||||||
|
{
|
||||||
|
QVector<int> rows;
|
||||||
|
for (int i = 0; i < m_tracks.size(); ++i)
|
||||||
|
if (m_tracks[i].isDiscHeader) rows.append(i);
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
int TrackListModel::rowCount(const QModelIndex &parent) const
|
int TrackListModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return parent.isValid() ? 0 : m_tracks.size();
|
return parent.isValid() ? 0 : m_tracks.size();
|
||||||
@@ -101,6 +195,19 @@ QVariant TrackListModel::data(const QModelIndex &index, int role) const
|
|||||||
return {};
|
return {};
|
||||||
|
|
||||||
const TrackItem &t = m_tracks.at(index.row());
|
const TrackItem &t = m_tracks.at(index.row());
|
||||||
|
|
||||||
|
// Disc header rows: styled separator spanning all columns via setFirstColumnSpanned
|
||||||
|
if (t.isDiscHeader) {
|
||||||
|
if (role == Qt::DisplayRole && index.column() == ColNumber)
|
||||||
|
return t.title;
|
||||||
|
if (role == Qt::FontRole) {
|
||||||
|
QFont f; f.setBold(true); return f;
|
||||||
|
}
|
||||||
|
if (role == Qt::ForegroundRole)
|
||||||
|
return QColor(0xFF, 0xB2, 0x32);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
const bool isPlaying = (t.id == m_playingId && m_playingId != 0);
|
const bool isPlaying = (t.id == m_playingId && m_playingId != 0);
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
@@ -128,6 +235,10 @@ QVariant TrackListModel::data(const QModelIndex &index, int role) const
|
|||||||
return QIcon(QStringLiteral(":/res/icons/media-track-show-active.svg"));
|
return QIcon(QStringLiteral(":/res/icons/media-track-show-active.svg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (role == Qt::DecorationRole && index.column() == ColTitle && m_favIds.contains(t.id)) {
|
||||||
|
return QIcon(QStringLiteral(":/res/icons/starred-symbolic.svg"));
|
||||||
|
}
|
||||||
|
|
||||||
if (role == TrackIdRole) return t.id;
|
if (role == TrackIdRole) return t.id;
|
||||||
if (role == TrackJsonRole) return t.raw;
|
if (role == TrackJsonRole) return t.raw;
|
||||||
if (role == HiResRole) return t.hiRes;
|
if (role == HiResRole) return t.hiRes;
|
||||||
@@ -179,7 +290,8 @@ void TrackListModel::sort(int column, Qt::SortOrder order)
|
|||||||
m_sortColumn = column;
|
m_sortColumn = column;
|
||||||
m_sortOrder = order;
|
m_sortOrder = order;
|
||||||
|
|
||||||
if (m_tracks.isEmpty()) return;
|
// Multi-disc albums keep their disc-ordered layout; don't re-sort
|
||||||
|
if (m_hasMultipleDiscs || m_tracks.isEmpty()) return;
|
||||||
|
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
sortData(column, order);
|
sortData(column, order);
|
||||||
@@ -190,7 +302,8 @@ void TrackListModel::sort(int column, Qt::SortOrder order)
|
|||||||
|
|
||||||
QString TrackListModel::formatDuration(qint64 secs)
|
QString TrackListModel::formatDuration(qint64 secs)
|
||||||
{
|
{
|
||||||
const int m = static_cast<int>(secs / 60);
|
if (secs < 0) secs = 0;
|
||||||
const int s = static_cast<int>(secs % 60);
|
const qint64 m = secs / 60;
|
||||||
|
const qint64 s = secs % 60;
|
||||||
return QStringLiteral("%1:%2").arg(m).arg(s, 2, 10, QLatin1Char('0'));
|
return QStringLiteral("%1:%2").arg(m).arg(s, 2, 10, QLatin1Char('0'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,15 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QSet>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
|
||||||
struct TrackItem {
|
struct TrackItem {
|
||||||
qint64 id = 0;
|
qint64 id = 0;
|
||||||
qint64 playlistTrackId = 0;
|
qint64 playlistTrackId = 0;
|
||||||
int number = 0;
|
int number = 0;
|
||||||
|
int discNumber = 1;
|
||||||
|
bool isDiscHeader = false;
|
||||||
QString title;
|
QString title;
|
||||||
QString artist;
|
QString artist;
|
||||||
QString album;
|
QString album;
|
||||||
@@ -52,17 +55,27 @@ public:
|
|||||||
void setPlayingId(qint64 id);
|
void setPlayingId(qint64 id);
|
||||||
qint64 playingId() const { return m_playingId; }
|
qint64 playingId() const { return m_playingId; }
|
||||||
|
|
||||||
|
void setFavIds(const QSet<qint64> &ids);
|
||||||
|
void addFavId(qint64 id);
|
||||||
|
void removeFavId(qint64 id);
|
||||||
|
bool isFav(qint64 id) const { return m_favIds.contains(id); }
|
||||||
|
|
||||||
|
bool hasMultipleDiscs() const { return m_hasMultipleDiscs; }
|
||||||
|
QVector<int> discHeaderRows() const;
|
||||||
|
|
||||||
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
|
|
||||||
/// Optimistically remove a row (e.g. after deleting from playlist).
|
/// Optimistically remove a row (e.g. after deleting from playlist).
|
||||||
void removeTrack(int row);
|
void removeTrack(int row);
|
||||||
|
|
||||||
const TrackItem &trackAt(int row) const { return m_tracks.at(row); }
|
const TrackItem &trackAt(int row) const { return m_tracks.at(row); }
|
||||||
|
|
||||||
// Returns the current (possibly sorted) raw JSON objects in display order.
|
// Returns the current (possibly sorted) raw JSON objects in display order, skipping disc headers.
|
||||||
QJsonArray currentTracksJson() const
|
QJsonArray currentTracksJson() const
|
||||||
{
|
{
|
||||||
QJsonArray out;
|
QJsonArray out;
|
||||||
for (const auto &t : m_tracks)
|
for (const auto &t : m_tracks)
|
||||||
out.append(t.raw);
|
if (!t.isDiscHeader) out.append(t.raw);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +94,9 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<TrackItem> m_tracks;
|
QVector<TrackItem> m_tracks;
|
||||||
|
QSet<qint64> m_favIds;
|
||||||
qint64 m_playingId = 0;
|
qint64 m_playingId = 0;
|
||||||
|
bool m_hasMultipleDiscs = false;
|
||||||
int m_sortColumn = -1;
|
int m_sortColumn = -1;
|
||||||
Qt::SortOrder m_sortOrder = Qt::AscendingOrder;
|
Qt::SortOrder m_sortOrder = Qt::AscendingOrder;
|
||||||
|
|
||||||
|
|||||||
@@ -107,6 +107,14 @@ public:
|
|||||||
emit queueChanged();
|
emit queueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Shuffle the current queue once without changing the global shuffle flag.
|
||||||
|
void shuffleNow()
|
||||||
|
{
|
||||||
|
if (m_queue.isEmpty()) return;
|
||||||
|
shuffleQueue(m_index);
|
||||||
|
emit queueChanged();
|
||||||
|
}
|
||||||
|
|
||||||
// ---- Play-next prepend queue (like "Add to queue" ----
|
// ---- Play-next prepend queue (like "Add to queue" ----
|
||||||
|
|
||||||
void addToQueue(const QJsonObject &track)
|
void addToQueue(const QJsonObject &track)
|
||||||
|
|||||||
85
src/util/trackinfo.hpp
Normal file
85
src/util/trackinfo.hpp
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace TrackInfoDialog
|
||||||
|
{
|
||||||
|
|
||||||
|
inline void show(const QJsonObject &track, QWidget *parent)
|
||||||
|
{
|
||||||
|
auto *dlg = new QDialog(parent);
|
||||||
|
dlg->setWindowTitle(QObject::tr("Track Info"));
|
||||||
|
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
dlg->setMinimumWidth(360);
|
||||||
|
|
||||||
|
auto *form = new QFormLayout(dlg);
|
||||||
|
|
||||||
|
auto addRow = [&](const QString &label, const QString &value) {
|
||||||
|
if (value.isEmpty()) return;
|
||||||
|
auto *val = new QLabel(value, dlg);
|
||||||
|
val->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
|
val->setWordWrap(true);
|
||||||
|
form->addRow(QStringLiteral("<b>%1</b>").arg(label), val);
|
||||||
|
};
|
||||||
|
|
||||||
|
const QString title = track["title"].toString();
|
||||||
|
const QString version = track["version"].toString().trimmed();
|
||||||
|
addRow(QObject::tr("Title"),
|
||||||
|
version.isEmpty() ? title : title + QStringLiteral(" (%1)").arg(version));
|
||||||
|
|
||||||
|
addRow(QObject::tr("Performer"), track["performer"].toObject()["name"].toString());
|
||||||
|
|
||||||
|
const QJsonObject composer = track["composer"].toObject();
|
||||||
|
if (!composer.isEmpty())
|
||||||
|
addRow(QObject::tr("Composer"), composer["name"].toString());
|
||||||
|
|
||||||
|
const QJsonObject album = track["album"].toObject();
|
||||||
|
addRow(QObject::tr("Album"), album["title"].toString());
|
||||||
|
addRow(QObject::tr("Album artist"), album["artist"].toObject()["name"].toString());
|
||||||
|
|
||||||
|
const int trackNum = track["track_number"].toInt();
|
||||||
|
const int discNum = track["media_number"].toInt();
|
||||||
|
if (trackNum > 0) {
|
||||||
|
const QString pos = discNum > 1
|
||||||
|
? QStringLiteral("%1-%2").arg(discNum).arg(trackNum)
|
||||||
|
: QString::number(trackNum);
|
||||||
|
addRow(QObject::tr("Track #"), pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
const qint64 dur = static_cast<qint64>(track["duration"].toDouble());
|
||||||
|
if (dur > 0) {
|
||||||
|
const int m = static_cast<int>(dur / 60);
|
||||||
|
const int s = static_cast<int>(dur % 60);
|
||||||
|
addRow(QObject::tr("Duration"),
|
||||||
|
QStringLiteral("%1:%2").arg(m).arg(s, 2, 10, QLatin1Char('0')));
|
||||||
|
}
|
||||||
|
|
||||||
|
const int bitDepth = track["maximum_bit_depth"].toInt();
|
||||||
|
const double sampleRate = track["maximum_sampling_rate"].toDouble();
|
||||||
|
if (bitDepth > 0 && sampleRate > 0) {
|
||||||
|
addRow(QObject::tr("Quality"),
|
||||||
|
QStringLiteral("%1-bit / %2 kHz").arg(bitDepth).arg(sampleRate, 0, 'f', 1));
|
||||||
|
} else if (bitDepth > 0) {
|
||||||
|
addRow(QObject::tr("Bit depth"), QStringLiteral("%1-bit").arg(bitDepth));
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool hiRes = track["hires_streamable"].toBool() || track["hires"].toBool();
|
||||||
|
addRow(QObject::tr("Hi-Res"), hiRes ? QObject::tr("Yes") : QObject::tr("No"));
|
||||||
|
|
||||||
|
const bool streamable = track["streamable"].toBool(true);
|
||||||
|
if (!streamable)
|
||||||
|
addRow(QObject::tr("Streamable"), QObject::tr("No"));
|
||||||
|
|
||||||
|
auto *buttons = new QDialogButtonBox(QDialogButtonBox::Close, dlg);
|
||||||
|
form->addRow(buttons);
|
||||||
|
QObject::connect(buttons, &QDialogButtonBox::rejected, dlg, &QDialog::close);
|
||||||
|
|
||||||
|
dlg->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace TrackInfoDialog
|
||||||
@@ -41,6 +41,25 @@ public:
|
|||||||
void setAlbums(const QJsonArray &albums)
|
void setAlbums(const QJsonArray &albums)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
addAlbums(albums);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Configure for artist page: hide Artist column, set fixed column widths
|
||||||
|
/// that match the Popular Tracks list for perfect vertical alignment.
|
||||||
|
void setArtistPageMode()
|
||||||
|
{
|
||||||
|
setColumnHidden(2, true); // Artist — redundant on artist page
|
||||||
|
header()->setSectionResizeMode(0, QHeaderView::Fixed);
|
||||||
|
header()->setSectionResizeMode(1, QHeaderView::Stretch);
|
||||||
|
header()->setSectionResizeMode(3, QHeaderView::Fixed);
|
||||||
|
header()->setSectionResizeMode(4, QHeaderView::Fixed);
|
||||||
|
header()->resizeSection(0, 40);
|
||||||
|
header()->resizeSection(3, 120);
|
||||||
|
header()->resizeSection(4, 70);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addAlbums(const QJsonArray &albums)
|
||||||
|
{
|
||||||
QFont hiResFont;
|
QFont hiResFont;
|
||||||
hiResFont.setBold(true);
|
hiResFont.setBold(true);
|
||||||
hiResFont.setPointSizeF(hiResFont.pointSizeF() * 0.85);
|
hiResFont.setPointSizeF(hiResFont.pointSizeF() * 0.85);
|
||||||
@@ -48,12 +67,23 @@ public:
|
|||||||
for (const auto &v : albums) {
|
for (const auto &v : albums) {
|
||||||
const QJsonObject a = v.toObject();
|
const QJsonObject a = v.toObject();
|
||||||
const QString id = a["id"].toString();
|
const QString id = a["id"].toString();
|
||||||
const QString title = a["title"].toString();
|
const QString base = a["title"].toString();
|
||||||
const QString artist = a["artist"].toObject()["name"].toString();
|
const QString ver = a["version"].toString().trimmed();
|
||||||
|
const QString title = ver.isEmpty() ? base : base + QStringLiteral(" (") + ver + QLatin1Char(')');
|
||||||
|
|
||||||
|
const QJsonValue artistNameVal = a["artist"].toObject()["name"];
|
||||||
|
const QString artist = artistNameVal.isObject()
|
||||||
|
? artistNameVal.toObject()["display"].toString()
|
||||||
|
: artistNameVal.toString();
|
||||||
|
|
||||||
const QString date = a["release_date_original"].toString();
|
const QString date = a["release_date_original"].toString();
|
||||||
const QString year = date.left(4);
|
const QString year = date.isEmpty()
|
||||||
|
? a["dates"].toObject()["original"].toString().left(4)
|
||||||
|
: date.left(4);
|
||||||
|
|
||||||
const int tracks = a["tracks_count"].toInt();
|
const int tracks = a["tracks_count"].toInt();
|
||||||
const bool hiRes = a["hires_streamable"].toBool();
|
const bool hiRes = a["hires_streamable"].toBool()
|
||||||
|
|| a["rights"].toObject()["hires_streamable"].toBool();
|
||||||
|
|
||||||
auto *item = new QTreeWidgetItem(this);
|
auto *item = new QTreeWidgetItem(this);
|
||||||
if (hiRes) {
|
if (hiRes) {
|
||||||
|
|||||||
427
src/view/artistview.cpp
Normal file
427
src/view/artistview.cpp
Normal file
@@ -0,0 +1,427 @@
|
|||||||
|
#include "artistview.hpp"
|
||||||
|
#include "albumlistview.hpp"
|
||||||
|
#include "../model/tracklistmodel.hpp"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
// Shared button style (mirrors TrackContextHeader)
|
||||||
|
static const QString kBtnBase = QStringLiteral(
|
||||||
|
"QPushButton { padding: 5px 16px; border-radius: 4px; font-weight: bold; }"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Section-toggle style: flat QPushButton, truly left-aligned
|
||||||
|
static const QString kToggleStyle = QStringLiteral(
|
||||||
|
"QPushButton { text-align: left; font-weight: bold; font-size: 13px;"
|
||||||
|
" padding: 6px 8px; border: none; border-bottom: 1px solid #333;"
|
||||||
|
" background: transparent; }"
|
||||||
|
"QPushButton:hover { background: #1e1e1e; }"
|
||||||
|
);
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// ArtistSection
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ArtistSection::ArtistSection(const QString &title, const QString &releaseType, QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
, m_baseTitle(title)
|
||||||
|
, m_releaseType(releaseType)
|
||||||
|
{
|
||||||
|
auto *layout = new QVBoxLayout(this);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->setSpacing(0);
|
||||||
|
|
||||||
|
m_toggle = new QPushButton(this);
|
||||||
|
m_toggle->setCheckable(true);
|
||||||
|
m_toggle->setChecked(true);
|
||||||
|
m_toggle->setFlat(true);
|
||||||
|
m_toggle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
|
m_toggle->setStyleSheet(kToggleStyle);
|
||||||
|
layout->addWidget(m_toggle);
|
||||||
|
|
||||||
|
m_list = new AlbumListView(this);
|
||||||
|
layout->addWidget(m_list);
|
||||||
|
|
||||||
|
connect(m_toggle, &QPushButton::toggled, this, [this](bool checked) {
|
||||||
|
m_list->setVisible(checked);
|
||||||
|
updateToggleText();
|
||||||
|
});
|
||||||
|
connect(m_list, &AlbumListView::albumSelected, this, &ArtistSection::albumSelected);
|
||||||
|
|
||||||
|
updateToggleText();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArtistSection::setAlbums(const QJsonArray &albums)
|
||||||
|
{
|
||||||
|
m_list->setAlbums(albums);
|
||||||
|
updateToggleText();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ArtistSection::isEmpty() const
|
||||||
|
{
|
||||||
|
return m_list->topLevelItemCount() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList ArtistSection::albumIds() const
|
||||||
|
{
|
||||||
|
QStringList ids;
|
||||||
|
for (int i = 0; i < m_list->topLevelItemCount(); ++i) {
|
||||||
|
const QString id = m_list->topLevelItem(i)->data(1, Qt::UserRole).toString();
|
||||||
|
if (!id.isEmpty())
|
||||||
|
ids.append(id);
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArtistSection::setArtistPageMode()
|
||||||
|
{
|
||||||
|
m_list->setArtistPageMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArtistSection::updateToggleText()
|
||||||
|
{
|
||||||
|
const int count = m_list->topLevelItemCount();
|
||||||
|
const QString arrow = m_toggle->isChecked() ? QStringLiteral("▼ ") : QStringLiteral("▶ ");
|
||||||
|
const QString text = count > 0
|
||||||
|
? QStringLiteral("%1%2 (%3)").arg(arrow, m_baseTitle).arg(count)
|
||||||
|
: arrow + m_baseTitle;
|
||||||
|
m_toggle->setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// ArtistView
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ArtistView::ArtistView(QobuzBackend *backend, PlayQueue *queue, QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
, m_backend(backend)
|
||||||
|
, m_queue(queue)
|
||||||
|
{
|
||||||
|
auto *outerLayout = new QVBoxLayout(this);
|
||||||
|
outerLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
outerLayout->setSpacing(0);
|
||||||
|
|
||||||
|
// --- Artist header (same structure as TrackContextHeader) ---
|
||||||
|
auto *header = new QWidget(this);
|
||||||
|
header->setFixedHeight(148);
|
||||||
|
auto *hlay = new QHBoxLayout(header);
|
||||||
|
hlay->setContentsMargins(12, 8, 12, 8);
|
||||||
|
hlay->setSpacing(14);
|
||||||
|
|
||||||
|
m_artLabel = new QLabel(header);
|
||||||
|
m_artLabel->setFixedSize(120, 120);
|
||||||
|
m_artLabel->setScaledContents(true);
|
||||||
|
m_artLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
m_artLabel->setStyleSheet(QStringLiteral("background: #1a1a1a; border-radius: 4px;"));
|
||||||
|
hlay->addWidget(m_artLabel, 0, Qt::AlignVCenter);
|
||||||
|
|
||||||
|
auto *info = new QWidget(header);
|
||||||
|
auto *vlay = new QVBoxLayout(info);
|
||||||
|
vlay->setContentsMargins(0, 0, 0, 0);
|
||||||
|
vlay->setSpacing(4);
|
||||||
|
|
||||||
|
m_nameLabel = new QLabel(info);
|
||||||
|
QFont f = m_nameLabel->font();
|
||||||
|
f.setPointSize(f.pointSize() + 5);
|
||||||
|
f.setBold(true);
|
||||||
|
m_nameLabel->setFont(f);
|
||||||
|
vlay->addWidget(m_nameLabel);
|
||||||
|
|
||||||
|
m_bioEdit = new QTextEdit(info);
|
||||||
|
m_bioEdit->setReadOnly(true);
|
||||||
|
m_bioEdit->setFrameShape(QFrame::NoFrame);
|
||||||
|
m_bioEdit->setMaximumHeight(56);
|
||||||
|
m_bioEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
|
m_bioEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
vlay->addWidget(m_bioEdit);
|
||||||
|
|
||||||
|
auto *btnRow = new QHBoxLayout;
|
||||||
|
btnRow->setSpacing(8);
|
||||||
|
btnRow->setContentsMargins(0, 4, 0, 0);
|
||||||
|
|
||||||
|
static const QString kOutlineBtn = kBtnBase +
|
||||||
|
QStringLiteral("QPushButton { background: #2a2a2a; color: #FFB232; border: 1px solid #FFB232; }"
|
||||||
|
"QPushButton:pressed { background: #333; }");
|
||||||
|
|
||||||
|
m_playBtn = new QPushButton(tr("▶ Play"), info);
|
||||||
|
m_playBtn->setStyleSheet(kBtnBase +
|
||||||
|
QStringLiteral("QPushButton { background: #FFB232; color: #000; }"
|
||||||
|
"QPushButton:pressed { background: #e09e28; }"));
|
||||||
|
|
||||||
|
m_shuffleTopBtn = new QPushButton(tr("⇄ Shuffle"), info);
|
||||||
|
m_shuffleTopBtn->setStyleSheet(kOutlineBtn);
|
||||||
|
|
||||||
|
m_shuffleBtn = new QPushButton(tr("⇄ Shuffle All"), info);
|
||||||
|
m_shuffleBtn->setStyleSheet(kOutlineBtn);
|
||||||
|
|
||||||
|
m_favBtn = new QPushButton(tr("♡ Favourite"), info);
|
||||||
|
m_favBtn->setStyleSheet(kBtnBase +
|
||||||
|
QStringLiteral("QPushButton { background: #2a2a2a; color: #ccc; border: 1px solid #555; }"
|
||||||
|
"QPushButton:pressed { background: #333; }"));
|
||||||
|
|
||||||
|
btnRow->addWidget(m_playBtn);
|
||||||
|
btnRow->addWidget(m_shuffleTopBtn);
|
||||||
|
btnRow->addWidget(m_shuffleBtn);
|
||||||
|
btnRow->addWidget(m_favBtn);
|
||||||
|
btnRow->addStretch();
|
||||||
|
vlay->addLayout(btnRow);
|
||||||
|
vlay->addStretch(1);
|
||||||
|
|
||||||
|
hlay->addWidget(info, 1);
|
||||||
|
outerLayout->addWidget(header);
|
||||||
|
|
||||||
|
// --- Network manager for portrait ---
|
||||||
|
m_nam = new QNetworkAccessManager(this);
|
||||||
|
QObject::connect(m_nam, &QNetworkAccessManager::finished,
|
||||||
|
this, [this](QNetworkReply *reply) {
|
||||||
|
reply->deleteLater();
|
||||||
|
if (reply->error() != QNetworkReply::NoError) return;
|
||||||
|
QPixmap pix;
|
||||||
|
if (pix.loadFromData(reply->readAll()))
|
||||||
|
m_artLabel->setPixmap(pix);
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- Scrollable sections area ---
|
||||||
|
auto *scroll = new QScrollArea(this);
|
||||||
|
scroll->setWidgetResizable(true);
|
||||||
|
scroll->setFrameShape(QFrame::NoFrame);
|
||||||
|
|
||||||
|
auto *content = new QWidget(scroll);
|
||||||
|
auto *sectLayout = new QVBoxLayout(content);
|
||||||
|
sectLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
sectLayout->setSpacing(0);
|
||||||
|
|
||||||
|
// Popular Tracks section — same toggle style as release sections
|
||||||
|
m_topTracksSection = new QWidget(content);
|
||||||
|
auto *ttLayout = new QVBoxLayout(m_topTracksSection);
|
||||||
|
ttLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
ttLayout->setSpacing(0);
|
||||||
|
|
||||||
|
m_topTracksToggle = new QPushButton(m_topTracksSection);
|
||||||
|
m_topTracksToggle->setCheckable(true);
|
||||||
|
m_topTracksToggle->setChecked(true);
|
||||||
|
m_topTracksToggle->setFlat(true);
|
||||||
|
m_topTracksToggle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
|
m_topTracksToggle->setStyleSheet(kToggleStyle);
|
||||||
|
ttLayout->addWidget(m_topTracksToggle);
|
||||||
|
|
||||||
|
m_topTracks = new List::Tracks(backend, queue, m_topTracksSection);
|
||||||
|
m_topTracks->setMaximumHeight(320);
|
||||||
|
// Artist page column layout: hide Artist & Album, match album-section widths
|
||||||
|
m_topTracks->setColumnHidden(TrackListModel::ColArtist, true);
|
||||||
|
m_topTracks->setColumnHidden(TrackListModel::ColAlbum, true);
|
||||||
|
m_topTracks->header()->setSectionResizeMode(TrackListModel::ColNumber, QHeaderView::Fixed);
|
||||||
|
m_topTracks->header()->setSectionResizeMode(TrackListModel::ColTitle, QHeaderView::Stretch);
|
||||||
|
m_topTracks->header()->setSectionResizeMode(TrackListModel::ColDuration, QHeaderView::Fixed);
|
||||||
|
m_topTracks->header()->resizeSection(TrackListModel::ColNumber, 40);
|
||||||
|
m_topTracks->header()->resizeSection(TrackListModel::ColDuration, 70);
|
||||||
|
ttLayout->addWidget(m_topTracks);
|
||||||
|
|
||||||
|
connect(m_topTracksToggle, &QPushButton::toggled, m_topTracks, &QWidget::setVisible);
|
||||||
|
connect(m_topTracks, &List::Tracks::playTrackRequested, this, &ArtistView::playTrackRequested);
|
||||||
|
|
||||||
|
sectLayout->addWidget(m_topTracksSection);
|
||||||
|
|
||||||
|
// Release sections
|
||||||
|
m_secAlbums = new ArtistSection(tr("Albums"), QStringLiteral("album"), content);
|
||||||
|
m_secEps = new ArtistSection(tr("Singles & EPs"), QStringLiteral("epSingle"), content);
|
||||||
|
m_secLive = new ArtistSection(tr("Live"), QStringLiteral("live"), content);
|
||||||
|
m_secCompilations = new ArtistSection(tr("Compilations"), QStringLiteral("compilation"), content);
|
||||||
|
m_secOther = new ArtistSection(tr("Other"), QStringLiteral("other"), content);
|
||||||
|
|
||||||
|
// Uniform column layout: hide Artist column, match fixed widths across all sections
|
||||||
|
for (ArtistSection *sec : {m_secAlbums, m_secEps, m_secLive, m_secCompilations, m_secOther})
|
||||||
|
sec->setArtistPageMode();
|
||||||
|
|
||||||
|
sectLayout->addWidget(m_secAlbums);
|
||||||
|
sectLayout->addWidget(m_secEps);
|
||||||
|
sectLayout->addWidget(m_secLive);
|
||||||
|
sectLayout->addWidget(m_secCompilations);
|
||||||
|
sectLayout->addWidget(m_secOther);
|
||||||
|
sectLayout->addStretch();
|
||||||
|
|
||||||
|
scroll->setWidget(content);
|
||||||
|
outerLayout->addWidget(scroll, 1);
|
||||||
|
|
||||||
|
// Play / shuffle top tracks
|
||||||
|
connect(m_playBtn, &QPushButton::clicked, m_topTracks, [this] { m_topTracks->playAll(false); });
|
||||||
|
connect(m_shuffleTopBtn, &QPushButton::clicked, m_topTracks, [this] { m_topTracks->playAll(true); });
|
||||||
|
|
||||||
|
// Deep shuffle: fetch all album tracks, combine, shuffle, play
|
||||||
|
connect(m_shuffleBtn, &QPushButton::clicked, this, [this] {
|
||||||
|
const QStringList ids = allAlbumIds();
|
||||||
|
if (ids.isEmpty()) return;
|
||||||
|
m_shuffleBtn->setEnabled(false);
|
||||||
|
m_shuffleBtn->setText(tr("Loading…"));
|
||||||
|
m_backend->getAlbumsTracks(ids);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Favourite button
|
||||||
|
connect(m_favBtn, &QPushButton::clicked, this, [this] {
|
||||||
|
if (m_artistId <= 0) return;
|
||||||
|
m_isFaved = !m_isFaved;
|
||||||
|
if (m_isFaved) {
|
||||||
|
m_backend->addFavArtist(m_artistId);
|
||||||
|
m_favArtistIds.insert(m_artistId);
|
||||||
|
} else {
|
||||||
|
m_backend->removeFavArtist(m_artistId);
|
||||||
|
m_favArtistIds.remove(m_artistId);
|
||||||
|
}
|
||||||
|
setFaved(m_isFaved);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Album section connections
|
||||||
|
connect(m_secAlbums, &ArtistSection::albumSelected, this, &ArtistView::albumSelected);
|
||||||
|
connect(m_secEps, &ArtistSection::albumSelected, this, &ArtistView::albumSelected);
|
||||||
|
connect(m_secLive, &ArtistSection::albumSelected, this, &ArtistView::albumSelected);
|
||||||
|
connect(m_secCompilations, &ArtistSection::albumSelected, this, &ArtistView::albumSelected);
|
||||||
|
connect(m_secOther, &ArtistSection::albumSelected, this, &ArtistView::albumSelected);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArtistView::setArtist(const QJsonObject &artist)
|
||||||
|
{
|
||||||
|
m_artistId = static_cast<qint64>(artist["id"].toDouble());
|
||||||
|
setFaved(m_favArtistIds.contains(m_artistId));
|
||||||
|
|
||||||
|
m_nameLabel->setText(artist["name"].toObject()["display"].toString());
|
||||||
|
|
||||||
|
// Biography: strip HTML tags
|
||||||
|
const QString bioHtml = artist["biography"].toObject()["content"].toString();
|
||||||
|
if (!bioHtml.isEmpty()) {
|
||||||
|
QString plain = bioHtml;
|
||||||
|
plain.remove(QRegularExpression(QStringLiteral("<[^>]*>")));
|
||||||
|
plain.replace(QStringLiteral("&"), QStringLiteral("&"));
|
||||||
|
plain.replace(QStringLiteral("<"), QStringLiteral("<"));
|
||||||
|
plain.replace(QStringLiteral(">"), QStringLiteral(">"));
|
||||||
|
plain.replace(QStringLiteral("""), QStringLiteral("\""));
|
||||||
|
plain.replace(QStringLiteral("'"), QStringLiteral("'"));
|
||||||
|
plain.replace(QStringLiteral(" "), QStringLiteral(" "));
|
||||||
|
plain = plain.trimmed();
|
||||||
|
m_bioEdit->setPlainText(plain);
|
||||||
|
m_bioEdit->setVisible(!plain.isEmpty());
|
||||||
|
} else {
|
||||||
|
m_bioEdit->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Artist portrait: images.portrait.hash + format → CDN URL
|
||||||
|
const QJsonObject portrait = artist["images"].toObject()["portrait"].toObject();
|
||||||
|
const QString hash = portrait["hash"].toString();
|
||||||
|
const QString format = portrait["format"].toString();
|
||||||
|
QString artUrl;
|
||||||
|
if (!hash.isEmpty()) {
|
||||||
|
artUrl = QStringLiteral("https://static.qobuz.com/images/artists/covers/large/%1.%2")
|
||||||
|
.arg(hash, format.isEmpty() ? QStringLiteral("jpg") : format);
|
||||||
|
} else {
|
||||||
|
const QJsonObject img = artist["image"].toObject();
|
||||||
|
artUrl = img["large"].toString();
|
||||||
|
if (artUrl.isEmpty()) artUrl = img["small"].toString();
|
||||||
|
}
|
||||||
|
if (!artUrl.isEmpty() && artUrl != m_currentArtUrl) {
|
||||||
|
m_currentArtUrl = artUrl;
|
||||||
|
m_nam->get(QNetworkRequest(QUrl(artUrl)));
|
||||||
|
} else if (artUrl.isEmpty()) {
|
||||||
|
m_artLabel->setPixmap(QPixmap());
|
||||||
|
m_currentArtUrl.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Popular tracks (flat array)
|
||||||
|
const QJsonArray topTracks = artist["top_tracks"].toArray();
|
||||||
|
m_topTracks->loadTracks(topTracks);
|
||||||
|
|
||||||
|
const int ttCount = topTracks.size();
|
||||||
|
disconnect(m_topTracksToggle, &QPushButton::toggled, nullptr, nullptr);
|
||||||
|
connect(m_topTracksToggle, &QPushButton::toggled, m_topTracks, &QWidget::setVisible);
|
||||||
|
connect(m_topTracksToggle, &QPushButton::toggled, this, [this, ttCount](bool open) {
|
||||||
|
const QString a = open ? QStringLiteral("▼ ") : QStringLiteral("▶ ");
|
||||||
|
m_topTracksToggle->setText(ttCount > 0
|
||||||
|
? QStringLiteral("%1Popular Tracks (%2)").arg(a).arg(ttCount)
|
||||||
|
: a + tr("Popular Tracks"));
|
||||||
|
});
|
||||||
|
m_topTracksToggle->setChecked(true);
|
||||||
|
m_topTracks->setVisible(true);
|
||||||
|
m_topTracksToggle->setText(ttCount > 0
|
||||||
|
? QStringLiteral("▼ Popular Tracks (%1)").arg(ttCount)
|
||||||
|
: QStringLiteral("▼ Popular Tracks"));
|
||||||
|
m_topTracksSection->setVisible(!topTracks.isEmpty());
|
||||||
|
|
||||||
|
// Reset shuffle button state
|
||||||
|
m_shuffleBtn->setEnabled(true);
|
||||||
|
m_shuffleBtn->setText(tr("⇄ Shuffle All"));
|
||||||
|
|
||||||
|
// Clear release sections
|
||||||
|
for (ArtistSection *sec : {m_secAlbums, m_secEps, m_secLive, m_secCompilations, m_secOther}) {
|
||||||
|
sec->setAlbums({});
|
||||||
|
sec->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArtistView::setReleases(const QString &releaseType, const QJsonArray &items,
|
||||||
|
bool /*hasMore*/, int /*offset*/)
|
||||||
|
{
|
||||||
|
ArtistSection *sec = nullptr;
|
||||||
|
if (releaseType == QStringLiteral("album")) sec = m_secAlbums;
|
||||||
|
else if (releaseType == QStringLiteral("epSingle")) sec = m_secEps;
|
||||||
|
else if (releaseType == QStringLiteral("live")) sec = m_secLive;
|
||||||
|
else if (releaseType == QStringLiteral("compilation")) sec = m_secCompilations;
|
||||||
|
else sec = m_secOther;
|
||||||
|
|
||||||
|
// Rust auto-paginates, so we always get the full list at once
|
||||||
|
sec->setAlbums(items);
|
||||||
|
sec->setVisible(!sec->isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArtistView::setFavArtistIds(const QSet<qint64> &ids)
|
||||||
|
{
|
||||||
|
m_favArtistIds = ids;
|
||||||
|
if (m_artistId > 0)
|
||||||
|
setFaved(ids.contains(m_artistId));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArtistView::onDeepShuffleTracks(const QJsonArray &tracks)
|
||||||
|
{
|
||||||
|
m_shuffleBtn->setEnabled(true);
|
||||||
|
m_shuffleBtn->setText(tr("⇄ Shuffle All"));
|
||||||
|
|
||||||
|
if (tracks.isEmpty()) return;
|
||||||
|
|
||||||
|
m_queue->setContext(tracks, 0);
|
||||||
|
m_queue->shuffleNow();
|
||||||
|
|
||||||
|
const QJsonObject first = m_queue->current();
|
||||||
|
const qint64 id = static_cast<qint64>(first["id"].toDouble());
|
||||||
|
if (id > 0)
|
||||||
|
emit playTrackRequested(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList ArtistView::allAlbumIds() const
|
||||||
|
{
|
||||||
|
QStringList ids;
|
||||||
|
for (const ArtistSection *sec : {m_secAlbums, m_secEps, m_secLive, m_secCompilations, m_secOther})
|
||||||
|
ids.append(sec->albumIds());
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArtistView::setFaved(bool faved)
|
||||||
|
{
|
||||||
|
m_isFaved = faved;
|
||||||
|
if (faved) {
|
||||||
|
m_favBtn->setText(tr("♥ Favourited"));
|
||||||
|
m_favBtn->setStyleSheet(kBtnBase +
|
||||||
|
QStringLiteral("QPushButton { background: #2a2a2a; color: #FFB232; border: 1px solid #FFB232; }"
|
||||||
|
"QPushButton:pressed { background: #333; }"));
|
||||||
|
} else {
|
||||||
|
m_favBtn->setText(tr("♡ Favourite"));
|
||||||
|
m_favBtn->setStyleSheet(kBtnBase +
|
||||||
|
QStringLiteral("QPushButton { background: #2a2a2a; color: #ccc; border: 1px solid #555; }"
|
||||||
|
"QPushButton:pressed { background: #333; }"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,64 +1,93 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "albumlistview.hpp"
|
#include "albumlistview.hpp"
|
||||||
|
#include "../list/tracks.hpp"
|
||||||
|
#include "../backend/qobuzbackend.hpp"
|
||||||
|
#include "../playqueue.hpp"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QFont>
|
#include <QTextEdit>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
/// Artist detail page: name, biography summary, and their album list.
|
class AlbumListView;
|
||||||
class ArtistView : public QWidget
|
|
||||||
|
/// One collapsible section (Albums / EPs / Live / etc.) inside ArtistView.
|
||||||
|
class ArtistSection : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ArtistView(QWidget *parent = nullptr) : QWidget(parent)
|
explicit ArtistSection(const QString &title, const QString &releaseType, QWidget *parent = nullptr);
|
||||||
{
|
|
||||||
auto *layout = new QVBoxLayout(this);
|
|
||||||
layout->setContentsMargins(8, 8, 8, 8);
|
|
||||||
layout->setSpacing(6);
|
|
||||||
|
|
||||||
m_nameLabel = new QLabel(this);
|
void setAlbums(const QJsonArray &albums);
|
||||||
QFont f = m_nameLabel->font();
|
bool isEmpty() const;
|
||||||
f.setPointSize(f.pointSize() + 4);
|
QStringList albumIds() const;
|
||||||
f.setBold(true);
|
void setArtistPageMode();
|
||||||
m_nameLabel->setFont(f);
|
|
||||||
|
|
||||||
m_bioLabel = new QLabel(this);
|
|
||||||
m_bioLabel->setWordWrap(true);
|
|
||||||
m_bioLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
||||||
m_bioLabel->setMaximumHeight(80);
|
|
||||||
|
|
||||||
m_albums = new AlbumListView(this);
|
|
||||||
|
|
||||||
layout->addWidget(m_nameLabel);
|
|
||||||
layout->addWidget(m_bioLabel);
|
|
||||||
layout->addWidget(m_albums, 1);
|
|
||||||
|
|
||||||
connect(m_albums, &AlbumListView::albumSelected,
|
|
||||||
this, &ArtistView::albumSelected);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setArtist(const QJsonObject &artist)
|
|
||||||
{
|
|
||||||
m_nameLabel->setText(artist["name"].toString());
|
|
||||||
|
|
||||||
const QString summary = artist["biography"].toObject()["summary"].toString();
|
|
||||||
m_bioLabel->setText(summary);
|
|
||||||
m_bioLabel->setVisible(!summary.isEmpty());
|
|
||||||
|
|
||||||
const QJsonArray albums = artist["albums"].toObject()["items"].toArray();
|
|
||||||
m_albums->setAlbums(albums);
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void albumSelected(const QString &albumId);
|
void albumSelected(const QString &albumId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel *m_nameLabel = nullptr;
|
QString m_baseTitle;
|
||||||
QLabel *m_bioLabel = nullptr;
|
QString m_releaseType;
|
||||||
AlbumListView *m_albums = nullptr;
|
QPushButton *m_toggle = nullptr;
|
||||||
|
AlbumListView *m_list = nullptr;
|
||||||
|
|
||||||
|
void updateToggleText();
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Artist detail page.
|
||||||
|
class ArtistView : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ArtistView(QobuzBackend *backend, PlayQueue *queue, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
void setArtist(const QJsonObject &artist);
|
||||||
|
void setReleases(const QString &releaseType, const QJsonArray &items,
|
||||||
|
bool hasMore = false, int offset = 0);
|
||||||
|
void setFavArtistIds(const QSet<qint64> &ids);
|
||||||
|
void onDeepShuffleTracks(const QJsonArray &tracks);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void albumSelected(const QString &albumId);
|
||||||
|
void playTrackRequested(qint64 trackId);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QobuzBackend *m_backend = nullptr;
|
||||||
|
PlayQueue *m_queue = nullptr;
|
||||||
|
qint64 m_artistId = 0;
|
||||||
|
|
||||||
|
// Header widgets
|
||||||
|
QLabel *m_artLabel = nullptr;
|
||||||
|
QLabel *m_nameLabel = nullptr;
|
||||||
|
QTextEdit *m_bioEdit = nullptr;
|
||||||
|
QPushButton *m_playBtn = nullptr;
|
||||||
|
QPushButton *m_shuffleTopBtn = nullptr;
|
||||||
|
QPushButton *m_shuffleBtn = nullptr;
|
||||||
|
QPushButton *m_favBtn = nullptr;
|
||||||
|
QNetworkAccessManager *m_nam = nullptr;
|
||||||
|
QString m_currentArtUrl;
|
||||||
|
bool m_isFaved = false;
|
||||||
|
QSet<qint64> m_favArtistIds;
|
||||||
|
|
||||||
|
// Popular tracks section
|
||||||
|
QWidget *m_topTracksSection = nullptr;
|
||||||
|
QPushButton *m_topTracksToggle = nullptr;
|
||||||
|
List::Tracks *m_topTracks = nullptr;
|
||||||
|
|
||||||
|
// Release sections
|
||||||
|
ArtistSection *m_secAlbums = nullptr;
|
||||||
|
ArtistSection *m_secEps = nullptr;
|
||||||
|
ArtistSection *m_secLive = nullptr;
|
||||||
|
ArtistSection *m_secCompilations = nullptr;
|
||||||
|
ArtistSection *m_secOther = nullptr;
|
||||||
|
|
||||||
|
QStringList allAlbumIds() const;
|
||||||
|
void setFaved(bool faved);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,11 +22,7 @@ View::View(QobuzBackend *backend, QWidget *parent)
|
|||||||
layout->setContentsMargins(8, 8, 8, 8);
|
layout->setContentsMargins(8, 8, 8, 8);
|
||||||
layout->setSpacing(6);
|
layout->setSpacing(6);
|
||||||
|
|
||||||
m_albumArt = new QLabel(container);
|
m_albumArt = new ArtWidget(container);
|
||||||
m_albumArt->setAlignment(Qt::AlignCenter);
|
|
||||||
m_albumArt->setStyleSheet(QStringLiteral(
|
|
||||||
"background: #1a1a1a; border-radius: 4px;"));
|
|
||||||
m_albumArt->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
||||||
layout->addWidget(m_albumArt);
|
layout->addWidget(m_albumArt);
|
||||||
|
|
||||||
m_title = new QLabel(tr("Not playing"), container);
|
m_title = new QLabel(tr("Not playing"), container);
|
||||||
@@ -45,7 +41,6 @@ View::View(QobuzBackend *backend, QWidget *parent)
|
|||||||
|
|
||||||
layout->addStretch();
|
layout->addStretch();
|
||||||
setWidget(container);
|
setWidget(container);
|
||||||
setMinimumWidth(160);
|
|
||||||
|
|
||||||
connect(m_backend, &QobuzBackend::trackChanged, this, &View::onTrackChanged);
|
connect(m_backend, &QobuzBackend::trackChanged, this, &View::onTrackChanged);
|
||||||
}
|
}
|
||||||
@@ -60,7 +55,6 @@ void View::onTrackChanged(const QJsonObject &track)
|
|||||||
m_title->setText(title.isEmpty() ? tr("Not playing") : title);
|
m_title->setText(title.isEmpty() ? tr("Not playing") : title);
|
||||||
m_artist->setText(artist);
|
m_artist->setText(artist);
|
||||||
|
|
||||||
// Prefer "large" image, fall back to "small"
|
|
||||||
const QJsonObject img = track["album"].toObject()["image"].toObject();
|
const QJsonObject img = track["album"].toObject()["image"].toObject();
|
||||||
QString artUrl = img["large"].toString();
|
QString artUrl = img["large"].toString();
|
||||||
if (artUrl.isEmpty())
|
if (artUrl.isEmpty())
|
||||||
@@ -77,26 +71,9 @@ void View::onArtReady(QNetworkReply *reply)
|
|||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
if (reply->error() != QNetworkReply::NoError)
|
if (reply->error() != QNetworkReply::NoError)
|
||||||
return;
|
return;
|
||||||
if (m_artPixmap.loadFromData(reply->readAll()))
|
QPixmap pix;
|
||||||
scaleArtToWidth();
|
if (pix.loadFromData(reply->readAll()))
|
||||||
}
|
m_albumArt->setPixmap(pix);
|
||||||
|
|
||||||
void View::resizeEvent(QResizeEvent *event)
|
|
||||||
{
|
|
||||||
QDockWidget::resizeEvent(event);
|
|
||||||
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;
|
|
||||||
const int side = qMax(32, width() - 16);
|
|
||||||
m_albumArt->setFixedHeight(side);
|
|
||||||
m_albumArt->setPixmap(m_artPixmap.scaled(side, side, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Context
|
} // namespace Context
|
||||||
|
|||||||
@@ -3,15 +3,49 @@
|
|||||||
#include "../../backend/qobuzbackend.hpp"
|
#include "../../backend/qobuzbackend.hpp"
|
||||||
|
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
|
#include <QWidget>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QResizeEvent>
|
#include <QPainter>
|
||||||
|
#include <QPaintEvent>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
namespace Context
|
namespace Context
|
||||||
{
|
{
|
||||||
|
/// Square art widget: always as wide as its parent allows, height follows width.
|
||||||
|
class ArtWidget : public QWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ArtWidget(QWidget *parent = nullptr) : QWidget(parent)
|
||||||
|
{
|
||||||
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPixmap(const QPixmap &px) { m_pix = px; update(); }
|
||||||
|
bool hasHeightForWidth() const override { return true; }
|
||||||
|
int heightForWidth(int w) const override { return w; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *) override
|
||||||
|
{
|
||||||
|
QPainter p(this);
|
||||||
|
if (m_pix.isNull()) {
|
||||||
|
p.fillRect(rect(), QColor(0x1a, 0x1a, 0x1a));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const QPixmap scaled = m_pix.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
p.fillRect(rect(), QColor(0x1a, 0x1a, 0x1a));
|
||||||
|
p.drawPixmap((width() - scaled.width()) / 2,
|
||||||
|
(height() - scaled.height()) / 2,
|
||||||
|
scaled);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPixmap m_pix;
|
||||||
|
};
|
||||||
|
|
||||||
class View : public QDockWidget
|
class View : public QDockWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -23,18 +57,12 @@ namespace Context
|
|||||||
void onTrackChanged(const QJsonObject &track);
|
void onTrackChanged(const QJsonObject &track);
|
||||||
void onArtReady(QNetworkReply *reply);
|
void onArtReady(QNetworkReply *reply);
|
||||||
|
|
||||||
protected:
|
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void scaleArtToWidth();
|
|
||||||
|
|
||||||
QobuzBackend *m_backend = nullptr;
|
QobuzBackend *m_backend = nullptr;
|
||||||
QLabel *m_albumArt = nullptr;
|
ArtWidget *m_albumArt = nullptr;
|
||||||
QLabel *m_title = nullptr;
|
QLabel *m_title = nullptr;
|
||||||
QLabel *m_artist = nullptr;
|
QLabel *m_artist = nullptr;
|
||||||
QNetworkAccessManager *m_nam = nullptr;
|
QNetworkAccessManager *m_nam = nullptr;
|
||||||
QString m_currentArtUrl;
|
QString m_currentArtUrl;
|
||||||
QPixmap m_artPixmap;
|
|
||||||
};
|
};
|
||||||
} // namespace Context
|
} // namespace Context
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ MainContent::MainContent(QobuzBackend *backend, PlayQueue *queue, QWidget *paren
|
|||||||
m_welcome = new QLabel(
|
m_welcome = new QLabel(
|
||||||
tr("<h2>Welcome to Qobuz</h2>"
|
tr("<h2>Welcome to Qobuz</h2>"
|
||||||
"<p>Select something from the library on the left to get started,<br>"
|
"<p>Select something from the library on the left to get started,<br>"
|
||||||
"or use the search panel (🔍) to find music.</p>"),
|
"or use the search panel to find music.</p>"),
|
||||||
this);
|
this);
|
||||||
m_welcome->setAlignment(Qt::AlignCenter);
|
m_welcome->setAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
@@ -36,10 +36,15 @@ MainContent::MainContent(QobuzBackend *backend, PlayQueue *queue, QWidget *paren
|
|||||||
[this] { m_tracks->playAll(false); });
|
[this] { m_tracks->playAll(false); });
|
||||||
QObject::connect(m_header->shuffleButton(), &QPushButton::clicked,
|
QObject::connect(m_header->shuffleButton(), &QPushButton::clicked,
|
||||||
[this] { m_tracks->playAll(true); });
|
[this] { m_tracks->playAll(true); });
|
||||||
|
QObject::connect(m_header->subtitleButton(), &QPushButton::clicked,
|
||||||
|
[this] {
|
||||||
|
const qint64 id = m_header->artistId();
|
||||||
|
if (id > 0) emit artistRequested(id);
|
||||||
|
});
|
||||||
|
|
||||||
m_albumList = new AlbumListView(this);
|
m_albumList = new AlbumListView(this);
|
||||||
m_artistList = new ArtistListView(this);
|
m_artistList = new ArtistListView(this);
|
||||||
m_artistView = new ArtistView(this);
|
m_artistView = new ArtistView(backend, queue, this);
|
||||||
|
|
||||||
m_stack->addWidget(m_welcome); // 0
|
m_stack->addWidget(m_welcome); // 0
|
||||||
m_stack->addWidget(tracksPage); // 1
|
m_stack->addWidget(tracksPage); // 1
|
||||||
@@ -52,6 +57,7 @@ MainContent::MainContent(QobuzBackend *backend, PlayQueue *queue, QWidget *paren
|
|||||||
connect(m_albumList, &AlbumListView::albumSelected, this, &MainContent::albumRequested);
|
connect(m_albumList, &AlbumListView::albumSelected, this, &MainContent::albumRequested);
|
||||||
connect(m_artistList, &ArtistListView::artistSelected, this, &MainContent::artistRequested);
|
connect(m_artistList, &ArtistListView::artistSelected, this, &MainContent::artistRequested);
|
||||||
connect(m_artistView, &ArtistView::albumSelected, this, &MainContent::albumRequested);
|
connect(m_artistView, &ArtistView::albumSelected, this, &MainContent::albumRequested);
|
||||||
|
connect(m_artistView, &ArtistView::playTrackRequested, this, &MainContent::playTrackRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainContent::showWelcome() { m_stack->setCurrentIndex(0); }
|
void MainContent::showWelcome() { m_stack->setCurrentIndex(0); }
|
||||||
@@ -101,3 +107,18 @@ void MainContent::showArtist(const QJsonObject &artist)
|
|||||||
m_artistView->setArtist(artist);
|
m_artistView->setArtist(artist);
|
||||||
m_stack->setCurrentIndex(4);
|
m_stack->setCurrentIndex(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainContent::updateArtistReleases(const QString &releaseType, const QJsonArray &items, bool hasMore, int offset)
|
||||||
|
{
|
||||||
|
m_artistView->setReleases(releaseType, items, hasMore, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainContent::setFavArtistIds(const QSet<qint64> &ids)
|
||||||
|
{
|
||||||
|
m_artistView->setFavArtistIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainContent::onDeepShuffleTracks(const QJsonArray &tracks)
|
||||||
|
{
|
||||||
|
m_artistView->onDeepShuffleTracks(tracks);
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,10 +31,16 @@ public:
|
|||||||
void showFavAlbums(const QJsonObject &result);
|
void showFavAlbums(const QJsonObject &result);
|
||||||
void showFavArtists(const QJsonObject &result);
|
void showFavArtists(const QJsonObject &result);
|
||||||
void showArtist(const QJsonObject &artist);
|
void showArtist(const QJsonObject &artist);
|
||||||
|
void updateArtistReleases(const QString &releaseType, const QJsonArray &items, bool hasMore, int offset);
|
||||||
|
void setFavArtistIds(const QSet<qint64> &ids);
|
||||||
|
void onDeepShuffleTracks(const QJsonArray &tracks);
|
||||||
|
|
||||||
|
ArtistView *artistView() const { return m_artistView; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void albumRequested(const QString &albumId);
|
void albumRequested(const QString &albumId);
|
||||||
void artistRequested(qint64 artistId);
|
void artistRequested(qint64 artistId);
|
||||||
|
void playTrackRequested(qint64 trackId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QobuzBackend *m_backend = nullptr;
|
QobuzBackend *m_backend = nullptr;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
MainToolBar::MainToolBar(QobuzBackend *backend, PlayQueue *queue, QWidget *parent)
|
MainToolBar::MainToolBar(QobuzBackend *backend, PlayQueue *queue, QWidget *parent)
|
||||||
: QToolBar(parent)
|
: QToolBar(parent)
|
||||||
@@ -34,6 +35,22 @@ MainToolBar::MainToolBar(QobuzBackend *backend, PlayQueue *queue, QWidget *paren
|
|||||||
m_trackLabel->setTextFormat(Qt::RichText);
|
m_trackLabel->setTextFormat(Qt::RichText);
|
||||||
addWidget(m_trackLabel);
|
addWidget(m_trackLabel);
|
||||||
|
|
||||||
|
m_trackLabel->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(m_trackLabel, &QLabel::customContextMenuRequested,
|
||||||
|
this, [this](const QPoint &pos) {
|
||||||
|
if (m_currentTrack.isEmpty()) return;
|
||||||
|
QMenu menu(this);
|
||||||
|
const QString albumId = m_currentTrack["album"].toObject()["id"].toString();
|
||||||
|
const qint64 artistId = static_cast<qint64>(
|
||||||
|
m_currentTrack["performer"].toObject()["id"].toDouble());
|
||||||
|
if (!albumId.isEmpty())
|
||||||
|
menu.addAction(tr("Go to Album"), this, [this, albumId] { emit albumRequested(albumId); });
|
||||||
|
if (artistId > 0)
|
||||||
|
menu.addAction(tr("Go to Artist"), this, [this, artistId] { emit artistRequested(artistId); });
|
||||||
|
if (!menu.isEmpty())
|
||||||
|
menu.exec(m_trackLabel->mapToGlobal(pos));
|
||||||
|
});
|
||||||
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
|
||||||
// ---- Media controls ----
|
// ---- Media controls ----
|
||||||
@@ -125,6 +142,7 @@ void MainToolBar::setPlaying(bool playing)
|
|||||||
|
|
||||||
void MainToolBar::setCurrentTrack(const QJsonObject &track)
|
void MainToolBar::setCurrentTrack(const QJsonObject &track)
|
||||||
{
|
{
|
||||||
|
m_currentTrack = track;
|
||||||
const QString title = track["title"].toString();
|
const QString title = track["title"].toString();
|
||||||
const QString artist = track["performer"].toObject()["name"].toString().isEmpty()
|
const QString artist = track["performer"].toObject()["name"].toString().isEmpty()
|
||||||
? track["album"].toObject()["artist"].toObject()["name"].toString()
|
? track["album"].toObject()["artist"].toObject()["name"].toString()
|
||||||
@@ -150,8 +168,8 @@ void MainToolBar::setCurrentTrack(const QJsonObject &track)
|
|||||||
void MainToolBar::updateProgress(quint64 position, quint64 duration)
|
void MainToolBar::updateProgress(quint64 position, quint64 duration)
|
||||||
{
|
{
|
||||||
if (m_seeking) return;
|
if (m_seeking) return;
|
||||||
const int sliderPos = duration > 0
|
const int sliderPos = (duration > 0)
|
||||||
? static_cast<int>(position * 1000 / duration) : 0;
|
? static_cast<int>(qMin(position * 1000 / duration, quint64(1000))) : 0;
|
||||||
m_progress->blockSignals(true);
|
m_progress->blockSignals(true);
|
||||||
m_progress->setValue(sliderPos);
|
m_progress->setValue(sliderPos);
|
||||||
m_progress->blockSignals(false);
|
m_progress->blockSignals(false);
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void searchToggled(bool visible);
|
void searchToggled(bool visible);
|
||||||
void queueToggled(bool visible);
|
void queueToggled(bool visible);
|
||||||
|
void albumRequested(const QString &albumId);
|
||||||
|
void artistRequested(qint64 artistId);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
@@ -68,6 +70,7 @@ private:
|
|||||||
|
|
||||||
QNetworkAccessManager *m_nam = nullptr;
|
QNetworkAccessManager *m_nam = nullptr;
|
||||||
QString m_currentArtUrl;
|
QString m_currentArtUrl;
|
||||||
|
QJsonObject m_currentTrack;
|
||||||
bool m_playing = false;
|
bool m_playing = false;
|
||||||
bool m_seeking = false;
|
bool m_seeking = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -173,7 +173,9 @@ void QueuePanel::refresh()
|
|||||||
|
|
||||||
for (int i = 0; i < upcoming.size(); ++i) {
|
for (int i = 0; i < upcoming.size(); ++i) {
|
||||||
const QJsonObject &t = upcoming.at(i);
|
const QJsonObject &t = upcoming.at(i);
|
||||||
const QString title = t["title"].toString();
|
const QString base = t["title"].toString();
|
||||||
|
const QString ver = t["version"].toString().trimmed();
|
||||||
|
const QString title = ver.isEmpty() ? base : base + QStringLiteral(" (") + ver + QLatin1Char(')');
|
||||||
const QString artist = t["performer"].toObject()["name"].toString().isEmpty()
|
const QString artist = t["performer"].toObject()["name"].toString().isEmpty()
|
||||||
? t["album"].toObject()["artist"].toObject()["name"].toString()
|
? t["album"].toObject()["artist"].toObject()["name"].toString()
|
||||||
: t["performer"].toObject()["name"].toString();
|
: t["performer"].toObject()["name"].toString();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "view.hpp"
|
#include "view.hpp"
|
||||||
|
#include "../../util/trackinfo.hpp"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
@@ -6,18 +7,21 @@
|
|||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
static constexpr int IdRole = Qt::UserRole + 1;
|
static constexpr int IdRole = Qt::UserRole + 1;
|
||||||
static constexpr int TypeRole = Qt::UserRole + 2;
|
static constexpr int TypeRole = Qt::UserRole + 2;
|
||||||
|
static constexpr int JsonRole = Qt::UserRole + 3;
|
||||||
|
|
||||||
namespace SidePanel
|
namespace SidePanel
|
||||||
{
|
{
|
||||||
|
|
||||||
// ---- SearchTab ----
|
// ---- SearchTab ----
|
||||||
|
|
||||||
SearchTab::SearchTab(QobuzBackend *backend, QWidget *parent)
|
SearchTab::SearchTab(QobuzBackend *backend, PlayQueue *queue, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_backend(backend)
|
, m_backend(backend)
|
||||||
|
, m_queue(queue)
|
||||||
{
|
{
|
||||||
auto *layout = new QVBoxLayout(this);
|
auto *layout = new QVBoxLayout(this);
|
||||||
layout->setContentsMargins(4, 4, 4, 4);
|
layout->setContentsMargins(4, 4, 4, 4);
|
||||||
@@ -25,7 +29,7 @@ SearchTab::SearchTab(QobuzBackend *backend, QWidget *parent)
|
|||||||
// Search bar
|
// Search bar
|
||||||
auto *barLayout = new QHBoxLayout;
|
auto *barLayout = new QHBoxLayout;
|
||||||
m_searchBox = new QLineEdit(this);
|
m_searchBox = new QLineEdit(this);
|
||||||
m_searchBox->setPlaceholderText(tr("Search Qobuz…"));
|
m_searchBox->setPlaceholderText(tr("Search Qobuz..."));
|
||||||
m_searchBox->setClearButtonEnabled(true);
|
m_searchBox->setClearButtonEnabled(true);
|
||||||
auto *searchBtn = new QPushButton(tr("Go"), this);
|
auto *searchBtn = new QPushButton(tr("Go"), this);
|
||||||
barLayout->addWidget(m_searchBox);
|
barLayout->addWidget(m_searchBox);
|
||||||
@@ -38,6 +42,7 @@ SearchTab::SearchTab(QobuzBackend *backend, QWidget *parent)
|
|||||||
m_trackResults = new QTreeWidget(this);
|
m_trackResults = new QTreeWidget(this);
|
||||||
m_trackResults->setHeaderLabels({tr("Title"), tr("Artist"), tr("Album")});
|
m_trackResults->setHeaderLabels({tr("Title"), tr("Artist"), tr("Album")});
|
||||||
m_trackResults->setRootIsDecorated(false);
|
m_trackResults->setRootIsDecorated(false);
|
||||||
|
m_trackResults->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
m_albumResults = new QTreeWidget(this);
|
m_albumResults = new QTreeWidget(this);
|
||||||
m_albumResults->setHeaderLabels({tr(""), tr("Album"), tr("Artist")});
|
m_albumResults->setHeaderLabels({tr(""), tr("Album"), tr("Artist")});
|
||||||
@@ -46,6 +51,7 @@ SearchTab::SearchTab(QobuzBackend *backend, QWidget *parent)
|
|||||||
m_albumResults->header()->setSectionResizeMode(1, QHeaderView::Stretch);
|
m_albumResults->header()->setSectionResizeMode(1, QHeaderView::Stretch);
|
||||||
m_albumResults->header()->setSectionResizeMode(2, QHeaderView::Stretch);
|
m_albumResults->header()->setSectionResizeMode(2, QHeaderView::Stretch);
|
||||||
m_albumResults->header()->setStretchLastSection(false);
|
m_albumResults->header()->setStretchLastSection(false);
|
||||||
|
m_albumResults->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
m_artistResults = new QTreeWidget(this);
|
m_artistResults = new QTreeWidget(this);
|
||||||
m_artistResults->setHeaderLabels({tr("Artist")});
|
m_artistResults->setHeaderLabels({tr("Artist")});
|
||||||
@@ -64,6 +70,17 @@ SearchTab::SearchTab(QobuzBackend *backend, QWidget *parent)
|
|||||||
connect(m_trackResults, &QTreeWidget::itemDoubleClicked, this, &SearchTab::onItemDoubleClicked);
|
connect(m_trackResults, &QTreeWidget::itemDoubleClicked, this, &SearchTab::onItemDoubleClicked);
|
||||||
connect(m_albumResults, &QTreeWidget::itemDoubleClicked, this, &SearchTab::onItemDoubleClicked);
|
connect(m_albumResults, &QTreeWidget::itemDoubleClicked, this, &SearchTab::onItemDoubleClicked);
|
||||||
connect(m_artistResults, &QTreeWidget::itemDoubleClicked, this, &SearchTab::onItemDoubleClicked);
|
connect(m_artistResults, &QTreeWidget::itemDoubleClicked, this, &SearchTab::onItemDoubleClicked);
|
||||||
|
|
||||||
|
// Context menus
|
||||||
|
connect(m_trackResults, &QTreeWidget::customContextMenuRequested,
|
||||||
|
this, &SearchTab::onTrackContextMenu);
|
||||||
|
connect(m_albumResults, &QTreeWidget::customContextMenuRequested,
|
||||||
|
this, &SearchTab::onAlbumContextMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchTab::setUserPlaylists(const QVector<QPair<qint64, QString>> &playlists)
|
||||||
|
{
|
||||||
|
m_userPlaylists = playlists;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchTab::onSearchSubmit()
|
void SearchTab::onSearchSubmit()
|
||||||
@@ -86,6 +103,7 @@ void SearchTab::onSearchResult(const QJsonObject &result)
|
|||||||
QStringList{t["title"].toString(), performer, album});
|
QStringList{t["title"].toString(), performer, album});
|
||||||
item->setData(0, IdRole, static_cast<qint64>(t["id"].toDouble()));
|
item->setData(0, IdRole, static_cast<qint64>(t["id"].toDouble()));
|
||||||
item->setData(0, TypeRole, QStringLiteral("track"));
|
item->setData(0, TypeRole, QStringLiteral("track"));
|
||||||
|
item->setData(0, JsonRole, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate albums
|
// Populate albums
|
||||||
@@ -109,8 +127,9 @@ void SearchTab::onSearchResult(const QJsonObject &result)
|
|||||||
item->setFont(0, hiResFont);
|
item->setFont(0, hiResFont);
|
||||||
item->setTextAlignment(0, Qt::AlignCenter);
|
item->setTextAlignment(0, Qt::AlignCenter);
|
||||||
}
|
}
|
||||||
item->setData(0, TypeRole, QStringLiteral("album")); // handler reads col 0
|
item->setData(0, TypeRole, QStringLiteral("album"));
|
||||||
item->setData(1, IdRole, a["id"].toString());
|
item->setData(1, IdRole, a["id"].toString());
|
||||||
|
item->setData(0, JsonRole, a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,20 +159,135 @@ void SearchTab::onItemDoubleClicked(QTreeWidgetItem *item, int)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchTab::onTrackContextMenu(const QPoint &pos)
|
||||||
|
{
|
||||||
|
auto *item = m_trackResults->itemAt(pos);
|
||||||
|
if (!item) return;
|
||||||
|
|
||||||
|
const qint64 trackId = item->data(0, IdRole).toLongLong();
|
||||||
|
const QJsonObject trackJson = item->data(0, JsonRole).toJsonObject();
|
||||||
|
if (trackId <= 0) return;
|
||||||
|
|
||||||
|
QMenu menu(this);
|
||||||
|
|
||||||
|
auto *playNow = menu.addAction(tr("Play now"));
|
||||||
|
auto *playNext = menu.addAction(tr("Play next"));
|
||||||
|
auto *addQueue = menu.addAction(tr("Add to queue"));
|
||||||
|
menu.addSeparator();
|
||||||
|
|
||||||
|
auto *addFav = menu.addAction(tr("Add to favorites"));
|
||||||
|
|
||||||
|
// Open album / artist
|
||||||
|
const QString albumId = trackJson["album"].toObject()["id"].toString();
|
||||||
|
const qint64 artistId = static_cast<qint64>(
|
||||||
|
trackJson["performer"].toObject()["id"].toDouble());
|
||||||
|
const QString artistName = trackJson["performer"].toObject()["name"].toString();
|
||||||
|
const QString albumTitle = trackJson["album"].toObject()["title"].toString();
|
||||||
|
|
||||||
|
menu.addSeparator();
|
||||||
|
if (!albumId.isEmpty()) {
|
||||||
|
auto *openAlbum = menu.addAction(tr("Go to album: %1").arg(albumTitle));
|
||||||
|
connect(openAlbum, &QAction::triggered, this, [this, albumId] {
|
||||||
|
emit albumSelected(albumId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (artistId > 0) {
|
||||||
|
auto *openArtist = menu.addAction(tr("Go to artist: %1").arg(artistName));
|
||||||
|
connect(openArtist, &QAction::triggered, this, [this, artistId] {
|
||||||
|
emit artistSelected(artistId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add to playlist submenu
|
||||||
|
if (!m_userPlaylists.isEmpty()) {
|
||||||
|
menu.addSeparator();
|
||||||
|
auto *plMenu = menu.addMenu(tr("Add to playlist"));
|
||||||
|
for (const auto &pl : m_userPlaylists) {
|
||||||
|
auto *act = plMenu->addAction(pl.second);
|
||||||
|
connect(act, &QAction::triggered, this, [this, trackId, plId = pl.first] {
|
||||||
|
emit addToPlaylistRequested(trackId, plId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track info
|
||||||
|
menu.addSeparator();
|
||||||
|
auto *info = menu.addAction(tr("Track info..."));
|
||||||
|
|
||||||
|
connect(playNow, &QAction::triggered, this, [this, trackId] {
|
||||||
|
emit trackPlayRequested(trackId);
|
||||||
|
});
|
||||||
|
connect(playNext, &QAction::triggered, this, [this, trackJson] {
|
||||||
|
m_queue->playNext(trackJson);
|
||||||
|
});
|
||||||
|
connect(addQueue, &QAction::triggered, this, [this, trackJson] {
|
||||||
|
m_queue->addToQueue(trackJson);
|
||||||
|
});
|
||||||
|
connect(addFav, &QAction::triggered, this, [this, trackId] {
|
||||||
|
m_backend->addFavTrack(trackId);
|
||||||
|
});
|
||||||
|
connect(info, &QAction::triggered, this, [this, trackJson] {
|
||||||
|
showTrackInfo(trackJson);
|
||||||
|
});
|
||||||
|
|
||||||
|
menu.exec(m_trackResults->viewport()->mapToGlobal(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchTab::onAlbumContextMenu(const QPoint &pos)
|
||||||
|
{
|
||||||
|
auto *item = m_albumResults->itemAt(pos);
|
||||||
|
if (!item) return;
|
||||||
|
|
||||||
|
const QString albumId = item->data(1, IdRole).toString();
|
||||||
|
const QJsonObject albumJson = item->data(0, JsonRole).toJsonObject();
|
||||||
|
if (albumId.isEmpty()) return;
|
||||||
|
|
||||||
|
QMenu menu(this);
|
||||||
|
|
||||||
|
auto *openAlbum = menu.addAction(tr("Open album"));
|
||||||
|
auto *addFav = menu.addAction(tr("Add to favorites"));
|
||||||
|
|
||||||
|
const qint64 artistId = static_cast<qint64>(
|
||||||
|
albumJson["artist"].toObject()["id"].toDouble());
|
||||||
|
const QString artistName = albumJson["artist"].toObject()["name"].toString();
|
||||||
|
if (artistId > 0) {
|
||||||
|
menu.addSeparator();
|
||||||
|
auto *openArtist = menu.addAction(tr("Go to artist: %1").arg(artistName));
|
||||||
|
connect(openArtist, &QAction::triggered, this, [this, artistId] {
|
||||||
|
emit artistSelected(artistId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(openAlbum, &QAction::triggered, this, [this, albumId] {
|
||||||
|
emit albumSelected(albumId);
|
||||||
|
});
|
||||||
|
connect(addFav, &QAction::triggered, this, [this, albumId] {
|
||||||
|
m_backend->addFavAlbum(albumId);
|
||||||
|
});
|
||||||
|
|
||||||
|
menu.exec(m_albumResults->viewport()->mapToGlobal(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchTab::showTrackInfo(const QJsonObject &track)
|
||||||
|
{
|
||||||
|
TrackInfoDialog::show(track, this);
|
||||||
|
}
|
||||||
|
|
||||||
// ---- View ----
|
// ---- View ----
|
||||||
|
|
||||||
View::View(QobuzBackend *backend, QWidget *parent)
|
View::View(QobuzBackend *backend, PlayQueue *queue, QWidget *parent)
|
||||||
: QDockWidget(tr("Search"), parent)
|
: QDockWidget(tr("Search"), parent)
|
||||||
{
|
{
|
||||||
setObjectName(QStringLiteral("searchPanel"));
|
setObjectName(QStringLiteral("searchPanel"));
|
||||||
setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable);
|
setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable);
|
||||||
|
|
||||||
m_search = new SearchTab(backend, this);
|
m_search = new SearchTab(backend, queue, this);
|
||||||
setWidget(m_search);
|
setWidget(m_search);
|
||||||
|
|
||||||
connect(m_search, &SearchTab::albumSelected, this, &View::albumSelected);
|
connect(m_search, &SearchTab::albumSelected, this, &View::albumSelected);
|
||||||
connect(m_search, &SearchTab::artistSelected, this, &View::artistSelected);
|
connect(m_search, &SearchTab::artistSelected, this, &View::artistSelected);
|
||||||
connect(m_search, &SearchTab::trackPlayRequested, this, &View::trackPlayRequested);
|
connect(m_search, &SearchTab::trackPlayRequested, this, &View::trackPlayRequested);
|
||||||
|
connect(m_search, &SearchTab::addToPlaylistRequested, this, &View::addToPlaylistRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace SidePanel
|
} // namespace SidePanel
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../backend/qobuzbackend.hpp"
|
#include "../../backend/qobuzbackend.hpp"
|
||||||
|
#include "../../playqueue.hpp"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
@@ -8,6 +9,8 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QPair>
|
||||||
|
|
||||||
namespace SidePanel
|
namespace SidePanel
|
||||||
{
|
{
|
||||||
@@ -15,12 +18,15 @@ namespace SidePanel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SearchTab(QobuzBackend *backend, QWidget *parent = nullptr);
|
explicit SearchTab(QobuzBackend *backend, PlayQueue *queue, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
void setUserPlaylists(const QVector<QPair<qint64, QString>> &playlists);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void albumSelected(const QString &albumId);
|
void albumSelected(const QString &albumId);
|
||||||
void artistSelected(qint64 artistId);
|
void artistSelected(qint64 artistId);
|
||||||
void trackPlayRequested(qint64 trackId);
|
void trackPlayRequested(qint64 trackId);
|
||||||
|
void addToPlaylistRequested(qint64 trackId, qint64 playlistId);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSearchResult(const QJsonObject &result);
|
void onSearchResult(const QJsonObject &result);
|
||||||
@@ -29,18 +35,24 @@ namespace SidePanel
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QobuzBackend *m_backend = nullptr;
|
QobuzBackend *m_backend = nullptr;
|
||||||
|
PlayQueue *m_queue = nullptr;
|
||||||
QLineEdit *m_searchBox = nullptr;
|
QLineEdit *m_searchBox = nullptr;
|
||||||
QTabWidget *m_resultTabs = nullptr;
|
QTabWidget *m_resultTabs = nullptr;
|
||||||
QTreeWidget *m_trackResults = nullptr;
|
QTreeWidget *m_trackResults = nullptr;
|
||||||
QTreeWidget *m_albumResults = nullptr;
|
QTreeWidget *m_albumResults = nullptr;
|
||||||
QTreeWidget *m_artistResults = nullptr;
|
QTreeWidget *m_artistResults = nullptr;
|
||||||
|
QVector<QPair<qint64, QString>> m_userPlaylists;
|
||||||
|
|
||||||
|
void onTrackContextMenu(const QPoint &pos);
|
||||||
|
void onAlbumContextMenu(const QPoint &pos);
|
||||||
|
void showTrackInfo(const QJsonObject &track);
|
||||||
};
|
};
|
||||||
|
|
||||||
class View : public QDockWidget
|
class View : public QDockWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit View(QobuzBackend *backend, QWidget *parent = nullptr);
|
explicit View(QobuzBackend *backend, PlayQueue *queue, QWidget *parent = nullptr);
|
||||||
|
|
||||||
SearchTab *searchTab() const { return m_search; }
|
SearchTab *searchTab() const { return m_search; }
|
||||||
|
|
||||||
@@ -48,6 +60,7 @@ namespace SidePanel
|
|||||||
void albumSelected(const QString &albumId);
|
void albumSelected(const QString &albumId);
|
||||||
void artistSelected(qint64 artistId);
|
void artistSelected(qint64 artistId);
|
||||||
void trackPlayRequested(qint64 trackId);
|
void trackPlayRequested(qint64 trackId);
|
||||||
|
void addToPlaylistRequested(qint64 trackId, qint64 playlistId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SearchTab *m_search = nullptr;
|
SearchTab *m_search = nullptr;
|
||||||
|
|||||||
@@ -49,11 +49,16 @@ public:
|
|||||||
m_title->setWordWrap(true);
|
m_title->setWordWrap(true);
|
||||||
vlay->addWidget(m_title);
|
vlay->addWidget(m_title);
|
||||||
|
|
||||||
m_subtitle = new QLabel(info);
|
m_subtitle = new QPushButton(info);
|
||||||
|
m_subtitle->setFlat(true);
|
||||||
|
m_subtitle->setStyleSheet(QStringLiteral(
|
||||||
|
"QPushButton { border: none; background: none; text-align: left; padding: 0; margin: 0; }"
|
||||||
|
"QPushButton:enabled:hover { color: #FFB232; }"
|
||||||
|
"QPushButton:!enabled { color: palette(text); }"
|
||||||
|
));
|
||||||
QFont sf = m_subtitle->font();
|
QFont sf = m_subtitle->font();
|
||||||
sf.setPointSize(sf.pointSize() + 1);
|
sf.setPointSize(sf.pointSize() + 1);
|
||||||
m_subtitle->setFont(sf);
|
m_subtitle->setFont(sf);
|
||||||
m_subtitle->setWordWrap(true);
|
|
||||||
vlay->addWidget(m_subtitle);
|
vlay->addWidget(m_subtitle);
|
||||||
|
|
||||||
m_meta = new QLabel(info);
|
m_meta = new QLabel(info);
|
||||||
@@ -90,6 +95,7 @@ public:
|
|||||||
|
|
||||||
btnRow->addStretch();
|
btnRow->addStretch();
|
||||||
vlay->addLayout(btnRow);
|
vlay->addLayout(btnRow);
|
||||||
|
vlay->addStretch(1);
|
||||||
|
|
||||||
hlay->addWidget(info, 1);
|
hlay->addWidget(info, 1);
|
||||||
|
|
||||||
@@ -108,10 +114,18 @@ public:
|
|||||||
QPushButton *playButton() { return m_playBtn; }
|
QPushButton *playButton() { return m_playBtn; }
|
||||||
QPushButton *shuffleButton() { return m_shuffleBtn; }
|
QPushButton *shuffleButton() { return m_shuffleBtn; }
|
||||||
|
|
||||||
|
QPushButton *subtitleButton() { return m_subtitle; }
|
||||||
|
qint64 artistId() const { return m_artistId; }
|
||||||
|
|
||||||
void setAlbum(const QJsonObject &album)
|
void setAlbum(const QJsonObject &album)
|
||||||
{
|
{
|
||||||
m_title->setText(album["title"].toString());
|
const QString base = album["title"].toString();
|
||||||
|
const QString ver = album["version"].toString().trimmed();
|
||||||
|
m_title->setText(ver.isEmpty() ? base : base + QStringLiteral(" (") + ver + QLatin1Char(')'));
|
||||||
|
m_artistId = static_cast<qint64>(album["artist"].toObject()["id"].toDouble());
|
||||||
m_subtitle->setText(album["artist"].toObject()["name"].toString());
|
m_subtitle->setText(album["artist"].toObject()["name"].toString());
|
||||||
|
m_subtitle->setEnabled(m_artistId > 0);
|
||||||
|
m_subtitle->setCursor(m_artistId > 0 ? Qt::PointingHandCursor : Qt::ArrowCursor);
|
||||||
m_meta->setText(buildAlbumMeta(album));
|
m_meta->setText(buildAlbumMeta(album));
|
||||||
fetchArt(album["image"].toObject());
|
fetchArt(album["image"].toObject());
|
||||||
show();
|
show();
|
||||||
@@ -120,9 +134,12 @@ public:
|
|||||||
void setPlaylist(const QJsonObject &playlist)
|
void setPlaylist(const QJsonObject &playlist)
|
||||||
{
|
{
|
||||||
m_title->setText(playlist["name"].toString());
|
m_title->setText(playlist["name"].toString());
|
||||||
|
m_artistId = 0;
|
||||||
const QString desc = playlist["description"].toString();
|
const QString desc = playlist["description"].toString();
|
||||||
const QString owner = playlist["owner"].toObject()["name"].toString();
|
const QString owner = playlist["owner"].toObject()["name"].toString();
|
||||||
m_subtitle->setText(desc.isEmpty() ? owner : desc);
|
m_subtitle->setText(desc.isEmpty() ? owner : desc);
|
||||||
|
m_subtitle->setEnabled(false);
|
||||||
|
m_subtitle->setCursor(Qt::ArrowCursor);
|
||||||
m_meta->setText(buildPlaylistMeta(playlist));
|
m_meta->setText(buildPlaylistMeta(playlist));
|
||||||
|
|
||||||
// Try images300 → images150 → images (API returns mosaic arrays, not image_rectangle)
|
// Try images300 → images150 → images (API returns mosaic arrays, not image_rectangle)
|
||||||
@@ -200,10 +217,11 @@ private:
|
|||||||
|
|
||||||
QLabel *m_art = nullptr;
|
QLabel *m_art = nullptr;
|
||||||
QLabel *m_title = nullptr;
|
QLabel *m_title = nullptr;
|
||||||
QLabel *m_subtitle = nullptr;
|
QPushButton *m_subtitle = nullptr;
|
||||||
QLabel *m_meta = nullptr;
|
QLabel *m_meta = nullptr;
|
||||||
QPushButton *m_playBtn = nullptr;
|
QPushButton *m_playBtn = nullptr;
|
||||||
QPushButton *m_shuffleBtn = nullptr;
|
QPushButton *m_shuffleBtn = nullptr;
|
||||||
QNetworkAccessManager *m_nam = nullptr;
|
QNetworkAccessManager *m_nam = nullptr;
|
||||||
QString m_currentArtUrl;
|
QString m_currentArtUrl;
|
||||||
|
qint64 m_artistId = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,10 +4,9 @@
|
|||||||
#include "../util/icon.hpp"
|
#include "../util/icon.hpp"
|
||||||
|
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QWidgetAction>
|
#include <QFrame>
|
||||||
#include <QMenu>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
/// A toolbar button that shows a volume slider popup when clicked.
|
/// A toolbar button that shows a volume slider popup when clicked.
|
||||||
class VolumeButton : public QToolButton
|
class VolumeButton : public QToolButton
|
||||||
@@ -17,33 +16,36 @@ class VolumeButton : public QToolButton
|
|||||||
public:
|
public:
|
||||||
explicit VolumeButton(QWidget *parent = nullptr) : QToolButton(parent)
|
explicit VolumeButton(QWidget *parent = nullptr) : QToolButton(parent)
|
||||||
{
|
{
|
||||||
setPopupMode(QToolButton::InstantPopup);
|
|
||||||
setIcon(Icon::volumeHigh());
|
setIcon(Icon::volumeHigh());
|
||||||
|
|
||||||
auto *menu = new QMenu(this);
|
// Qt::Popup closes automatically when the user clicks outside.
|
||||||
auto *widget = new QWidget(menu);
|
m_popup = new QFrame(this, Qt::Popup);
|
||||||
widget->setMinimumWidth(72);
|
m_popup->setFrameShape(QFrame::StyledPanel);
|
||||||
auto *layout = new QVBoxLayout(widget);
|
m_popup->setFrameShadow(QFrame::Raised);
|
||||||
layout->setContentsMargins(6, 6, 6, 6);
|
|
||||||
|
|
||||||
m_label = new QLabel("80%", widget);
|
auto *layout = new QVBoxLayout(m_popup);
|
||||||
|
layout->setContentsMargins(10, 10, 10, 10);
|
||||||
|
layout->setSpacing(6);
|
||||||
|
|
||||||
|
m_label = new QLabel(QStringLiteral("80%"), m_popup);
|
||||||
m_label->setAlignment(Qt::AlignCenter);
|
m_label->setAlignment(Qt::AlignCenter);
|
||||||
|
layout->addWidget(m_label);
|
||||||
|
|
||||||
m_slider = new ClickableSlider(Qt::Vertical, widget);
|
m_slider = new ClickableSlider(Qt::Vertical, m_popup);
|
||||||
m_slider->setRange(0, 100);
|
m_slider->setRange(0, 100);
|
||||||
m_slider->setValue(80);
|
m_slider->setValue(80);
|
||||||
m_slider->setFixedHeight(120);
|
m_slider->setFixedHeight(120);
|
||||||
|
layout->addWidget(m_slider, 0, Qt::AlignHCenter);
|
||||||
|
|
||||||
layout->addWidget(m_label);
|
// Size the popup at its maximum (label = "100%") and lock it
|
||||||
layout->addWidget(m_slider);
|
m_label->setText(QStringLiteral("100%"));
|
||||||
|
m_popup->adjustSize();
|
||||||
auto *action = new QWidgetAction(menu);
|
m_popup->setFixedSize(m_popup->sizeHint());
|
||||||
action->setDefaultWidget(widget);
|
m_label->setText(QStringLiteral("80%"));
|
||||||
menu->addAction(action);
|
|
||||||
setMenu(menu);
|
|
||||||
|
|
||||||
|
connect(this, &QToolButton::clicked, this, &VolumeButton::togglePopup);
|
||||||
connect(m_slider, &QSlider::valueChanged, this, [this](int v) {
|
connect(m_slider, &QSlider::valueChanged, this, [this](int v) {
|
||||||
m_label->setText(QString::number(v) + "%");
|
m_label->setText(QString::number(v) + QStringLiteral("%"));
|
||||||
updateIcon(v);
|
updateIcon(v);
|
||||||
emit volumeChanged(v);
|
emit volumeChanged(v);
|
||||||
});
|
});
|
||||||
@@ -56,14 +58,31 @@ public:
|
|||||||
m_slider->blockSignals(true);
|
m_slider->blockSignals(true);
|
||||||
m_slider->setValue(v);
|
m_slider->setValue(v);
|
||||||
m_slider->blockSignals(false);
|
m_slider->blockSignals(false);
|
||||||
m_label->setText(QString::number(v) + "%");
|
m_label->setText(QString::number(v) + QStringLiteral("%"));
|
||||||
updateIcon(v);
|
updateIcon(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void volumeChanged(int volume);
|
void volumeChanged(int volume);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void togglePopup()
|
||||||
|
{
|
||||||
|
if (m_popup->isVisible()) {
|
||||||
|
m_popup->hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Centre popup horizontally over button, place below it
|
||||||
|
const QPoint global = mapToGlobal(
|
||||||
|
QPoint(width() / 2 - m_popup->width() / 2,
|
||||||
|
height() + 4));
|
||||||
|
m_popup->move(global);
|
||||||
|
m_popup->show();
|
||||||
|
m_popup->raise();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QFrame *m_popup = nullptr;
|
||||||
ClickableSlider *m_slider = nullptr;
|
ClickableSlider *m_slider = nullptr;
|
||||||
QLabel *m_label = nullptr;
|
QLabel *m_label = nullptr;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user