+
+ }
+ void PlayerMainWindow::playlistIdUpdated(int id, bool hasart, QString extension) {
+ if (hasart) {
+ getCoverArt(id);
+ }
+ else {
+ ui->labelArtLandscape->setVisible(false);
+ ui->labelArtPortrait->setVisible(false);
+ // could use a default graphic here!
+ // setCoverArtFromPixmap();
+ }
+ }
+ void PlayerMainWindow::readReady() {
+ QNetworkReply * reply = qobject_cast<QNetworkReply*>(sender());
+ // append to buffer
+ mResponse += reply->readAll();
+ }
+ void PlayerMainWindow::finished(QNetworkReply * reply) {
+ // now we can call setCoverArt to process the full buffers
+ this->setCoverArt(mResponse);
+ // only interested in finished signals
+ disconnect(mNetManager,SIGNAL(finished(QNetworkReply *)),this,SLOT(finished(QNetworkReply *)));
+ }
+ void PlayerMainWindow::getCoverArt(int id) {
+ mResponse.clear();
+ QNetworkReply * reply = mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/art?id=" + QString::number(id))));
+ connect(reply,SIGNAL(readyRead()),this,SLOT(readReady()));
+ connect(mNetManager,SIGNAL(finished(QNetworkReply *)),this,SLOT(finished(QNetworkReply *)));
+
+ }
+ void PlayerMainWindow::setCoverArt(const QByteArray data) {
+ QPixmap* image = new QPixmap();
+ if (image->loadFromData(data)) {
+ mHasImage = true;
+ ui->labelArtLandscape->setPixmap(image->scaledToHeight(120, Qt::SmoothTransformation));
+ ui->labelArtPortrait->setPixmap(image->scaledToHeight(310, Qt::SmoothTransformation));
+ if (mIsLandscape) {
+ ui->labelArtPortrait->setVisible(false);
+ ui->labelArtLandscape->setVisible(true);
+ }
+ else {
+ ui->labelArtLandscape->setVisible(false);
+ ui->labelArtPortrait->setVisible(true);
+ }
+ }
+ else {
+ ui->labelArtPortrait->setVisible(false);
+ ui->labelArtLandscape->setVisible(false);
+ }
+ }
+ void PlayerMainWindow::setCoverArtFromPixmap(QPixmap image) {
+ mHasImage = true;
+ ui->labelArtLandscape->setPixmap(image.scaledToHeight(120, Qt::SmoothTransformation));
+ ui->labelArtPortrait->setPixmap(image.scaledToHeight(310, Qt::SmoothTransformation));
+ if (mIsLandscape) {
+ ui->labelArtPortrait->setVisible(false);
+ ui->labelArtLandscape->setVisible(true);
+ }
+ else {
+ ui->labelArtLandscape->setVisible(false);
+ ui->labelArtPortrait->setVisible(true);
+ }