Refactor Tidal, Spotify, Qobuz, Subsonic and cover providers
Use common HTTP, Json and OAuthenticator class
This commit is contained in:
@@ -59,6 +59,8 @@ class StreamingService : public QObject {
|
||||
virtual bool authenticated() const { return false; }
|
||||
virtual int Search(const QString &query, const SearchType type) { Q_UNUSED(query); Q_UNUSED(type); return 0; }
|
||||
virtual void CancelSearch() {}
|
||||
virtual bool show_progress() const { return true; }
|
||||
virtual bool enable_refresh_button() const { return true; }
|
||||
|
||||
virtual SharedPtr<CollectionBackend> artists_collection_backend() { return nullptr; }
|
||||
virtual SharedPtr<CollectionBackend> albums_collection_backend() { return nullptr; }
|
||||
@@ -87,14 +89,14 @@ class StreamingService : public QObject {
|
||||
void RequestLogout();
|
||||
void LoginWithCredentials(const QString &api_token, const QString &username, const QString &password);
|
||||
void LoginSuccess();
|
||||
void LoginFailure(const QString &failure_reason);
|
||||
void LoginComplete(const bool success, const QString &error = QString());
|
||||
void LoginFailure(const QString &error);
|
||||
void LoginFinished(const bool success, const QString &error = QString());
|
||||
|
||||
void TestSuccess();
|
||||
void TestFailure(const QString &failure_reason);
|
||||
void TestFailure(const QString &error);
|
||||
void TestComplete(const bool success, const QString &error = QString());
|
||||
|
||||
void Error(const QString &error);
|
||||
void ShowErrorDialog(const QString &error);
|
||||
void Results(const SongMap &songs, const QString &error);
|
||||
void UpdateStatus(const QString &text);
|
||||
void ProgressSetMaximum(const int max);
|
||||
@@ -131,6 +133,7 @@ class StreamingService : public QObject {
|
||||
|
||||
void StreamURLFailure(const uint id, const QUrl &media_url, const QString &error);
|
||||
void StreamURLSuccess(const uint id, const QUrl &media_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration);
|
||||
void StreamURLRequestFinished(const uint id, const QUrl &media_url, const bool success, const QUrl &stream_url, const QString &error = QString());
|
||||
|
||||
void OpenSettingsDialog(const Song::Source source);
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ StreamingSongsView::StreamingSongsView(const StreamingServicePtr service, const
|
||||
ui_->view->SetFilter(ui_->filter_widget);
|
||||
ui_->filter_widget->SetSettingsGroup(settings_group);
|
||||
ui_->filter_widget->Init(service_->songs_collection_model(), service_->songs_collection_filter_model());
|
||||
ui_->refresh->setVisible(service_->enable_refresh_button());
|
||||
|
||||
QAction *action_configure = new QAction(IconLoader::Load(u"configure"_s), tr("Configure %1...").arg(Song::DescriptionForSource(service_->source())), this);
|
||||
QObject::connect(action_configure, &QAction::triggered, this, &StreamingSongsView::Configure);
|
||||
@@ -66,6 +67,7 @@ StreamingSongsView::StreamingSongsView(const StreamingServicePtr service, const
|
||||
QObject::connect(ui_->refresh, &QPushButton::clicked, this, &StreamingSongsView::GetSongs);
|
||||
QObject::connect(ui_->close, &QPushButton::clicked, this, &StreamingSongsView::AbortGetSongs);
|
||||
QObject::connect(ui_->abort, &QPushButton::clicked, this, &StreamingSongsView::AbortGetSongs);
|
||||
QObject::connect(&*service_, &StreamingService::ShowErrorDialog, this, &StreamingSongsView::ShowErrorDialog);
|
||||
QObject::connect(&*service_, &StreamingService::SongsResults, this, &StreamingSongsView::SongsFinished);
|
||||
QObject::connect(&*service_, &StreamingService::SongsUpdateStatus, ui_->status, &QLabel::setText);
|
||||
QObject::connect(&*service_, &StreamingService::SongsProgressSetMaximum, ui_->progressbar, &QProgressBar::setMaximum);
|
||||
@@ -101,11 +103,14 @@ void StreamingSongsView::GetSongs() {
|
||||
return;
|
||||
}
|
||||
|
||||
ui_->status->clear();
|
||||
ui_->progressbar->show();
|
||||
ui_->abort->show();
|
||||
ui_->close->hide();
|
||||
ui_->stacked->setCurrentWidget(ui_->help_page);
|
||||
if (service_->show_progress()) {
|
||||
ui_->status->clear();
|
||||
ui_->progressbar->show();
|
||||
ui_->abort->show();
|
||||
ui_->close->hide();
|
||||
ui_->stacked->setCurrentWidget(ui_->help_page);
|
||||
}
|
||||
|
||||
service_->GetSongs();
|
||||
|
||||
}
|
||||
@@ -113,9 +118,12 @@ void StreamingSongsView::GetSongs() {
|
||||
void StreamingSongsView::AbortGetSongs() {
|
||||
|
||||
service_->ResetSongsRequest();
|
||||
ui_->progressbar->setValue(0);
|
||||
ui_->status->clear();
|
||||
ui_->stacked->setCurrentWidget(ui_->streamingcollection_page);
|
||||
|
||||
if (service_->show_progress()) {
|
||||
ui_->progressbar->setValue(0);
|
||||
ui_->status->clear();
|
||||
ui_->stacked->setCurrentWidget(ui_->streamingcollection_page);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ class StreamingSongsView : public QWidget {
|
||||
void SongsFinished(const SongMap &songs, const QString &error);
|
||||
|
||||
Q_SIGNALS:
|
||||
void ShowErrorDialog(const QString &error);
|
||||
void OpenSettingsDialog(const Song::Source source);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user