- Adds extra=topTracks to artist/page API request - Embeds a List::Tracks widget at the top of ArtistView showing the artist's most popular tracks, with Play and Shuffle buttons - Bubbles playTrackRequested through MainContent up to MainWindow - Also adds the viz PCM ring buffer FFI infrastructure (for future spectrum widget) to the Rust backend Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
117 lines
3.7 KiB
C++
117 lines
3.7 KiB
C++
#pragma once
|
|
|
|
#include "qobuz_backend.h"
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QJsonObject>
|
|
#include <QTimer>
|
|
|
|
/// Qt wrapper around the Rust qobuz-backend static library.
|
|
///
|
|
/// All signals are emitted on the Qt main thread regardless of which thread
|
|
/// the Rust callback fires on (marshalled via QMetaObject::invokeMethod with
|
|
/// Qt::QueuedConnection).
|
|
class QobuzBackend : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit QobuzBackend(QObject *parent = nullptr);
|
|
~QobuzBackend() override;
|
|
|
|
// --- auth ---
|
|
void login(const QString &email, const QString &password);
|
|
void setToken(const QString &token);
|
|
void getUser();
|
|
|
|
// --- catalog ---
|
|
void search(const QString &query, quint32 offset = 0, quint32 limit = 20);
|
|
void getAlbum(const QString &albumId);
|
|
void getArtist(qint64 artistId);
|
|
void getPlaylist(qint64 playlistId, quint32 offset = 0, quint32 limit = 500);
|
|
|
|
// --- favorites ---
|
|
void getFavTracks(quint32 offset = 0, quint32 limit = 500);
|
|
void getFavAlbums(quint32 offset = 0, quint32 limit = 200);
|
|
void getFavArtists(quint32 offset = 0, quint32 limit = 200);
|
|
void getUserPlaylists(quint32 offset = 0, quint32 limit = 200);
|
|
|
|
// --- playback options ---
|
|
void setReplayGain(bool enabled);
|
|
void setGapless(bool enabled);
|
|
void prefetchTrack(qint64 trackId, int formatId = 6);
|
|
|
|
// --- playlist management ---
|
|
void createPlaylist(const QString &name);
|
|
void deletePlaylist(qint64 playlistId);
|
|
void addTrackToPlaylist(qint64 playlistId, qint64 trackId);
|
|
void deleteTrackFromPlaylist(qint64 playlistId, qint64 playlistTrackId);
|
|
|
|
// --- fav modification ---
|
|
void addFavTrack(qint64 trackId);
|
|
void removeFavTrack(qint64 trackId);
|
|
void addFavAlbum(const QString &albumId);
|
|
void removeFavAlbum(const QString &albumId);
|
|
|
|
// --- playback ---
|
|
void playTrack(qint64 trackId, int formatId = 6);
|
|
void pause();
|
|
void resume();
|
|
void stop();
|
|
void setVolume(int volume);
|
|
void seek(quint64 positionSecs);
|
|
|
|
quint64 position() const;
|
|
quint64 duration() const;
|
|
int volume() const;
|
|
/// 1 = playing, 2 = paused, 0 = idle
|
|
int state() const;
|
|
|
|
// --- visualizer PCM ---
|
|
quint32 vizRead(float *buf, quint32 maxSamples);
|
|
quint32 vizSampleRate() const;
|
|
quint32 vizChannels() const;
|
|
|
|
signals:
|
|
// auth
|
|
void loginSuccess(const QString &token, const QJsonObject &user);
|
|
void loginError(const QString &error);
|
|
void userLoaded(const QJsonObject &user);
|
|
|
|
// catalog
|
|
void searchResult(const QJsonObject &result);
|
|
void albumLoaded(const QJsonObject &album);
|
|
void artistLoaded(const QJsonObject &artist);
|
|
void playlistLoaded(const QJsonObject &playlist);
|
|
void playlistCreated(const QJsonObject &playlist);
|
|
void playlistDeleted(const QJsonObject &result);
|
|
void playlistTrackAdded(qint64 playlistId);
|
|
|
|
// favorites
|
|
void favTracksLoaded(const QJsonObject &result);
|
|
void favAlbumsLoaded(const QJsonObject &result);
|
|
void favArtistsLoaded(const QJsonObject &result);
|
|
void userPlaylistsLoaded(const QJsonObject &result);
|
|
|
|
// playback
|
|
void trackChanged(const QJsonObject &track);
|
|
void stateChanged(const QString &state);
|
|
void positionChanged(quint64 position, quint64 duration);
|
|
void trackFinished();
|
|
|
|
// errors
|
|
void error(const QString &message);
|
|
|
|
private slots:
|
|
Q_INVOKABLE void onEvent(int eventType, const QString &json);
|
|
void onPositionTick();
|
|
|
|
private:
|
|
QobuzBackendOpaque *m_backend = nullptr;
|
|
QTimer *m_positionTimer = nullptr;
|
|
|
|
// Static trampoline called from Rust threads
|
|
static void eventTrampoline(void *userdata, int eventType, const char *json);
|
|
};
|