Exemplo n.º 1
0
void Metadata::setEmbeddedAlbumArt(AlbumArtList &albumart)
{
    // add the images found in the tag to the ones we got from the DB

    if (!m_albumArt)
        m_albumArt = new AlbumArtImages(this);

    for (int x = 0; x < albumart.size(); x++)
    {
        m_albumArt->addImage(albumart.at(x));
    }

    m_changed = true;
}
Exemplo n.º 2
0
void EditMetadataDialog::updateImageGrid()
{
    AlbumArtList *albumArtList = albumArt->getImageList();

    QSize size = coverart_grid->getImageItemSize();

    for (int x = 0; x < albumArtList->size(); x++)
    {
        if (albumArtList->at(x)->embedded)
            continue;

        QPixmap *pixmap = createScaledPixmap(albumArtList->at(x)->filename,
                                             size.width(), size.height(),
                                             Qt::KeepAspectRatio);

        ImageGridItem *item = new ImageGridItem(AlbumArtImages::getTypeName(albumArtList->at(x)->imageType),
                pixmap, false, (void*) albumArtList->at(x));
        coverart_grid->appendItem(item);
    }

    coverart_grid->setItemCount(albumArtList->size());
    coverart_grid->recalculateLayout();

    if (!albumArtList->empty())
        gridItemChanged(coverart_grid->getItemAt(0));

    coverart_grid->refresh();
}
Exemplo n.º 3
0
void EditMetadataCommon::scanForImages(void)
{
    // clear the original images
    AlbumArtList *imageList = m_metadata->getAlbumArtImages()->getImageList();
    while (!imageList->isEmpty())
    {
        delete imageList->back();
        imageList->pop_back();
    }

    // scan the directory for images
    QFileInfo fi(m_metadata->Filename());
    QDir dir = fi.absoluteDir();

    QString nameFilter = gCoreContext->GetSetting("AlbumArtFilter",
                                                  "*.png;*.jpg;*.jpeg;*.gif;*.bmp");
    dir.setNameFilters(nameFilter.split(";"));

    QStringList files = dir.entryList();

    for (int x = 0; x < files.size(); x++)
    {
        AlbumArtImage *image = new AlbumArtImage();
        //image->id = 0;
        image->filename = dir.absolutePath() + '/' + files.at(x);
        image->embedded = false;
        image->imageType = AlbumArtImages::guessImageType(image->filename);
        image->description = "";
        m_metadata->getAlbumArtImages()->addImage(image);
    }

    // scan the tracks tag for any images
    MetaIO *tagger = m_metadata->getTagger();

    if (tagger->supportsEmbeddedImages())
    {
        AlbumArtList art = tagger->getAlbumArtList(m_metadata->Filename());
        for (int x = 0; x < art.count(); x++)
        {
            AlbumArtImage image = art.at(x);
            m_metadata->getAlbumArtImages()->addImage(image);
        }
    }
}
Exemplo n.º 4
0
void EditAlbumartDialog::updateImageGrid(void)
{
    AlbumArtList *albumArtList = m_albumArt->getImageList();

    m_coverartList->Reset();

    for (int x = 0; x < albumArtList->size(); x++)
    {
        MythUIButtonListItem *item =
            new MythUIButtonListItem(m_coverartList,
                                     AlbumArtImages::getTypeName(albumArtList->at(x)->imageType),
                                     qVariantFromValue(albumArtList->at(x)));
        item->SetImage(albumArtList->at(x)->filename);
        QString state = albumArtList->at(x)->embedded ? "tag" : "file";
        item->DisplayState(state, "locationstate");
    }
}
Exemplo n.º 5
0
/*!
 * \brief Read the albumart images from the file
 *
 * \param tag The ID3v2 tag object in which to look for Album Art
 * \returns A QList containing a list of AlbumArtImage's
 *          with the type and description of the APIC tag.
 */
AlbumArtList MetaIOID3::readAlbumArt(TagLib::ID3v2::Tag *tag)
{
    AlbumArtList artlist;

    if (!tag->frameListMap()["APIC"].isEmpty())
    {
        TagLib::ID3v2::FrameList apicframes = tag->frameListMap()["APIC"];

        for(TagLib::ID3v2::FrameList::Iterator it = apicframes.begin();
            it != apicframes.end(); ++it)
        {

            AttachedPictureFrame *frame =
                static_cast<AttachedPictureFrame *>(*it);

            // Assume a valid image would have at least
            // 100 bytes of data (1x1 indexed gif is 35 bytes)
            if (frame->picture().size() < 100)
            {
                LOG(VB_GENERAL, LOG_NOTICE,
                    "Music Scanner - Discarding APIC frame "
                    "with size less than 100 bytes");
                continue;
            }

            AlbumArtImage *art = new AlbumArtImage();

            if (frame->description().isEmpty())
                art->m_description.clear();
            else
                art->m_description = TStringToQString(frame->description());

            art->m_embedded = true;
            art->m_hostname = gCoreContext->GetHostName();

            QString ext = getExtFromMimeType(
                                TStringToQString(frame->mimeType()).toLower());

            switch (frame->type())
            {
                case AttachedPictureFrame::FrontCover :
                    art->m_imageType = IT_FRONTCOVER;
                    art->m_filename = QString("front") + ext;
                    break;
                case AttachedPictureFrame::BackCover :
                    art->m_imageType = IT_BACKCOVER;
                    art->m_filename = QString("back") + ext;
                    break;
                case AttachedPictureFrame::Media :
                    art->m_imageType = IT_CD;
                    art->m_filename = QString("cd") + ext;
                    break;
                case AttachedPictureFrame::LeafletPage :
                    art->m_imageType = IT_INLAY;
                    art->m_filename = QString("inlay") + ext;
                    break;
                case AttachedPictureFrame::Artist :
                    art->m_imageType = IT_ARTIST;
                    art->m_filename = QString("artist") + ext;
                    break;
                case AttachedPictureFrame::Other :
                    art->m_imageType = IT_UNKNOWN;
                    art->m_filename = QString("unknown") + ext;
                    break;
                default:
                    LOG(VB_GENERAL, LOG_ERR, "Music Scanner - APIC tag found "
                                             "with unsupported type");
                    delete art;
                    continue;
            }

            artlist.append(art);
        }
    }

    return artlist;
}