731 return result; |
733 return result; |
732 */ |
734 */ |
733 // TODO: this is temporary solution until base64 defect in QT is fixed. |
735 // TODO: this is temporary solution until base64 defect in QT is fixed. |
734 TX_LOG |
736 TX_LOG |
735 QByteArray array; |
737 QByteArray array; |
736 QFile file( "e:\\album_art.png" ); |
738 |
|
739 // Remove old album art in case new one cannot be written. |
|
740 removeAlbumArtFile(); |
|
741 |
|
742 QString sTimeStamp = QTime::currentTime().toString( "hhmmsszzz" ); |
|
743 QString sTempFileLocation = QString( "e:\\album_art_%1.png" ).arg( sTimeStamp ); |
|
744 |
|
745 ( ( MpSongData* ) this )->mTempAlbumArt = sTempFileLocation; |
|
746 TX_LOG_ARGS( "Create album art file " << mTempAlbumArt ); |
|
747 |
|
748 QFile file( mTempAlbumArt ); |
737 file.open( QIODevice::WriteOnly ); |
749 file.open( QIODevice::WriteOnly ); |
738 if ( mAlbumArt && !mAlbumArt->isNull() && !mAlbumArt->qicon().isNull() ) |
750 if ( mAlbumArt && !mAlbumArt->isNull() && !mAlbumArt->qicon().isNull() ) |
739 { |
751 { |
740 QPixmap p = mAlbumArt->qicon().pixmap( QSize( 74, 74 ), QIcon::Normal, QIcon::Off ); |
752 QPixmap p = mAlbumArt->qicon().pixmap( QSize( 74, 74 ), QIcon::Normal, QIcon::Off ); |
741 p.save( &file, "PNG" ); |
753 p.save( &file, "PNG" ); |
742 //mAlbumArt->pixmap().save( &file, "PNG" ); // writes pixmap into bytes in PNG format |
754 //mAlbumArt->pixmap().save( &file, "PNG" ); // writes pixmap into bytes in PNG format |
743 } |
755 } |
744 file.close(); |
756 file.close(); |
745 return "e:\\album_art.png"; |
757 return mTempAlbumArt; |
746 } |
758 } |
747 |
759 |
|
760 /*! |
|
761 Delete temporary album art file. |
|
762 */ |
|
763 void MpSongData::removeAlbumArtFile() const |
|
764 { |
|
765 TX_ENTRY |
|
766 if ( !mTempAlbumArt.isEmpty() ) |
|
767 { |
|
768 TX_LOG_ARGS( "Remove album art file " << mTempAlbumArt ); |
|
769 QFile::remove( mTempAlbumArt ); |
|
770 ( ( MpSongData* ) this )->mTempAlbumArt = ""; |
|
771 } |
|
772 else |
|
773 { |
|
774 TX_LOG_ARGS( "Album art filename is empty" ); |
|
775 } |
|
776 TX_EXIT |
|
777 } |