Prioritize album artist in cover search and manager
This commit is contained in:
parent
5d0cf343d5
commit
62cec8cf28
|
@ -523,19 +523,33 @@ QStringList LibraryBackend::GetAllArtists(const QueryOptions& opt) {
|
|||
}
|
||||
|
||||
QStringList LibraryBackend::GetAllArtistsWithAlbums(const QueryOptions& opt) {
|
||||
// Albums with 'albumartist' field set:
|
||||
LibraryQuery query(opt);
|
||||
query.SetColumnSpec("DISTINCT artist");
|
||||
query.SetColumnSpec("DISTINCT albumartist");
|
||||
query.AddCompilationRequirement(false);
|
||||
query.AddWhere("album", "", "!=");
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
if (!ExecQuery(&query)) return QStringList();
|
||||
// Albums with no 'albumartist' (extract 'artist'):
|
||||
LibraryQuery query2(opt);
|
||||
query2.SetColumnSpec("DISTINCT artist");
|
||||
query2.AddCompilationRequirement(false);
|
||||
query2.AddWhere("album", "", "!=");
|
||||
query2.AddWhere("albumartist", "", "=");
|
||||
|
||||
QStringList ret;
|
||||
QMutexLocker l(db_->Mutex());
|
||||
ExecQuery(&query);
|
||||
ExecQuery(&query2);
|
||||
l.unlock();
|
||||
|
||||
QSet<QString> artists;
|
||||
while (query.Next()) {
|
||||
ret << query.Value(0).toString();
|
||||
artists << query.Value(0).toString();
|
||||
}
|
||||
return ret;
|
||||
while (query2.Next()) {
|
||||
artists << query2.Value(0).toString();
|
||||
}
|
||||
|
||||
return QStringList(artists.toList());
|
||||
}
|
||||
|
||||
LibraryBackend::AlbumList LibraryBackend::GetAllAlbums(
|
||||
|
|
|
@ -56,23 +56,23 @@ AlbumCoverChoiceController::AlbumCoverChoiceController(QWidget* parent)
|
|||
cover_fetcher_(nullptr),
|
||||
save_file_dialog_(nullptr),
|
||||
cover_from_url_dialog_(nullptr) {
|
||||
cover_from_file_ = new QAction(IconLoader::Load("document-open", IconLoader::Base),
|
||||
tr("Load cover from disk..."), this);
|
||||
cover_to_file_ = new QAction(IconLoader::Load("document-save", IconLoader::Base),
|
||||
tr("Save cover to disk..."), this);
|
||||
cover_from_file_ =
|
||||
new QAction(IconLoader::Load("document-open", IconLoader::Base),
|
||||
tr("Load cover from disk..."), this);
|
||||
cover_to_file_ =
|
||||
new QAction(IconLoader::Load("document-save", IconLoader::Base),
|
||||
tr("Save cover to disk..."), this);
|
||||
cover_from_url_ = new QAction(IconLoader::Load("download", IconLoader::Base),
|
||||
tr("Load cover from URL..."), this);
|
||||
search_for_cover_ = new QAction(IconLoader::Load("find", IconLoader::Base),
|
||||
tr("Search for album covers..."), this);
|
||||
unset_cover_ =
|
||||
new QAction(IconLoader::Load("list-remove", IconLoader::Base),
|
||||
tr("Unset cover"), this);
|
||||
show_cover_ =
|
||||
new QAction(IconLoader::Load("zoom-in", IconLoader::Base),
|
||||
tr("Show fullsize..."), this);
|
||||
unset_cover_ = new QAction(IconLoader::Load("list-remove", IconLoader::Base),
|
||||
tr("Unset cover"), this);
|
||||
show_cover_ = new QAction(IconLoader::Load("zoom-in", IconLoader::Base),
|
||||
tr("Show fullsize..."), this);
|
||||
|
||||
search_cover_auto_ =
|
||||
new QAction(IconLoader::Load("find", IconLoader::Base), tr("Search automatically"), this);
|
||||
search_cover_auto_ = new QAction(IconLoader::Load("find", IconLoader::Base),
|
||||
tr("Search automatically"), this);
|
||||
search_cover_auto_->setCheckable(true);
|
||||
search_cover_auto_->setChecked(false);
|
||||
|
||||
|
@ -168,7 +168,8 @@ QString AlbumCoverChoiceController::LoadCoverFromURL(Song* song) {
|
|||
QImage image = cover_from_url_dialog_->Exec();
|
||||
|
||||
if (!image.isNull()) {
|
||||
QString cover = SaveCoverInCache(song->artist(), song->album(), image);
|
||||
QString cover =
|
||||
SaveCoverInCache(song->effective_albumartist(), song->album(), image);
|
||||
SaveCover(song, cover);
|
||||
|
||||
return cover;
|
||||
|
@ -179,10 +180,12 @@ QString AlbumCoverChoiceController::LoadCoverFromURL(Song* song) {
|
|||
|
||||
QString AlbumCoverChoiceController::SearchForCover(Song* song) {
|
||||
// Get something sensible to stick in the search box
|
||||
QImage image = cover_searcher_->Exec(song->artist(), song->album());
|
||||
QImage image =
|
||||
cover_searcher_->Exec(song->effective_albumartist(), song->album());
|
||||
|
||||
if (!image.isNull()) {
|
||||
QString cover = SaveCoverInCache(song->artist(), song->album(), image);
|
||||
QString cover =
|
||||
SaveCoverInCache(song->effective_albumartist(), song->album(), image);
|
||||
SaveCover(song, cover);
|
||||
|
||||
return cover;
|
||||
|
@ -204,7 +207,7 @@ void AlbumCoverChoiceController::ShowCover(const Song& song) {
|
|||
|
||||
// Use Artist - Album as the window title
|
||||
QString title_text(song.albumartist());
|
||||
if (title_text.isEmpty()) title_text = song.artist();
|
||||
if (title_text.isEmpty()) title_text = song.effective_albumartist();
|
||||
|
||||
if (!song.album().isEmpty()) title_text += " - " + song.album();
|
||||
|
||||
|
@ -244,7 +247,8 @@ void AlbumCoverChoiceController::ShowCover(const Song& song) {
|
|||
}
|
||||
|
||||
void AlbumCoverChoiceController::SearchCoverAutomatically(const Song& song) {
|
||||
qint64 id = cover_fetcher_->FetchAlbumCover(song.artist(), song.album());
|
||||
qint64 id = cover_fetcher_->FetchAlbumCover(song.effective_albumartist(),
|
||||
song.album());
|
||||
cover_fetching_tasks_[id] = song;
|
||||
}
|
||||
|
||||
|
@ -256,7 +260,8 @@ void AlbumCoverChoiceController::AlbumCoverFetched(
|
|||
}
|
||||
|
||||
if (!image.isNull()) {
|
||||
QString cover = SaveCoverInCache(song.artist(), song.album(), image);
|
||||
QString cover =
|
||||
SaveCoverInCache(song.effective_albumartist(), song.album(), image);
|
||||
SaveCover(&song, cover);
|
||||
}
|
||||
|
||||
|
@ -266,8 +271,8 @@ void AlbumCoverChoiceController::AlbumCoverFetched(
|
|||
void AlbumCoverChoiceController::SaveCover(Song* song, const QString& cover) {
|
||||
if (song->is_valid() && song->id() != -1) {
|
||||
song->set_art_manual(cover);
|
||||
app_->library_backend()->UpdateManualAlbumArtAsync(song->artist(),
|
||||
song->album(), cover);
|
||||
app_->library_backend()->UpdateManualAlbumArtAsync(
|
||||
song->effective_albumartist(), song->album(), cover);
|
||||
|
||||
if (song->url() == app_->current_art_loader()->last_song().url()) {
|
||||
app_->current_art_loader()->LoadArt(*song);
|
||||
|
@ -336,7 +341,7 @@ QString AlbumCoverChoiceController::SaveCover(Song* song, const QDropEvent* e) {
|
|||
QImage image = qvariant_cast<QImage>(e->mimeData()->imageData());
|
||||
if (!image.isNull()) {
|
||||
QString cover_path =
|
||||
SaveCoverInCache(song->artist(), song->album(), image);
|
||||
SaveCoverInCache(song->effective_albumartist(), song->album(), image);
|
||||
SaveCover(song, cover_path);
|
||||
return cover_path;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue