Improve album cover searching and cover manager, use HttpStatusCodeAttribute and QSslError for services

- Improve album cover manager
- Change art_automatic and art_manual to QUrl
- Refresh collection album covers when new album covers are fetched
- Fix automatic album cover searching for local files outside of the collection
- Make all Json services check HttpStatusCodeAttribute
- Show detailed SSL errors for Subsonic, Tidal and Qobuz
This commit is contained in:
Jonas Kvinge
2019-07-07 21:14:24 +02:00
parent c92a7967ea
commit 65780e1672
101 changed files with 1531 additions and 1239 deletions

View File

@@ -43,7 +43,7 @@
#include "core/application.h"
#include "core/logging.h"
#include "core/systemtrayicon.h"
#include "covermanager/currentartloader.h"
#include "covermanager/currentalbumcoverloader.h"
const char *OSD::kSettingsGroup = "OSD";
@@ -68,7 +68,7 @@ OSD::OSD(SystemTrayIcon *tray_icon, Application *app, QObject *parent)
pretty_popup_(new OSDPretty(OSDPretty::Mode_Popup))
{
connect(app_->current_art_loader(), SIGNAL(ThumbnailLoaded(Song, QString, QImage)), SLOT(AlbumArtLoaded(Song, QString, QImage)));
connect(app_->current_albumcover_loader(), SIGNAL(ThumbnailLoaded(Song, QUrl, QImage)), SLOT(AlbumCoverLoaded(Song, QUrl, QImage)));
ReloadSettings();
Init();
@@ -114,18 +114,18 @@ void OSD::ReloadPrettyOSDSettings() {
void OSD::ReshowCurrentSong() {
force_show_next_ = true;
AlbumArtLoaded(last_song_, last_image_uri_, last_image_);
AlbumCoverLoaded(last_song_, last_image_uri_, last_image_);
}
void OSD::AlbumArtLoaded(const Song &song, const QString &uri, const QImage &image) {
void OSD::AlbumCoverLoaded(const Song &song, const QUrl &cover_url, const QImage &image) {
// Don't change tray icon details if it's a preview
if (!preview_mode_ && tray_icon_)
tray_icon_->SetNowPlaying(song, uri);
tray_icon_->SetNowPlaying(song, cover_url);
last_song_ = song;
last_image_ = image;
last_image_uri_ = uri;
last_image_uri_ = cover_url;
QStringList message_parts;
QString summary;
@@ -187,7 +187,7 @@ void OSD::Paused() {
void OSD::Resumed() {
if (show_on_resume_) {
AlbumArtLoaded(last_song_, last_image_uri_, last_image_);
AlbumCoverLoaded(last_song_, last_image_uri_, last_image_);
}
}
@@ -373,7 +373,8 @@ void OSD::ShowPreview(const Behaviour type, const QString &line1, const QString
// We want to reload the settings, but we can't do this here because the cover art loading is asynch
preview_mode_ = true;
AlbumArtLoaded(song, QString(), QImage());
AlbumCoverLoaded(song, QUrl(), QImage());
}
void OSD::SetPrettyOSDToggleMode(bool toggle) {

View File

@@ -104,7 +104,7 @@ class OSD : public QObject {
#if defined(HAVE_DBUS)
void CallFinished(QDBusPendingCallWatcher *watcher);
#endif
void AlbumArtLoaded(const Song &song, const QString &uri, const QImage &image);
void AlbumCoverLoaded(const Song &song, const QUrl &cover_url, const QImage &image);
private:
Application *app_;
@@ -128,7 +128,7 @@ class OSD : public QObject {
OSDPretty *pretty_popup_;
Song last_song_;
QString last_image_uri_;
QUrl last_image_uri_;
QImage last_image_;
#ifdef HAVE_DBUS

View File

@@ -46,7 +46,7 @@
#include "core/application.h"
#include "covermanager/albumcoverchoicecontroller.h"
#include "covermanager/albumcoverloader.h"
#include "covermanager/currentartloader.h"
#include "covermanager/currentalbumcoverloader.h"
#include "playingwidget.h"
using std::unique_ptr;
@@ -131,13 +131,12 @@ PlayingWidget::PlayingWidget(QWidget *parent)
PlayingWidget::~PlayingWidget() {}
void PlayingWidget::SetApplication(Application *app, AlbumCoverChoiceController *album_cover_choice_controller) {
void PlayingWidget::Init(Application *app, AlbumCoverChoiceController *album_cover_choice_controller) {
app_ = app;
connect(app_->current_art_loader(), SIGNAL(ArtLoaded(Song, QString, QImage)), SLOT(AlbumArtLoaded(Song, QString, QImage)));
album_cover_choice_controller_ = album_cover_choice_controller;
album_cover_choice_controller_->SetApplication(app_);
album_cover_choice_controller_->Init(app_);
QList<QAction*> cover_actions = album_cover_choice_controller_->GetAllActions();
cover_actions.append(album_cover_choice_controller_->search_cover_auto_action());
menu_->addActions(cover_actions);
@@ -152,7 +151,6 @@ void PlayingWidget::SetApplication(Application *app, AlbumCoverChoiceController
connect(above_statusbar_action_, SIGNAL(toggled(bool)), SLOT(ShowAboveStatusBar(bool)));
connect(album_cover_choice_controller_, SIGNAL(AutomaticCoverSearchDone()), this, SLOT(AutomaticCoverSearchDone()));
connect(album_cover_choice_controller_->search_cover_auto_action(), SIGNAL(triggered()), this, SLOT(SearchCoverAutomatically()));
}
@@ -270,7 +268,7 @@ void PlayingWidget::SongChanged(const Song &song) {
song_ = song;
}
void PlayingWidget::AlbumArtLoaded(const Song &song, const QString &, const QImage &image) {
void PlayingWidget::AlbumCoverLoaded(const Song &song, const QUrl &cover_url, const QImage &image) {
if (!playing_ || song.id() != song_playing_.id() || song.url() != song_playing_.url() || song.effective_albumartist() != song_playing_.effective_albumartist() || song.effective_album() != song_playing_.effective_album() || song.title() != song_playing_.title()) return;
if (timeline_fade_->state() == QTimeLine::Running && image == image_original_) return;
@@ -279,7 +277,6 @@ void PlayingWidget::AlbumArtLoaded(const Song &song, const QString &, const QIma
downloading_covers_ = false;
song_ = song;
SetImage(image);
GetCoverAutomatically();
}
@@ -495,28 +492,15 @@ void PlayingWidget::dropEvent(QDropEvent *e) {
}
void PlayingWidget::GetCoverAutomatically() {
void PlayingWidget::SearchCoverInProgress() {
// Search for cover automatically?
bool search =
album_cover_choice_controller_->search_cover_auto_action()->isChecked() &&
!song_.has_manually_unset_cover() &&
song_.art_automatic().isEmpty() &&
song_.art_manual().isEmpty() &&
!song_.effective_albumartist().isEmpty() &&
!song_.effective_album().isEmpty();
downloading_covers_ = true;
if (search) {
downloading_covers_ = true;
// This is done in mainwindow instead to avoid searching multiple times (ContextView & PlayingWidget)
// album_cover_choice_controller_->SearchCoverAutomatically(song_);
// Show a spinner animation
spinner_animation_.reset(new QMovie(":/pictures/spinner.gif", QByteArray(), this));
connect(spinner_animation_.get(), SIGNAL(updated(const QRect&)), SLOT(update()));
spinner_animation_->start();
update();
}
// Show a spinner animation
spinner_animation_.reset(new QMovie(":/pictures/spinner.gif", QByteArray(), this));
connect(spinner_animation_.get(), SIGNAL(updated(const QRect&)), SLOT(update()));
spinner_animation_->start();
update();
}
@@ -527,7 +511,3 @@ void PlayingWidget::AutomaticCoverSearchDone() {
update();
}
void PlayingWidget::SearchCoverAutomatically() {
GetCoverAutomatically();
}

View File

@@ -66,7 +66,7 @@ class PlayingWidget : public QWidget {
PlayingWidget(QWidget *parent = nullptr);
~PlayingWidget();
void SetApplication(Application *app, AlbumCoverChoiceController *album_cover_choice_controller);
void Init(Application *app, AlbumCoverChoiceController *album_cover_choice_controller);
bool IsEnabled() { return enabled_; }
void SetEnabled(bool enabled);
void SetEnabled();
@@ -83,6 +83,7 @@ class PlayingWidget : public QWidget {
void Stopped();
void Error();
void SongChanged(const Song &song);
void SearchCoverInProgress();
protected:
void paintEvent(QPaintEvent *e);
@@ -97,10 +98,9 @@ class PlayingWidget : public QWidget {
void ShowAboveStatusBar(bool above);
void FitCoverWidth(bool fit);
void SearchCoverAutomatically();
void AutomaticCoverSearchDone();
void AlbumArtLoaded(const Song &song, const QString &uri, const QImage &image);
void AlbumCoverLoaded(const Song &song, const QUrl &cover_url, const QImage &image);
void SetHeight(int height);
void FadePreviousTrack(qreal value);