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:
@@ -61,7 +61,7 @@ InternetSearch::InternetSearch(Application *app, Song::Source source, QObject *p
|
||||
cover_loader_options_.pad_output_image_ = true;
|
||||
cover_loader_options_.scale_output_image_ = true;
|
||||
|
||||
connect(app_->album_cover_loader(), SIGNAL(ImageLoaded(quint64, QImage)), SLOT(AlbumArtLoaded(const quint64, const QImage&)));
|
||||
connect(app_->album_cover_loader(), SIGNAL(ImageLoaded(quint64, QUrl, QImage)), SLOT(AlbumCoverLoaded(quint64, QUrl, QImage)));
|
||||
connect(this, SIGNAL(SearchAsyncSig(const int, const QString&, const SearchType)), this, SLOT(DoSearchAsync(const int, const QString&, const SearchType)));
|
||||
|
||||
connect(service_, SIGNAL(SearchUpdateStatus(const int, const QString&)), SLOT(UpdateStatusSlot(const int, const QString&)));
|
||||
@@ -206,7 +206,7 @@ bool InternetSearch::FindCachedPixmap(const InternetSearch::Result &result, QPix
|
||||
return pixmap_cache_.find(result.pixmap_cache_key_, pixmap);
|
||||
}
|
||||
|
||||
int InternetSearch::LoadArtAsync(const InternetSearch::Result &result) {
|
||||
int InternetSearch::LoadAlbumCoverAsync(const InternetSearch::Result &result) {
|
||||
|
||||
const int id = art_searches_next_id_++;
|
||||
|
||||
@@ -219,7 +219,7 @@ int InternetSearch::LoadArtAsync(const InternetSearch::Result &result) {
|
||||
|
||||
}
|
||||
|
||||
void InternetSearch::AlbumArtLoaded(const quint64 id, const QImage &image) {
|
||||
void InternetSearch::AlbumCoverLoaded(const quint64 id, const QUrl &cover_url, const QImage &image) {
|
||||
|
||||
if (!cover_loader_tasks_.contains(id)) return;
|
||||
int orig_id = cover_loader_tasks_.take(id);
|
||||
@@ -229,7 +229,7 @@ void InternetSearch::AlbumArtLoaded(const quint64 id, const QImage &image) {
|
||||
QPixmap pixmap = QPixmap::fromImage(image);
|
||||
pixmap_cache_.insert(key, pixmap);
|
||||
|
||||
emit ArtLoaded(orig_id, pixmap);
|
||||
emit AlbumCoverLoaded(orig_id, pixmap);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class InternetSearch : public QObject {
|
||||
InternetService *service() const { return service_; }
|
||||
|
||||
int SearchAsync(const QString &query, SearchType type);
|
||||
int LoadArtAsync(const InternetSearch::Result &result);
|
||||
int LoadAlbumCoverAsync(const InternetSearch::Result &result);
|
||||
|
||||
void CancelSearch(const int id);
|
||||
void CancelArt(const int id);
|
||||
@@ -86,7 +86,7 @@ class InternetSearch : public QObject {
|
||||
void ProgressSetMaximum(const int id, const int progress);
|
||||
void UpdateProgress(const int id, const int max);
|
||||
|
||||
void ArtLoaded(const int id, const QPixmap &pixmap);
|
||||
void AlbumCoverLoaded(const int id, const QPixmap &pixmap);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -117,7 +117,7 @@ class InternetSearch : public QObject {
|
||||
void DoSearchAsync(const int id, const QString &query, const SearchType type);
|
||||
void SearchDone(const int service_id, const SongList &songs, const QString &error);
|
||||
|
||||
void AlbumArtLoaded(const quint64 id, const QImage &image);
|
||||
void AlbumCoverLoaded(const quint64 id, const QUrl &cover_url, const QImage &image);
|
||||
|
||||
void UpdateStatusSlot(const int id, const QString &text);
|
||||
void ProgressSetMaximumSlot(const int id, const int progress);
|
||||
|
||||
@@ -30,7 +30,7 @@ InternetSearchItemDelegate::InternetSearchItemDelegate(InternetSearchView *view)
|
||||
void InternetSearchItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
|
||||
// Tell the view we painted this item so it can lazy load some art.
|
||||
const_cast<InternetSearchView*>(view_)->LazyLoadArt(index);
|
||||
const_cast<InternetSearchView*>(view_)->LazyLoadAlbumCover(index);
|
||||
|
||||
CollectionItemDelegate::paint(painter, option, index);
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ void InternetSearchView::Init(Application *app, InternetSearch *engine, const QS
|
||||
|
||||
connect(engine_, SIGNAL(AddResults(const int, InternetSearch::ResultList)), SLOT(AddResults(const int, const InternetSearch::ResultList)), Qt::QueuedConnection);
|
||||
connect(engine_, SIGNAL(SearchError(const int, const QString&)), SLOT(SearchError(const int, const QString&)), Qt::QueuedConnection);
|
||||
connect(engine_, SIGNAL(ArtLoaded(const int, const QPixmap&)), SLOT(ArtLoaded(const int, const QPixmap&)), Qt::QueuedConnection);
|
||||
connect(engine_, SIGNAL(AlbumCoverLoaded(const int, const QPixmap&)), SLOT(AlbumCoverLoaded(const int, const QPixmap&)), Qt::QueuedConnection);
|
||||
|
||||
ReloadSettings();
|
||||
|
||||
@@ -294,7 +294,7 @@ void InternetSearchView::SwapModels() {
|
||||
|
||||
}
|
||||
|
||||
void InternetSearchView::LazyLoadArt(const QModelIndex &proxy_index) {
|
||||
void InternetSearchView::LazyLoadAlbumCover(const QModelIndex &proxy_index) {
|
||||
|
||||
if (!proxy_index.isValid() || proxy_index.model() != front_proxy_) {
|
||||
return;
|
||||
@@ -332,12 +332,12 @@ void InternetSearchView::LazyLoadArt(const QModelIndex &proxy_index) {
|
||||
const InternetSearch::Result result = item->data(InternetSearchModel::Role_Result).value<InternetSearch::Result>();
|
||||
|
||||
// Load the art.
|
||||
int id = engine_->LoadArtAsync(result);
|
||||
int id = engine_->LoadAlbumCoverAsync(result);
|
||||
art_requests_[id] = source_index;
|
||||
|
||||
}
|
||||
|
||||
void InternetSearchView::ArtLoaded(const int id, const QPixmap &pixmap) {
|
||||
void InternetSearchView::AlbumCoverLoaded(const int id, const QPixmap &pixmap) {
|
||||
|
||||
if (!art_requests_.contains(id)) return;
|
||||
QModelIndex index = art_requests_.take(id);
|
||||
@@ -545,7 +545,7 @@ void InternetSearchView::SetGroupBy(const CollectionModel::Grouping &g) {
|
||||
|
||||
// Clear requests: changing "group by" on the models will cause all the items to be removed/added again,
|
||||
// so all the QModelIndex here will become invalid. New requests will be created for those
|
||||
// songs when they will be displayed again anyway (when InternetSearchItemDelegate::paint will call LazyLoadArt)
|
||||
// songs when they will be displayed again anyway (when InternetSearchItemDelegate::paint will call LazyLoadAlbumCover)
|
||||
art_requests_.clear();
|
||||
// Update the models
|
||||
front_model_->SetGroupBy(g, true);
|
||||
|
||||
@@ -63,7 +63,7 @@ class InternetSearchView : public QWidget {
|
||||
|
||||
static const int kSwapModelsTimeoutMsec;
|
||||
|
||||
void LazyLoadArt(const QModelIndex &index);
|
||||
void LazyLoadAlbumCover(const QModelIndex &index);
|
||||
|
||||
void showEvent(QShowEvent *e);
|
||||
void hideEvent(QHideEvent *e);
|
||||
@@ -89,7 +89,7 @@ class InternetSearchView : public QWidget {
|
||||
void UpdateProgress(const int id, const int max);
|
||||
void AddResults(const int id, const InternetSearch::ResultList &results);
|
||||
void SearchError(const int id, const QString &error);
|
||||
void ArtLoaded(const int id, const QPixmap &pixmap);
|
||||
void AlbumCoverLoaded(const int id, const QPixmap &pixmap);
|
||||
|
||||
void FocusOnFilter(QKeyEvent *event);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user