Cover setting

This commit is contained in:
craig
2012-03-29 16:11:08 +00:00
committed by craig
parent 15b7baf6f5
commit f1f37390a9
2 changed files with 34 additions and 22 deletions

View File

@@ -1602,26 +1602,7 @@ void MainWindow::updateCurrentSong(const Song &song)
}
positionSlider->setEnabled(!currentIsStream());
// Determine if album cover should be updated
const QString &albumArtist=current.albumArtist();
QString covArtist=coverWidget->property("artist").toString();
QString covAlbum=coverWidget->property("album").toString();
if (covArtist!= albumArtist || covAlbum != current.album || (covArtist.isEmpty() && covAlbum.isEmpty())) {
if (!albumArtist.isEmpty() && !current.album.isEmpty()) {
Covers::Image img=Covers::self()->get(song, MPDParseUtils::groupSingle() && MusicLibraryModel::self()->isFromSingleTracks(song));
if (!img.img.isNull()) {
coverSong=current;
coverWidget->setPixmap(QPixmap::fromImage(img.img).scaled(coverWidget->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
coverFileName=img.fileName;
emit coverFile(img.fileName);
}
} else {
coverWidget->setPixmap(currentIsStream() ? noStreamCover : noCover);
}
coverWidget->setProperty("artist", albumArtist);
coverWidget->setProperty("album", current.album);
}
updateCurrentCover();
if (current.name.isEmpty()) {
trackLabel->setText(current.title);
@@ -1732,6 +1713,32 @@ void MainWindow::updateCurrentSong(const Song &song)
}
}
void MainWindow::updateCurrentCover()
{
// Determine if album cover should be updated
const QString &albumArtist=current.albumArtist();
QString covArtist=coverWidget->property("artist").toString();
QString covAlbum=coverWidget->property("album").toString();
if (covArtist!= albumArtist || covAlbum != current.album || (covArtist.isEmpty() && covAlbum.isEmpty())) {
if (!albumArtist.isEmpty() && !current.album.isEmpty()) {
Covers::Image img=Covers::self()->get(current, MPDParseUtils::groupSingle() && MusicLibraryModel::self()->isFromSingleTracks(current));
if (!img.img.isNull()) {
coverSong=current;
coverWidget->setPixmap(QPixmap::fromImage(img.img).scaled(coverWidget->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
coverFileName=img.fileName;
emit coverFile(img.fileName);
}
} else {
coverWidget->setPixmap(currentIsStream() ? noStreamCover : noCover);
if (dock && dock->enabled()) {
emit coverFile(QString());
}
}
coverWidget->setProperty("artist", albumArtist);
coverWidget->setProperty("album", current.album);
}
}
void MainWindow::scrollPlayQueue()
{
if (autoScrollPlayQueue && MPDState_Playing==MPDStatus::self()->state() && !playQueueModel.isGrouped()) {
@@ -1849,8 +1856,12 @@ void MainWindow::updateStatus()
stopTrackAction->setEnabled(false);
nextTrackAction->setEnabled(false);
prevTrackAction->setEnabled(false);
trackLabel->setText(QString());
artistLabel->setText(QString());
if (!playPauseTrackAction->isEnabled()) {
trackLabel->setText(QString());
artistLabel->setText(QString());
current=Song();
updateCurrentCover();
}
setWindowTitle("Cantata");
current.id=0;

View File

@@ -242,6 +242,7 @@ private Q_SLOTS:
void realSearchPlaylist();
void updatePlaylist(const QList<Song> &songs);
void updateCurrentSong(const Song &song);
void updateCurrentCover();
void scrollPlayQueue();
void updateStats();
void updateStatus();