Use const reference for AlbumCoverLoaderResult
This commit is contained in:
@@ -1304,7 +1304,7 @@ void MainWindow::MediaStopped() {
|
||||
|
||||
song_playing_ = Song();
|
||||
song_ = Song();
|
||||
album_cover_.reset();
|
||||
album_cover_ = AlbumCoverImageResult();
|
||||
|
||||
app_->scrobbler()->ClearPlaying();
|
||||
|
||||
@@ -3038,11 +3038,7 @@ void MainWindow::SearchForCover() {
|
||||
}
|
||||
|
||||
void MainWindow::SaveCoverToFile() {
|
||||
|
||||
if (album_cover_) {
|
||||
album_cover_choice_controller_->SaveCoverToFileManual(song_, album_cover_);
|
||||
}
|
||||
|
||||
album_cover_choice_controller_->SaveCoverToFileManual(song_, album_cover_);
|
||||
}
|
||||
|
||||
void MainWindow::UnsetCover() {
|
||||
@@ -3058,11 +3054,7 @@ void MainWindow::DeleteCover() {
|
||||
}
|
||||
|
||||
void MainWindow::ShowCover() {
|
||||
|
||||
if (album_cover_) {
|
||||
album_cover_choice_controller_->ShowCover(song_, album_cover_->image);
|
||||
}
|
||||
|
||||
album_cover_choice_controller_->ShowCover(song_, album_cover_.image);
|
||||
}
|
||||
|
||||
void MainWindow::SearchCoverAutomatically() {
|
||||
@@ -3071,29 +3063,24 @@ void MainWindow::SearchCoverAutomatically() {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::AlbumCoverLoaded(const Song &song, AlbumCoverLoaderResultPtr result) {
|
||||
void MainWindow::AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &result) {
|
||||
|
||||
if (song != song_playing_) return;
|
||||
|
||||
song_ = song;
|
||||
if (result) {
|
||||
album_cover_ = result->album_cover;
|
||||
emit AlbumCoverReady(song, result->album_cover->image);
|
||||
}
|
||||
else {
|
||||
album_cover_.reset();
|
||||
emit AlbumCoverReady(song, QImage());
|
||||
}
|
||||
album_cover_ = result.album_cover;
|
||||
|
||||
emit AlbumCoverReady(song, result.album_cover.image);
|
||||
|
||||
const bool enable_change_art = song.is_collection_song() && !song.effective_albumartist().isEmpty() && !song.album().isEmpty();
|
||||
album_cover_choice_controller_->show_cover_action()->setEnabled(result && result->success && result->type != AlbumCoverLoaderResult::Type::ManuallyUnset);
|
||||
album_cover_choice_controller_->cover_to_file_action()->setEnabled(result && result->success && result->type != AlbumCoverLoaderResult::Type::ManuallyUnset);
|
||||
album_cover_choice_controller_->show_cover_action()->setEnabled(result.success && result.type != AlbumCoverLoaderResult::Type::ManuallyUnset);
|
||||
album_cover_choice_controller_->cover_to_file_action()->setEnabled(result.success && result.type != AlbumCoverLoaderResult::Type::ManuallyUnset);
|
||||
album_cover_choice_controller_->cover_from_file_action()->setEnabled(enable_change_art);
|
||||
album_cover_choice_controller_->cover_from_url_action()->setEnabled(enable_change_art);
|
||||
album_cover_choice_controller_->search_for_cover_action()->setEnabled(app_->cover_providers()->HasAnyProviders() && enable_change_art);
|
||||
album_cover_choice_controller_->unset_cover_action()->setEnabled(enable_change_art && !song.has_manually_unset_cover());
|
||||
album_cover_choice_controller_->clear_cover_action()->setEnabled(enable_change_art && !song.art_manual().isEmpty());
|
||||
album_cover_choice_controller_->delete_cover_action()->setEnabled(enable_change_art && result && result->success && result->type != AlbumCoverLoaderResult::Type::ManuallyUnset);
|
||||
album_cover_choice_controller_->delete_cover_action()->setEnabled(enable_change_art && result.success && result.type != AlbumCoverLoaderResult::Type::ManuallyUnset);
|
||||
|
||||
GetCoverAutomatically();
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
void DeleteCover();
|
||||
void ShowCover();
|
||||
void SearchCoverAutomatically();
|
||||
void AlbumCoverLoaded(const Song &song, AlbumCoverLoaderResultPtr result);
|
||||
void AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &result);
|
||||
|
||||
void ScrobblingEnabledChanged(const bool value);
|
||||
void ScrobbleButtonVisibilityChanged(const bool value);
|
||||
@@ -390,7 +390,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
|
||||
Song song_;
|
||||
Song song_playing_;
|
||||
AlbumCoverImageResultPtr album_cover_;
|
||||
AlbumCoverImageResult album_cover_;
|
||||
bool exit_;
|
||||
int exit_count_;
|
||||
bool delete_files_;
|
||||
|
||||
@@ -122,7 +122,6 @@ void RegisterMetaTypes() {
|
||||
qRegisterMetaType<PlaylistSequence::RepeatMode>("PlaylistSequence::RepeatMode");
|
||||
qRegisterMetaType<PlaylistSequence::ShuffleMode>("PlaylistSequence::ShuffleMode");
|
||||
qRegisterMetaType<AlbumCoverLoaderResult>("AlbumCoverLoaderResult");
|
||||
qRegisterMetaType<AlbumCoverLoaderResultPtr>("AlbumCoverLoaderResultPtr");
|
||||
qRegisterMetaType<AlbumCoverLoaderResult::Type>("AlbumCoverLoaderResult::Type");
|
||||
qRegisterMetaType<CoverProviderSearchResult>("CoverProviderSearchResult");
|
||||
qRegisterMetaType<CoverProviderSearchResults>("CoverProviderSearchResults");
|
||||
|
||||
@@ -386,9 +386,7 @@ void Mpris2::CurrentSongChanged(const Song &song) {
|
||||
}
|
||||
|
||||
// ... and we add the cover information later, when it's available.
|
||||
void Mpris2::AlbumCoverLoaded(const Song &song, AlbumCoverLoaderResultPtr result) {
|
||||
|
||||
if (!result) return;
|
||||
void Mpris2::AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &result) {
|
||||
|
||||
last_metadata_ = QVariantMap();
|
||||
song.ToXesam(&last_metadata_);
|
||||
@@ -397,11 +395,11 @@ void Mpris2::AlbumCoverLoaded(const Song &song, AlbumCoverLoaderResultPtr result
|
||||
AddMetadata("mpris:trackid", current_track_id(), &last_metadata_);
|
||||
|
||||
QUrl cover_url;
|
||||
if (result->album_cover->cover_url.isValid() && result->album_cover->cover_url.isLocalFile() && QFile(result->album_cover->cover_url.toLocalFile()).exists()) {
|
||||
cover_url = result->album_cover->cover_url;
|
||||
if (result.album_cover.cover_url.isValid() && result.album_cover.cover_url.isLocalFile() && QFile(result.album_cover.cover_url.toLocalFile()).exists()) {
|
||||
cover_url = result.album_cover.cover_url;
|
||||
}
|
||||
else if (result->temp_cover_url.isValid() && result->temp_cover_url.isLocalFile()) {
|
||||
cover_url = result->temp_cover_url;
|
||||
else if (result.temp_cover_url.isValid() && result.temp_cover_url.isLocalFile()) {
|
||||
cover_url = result.temp_cover_url;
|
||||
}
|
||||
else if (song.art_manual().isValid() && song.art_manual().isLocalFile() && song.art_manual().path() != Song::kManuallyUnsetCover && song.art_manual().path() != Song::kEmbeddedCover) {
|
||||
cover_url = song.art_manual();
|
||||
|
||||
@@ -202,7 +202,7 @@ class Mpris2 : public QObject {
|
||||
void PlaylistChanged(const MprisPlaylist &playlist);
|
||||
|
||||
private slots:
|
||||
void AlbumCoverLoaded(const Song &song, AlbumCoverLoaderResultPtr result = AlbumCoverLoaderResultPtr());
|
||||
void AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &result = AlbumCoverLoaderResult());
|
||||
void EngineStateChanged(EngineBase::State newState);
|
||||
void VolumeChanged();
|
||||
|
||||
|
||||
@@ -96,15 +96,15 @@ void StandardItemIconLoader::ModelReset() {
|
||||
|
||||
}
|
||||
|
||||
void StandardItemIconLoader::AlbumCoverLoaded(const quint64 id, AlbumCoverLoaderResultPtr result) {
|
||||
void StandardItemIconLoader::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderResult &result) {
|
||||
|
||||
if (!pending_covers_.contains(id)) return;
|
||||
|
||||
QStandardItem *item = pending_covers_.take(id);
|
||||
if (!item) return;
|
||||
|
||||
if (result && result->success && !result->image_scaled.isNull() && result->type != AlbumCoverLoaderResult::Type::ManuallyUnset) {
|
||||
item->setIcon(QIcon(QPixmap::fromImage(result->image_scaled)));
|
||||
if (result.success && !result.image_scaled.isNull() && result.type != AlbumCoverLoaderResult::Type::ManuallyUnset) {
|
||||
item->setIcon(QIcon(QPixmap::fromImage(result.image_scaled)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class StandardItemIconLoader : public QObject {
|
||||
void LoadIcon(const Song &song, QStandardItem *for_item);
|
||||
|
||||
private slots:
|
||||
void AlbumCoverLoaded(const quint64 id, AlbumCoverLoaderResultPtr result);
|
||||
void AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderResult &result);
|
||||
void RowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
|
||||
void ModelReset();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user