fix: display default album cover and other fix
This commit is contained in:
		@ -129,9 +129,9 @@ void MainWindow::setAudioMetadataForDisplay(QString title, QString artist, QStri
 | 
				
			|||||||
        if (!artist.isEmpty()) {
 | 
					        if (!artist.isEmpty()) {
 | 
				
			||||||
            ui->titleLabel->setText(QString("%1 - %2").arg(artist, title));
 | 
					            ui->titleLabel->setText(QString("%1 - %2").arg(artist, title));
 | 
				
			||||||
        } else if (!album.isEmpty()) {
 | 
					        } else if (!album.isEmpty()) {
 | 
				
			||||||
            ui->titleLabel->setText(QString("%1 - %2").arg(artist, album));
 | 
					            ui->titleLabel->setText(QString("%1 - %2").arg(album, title));
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            ui->titleLabel->setText(QString("%1").arg(artist));
 | 
					            ui->titleLabel->setText(QString("%1").arg(title));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -448,19 +448,27 @@ void MainWindow::initConnections()
 | 
				
			|||||||
            using namespace spID3;
 | 
					            using namespace spID3;
 | 
				
			||||||
            using namespace spFLAC;
 | 
					            using namespace spFLAC;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            bool coverLoaded = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (suffix == "MP3") {
 | 
					            if (suffix == "MP3") {
 | 
				
			||||||
                if (spID3::loadPictureData(filePath.toLocal8Bit().data())) {
 | 
					                if (spID3::loadPictureData(filePath.toLocal8Bit().data())) {
 | 
				
			||||||
 | 
					                    coverLoaded = true;
 | 
				
			||||||
                    QByteArray picData((const char*)spID3::getPictureDataPtr(), spID3::getPictureLength());
 | 
					                    QByteArray picData((const char*)spID3::getPictureDataPtr(), spID3::getPictureLength());
 | 
				
			||||||
                    ui->coverLabel->setPixmap(QPixmap::fromImage(QImage::fromData(picData)));
 | 
					                    ui->coverLabel->setPixmap(QPixmap::fromImage(QImage::fromData(picData)));
 | 
				
			||||||
                    spID3::freePictureData();
 | 
					                    spID3::freePictureData();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } else if (suffix == "FLAC") {
 | 
					            } else if (suffix == "FLAC") {
 | 
				
			||||||
                if (spFLAC::loadPictureData(filePath.toLocal8Bit().data())) {
 | 
					                if (spFLAC::loadPictureData(filePath.toLocal8Bit().data())) {
 | 
				
			||||||
 | 
					                    coverLoaded = true;
 | 
				
			||||||
                    QByteArray picData((const char*)spFLAC::getPictureDataPtr(), spFLAC::getPictureLength());
 | 
					                    QByteArray picData((const char*)spFLAC::getPictureDataPtr(), spFLAC::getPictureLength());
 | 
				
			||||||
                    ui->coverLabel->setPixmap(QPixmap::fromImage(QImage::fromData(picData)));
 | 
					                    ui->coverLabel->setPixmap(QPixmap::fromImage(QImage::fromData(picData)));
 | 
				
			||||||
                    spFLAC::freePictureData();
 | 
					                    spFLAC::freePictureData();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!coverLoaded) {
 | 
				
			||||||
 | 
					                ui->coverLabel->setPixmap(QPixmap(":/icons/icons/media-album-cover.svg"));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user