예제 #1
0
bool EditAlbumartDialog::Create(void)
{
    if (! LoadWindowFromXML("music-ui.xml", "editalbumart", this))
        return false;

    bool err = CreateCommon();

    UIUtilE::Assign(this, m_coverartList,      "coverartlist",      &err);
    UIUtilE::Assign(this, m_imagetypeText,     "imagetypetext",     &err);
    UIUtilE::Assign(this, m_imagefilenameText, "imagefilenametext", &err);
    UIUtilE::Assign(this, m_coverartImage,     "coverartimage",     &err);

    UIUtilE::Assign(this, m_metadataButton,    "metadatabutton",    &err);

    if (err)
    {
        LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'editalbumart'");
        return false;
    }

    updateImageGrid();

    connect(m_coverartList, SIGNAL(itemSelected(MythUIButtonListItem*)),
            this, SLOT(gridItemChanged(MythUIButtonListItem*)));

    connect(m_metadataButton, SIGNAL(Clicked()), SLOT(switchToMetadata()));

    BuildFocusList();

    return true;
}
예제 #2
0
void EditAlbumartDialog::customEvent(QEvent *event)
{
    if (event->type() == DialogCompletionEvent::kEventType)
    {
        DialogCompletionEvent *dce = (DialogCompletionEvent*)(event);

        // make sure the user didn't ESCAPE out of the menu
        if (dce->GetResult() < 0)
            return;

        QString resultid   = dce->GetId();
        QString resulttext = dce->GetResultText();

        if (resultid == "changetypemenu")
        {
            int type = dce->GetData().toInt();

            if ((type >= IT_UNKNOWN) && (type < IT_LAST))
            {
                // get selected image in list
                MythUIButtonListItem *item = m_coverartList->GetItemCurrent();
                if (item)
                {
                    item->SetText(m_albumArt->getTypeName((ImageType) type));
                    AlbumArtImage *image = qVariantValue<AlbumArtImage*> (item->GetData());
                    if (image)
                    {
                        AlbumArtImage oldImage = *image;

                        image->imageType = (ImageType) type;

                        if (image->imageType == oldImage.imageType)
                            return;

                        // rename any cached image to match the new type
                        if (image->embedded)
                        {
                            // update the new cached image filename
                            image->filename = QString(GetConfDir() + "/MythMusic/AlbumArt/%1-%2.jpg")
                                                .arg(m_metadata->ID())
                                                .arg(AlbumArtImages::getTypeFilename(image->imageType));

                            if (image->filename != oldImage.filename && QFile::exists(oldImage.filename))
                            {
                                // remove any old cached file with the same name as the new one
                                QFile::remove(image->filename);
                                // rename the old cached file to the new one
                                QFile::rename(oldImage.filename, image->filename);

                                // force the theme image cache to refresh the image
                                GetMythUI()->RemoveFromCacheByFile(image->filename);
                            }

                            // change the image type in the tag if it supports it
                            MetaIO *tagger = m_metadata->getTagger();

                            if (tagger && tagger->supportsEmbeddedImages())
                            {
                                if (!tagger->changeImageType(m_metadata->Filename(), &oldImage, image->imageType))
                                    LOG(VB_GENERAL, LOG_INFO, "EditAlbumartDialog: failed to change image type");
                            }
                        }
                        else
                        {
                            QFileInfo fi(oldImage.filename);

                            // get the new images filename
                            image->filename = QString(fi.absolutePath() + "/%1.jpg")
                                    .arg(AlbumArtImages::getTypeFilename(image->imageType));

                            if (image->filename != oldImage.filename && QFile::exists(oldImage.filename))
                            {
                                // remove any old cached file with the same name as the new one
                                QFile::remove(image->filename);
                                // rename the old cached file to the new one
                                QFile::rename(oldImage.filename, image->filename);

                                // force the theme image cache to refresh the image
                                GetMythUI()->RemoveFromCacheByFile(image->filename);
                            }
                        }

                        m_albumArtChanged = true;

                        gridItemChanged(item);
                    }
                }
            }
        }
        else if (resultid == "asktypemenu")
        {
            int type = dce->GetData().toInt();

            if ((type >= IT_UNKNOWN) && (type < IT_LAST))
                copyImageToTag((ImageType) type);
        }
        else if (resultid == "optionsmenu")
        {
            if (resulttext == tr("Edit Metadata"))
                switchToMetadata();
            else if (resulttext == tr("Rescan For Images"))
                rescanForImages();
            else if (resulttext == tr("Search Internet For Images"))
                searchForAlbumImages();
            else if (resulttext == tr("Change Image Type"))
                showTypeMenu();
            else if (resulttext == tr("Copy Selected Image To Tag"))
                copySelectedImageToTag();
            else if (resulttext == tr("Remove Selected Image From Tag"))
                removeSelectedImageFromTag();
            else if (resulttext == tr("Copy Image To Tag"))
                startCopyImageToTag();
        }
        else if (resultid == "imagelocation")
        {
            m_imageFilename = resulttext;

            // save directory location for next time
            QFileInfo fi(m_imageFilename);
            gCoreContext->SaveSetting("MusicLastImageLocation", fi.canonicalPath());

            showTypeMenu(false);
        }
    }
    else if (event->type() == MythEvent::MythEventMessage)
    {
        MythEvent *me = (MythEvent *)event;
        QStringList tokens = me->Message().split(" ", QString::SkipEmptyParts);

        if (!tokens.isEmpty())
        {
            if (tokens[0] == "BROWSER_DOWNLOAD_FINISHED")
                rescanForImages();
        }
    }
}
예제 #3
0
void EditMetadataDialog::wireUpTheme()
{
    artist_edit = getUIRemoteEditType("artist_edit");
    if (artist_edit)
    {
        artist_edit->createEdit(this);
        connect(artist_edit, SIGNAL(loosingFocus()), this, SLOT(editLostFocus()));
    }

    compilation_artist_edit = getUIRemoteEditType("compilation_artist_edit");
    if (compilation_artist_edit)
    {
        compilation_artist_edit->createEdit(this);
        connect(compilation_artist_edit, SIGNAL(loosingFocus()), this, SLOT(editLostFocus()));
    }

    album_edit = getUIRemoteEditType("album_edit");
    if (album_edit)
    {
        album_edit->createEdit(this);
        connect(album_edit, SIGNAL(loosingFocus()), this, SLOT(editLostFocus()));
    }

    title_edit = getUIRemoteEditType("title_edit");
    if (title_edit)
    {
        title_edit->createEdit(this);
        connect(title_edit, SIGNAL(loosingFocus()), this, SLOT(editLostFocus()));
    }

    genre_edit = getUIRemoteEditType("genre_edit");
    if (genre_edit)
    {
        genre_edit->createEdit(this);
        connect(genre_edit, SIGNAL(loosingFocus()), this, SLOT(editLostFocus()));
    }

    year_edit = getUIRemoteEditType("year_edit");
    if (year_edit)
    {
        year_edit->createEdit(this);
        connect(year_edit, SIGNAL(loosingFocus()), this, SLOT(editLostFocus()));
    }

    track_edit = getUIRemoteEditType("track_edit");
    if (track_edit)
    {
        track_edit->createEdit(this);
        connect(track_edit, SIGNAL(loosingFocus()), this, SLOT(editLostFocus()));
    }

    lastplay_text = getUITextType("lastplay_text");
    playcount_text = getUITextType("playcount_text");
    filename_text = getUITextType("filename_text");
    rating_image = getUIRepeatedImageType("rating_image");

    compilation_check = getUICheckBoxType("compilation_check");
    if (compilation_check)
    {
        connect(compilation_check, SIGNAL(pushed(bool)), this, SLOT(checkClicked(bool)));
    }

    searchartist_button = getUIPushButtonType("searchartist_button");
    if (searchartist_button)
    {
        connect(searchartist_button, SIGNAL(pushed()), this, SLOT(searchArtist()));
    }

    searchcompilation_artist_button = getUIPushButtonType("searchcompilation_artist_button");
    if (searchcompilation_artist_button)
    {
        connect(searchcompilation_artist_button, SIGNAL(pushed()), this, SLOT(searchCompilationArtist()));
    }

    searchalbum_button = getUIPushButtonType("searchalbum_button");
    if (searchalbum_button)
    {
        connect(searchalbum_button, SIGNAL(pushed()), this, SLOT(searchAlbum()));
    }

    searchgenre_button = getUIPushButtonType("searchgenre_button");
    if (searchgenre_button)
    {
        connect(searchgenre_button, SIGNAL(pushed()), this, SLOT(searchGenre()));
    }

    metadata_button = getUITextButtonType("metadata_button");
    if (metadata_button)
    {
        metadata_button->setText(tr("Track Info."));
        connect(metadata_button, SIGNAL(pushed()), this, SLOT(switchToMetadata()));
    }

    albumart_button = getUITextButtonType("albumart_button");
    if (albumart_button)
    {
        albumart_button->setText(tr("Album Art"));
        connect(albumart_button, SIGNAL(pushed()), this, SLOT(switchToAlbumArt()));
    }

    dbstatistics_button = getUITextButtonType("dbstats_button");
    if (dbstatistics_button)
    {
        dbstatistics_button->setText(tr("Statistics"));
        connect(dbstatistics_button, SIGNAL(pushed()), this, SLOT(switchToDBStats()));
    }

    done_button = getUITextButtonType("done_button");
    if (done_button)
    {
        done_button->setText(tr("Done"));
        connect(done_button, SIGNAL(pushed()), this, SLOT(showSaveMenu()));
    }

    coverart_image = getUIImageType("coverart_image");
    coverart_grid = getUIImageGridType("coverart_grid");
    if (coverart_grid)
    {
        connect(coverart_grid, SIGNAL(itemChanged(ImageGridItem *)),
                this, SLOT(gridItemChanged(ImageGridItem *)));
    }

    imagetype_text = getUITextType("imagetype_text");
    imagefilename_text = getUITextType("imagefilename_text");

    rating_button = getUISelectorType("rating_button");
    if (rating_button)
    {

    }

    buildFocusList();
}