bool EditMetadataDialog::Create(void) { if (! LoadWindowFromXML("music-ui.xml", "editmetadata", this)) return false; bool err = CreateCommon(); UIUtilE::Assign(this, m_titleEdit, "titleedit", &err); UIUtilE::Assign(this, m_artistEdit, "artistedit", &err); UIUtilE::Assign(this, m_compArtistEdit, "compartistedit", &err); UIUtilE::Assign(this, m_albumEdit, "albumedit", &err); UIUtilE::Assign(this, m_genreEdit, "genreedit", &err); UIUtilE::Assign(this, m_yearSpin, "yearspin", &err); UIUtilE::Assign(this, m_trackSpin, "tracknumspin", &err); UIUtilE::Assign(this, m_searchArtistButton, "searchartistbutton", &err); UIUtilE::Assign(this, m_searchCompArtistButton, "searchcompartistbutton", &err); UIUtilE::Assign(this, m_searchAlbumButton, "searchalbumbutton", &err); UIUtilE::Assign(this, m_searchGenreButton, "searchgenrebutton", &err); UIUtilW::Assign(this, m_artistIcon, "artisticon", &err); UIUtilW::Assign(this, m_albumIcon, "albumicon", &err); UIUtilW::Assign(this, m_genreIcon, "genreicon", &err); UIUtilW::Assign(this, m_ratingState, "ratingstate", &err); UIUtilW::Assign(this, m_ratingSpin, "ratingspin", &err); UIUtilW::Assign(this, m_incRatingButton, "incratingbutton", &err); UIUtilW::Assign(this, m_decRatingButton, "decratingbutton", &err); UIUtilE::Assign(this, m_compilationCheck, "compilationcheck", &err); UIUtilE::Assign(this, m_albumartButton, "albumartbutton", &err); if (err) { LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'editmetadata'"); return false; } m_yearSpin->SetRange(0, 9999, 1); m_trackSpin->SetRange(0, 9999, 1); if (m_ratingSpin) { m_ratingSpin->SetRange(0, 10, 1); connect(m_ratingSpin, SIGNAL(itemSelected(MythUIButtonListItem*)), SLOT(ratingSpinChanged(MythUIButtonListItem*))); } connect(m_artistEdit, SIGNAL(LosingFocus()), SLOT(artistLostFocus())); connect(m_albumEdit, SIGNAL(LosingFocus()), SLOT(albumLostFocus())); connect(m_genreEdit, SIGNAL(LosingFocus()), SLOT(genreLostFocus())); connect(m_searchArtistButton, SIGNAL(Clicked()), SLOT(searchArtist())); connect(m_searchCompArtistButton, SIGNAL(Clicked()), SLOT(searchCompilationArtist())); connect(m_searchAlbumButton, SIGNAL(Clicked()), SLOT(searchAlbum())); connect(m_searchGenreButton, SIGNAL(Clicked()), SLOT(searchGenre())); if (m_incRatingButton && m_decRatingButton) { connect(m_incRatingButton, SIGNAL(Clicked()), SLOT(incRating())); connect(m_decRatingButton, SIGNAL(Clicked()), SLOT(decRating())); } connect(m_compilationCheck, SIGNAL(toggled(bool)), SLOT(checkClicked(bool))); connect(m_albumartButton, SIGNAL(Clicked()), SLOT(switchToAlbumArt())); fillWidgets(); BuildFocusList(); return true; }
void EditMetadataDialog::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 == "optionsmenu") { if (resulttext == tr("Edit Albumart Images")) switchToAlbumArt(); else if (resulttext == tr("Search Internet For Genre Image")) { updateMetadata(); searchForGenreImages(); } else if (resulttext == tr("Search Internet For Artist Image")) { updateMetadata(); searchForArtistImages(); } else if (resulttext == tr("Search Internet For Album Image")) { updateMetadata(); searchForAlbumImages(); } else if (resulttext == tr("Check Track Length")) { int length = calcTrackLength(m_metadata->Filename()); if (length != m_metadata->Length() / 1000) { int oldLength = m_metadata->Length() / 1000; // save the new length to our working copy of the metadata m_metadata->setLength(length * 1000); // save the new length to the source copy of the metadata m_sourceMetadata->setLength(length * 1000); m_sourceMetadata->dumpToDatabase(); // this will update any track lengths displayed on screen gPlayer->sendMetadataChangedEvent(m_sourceMetadata->ID()); // this will force the playlist stats to update MusicPlayerEvent me(MusicPlayerEvent::TrackChangeEvent, gPlayer->getCurrentTrackPos()); gPlayer->dispatch(me); ShowOkPopup(QString("Updated track length to %1 seconds\nwas %2 seconds").arg(length).arg(oldLength)); } } } } 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") { scanForImages(); // force the icons to update updateAlbumImage(); updateArtistImage(); updateGenreImage(); m_metadata->getAlbumArtImages()->dumpToDatabase(); // force a reload of the images for any tracks affected MetadataPtrList *allMusic = gMusicData->all_music->getAllMetadata(); for (int x = 0; x < allMusic->count(); x++) { if ((allMusic->at(x)->ID() == m_sourceMetadata->ID()) || (allMusic->at(x)->getDirectoryId() == m_sourceMetadata->getDirectoryId())) { allMusic->at(x)->reloadAlbumArtImages(); gPlayer->sendAlbumArtChangedEvent(allMusic->at(x)->ID()); } } } } } }
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(); }