MythTV  master
mythmusic/mythmusic/editmetadata.cpp
Go to the documentation of this file.
1 // qt
2 #include <QKeyEvent>
3 #include <utility>
4 
5 // mythtv
6 #include <mythcontext.h>
7 #include <mythdbcon.h>
8 #include <mythuihelper.h>
9 #include <mythdirs.h>
10 #include <mythdialogbox.h>
11 #include <mythuitextedit.h>
12 #include <mythuitext.h>
13 #include <mythuibutton.h>
14 #include <mythuicheckbox.h>
15 #include <mythuistatetype.h>
16 #include <mythuibuttonlist.h>
17 #include <mythuispinbox.h>
18 #include <mythuiimage.h>
19 #include <mythuiwebbrowser.h>
20 #include <mythuifilebrowser.h>
21 #include <musicutils.h>
22 #include <mythprogressdialog.h>
23 #include <remotefile.h>
24 #include <mthreadpool.h>
25 
26 // mythmusic
27 #include "musicdata.h"
28 #include "decoder.h"
29 #include "genres.h"
30 #include "metaio.h"
31 #include "musicplayer.h"
32 
33 
34 #include "editmetadata.h"
35 
36 // these need to be static so both screens can pick them up
40 
42  MusicMetadata *source_metadata,
43  const QString &name) :
44  MythScreenType(parent, name)
45 {
46  // make a copy so we can abandon changes
47  s_metadata = new MusicMetadata(*source_metadata);
48  s_sourceMetadata = source_metadata;
49 
50  s_metadataOnly = false;
51 }
52 
54 {
55  // do we need to save anything?
57  {
59 
60  // force a reload of the images for any tracks affected
62  for (int x = 0; x < allMusic->count(); x++)
63  {
64  if ((allMusic->at(x)->ID() == s_sourceMetadata->ID()) ||
65  (allMusic->at(x)->getDirectoryId() == s_sourceMetadata->getDirectoryId()))
66  {
67  allMusic->at(x)->reloadAlbumArtImages();
68  gPlayer->sendAlbumArtChangedEvent(allMusic->at(x)->ID());
69  }
70  }
71  }
72 }
73 
75 {
76  bool err = false;
77 
78  UIUtilE::Assign(this, m_doneButton, "donebutton", &err);
79 
81 
82  return err;
83 }
84 
85 bool EditMetadataCommon::keyPressEvent(QKeyEvent *event)
86 {
87  if (GetFocusWidget() && GetFocusWidget()->keyPressEvent(event))
88  return true;
89 
90  QStringList actions;
91  bool handled = GetMythMainWindow()->TranslateKeyPress("Music", event, actions);
92 
93  for (int i = 0; i < actions.size() && !handled; i++)
94  {
95  QString action = actions[i];
96  handled = true;
97 
98  if (action == "ESCAPE")
99  showSaveMenu();
100  else
101  handled = false;
102  }
103 
104  if (!handled && MythScreenType::keyPressEvent(event))
105  handled = true;
106 
107  return handled;
108 }
109 
111 {
112  MythUITextEdit *edit = dynamic_cast<MythUITextEdit *>(GetChild("albumedit"));
113  if (edit)
114  s_metadata->setAlbum(edit->GetText());
115 
116  edit = dynamic_cast<MythUITextEdit *>(GetChild("artistedit"));
117  if (edit)
118  s_metadata->setArtist(edit->GetText());
119 
120  edit = dynamic_cast<MythUITextEdit *>(GetChild("compartistedit"));
121  if (edit)
123 
124  edit = dynamic_cast<MythUITextEdit *>(GetChild("titleedit"));
125  if (edit)
126  s_metadata->setTitle(edit->GetText());
127 
128  edit = dynamic_cast<MythUITextEdit *>(GetChild("genreedit"));
129  if (edit)
130  s_metadata->setGenre(edit->GetText());
131 
132  MythUISpinBox *spin = dynamic_cast<MythUISpinBox *>(GetChild("yearspin"));
133  if (spin)
134  s_metadata->setYear(spin->GetIntValue());
135 
136  spin = dynamic_cast<MythUISpinBox *>(GetChild("tracknumspin"));
137  if (spin)
138  s_metadata->setTrack(spin->GetIntValue());
139 
140  spin = dynamic_cast<MythUISpinBox *>(GetChild("discnumspin"));
141  if (spin)
143 
144  spin = dynamic_cast<MythUISpinBox *>(GetChild("ratingspin"));
145  if (spin)
146  s_metadata->setRating(spin->GetIntValue());
147 
148  MythUICheckBox *check = dynamic_cast<MythUICheckBox *>(GetChild("compilationcheck"));
149  if (check)
151 }
152 
154 {
155  updateMetadata();
156 
157  if (!hasMetadataChanged())
158  {
159  Close();
160  return;
161  }
162 
163  QString label = tr("Save Changes?");
164 
165  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
166 
167  auto *menu = new MythDialogBox(label, popupStack, "savechangesmenu");
168 
169  if (!menu->Create())
170  {
171  delete menu;
172  return;
173  }
174 
175  menu->SetReturnEvent(this, "savechangesmenu");
176 
177  if (s_metadataOnly)
178  menu->AddButton(tr("Save Changes"), SLOT(saveToMetadata()));
179  else
180  menu->AddButton(tr("Save Changes"), SLOT(saveAll()));
181 
182  menu->AddButton(tr("Exit/Do Not Save"), SLOT(cleanupAndClose()));
183 
184  popupStack->AddScreen(menu);
185 }
186 
188 {
189  if (s_metadata)
190  {
191  delete s_metadata;
192  s_metadata = nullptr;
193  }
194 
195  Close();
196 }
197 
199 {
201  emit metadataChanged();
202  cleanupAndClose();
203 }
204 
206 {
207  s_metadata->setAlbumId(-1);
208  s_metadata->setGenreId(-1);
209  s_metadata->setArtistId(-1);
210 
213 
215 }
216 
218 {
219  saveToDatabase();
220 
221  // only write to the tag if it's enabled by the user
222  if (GetMythDB()->GetBoolSetting("AllowTagWriting", false))
223  {
224  QStringList strList;
225  strList << "MUSIC_TAG_UPDATE_METADATA %1 %2"
226  << s_metadata->Hostname()
227  << QString::number(s_metadata->ID());
228 
229  auto *thread = new SendStringListThread(strList);
230  MThreadPool::globalInstance()->start(thread, "UpdateMetadata");
231  }
232 
233  cleanupAndClose();
234 }
235 
237 {
238  s_metadataOnly = true;
239 
240  MythUIButton *albumartButton = dynamic_cast<MythUIButton *>(GetChild("albumartbutton"));
241  if (albumartButton)
242  albumartButton->Hide();
243 }
244 
246 {
247  bool changed = false;
248 
249  changed |= (s_metadata->Album() != s_sourceMetadata->Album());
250  changed |= (s_metadata->Artist() != s_sourceMetadata->Artist());
252  changed |= (s_metadata->Title() != s_sourceMetadata->Title());
253  changed |= (s_metadata->Genre() != s_sourceMetadata->Genre());
254  changed |= (s_metadata->Year() != s_sourceMetadata->Year());
255  changed |= (s_metadata->Track() != s_sourceMetadata->Track());
256  changed |= (s_metadata->DiscNumber() != s_sourceMetadata->DiscNumber());
257  changed |= (s_metadata->Compilation() != s_sourceMetadata->Compilation());
258  changed |= (s_metadata->Rating() != s_sourceMetadata->Rating());
259 
260  return changed;
261 }
262 
265 {
266  QString artist = s_metadata->Artist().replace(' ', '+');
267  artist = QUrl::toPercentEncoding(artist, "+");
268 
269  QString album = s_metadata->Album().replace(' ', '+');
270  album = QUrl::toPercentEncoding(album, "+");
271 
272  QUrl url("http://www.google.co.uk/images?q=" + artist + "+" + album, QUrl::TolerantMode);
273 
274  m_searchType = "album";
275 
276  GetMythMainWindow()->HandleMedia("WebBrowser", url.toString(), GetConfDir() + "/MythMusic/", "front.jpg");
277 }
278 
280 {
282 }
283 
285 // EditMatadataDialog
286 
288  : EditMetadataCommon(parent, source_metadata, "EditMetadataDialog")
289 {
290  gCoreContext->addListener(this);
291 }
292 
294  : EditMetadataCommon(parent, "EditMetadataDialog")
295 {
296  gCoreContext->addListener(this);
297 }
298 
300 {
302 }
303 
305 {
306  if (! LoadWindowFromXML("music-ui.xml", "editmetadata", this))
307  return false;
308 
309  bool err = CreateCommon();
310 
311  UIUtilE::Assign(this, m_titleEdit, "titleedit", &err);
312  UIUtilE::Assign(this, m_artistEdit, "artistedit", &err);
313  UIUtilE::Assign(this, m_compArtistEdit, "compartistedit", &err);
314  UIUtilE::Assign(this, m_albumEdit, "albumedit", &err);
315  UIUtilE::Assign(this, m_genreEdit, "genreedit", &err);
316 
317  UIUtilE::Assign(this, m_yearSpin, "yearspin", &err);
318  UIUtilE::Assign(this, m_trackSpin, "tracknumspin", &err);
319  UIUtilW::Assign(this, m_discSpin, "discnumspin", &err);
320 
321  UIUtilE::Assign(this, m_searchArtistButton, "searchartistbutton", &err);
322  UIUtilE::Assign(this, m_searchCompArtistButton, "searchcompartistbutton", &err);
323  UIUtilE::Assign(this, m_searchAlbumButton, "searchalbumbutton", &err);
324  UIUtilE::Assign(this, m_searchGenreButton, "searchgenrebutton", &err);
325 
326  UIUtilW::Assign(this, m_artistIcon, "artisticon", &err);
327  UIUtilW::Assign(this, m_albumIcon, "albumicon", &err);
328  UIUtilW::Assign(this, m_genreIcon, "genreicon", &err);
329 
330  UIUtilW::Assign(this, m_ratingState, "ratingstate", &err);
331  UIUtilW::Assign(this, m_ratingSpin, "ratingspin", &err);
332 
333  UIUtilW::Assign(this, m_incRatingButton, "incratingbutton", &err);
334  UIUtilW::Assign(this, m_decRatingButton, "decratingbutton", &err);
335 
336  UIUtilE::Assign(this, m_compilationCheck, "compilationcheck", &err);
337 
338  UIUtilE::Assign(this, m_albumartButton, "albumartbutton", &err);
339 
340  if (err)
341  {
342  LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'editmetadata'");
343  return false;
344  }
345 
346  m_yearSpin->SetRange(QDate::currentDate().year(), 1000, 1);
347  m_yearSpin->AddSelection(0, "None");
348  m_trackSpin->SetRange(0, 999, 1);
349 
350  if (m_discSpin)
351  m_discSpin->SetRange(0, 999, 1);
352 
353  if (m_ratingSpin)
354  {
355  m_ratingSpin->SetRange(0, 10, 1, 2);
358  }
359 
363 
368 
370  {
373  }
374 
376 
378 
379  fillWidgets();
380 
381  BuildFocusList();
382 
383  return true;
384 }
385 
387 {
388  m_compArtistEdit->SetText(s_metadata->CompilationArtist());
389  m_albumEdit->SetText(s_metadata->Album());
390  m_artistEdit->SetText(s_metadata->Artist());
391  m_genreEdit->SetText(s_metadata->Genre());
392  m_titleEdit->SetText(s_metadata->Title());
393  m_yearSpin->SetValue(s_metadata->Year());
394  m_trackSpin->SetValue(s_metadata->Track());
395  m_compilationCheck->SetCheckState(s_metadata->Compilation());
396 
397  if (m_discSpin)
398  m_discSpin->SetValue(s_metadata->DiscNumber());
399 
400  updateRating();
401 
405 }
406 
408 {
409  s_metadata->incRating();
410  updateRating();
411 }
412 
414 {
415  s_metadata->decRating();
416  updateRating();
417 }
418 
420 {
421  if (item)
422  {
423  int rating = item->GetData().value<int>();
424  s_metadata->setRating(rating);
425 
426  if (m_ratingState)
427  m_ratingState->DisplayState(QString("%1").arg(s_metadata->Rating()));
428  }
429 }
430 
432 {
433  if (m_ratingState)
434  m_ratingState->DisplayState(QString("%1").arg(s_metadata->Rating()));
435 
436  if (m_ratingSpin)
437  m_ratingSpin->SetValue(s_metadata->Rating());
438 }
439 
440 bool EditMetadataDialog::keyPressEvent(QKeyEvent *event)
441 {
442  if (GetFocusWidget() && GetFocusWidget()->keyPressEvent(event))
443  return true;
444 
445  QStringList actions;
446  bool handled = GetMythMainWindow()->TranslateKeyPress("Music", event, actions);
447 
448  for (int i = 0; i < actions.size() && !handled; i++)
449  {
450  QString action = actions[i];
451  handled = true;
452 
453  if (action == "THMBUP")
454  incRating();
455  else if (action == "THMBDOWN")
456  decRating();
457  else if (action == "MENU")
458  showMenu();
459  else
460  handled = false;
461  }
462 
463  if (!handled && EditMetadataCommon::keyPressEvent(event))
464  handled = true;
465 
466  return handled;
467 }
468 
470 {
471  if (s_metadataOnly)
472  return;
473 
474  QString label = tr("Options");
475 
476  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
477 
478  auto *menu = new MythDialogBox(label, popupStack, "optionsmenu");
479 
480  if (!menu->Create())
481  {
482  delete menu;
483  return;
484  }
485 
486  menu->SetReturnEvent(this, "optionsmenu");
487 
488  menu->AddButton(tr("Edit Albumart Images"));
489  menu->AddButton(tr("Search Internet For Artist Image"));
490  menu->AddButton(tr("Search Internet For Album Image"));
491  menu->AddButton(tr("Search Internet For Genre Image"));
492  menu->AddButton(tr("Check Track Length"));
493 
494  popupStack->AddScreen(menu);
495 }
496 
498 {
499  updateMetadata();
500 
502 
503  auto *editDialog = new EditAlbumartDialog(mainStack);
504 
505  if (!editDialog->Create())
506  {
507  delete editDialog;
508  return;
509  }
510 
511  mainStack->AddScreen(editDialog);
512 
513  Close();
514 }
515 
517 {
518  if (!state)
519  {
520  m_compArtistEdit->SetText(s_metadata->Artist());
521  }
522  else
523  {
524  if (m_compArtistEdit->GetText().isEmpty() ||
526  {
527  m_compArtistEdit->SetText(tr("Various Artists"));
528  }
529  }
530 }
531 
533 {
534  QString msg = tr("Select an Artist");
535  QStringList searchList = MusicMetadata::fillFieldList("artist");
536  QString s = s_metadata->Artist();
537 
538  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
539  auto *searchDlg = new MythUISearchDialog(popupStack, msg, searchList, false, s);
540 
541  if (!searchDlg->Create())
542  {
543  delete searchDlg;
544  return;
545  }
546 
548 
549  popupStack->AddScreen(searchDlg);
550 }
551 
552 void EditMetadataDialog::setArtist(const QString& artist)
553 {
554  m_artistEdit->SetText(artist);
556 }
557 
559 {
560  QString artist = m_artistEdit->GetText();
561 
562  QString file;
563 
564  if (m_artistIcon)
565  {
566  file = findIcon("artist", artist.toLower(), true);
567  if (!file.isEmpty())
568  {
570  m_artistIcon->Load();
571  }
572  else
573  m_artistIcon->Reset();
574  }
575 }
576 
578 {
579  QString msg = tr("Select a Compilation Artist");
580  QStringList searchList = MusicMetadata::fillFieldList("compilation_artist");
581  QString s = s_metadata->CompilationArtist();
582 
583  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
584  auto *searchDlg = new MythUISearchDialog(popupStack, msg, searchList, false, s);
585 
586  if (!searchDlg->Create())
587  {
588  delete searchDlg;
589  return;
590  }
591 
593 
594  popupStack->AddScreen(searchDlg);
595 }
596 
597 void EditMetadataDialog::setCompArtist(const QString& compArtist)
598 {
599  m_compArtistEdit->SetText(compArtist);
600 }
601 
603 {
604  QString msg = tr("Select an Album");
605  QStringList searchList = MusicMetadata::fillFieldList("album");
606  QString s = s_metadata->Album();
607 
608  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
609  auto *searchDlg = new MythUISearchDialog(popupStack, msg, searchList, false, s);
610 
611  if (!searchDlg->Create())
612  {
613  delete searchDlg;
614  return;
615  }
616 
618 
619  popupStack->AddScreen(searchDlg);
620 }
621 
622 void EditMetadataDialog::setAlbum(const QString& album)
623 {
624  m_albumEdit->SetText(album);
626 }
627 
629 {
630  QString file;
631 
632  if (m_albumIcon)
633  {
634  file = s_metadata->getAlbumArtFile();
635  if (!file.isEmpty())
636  {
638  m_albumIcon->Load();
639  }
640  else
641  m_albumIcon->Reset();
642  }
643 }
644 
646 {
647  QString msg = tr("Select a Genre");
648  QStringList searchList = MusicMetadata::fillFieldList("genre");
649  // load genre list
650  /*
651  searchList.clear();
652  for (const auto &genre : genre_table)
653  searchList.push_back(QString::fromStdString(genre));
654  searchList.sort();
655  */
656 
657  QString s = s_metadata->Genre();
658 
659  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
660  auto *searchDlg = new MythUISearchDialog(popupStack, msg, searchList, false, s);
661 
662  if (!searchDlg->Create())
663  {
664  delete searchDlg;
665  return;
666  }
667 
669 
670  popupStack->AddScreen(searchDlg);
671 }
672 
673 void EditMetadataDialog::setGenre(const QString& genre)
674 {
675  m_genreEdit->SetText(genre);
677 }
678 
680 {
681  QString genre = m_genreEdit->GetText();
682  QString file;
683 
684  if (m_genreIcon)
685  {
686  file = findIcon("genre", genre.toLower(), true);
687  if (!file.isEmpty())
688  {
690  m_genreIcon->Load();
691  }
692  else
693  m_genreIcon->Reset();
694  }
695 }
696 
698 {
700 }
701 
703 {
705 }
706 
708 {
710 }
711 
714 {
715  QString genre= s_metadata->Genre().replace(' ', '+');
716  genre = QUrl::toPercentEncoding(genre, "+");
717 
718  QUrl url("http://www.flickr.com/search/groups/?w=908425%40N22&m=pool&q=" + genre, QUrl::TolerantMode);
719 
720  m_searchType = "genre";
721  GetMythMainWindow()->HandleMedia("WebBrowser", url.toString(), GetConfDir() + "/MythMusic/", "genre.jpg");
722 }
723 
726 {
727  QString artist = s_metadata->Artist().replace(' ', '+');
728  artist = QUrl::toPercentEncoding(artist, "+");
729 
730  QUrl url("http://www.google.co.uk/images?q=" + artist, QUrl::TolerantMode);
731 
732  m_searchType = "artist";
733  GetMythMainWindow()->HandleMedia("WebBrowser", url.toString(), GetConfDir() + "/MythMusic/", "artist.jpg");
734 }
735 
736 void EditMetadataDialog::customEvent(QEvent *event)
737 {
738  if (event->type() == DialogCompletionEvent::kEventType)
739  {
740  auto *dce = dynamic_cast<DialogCompletionEvent*>(event);
741  // make sure the user didn't ESCAPE out of the menu
742  if ((dce == nullptr) || (dce->GetResult() < 0))
743  return;
744 
745  QString resultid = dce->GetId();
746  QString resulttext = dce->GetResultText();
747 
748 
749  if (resultid == "optionsmenu")
750  {
751  if (resulttext == tr("Edit Albumart Images"))
753  else if (resulttext == tr("Search Internet For Genre Image"))
754  {
755  updateMetadata();
757  }
758  else if (resulttext == tr("Search Internet For Artist Image"))
759  {
760  updateMetadata();
762  }
763  else if (resulttext == tr("Search Internet For Album Image"))
764  {
765  updateMetadata();
766  searchForAlbumImages();
767  }
768  else if (resulttext == tr("Check Track Length"))
769  {
770  QStringList strList;
771  strList << "MUSIC_CALC_TRACK_LENGTH"
772  << s_metadata->Hostname()
773  << QString::number(s_metadata->ID());
774 
775  auto *thread = new SendStringListThread(strList);
776  MThreadPool::globalInstance()->start(thread, "Send MUSIC_CALC_TRACK_LENGTH");
777 
778  ShowOkPopup(tr("Asked the backend to check the tracks length"));
779  }
780  }
781  }
782  else if (event->type() == MythEvent::MythEventMessage)
783  {
784  auto *me = dynamic_cast<MythEvent *>(event);
785  if (me == nullptr)
786  return;
787 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
788  QStringList tokens = me->Message().split(" ", QString::SkipEmptyParts);
789 #else
790  QStringList tokens = me->Message().split(" ", Qt::SkipEmptyParts);
791 #endif
792 
793  if (!tokens.isEmpty())
794  {
795  if (tokens[0] == "BROWSER_DOWNLOAD_FINISHED")
796  {
797  QStringList args = me->ExtraDataList();
798  QString oldFilename = args[1];
799  int fileSize = args[2].toInt();
800  int errorCode = args[4].toInt();
801 
802  if ((errorCode != 0) || (fileSize == 0))
803  return;
804 
805  QString newFilename;
806 
807  if (m_searchType == "artist")
808  {
809  QString cleanName = fixFilename(s_metadata->Artist().toLower());
810  QString file = QString("Icons/%1/%2.jpg").arg("artist").arg(cleanName);
812  0, file, "MusicArt");
813  }
814  else if (m_searchType == "genre")
815  {
816  QString cleanName = fixFilename(s_metadata->Genre().toLower());
817  QString file = QString("Icons/%1/%2.jpg").arg("genre").arg(cleanName);
819  0, file, "MusicArt");
820  }
821  else if (m_searchType == "album")
822  {
823  // move the image from the MythMusic config dir to the tracks
824  // dir in the 'Music' storage group
825  newFilename = s_metadata->Filename();
826  newFilename = newFilename.section( '/', 0, -2);
827  newFilename = newFilename + '/' + oldFilename.section( '/', -1, -1);
828  }
829  else
830  {
831  LOG(VB_GENERAL, LOG_ERR, QString("Got unknown search type '%1' "
832  "in BROWSER_DOWNLOAD_FINISHED event")
833  .arg(m_searchType));
834  return;
835  }
836 
837  RemoteFile::CopyFile(oldFilename, newFilename, true);
838  QFile::remove(oldFilename);
839 
840  if (m_searchType == "album")
841  scanForImages();
842 
843  // force the icons to update
847 
848  s_metadata->getAlbumArtImages()->dumpToDatabase();
849  // force a reload of the images for any tracks affected
851  for (int x = 0; x < allMusic->count(); x++)
852  {
853  if ((allMusic->at(x)->ID() == s_sourceMetadata->ID()) ||
854  (allMusic->at(x)->getDirectoryId() == s_sourceMetadata->getDirectoryId()))
855  {
856  allMusic->at(x)->reloadAlbumArtImages();
857  gPlayer->sendAlbumArtChangedEvent(allMusic->at(x)->ID());
858  }
859  }
860  }
861  }
862  }
863 }
864 
866 // EditAlbumartDialog
867 
869  : EditMetadataCommon(parent, "EditAlbumartDialog")
870 {
871  gCoreContext->addListener(this);
872 }
873 
875 {
877 }
878 
880 {
881  if (! LoadWindowFromXML("music-ui.xml", "editalbumart", this))
882  return false;
883 
884  bool err = CreateCommon();
885 
886  UIUtilE::Assign(this, m_coverartList, "coverartlist", &err);
887  UIUtilE::Assign(this, m_imagetypeText, "imagetypetext", &err);
888  UIUtilE::Assign(this, m_imagefilenameText, "imagefilenametext", &err);
889  UIUtilE::Assign(this, m_coverartImage, "coverartimage", &err);
890 
891  UIUtilE::Assign(this, m_metadataButton, "metadatabutton", &err);
892 
893  if (err)
894  {
895  LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'editalbumart'");
896  return false;
897  }
898 
899  updateImageGrid();
900 
903 
905 
906  BuildFocusList();
907 
908  return true;
909 }
910 
912 {
913  if (!item)
914  return;
915 
916  if (m_coverartImage)
917  {
918  auto *image = item->GetData().value<AlbumArtImage*>();
919  if (image)
920  {
921  m_coverartImage->SetFilename(image->m_filename);
923  if (m_imagetypeText)
926  {
927  QFileInfo fi(image->m_filename);
928  m_imagefilenameText->SetText(fi.fileName());
929  }
930  }
931  }
932 }
933 
935 {
937 
939 
940  for (auto *art : qAsConst(*albumArtList))
941  {
942  auto *item = new MythUIButtonListItem(m_coverartList,
943  AlbumArtImages::getTypeName(art->m_imageType),
944  QVariant::fromValue(art));
945  item->SetImage(art->m_filename);
946  QString state = art->m_embedded ? "tag" : "file";
947  item->DisplayState(state, "locationstate");
948  }
949 }
950 
951 bool EditAlbumartDialog::keyPressEvent(QKeyEvent *event)
952 {
953  if (GetFocusWidget() && GetFocusWidget()->keyPressEvent(event))
954  return true;
955 
956  QStringList actions;
957  bool handled = GetMythMainWindow()->TranslateKeyPress("Music", event, actions);
958 
959  for (int i = 0; i < actions.size() && !handled; i++)
960  {
961  QString action = actions[i];
962  handled = true;
963 
964  if (action == "MENU")
965  showMenu();
966  else if (action == "INFO")
967  showTypeMenu();
968  else
969  handled = false;
970  }
971 
972  if (!handled && EditMetadataCommon::keyPressEvent(event))
973  handled = true;
974 
975  return handled;
976 }
977 
979 {
981 
982  auto *editDialog = new EditMetadataDialog(mainStack);
983 
984  if (!editDialog->Create())
985  {
986  delete editDialog;
987  return;
988  }
989 
990  mainStack->AddScreen(editDialog);
991 
992  Close();
993 }
994 
995 void EditAlbumartDialog::showTypeMenu(bool changeType)
996 {
997  if (changeType && m_coverartList->GetCount() == 0)
998  return;
999 
1000  QString label;
1001 
1002  if (changeType)
1003  label = tr("Change Image Type");
1004  else
1005  label = tr("What image type do you want to use for this image?");
1006 
1007  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
1008 
1009  auto *menu = new MythDialogBox(label, popupStack, "typemenu");
1010 
1011  if (!menu->Create())
1012  {
1013  delete menu;
1014  return;
1015  }
1016 
1017  ImageType imageType = IT_UNKNOWN;
1018  if (changeType)
1019  menu->SetReturnEvent(this, "changetypemenu");
1020  else
1021  {
1022  menu->SetReturnEvent(this, "asktypemenu");
1024  }
1025 
1026  menu->AddButton(AlbumArtImages::getTypeName(IT_UNKNOWN), QVariant::fromValue((int)IT_UNKNOWN), false, (imageType == IT_UNKNOWN));
1027  menu->AddButton(AlbumArtImages::getTypeName(IT_FRONTCOVER), QVariant::fromValue((int)IT_FRONTCOVER), false, (imageType == IT_FRONTCOVER));
1028  menu->AddButton(AlbumArtImages::getTypeName(IT_BACKCOVER), QVariant::fromValue((int)IT_BACKCOVER), false, (imageType == IT_BACKCOVER));
1029  menu->AddButton(AlbumArtImages::getTypeName(IT_CD), QVariant::fromValue((int)IT_CD), false, (imageType == IT_CD));
1030  menu->AddButton(AlbumArtImages::getTypeName(IT_INLAY), QVariant::fromValue((int)IT_INLAY), false, (imageType == IT_INLAY));
1031  menu->AddButton(AlbumArtImages::getTypeName(IT_ARTIST), QVariant::fromValue((int)IT_ARTIST), false, (imageType == IT_ARTIST));
1032 
1033  popupStack->AddScreen(menu);
1034 }
1035 
1037 {
1038  QString label = tr("Options");
1039 
1040  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
1041 
1042  auto *menu = new MythDialogBox(label, popupStack, "optionsmenu");
1043 
1044  if (!menu->Create())
1045  {
1046  delete menu;
1047  return;
1048  }
1049 
1050  menu->SetReturnEvent(this, "optionsmenu");
1051 
1052  menu->AddButton(tr("Edit Metadata"));
1053  menu->AddButton(tr("Rescan For Images"));
1054 
1055 
1056  menu->AddButton(tr("Search Internet For Images"));
1057 
1058  MetaIO *tagger = MetaIO::createTagger(s_metadata->Filename(false));
1059 
1061  {
1062  menu->AddButton(tr("Change Image Type"), nullptr, true);
1063 
1064  if (GetMythDB()->GetBoolSetting("AllowTagWriting", false))
1065  {
1067  if (item)
1068  {
1069  auto *image = item->GetData().value<AlbumArtImage*>();
1070  if (image)
1071  {
1072  if (!image->m_embedded)
1073  {
1074  if (tagger && tagger->supportsEmbeddedImages())
1075  menu->AddButton(tr("Copy Selected Image To Tag"));
1076  }
1077  else
1078  {
1079  if (tagger && tagger->supportsEmbeddedImages())
1080  menu->AddButton(tr("Remove Selected Image From Tag"));
1081  }
1082  }
1083  }
1084  }
1085  }
1086 
1087  if (GetMythDB()->GetBoolSetting("AllowTagWriting", false))
1088  {
1089  if (tagger && tagger->supportsEmbeddedImages())
1090  menu->AddButton(tr("Copy Image To Tag"));
1091  }
1092 
1093  delete tagger;
1094 
1095  popupStack->AddScreen(menu);
1096 }
1097 
1099 {
1100  if (event->type() == DialogCompletionEvent::kEventType)
1101  {
1102  auto *dce = dynamic_cast<DialogCompletionEvent*>(event);
1103  // make sure the user didn't ESCAPE out of the menu
1104  if ((dce == nullptr) || (dce->GetResult() < 0))
1105  return;
1106 
1107  QString resultid = dce->GetId();
1108  QString resulttext = dce->GetResultText();
1109 
1110  if (resultid == "changetypemenu")
1111  {
1112  int type = dce->GetData().toInt();
1113 
1114  if ((type >= IT_UNKNOWN) && (type < IT_LAST))
1115  {
1116  // get selected image in list
1118  if (item)
1119  {
1121  auto *image = item->GetData().value<AlbumArtImage*>();
1122  if (image)
1123  {
1124  QStringList strList("MUSIC_TAG_CHANGEIMAGE");
1125  strList << s_metadata->Hostname()
1126  << QString::number(s_metadata->ID())
1127  << QString::number(image->m_imageType)
1128  << QString::number(type);
1129 
1131 
1132  m_albumArtChanged = true;
1133 
1134  gridItemChanged(item);
1135  }
1136  }
1137  }
1138  }
1139  else if (resultid == "asktypemenu")
1140  {
1141  int type = dce->GetData().toInt();
1142 
1143  if ((type >= IT_UNKNOWN) && (type < IT_LAST))
1145  }
1146  else if (resultid == "optionsmenu")
1147  {
1148  if (resulttext == tr("Edit Metadata"))
1149  switchToMetadata();
1150  else if (resulttext == tr("Rescan For Images"))
1151  rescanForImages();
1152  else if (resulttext == tr("Search Internet For Images"))
1154  else if (resulttext == tr("Change Image Type"))
1155  showTypeMenu();
1156  else if (resulttext == tr("Copy Selected Image To Tag"))
1158  else if (resulttext == tr("Remove Selected Image From Tag"))
1160  else if (resulttext == tr("Copy Image To Tag"))
1162  }
1163  else if (resultid == "imagelocation")
1164  {
1165  m_imageFilename = resulttext;
1166 
1167  // save directory location for next time
1168  QFileInfo fi(m_imageFilename);
1169  gCoreContext->SaveSetting("MusicLastImageLocation", fi.canonicalPath());
1170 
1171  showTypeMenu(false);
1172  }
1173  }
1174  else if (event->type() == MythEvent::MythEventMessage)
1175  {
1176  auto *me = dynamic_cast<MythEvent *>(event);
1177  if (me == nullptr)
1178  return;
1179 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
1180  QStringList tokens = me->Message().split(" ", QString::SkipEmptyParts);
1181 #else
1182  QStringList tokens = me->Message().split(" ", Qt::SkipEmptyParts);
1183 #endif
1184 
1185  if (!tokens.isEmpty())
1186  {
1187  if (tokens[0] == "BROWSER_DOWNLOAD_FINISHED")
1188  rescanForImages();
1189  else if (tokens[0] == "MUSIC_ALBUMART_CHANGED")
1190  {
1191  if (tokens.size() >= 2)
1192  {
1193  auto songID = (MusicMetadata::IdType)tokens[1].toInt();
1194 
1195  if (s_metadata->ID() == songID)
1196  {
1197  // force all the image to reload
1198  for (uint x = 0; x < s_metadata->getAlbumArtImages()->getImageCount(); x++)
1200 
1201  updateImageGrid();
1202  }
1203  }
1204  }
1205  }
1206  }
1207 }
1208 
1211 {
1212  // scan the tracks directory and tag for any images
1213  scanForImages();
1214 
1215  updateImageGrid();
1216 
1218  if (albumArt->getImageCount() > 0)
1219  m_albumArtChanged = true;
1220 }
1221 
1223 {
1224  QString lastLocation = gCoreContext->GetSetting("MusicLastImageLocation", "/");
1225 
1226  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
1227  auto *fb = new MythUIFileBrowser(popupStack, lastLocation);
1228 
1229  fb->SetTypeFilter(QDir::AllDirs | QDir::Files | QDir::Readable);
1230 
1231  QStringList filters;
1232  filters << "*.png" << "*.jpg" << "*.jpeg" << "*.gif";
1233  fb->SetNameFilter(filters);
1234 
1235  if (fb->Create())
1236  {
1237  fb->SetReturnEvent(this, "imagelocation");
1238  popupStack->AddScreen(fb);
1239  }
1240  else
1241  delete fb;
1242 }
1243 
1245 {
1246  AlbumArtImage image;
1247  image.m_filename = m_imageFilename;
1248  image.m_imageType = imageType;
1249 
1250  doCopyImageToTag(&image);
1251 }
1252 
1254 {
1256  if (item)
1257  {
1258  auto *image = item->GetData().value<AlbumArtImage*>();
1259  if (image)
1260  doCopyImageToTag(image);
1261  }
1262 }
1263 
1265 {
1267  if (item)
1268  {
1269  auto *image = item->GetData().value<AlbumArtImage*>();
1270  if (image)
1271  {
1272  QString msg = tr("Are you sure you want to permanently remove this image from the tag?");
1273  ShowOkPopup(msg, this, SLOT(doRemoveImageFromTag(bool)), true);
1274  }
1275  }
1276 }
1277 
1279 {
1280  if (!doIt)
1281  return;
1282 
1284  if (item)
1285  {
1286  auto *image = item->GetData().value<AlbumArtImage*>();
1287  if (image)
1288  {
1289  // ask the backend to remove the image from the tracks tag
1290  QStringList strList("MUSIC_TAG_REMOVEIMAGE");
1291  strList << s_metadata->Hostname()
1292  << QString::number(s_metadata->ID())
1293  << QString::number(image->m_id);
1294 
1296 
1297  removeCachedImage(image);
1298  rescanForImages();
1299  }
1300  }
1301 }
1302 
1304 {
1305  public:
1306  explicit CopyImageThread(QStringList strList) :
1307  MThread("CopyImage"), m_strList(std::move(strList)) {}
1308 
1309  void run() override // MThread
1310  {
1311  RunProlog();
1313  RunEpilog();
1314  }
1315 
1316  QStringList getResult(void) { return m_strList; }
1317 
1318  private:
1319  QStringList m_strList;
1320 };
1321 
1323 {
1324  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
1325  auto *busy = new MythUIBusyDialog(tr("Copying image to tag..."),
1326  popupStack, "copyimagebusydialog");
1327 
1328  if (busy->Create())
1329  {
1330  popupStack->AddScreen(busy, false);
1331  }
1332  else
1333  {
1334  delete busy;
1335  busy = nullptr;
1336  }
1337 
1338  // copy the image to the tracks host
1339  QFileInfo fi(image->m_filename);
1340  QString saveFilename = MythCoreContext::GenMythURL(s_metadata->Hostname(), 0,
1341  QString("AlbumArt/") + fi.fileName(),
1342  "MusicArt");
1343 
1344  RemoteFile::CopyFile(image->m_filename, saveFilename, true);
1345 
1346  // ask the backend to add the image to the tracks tag
1347  QStringList strList("MUSIC_TAG_ADDIMAGE");
1348  strList << s_metadata->Hostname()
1349  << QString::number(s_metadata->ID())
1350  << fi.fileName()
1351  << QString::number(image->m_imageType);
1352 
1353  auto *copyThread = new CopyImageThread(strList);
1354  copyThread->start();
1355 
1356  while (copyThread->isRunning())
1357  {
1358  qApp->processEvents();
1359  const struct timespec onems {0, 1000000};
1360  nanosleep(&onems, nullptr);
1361  }
1362 
1363  strList = copyThread->getResult();
1364 
1365  delete copyThread;
1366 
1367  if (busy)
1368  busy->Close();
1369 
1370  removeCachedImage(image);
1371 
1372  rescanForImages();
1373 }
1374 
1376 {
1377  if (!image->m_embedded)
1378  return;
1379 
1381 }
MythDB::GetBoolSetting
bool GetBoolSetting(const QString &key, bool defaultval)
Definition: mythdb.cpp:562
CopyImageThread::CopyImageThread
CopyImageThread(QStringList strList)
Definition: mythmusic/mythmusic/editmetadata.cpp:1306
MythUIButton::Clicked
void Clicked()
EditMetadataDialog::m_searchGenreButton
MythUIButton * m_searchGenreButton
Definition: mythmusic/mythmusic/editmetadata.h:130
build_compdb.args
args
Definition: build_compdb.py:11
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:321
EditMetadataDialog::m_incRatingButton
MythUIButton * m_incRatingButton
Definition: mythmusic/mythmusic/editmetadata.h:124
MythUISearchDialog
Provide a dialog to quickly find an entry in a list.
Definition: mythdialogbox.h:349
MusicMetadata::Title
QString Title() const
Definition: musicmetadata.h:162
gPlayer
MusicPlayer * gPlayer
Definition: musicplayer.cpp:35
MusicMetadata::Filename
QString Filename(bool find=true)
Definition: musicmetadata.cpp:966
MythEvent::MythEventMessage
static Type MythEventMessage
Definition: mythevent.h:73
MythUIButtonList::GetItemCurrent
MythUIButtonListItem * GetItemCurrent() const
Definition: mythuibuttonlist.cpp:1590
AlbumArtImage::m_imageType
ImageType m_imageType
Definition: musicmetadata.h:51
EditMetadataCommon::updateMetadata
void updateMetadata(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:110
MythCoreContext::GetMasterHostName
QString GetMasterHostName(void)
Definition: mythcorecontext.cpp:824
EditMetadataDialog::m_trackSpin
MythUISpinBox * m_trackSpin
Definition: mythmusic/mythmusic/editmetadata.h:119
mythuitext.h
DialogCompletionEvent::GetId
QString GetId()
Definition: mythdialogbox.h:52
MusicMetadata::Genre
QString Genre() const
Definition: musicmetadata.h:175
editmetadata.h
ShowOkPopup
MythConfirmationDialog * ShowOkPopup(const QString &message, QObject *parent, const char *slot, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
Definition: mythdialogbox.cpp:551
EditAlbumartDialog::EditAlbumartDialog
EditAlbumartDialog(MythScreenStack *parent)
Definition: mythmusic/mythmusic/editmetadata.cpp:868
EditMetadataDialog::updateRating
void updateRating(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:431
EditAlbumartDialog::copySelectedImageToTag
void copySelectedImageToTag(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:1253
MythCoreContext::SendReceiveStringList
bool SendReceiveStringList(QStringList &strlist, bool quickTimeout=false, bool block=true)
Send a message to the backend and wait for a response.
Definition: mythcorecontext.cpp:1376
EditMetadataDialog::m_searchArtistButton
MythUIButton * m_searchArtistButton
Definition: mythmusic/mythmusic/editmetadata.h:127
EditMetadataDialog::Create
bool Create() override
Definition: editvideometadata.cpp:52
fixFilename
META_PUBLIC QString fixFilename(const QString &filename)
remove any bad filename characters
EditMetadataDialog::m_ratingState
MythUIStateType * m_ratingState
Definition: mythmusic/mythmusic/editmetadata.h:123
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:402
MusicMetadata::getAlbumArtImages
AlbumArtImages * getAlbumArtImages(void)
Definition: musicmetadata.cpp:1365
EditMetadataDialog::m_artistIcon
MythUIImage * m_artistIcon
Definition: mythmusic/mythmusic/editmetadata.h:132
MusicMetadata::setDiscNumber
void setDiscNumber(int discnum)
Definition: musicmetadata.h:209
MusicMetadata::CompilationArtist
QString CompilationArtist() const
Definition: musicmetadata.h:138
MusicMetadata::fillFieldList
static QStringList fillFieldList(const QString &field)
Definition: musicmetadata.cpp:1220
EditMetadataDialog::m_discSpin
MythUISpinBox * m_discSpin
Definition: mythmusic/mythmusic/editmetadata.h:120
MetaIO::createTagger
static MetaIO * createTagger(const QString &filename)
Finds an appropriate tagger for the given file.
Definition: metaio.cpp:32
AlbumArtImages::getImageList
AlbumArtList * getImageList(void)
Definition: musicmetadata.h:533
EditMetadataCommon::s_sourceMetadata
static MusicMetadata * s_sourceMetadata
Definition: mythmusic/mythmusic/editmetadata.h:52
MythMainWindow::TranslateKeyPress
bool TranslateKeyPress(const QString &context, QKeyEvent *e, QStringList &actions, bool allowJumps=true)
Get a list of actions for a keypress in the given context.
Definition: mythmainwindow.cpp:1139
MythUIType::GetChild
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:131
MusicMetadata::setArtistId
void setArtistId(int lartistid)
Definition: musicmetadata.h:184
MythUIImage::Load
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
Definition: mythuiimage.cpp:968
EditMetadataDialog::checkClicked
void checkClicked(bool state)
Definition: mythmusic/mythmusic/editmetadata.cpp:516
MythUISearchDialog::haveResult
void haveResult(QString)
EditMetadataCommon::searchForAlbumImages
void searchForAlbumImages(void)
search Google for images
Definition: mythmusic/mythmusic/editmetadata.cpp:264
EditMetadataCommon::scanForImages
static void scanForImages(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:279
DialogCompletionEvent::kEventType
static Type kEventType
Definition: mythdialogbox.h:57
MusicMetadata::setTrack
void setTrack(int ltrack)
Definition: musicmetadata.h:200
MythUIButtonList::itemSelected
void itemSelected(MythUIButtonListItem *item)
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:17
MythUICheckBox::GetBooleanCheckState
bool GetBooleanCheckState(void) const
Definition: mythuicheckbox.cpp:103
EditMetadataDialog::artistLostFocus
void artistLostFocus(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:697
EditMetadataDialog::genreLostFocus
void genreLostFocus(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:707
EditMetadataDialog::m_albumIcon
MythUIImage * m_albumIcon
Definition: mythmusic/mythmusic/editmetadata.h:133
mythdialogbox.h
MythScreenStack
Definition: mythscreenstack.h:16
arg
arg(title).arg(filename).arg(doDelete))
mythdbcon.h
MetaIO
Definition: metaio.h:18
EditMetadataCommon::EditMetadataCommon
EditMetadataCommon(MythScreenStack *parent, MusicMetadata *source_metadata, const QString &name)
Definition: mythmusic/mythmusic/editmetadata.cpp:41
MusicMetadata::ID
IdType ID() const
Definition: musicmetadata.h:217
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:33
MusicMetadata::setAlbum
void setAlbum(const QString &lalbum, const QString &lalbum_sort=nullptr)
Definition: musicmetadata.h:152
EditAlbumartDialog::doCopyImageToTag
void doCopyImageToTag(const AlbumArtImage *image)
Definition: mythmusic/mythmusic/editmetadata.cpp:1322
EditMetadataDialog::m_albumartButton
MythUIButton * m_albumartButton
Definition: mythmusic/mythmusic/editmetadata.h:138
MusicMetadata::Track
int Track() const
Definition: musicmetadata.h:199
genres.h
MusicMetadata::setRating
void setRating(int lrating)
Definition: musicmetadata.h:241
EditMetadataDialog::setArtist
void setArtist(const QString &artist)
Definition: mythmusic/mythmusic/editmetadata.cpp:552
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MThread::RunProlog
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
Definition: mthread.cpp:198
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
mythuistatetype.h
IT_BACKCOVER
@ IT_BACKCOVER
Definition: musicmetadata.h:32
MusicMetadata
Definition: musicmetadata.h:81
EditMetadataDialog::updateArtistImage
void updateArtistImage(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:558
AlbumArtImages::guessImageType
static ImageType guessImageType(const QString &filename)
Definition: musicmetadata.cpp:2182
GetMythDB
MythDB * GetMythDB(void)
Definition: mythdb.cpp:45
MythUITextEdit::GetText
QString GetText(void) const
Definition: mythuitextedit.h:47
build_compdb.file
file
Definition: build_compdb.py:55
mythdirs.h
MythUIImage::Reset
void Reset(void) override
Reset the image back to the default defined in the theme.
Definition: mythuiimage.cpp:645
MusicMetadata::Artist
QString Artist() const
Definition: musicmetadata.h:126
menu
static MythThemedMenu * menu
Definition: mythtv/programs/mythtv-setup/main.cpp:53
MythUISpinBox::SetRange
void SetRange(int low, int high, int step, uint pageMultiple=5)
Set the lower and upper bounds of the spinbox, the interval and page amount.
Definition: mythuispinbox.cpp:25
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &stackname)
Definition: mythmainwindow.cpp:326
mythuibuttonlist.h
mythuiimage.h
MythUIButtonList::GetCount
int GetCount() const
Definition: mythuibuttonlist.cpp:1655
EditMetadataCommon::hasMetadataChanged
static bool hasMetadataChanged(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:245
musicutils.h
mythprogressdialog.h
MythEvent::Message
const QString & Message() const
Definition: mythevent.h:65
EditMetadataDialog::incRating
void incRating(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:407
EditAlbumartDialog::showTypeMenu
void showTypeMenu(bool changeType=true)
Definition: mythmusic/mythmusic/editmetadata.cpp:995
EditAlbumartDialog::removeCachedImage
static void removeCachedImage(const AlbumArtImage *image)
Definition: mythmusic/mythmusic/editmetadata.cpp:1375
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:112
AllMusic::getAllMetadata
MetadataPtrList * getAllMetadata(void)
Definition: musicmetadata.h:446
MythUICheckBox::toggled
void toggled(bool)
MythUIButtonListItem::SetText
void SetText(const QString &text, const QString &name="", const QString &state="")
Definition: mythuibuttonlist.cpp:3264
MythObservable::addListener
void addListener(QObject *listener)
Add a listener to the observable.
Definition: mythobservable.cpp:38
EditMetadataDialog::setAlbum
void setAlbum(const QString &album)
Definition: mythmusic/mythmusic/editmetadata.cpp:622
EditMetadataDialog::decRating
void decRating(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:413
MythUIButtonListItem
Definition: mythuibuttonlist.h:28
MetaIO::supportsEmbeddedImages
virtual bool supportsEmbeddedImages(void)
Does the tag support embedded cover art.
Definition: metaio.h:60
MythUISpinBox::SetValue
void SetValue(int val) override
Definition: mythuispinbox.h:26
CopyImageThread::run
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: mythmusic/mythmusic/editmetadata.cpp:1309
MythUITextEdit::SetText
void SetText(const QString &text, bool moveCursor=true)
Definition: mythuitextedit.cpp:216
AlbumArtImages::getImageCount
uint getImageCount()
Definition: musicmetadata.h:529
EditAlbumartDialog::doRemoveImageFromTag
void doRemoveImageFromTag(bool doIt)
Definition: mythmusic/mythmusic/editmetadata.cpp:1278
MythCoreContext::GenMythURL
static QString GenMythURL(const QString &host=QString(), int port=0, QString path=QString(), const QString &storageGroup=QString())
Definition: mythcorecontext.cpp:777
GetConfDir
QString GetConfDir(void)
Definition: mythdirs.cpp:224
EditMetadataCommon::s_metadataOnly
static bool s_metadataOnly
Definition: mythmusic/mythmusic/editmetadata.h:50
EditAlbumartDialog::m_coverartImage
MythUIImage * m_coverartImage
Definition: mythmusic/mythmusic/editmetadata.h:183
remotefile.h
EditMetadataDialog::setCompArtist
void setCompArtist(const QString &compArtist)
Definition: mythmusic/mythmusic/editmetadata.cpp:597
MythDialogBox
Basic menu dialog, message and a list of options.
Definition: mythdialogbox.h:138
MythUISpinBox::GetIntValue
int GetIntValue(void) const override
Definition: mythuispinbox.h:33
EditMetadataDialog::m_searchCompArtistButton
MythUIButton * m_searchCompArtistButton
Definition: mythmusic/mythmusic/editmetadata.h:128
EditMetadataCommon::~EditMetadataCommon
~EditMetadataCommon(void) override
Definition: mythmusic/mythmusic/editmetadata.cpp:53
MusicMetadata::setGenre
void setGenre(const QString &lgenre)
Definition: musicmetadata.h:176
EditMetadataCommon::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythmusic/mythmusic/editmetadata.cpp:85
EditMetadataDialog::searchCompilationArtist
void searchCompilationArtist(void) const
Definition: mythmusic/mythmusic/editmetadata.cpp:577
EditMetadataCommon::s_metadata
static MusicMetadata * s_metadata
Definition: mythmusic/mythmusic/editmetadata.h:51
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:222
EditMetadataDialog::m_compilationCheck
MythUICheckBox * m_compilationCheck
Definition: mythmusic/mythmusic/editmetadata.h:136
hardwareprofile.scan.rating
def rating(profile, smoonURL, gate)
Definition: scan.py:39
EditAlbumartDialog::~EditAlbumartDialog
~EditAlbumartDialog() override
Definition: mythmusic/mythmusic/editmetadata.cpp:874
AlbumArtImages::getImageAt
AlbumArtImage * getImageAt(uint index)
Definition: musicmetadata.cpp:2139
MusicMetadata::setTitle
void setTitle(const QString &ltitle, const QString &ltitle_sort=nullptr)
Definition: musicmetadata.h:164
EditMetadataDialog::switchToAlbumArt
void switchToAlbumArt(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:497
MythUIButton
A single button widget.
Definition: mythuibutton.h:22
EditMetadataDialog::m_searchAlbumButton
MythUIButton * m_searchAlbumButton
Definition: mythmusic/mythmusic/editmetadata.h:129
EditMetadataCommon::m_albumArtChanged
bool m_albumArtChanged
Definition: mythmusic/mythmusic/editmetadata.h:54
AlbumArtImages::scanForImages
void scanForImages(void)
Definition: musicmetadata.cpp:2025
EditMetadataDialog
Definition: editvideometadata.h:20
EditMetadataCommon::saveAll
void saveAll(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:217
SendStringListThread
send a message to the master BE without blocking the UI thread
Definition: musicdata.h:22
MythUIThemeCache::RemoveFromCacheByFile
void RemoveFromCacheByFile(const QString &File)
Definition: mythuithemecache.cpp:525
EditAlbumartDialog::m_imagefilenameText
MythUIText * m_imagefilenameText
Definition: mythmusic/mythmusic/editmetadata.h:186
EditAlbumartDialog::m_imagetypeText
MythUIText * m_imagetypeText
Definition: mythmusic/mythmusic/editmetadata.h:185
MThread::RunEpilog
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
Definition: mthread.cpp:211
CopyImageThread::getResult
QStringList getResult(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:1316
EditMetadataDialog::searchGenre
void searchGenre(void) const
Definition: mythmusic/mythmusic/editmetadata.cpp:645
MusicMetadata::getDirectoryId
int getDirectoryId()
Definition: musicmetadata.cpp:455
MythUIBusyDialog
Definition: mythprogressdialog.h:37
EditAlbumartDialog::m_metadataButton
MythUIButton * m_metadataButton
Definition: mythmusic/mythmusic/editmetadata.h:181
mythuifilebrowser.h
EditMetadataDialog::searchAlbum
void searchAlbum(void) const
Definition: mythmusic/mythmusic/editmetadata.cpp:602
AlbumArtImages::getTypeName
static QString getTypeName(ImageType type)
Definition: musicmetadata.cpp:2148
MythUIButtonListItem::GetData
QVariant GetData()
Definition: mythuibuttonlist.cpp:3580
EditMetadataDialog::updateAlbumImage
void updateAlbumImage(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:628
MusicPlayer::sendMetadataChangedEvent
void sendMetadataChangedEvent(int trackID)
Definition: musicplayer.cpp:1334
uint
unsigned int uint
Definition: compat.h:140
IT_ARTIST
@ IT_ARTIST
Definition: musicmetadata.h:35
EditMetadataDialog::m_albumEdit
MythUITextEdit * m_albumEdit
Definition: mythmusic/mythmusic/editmetadata.h:114
EditAlbumartDialog::copyImageToTag
void copyImageToTag(ImageType imageType)
Definition: mythmusic/mythmusic/editmetadata.cpp:1244
IT_CD
@ IT_CD
Definition: musicmetadata.h:33
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:56
MythUICheckBox
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
Definition: mythuicheckbox.h:16
EditAlbumartDialog::removeSelectedImageFromTag
void removeSelectedImageFromTag(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:1264
RemoteFile::CopyFile
static bool CopyFile(const QString &src, const QString &dst, bool overwrite=false, bool verify=false)
Definition: remotefile.cpp:587
EditMetadataDialog::searchArtist
void searchArtist(void) const
Definition: mythmusic/mythmusic/editmetadata.cpp:532
MythUIFileBrowser
Definition: mythuifilebrowser.h:81
musicdata.h
UIUtilDisp::Assign
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
EditMetadataDialog::m_artistEdit
MythUITextEdit * m_artistEdit
Definition: mythmusic/mythmusic/editmetadata.h:112
EditMetadataDialog::m_genreEdit
MythUITextEdit * m_genreEdit
Definition: mythmusic/mythmusic/editmetadata.h:116
MythUIType::Hide
void Hide(void)
Definition: mythuitype.cpp:1119
EditMetadataCommon::setSaveMetadataOnly
void setSaveMetadataOnly(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:236
MusicMetadata::Album
QString Album() const
Definition: musicmetadata.h:150
gMusicData
MusicData * gMusicData
Definition: musicdata.cpp:20
mythuispinbox.h
MusicMetadata::IdType
uint32_t IdType
Definition: musicmetadata.h:86
EditAlbumartDialog::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythmusic/mythmusic/editmetadata.cpp:951
MusicMetadata::setCompilationArtist
void setCompilationArtist(const QString &lcompilation_artist, const QString &lcompilation_artist_sort=nullptr)
Definition: musicmetadata.h:140
mthreadpool.h
mythuihelper.h
EditAlbumartDialog::m_imageFilename
QString m_imageFilename
Definition: mythmusic/mythmusic/editmetadata.h:176
CopyImageThread::m_strList
QStringList m_strList
Definition: mythmusic/mythmusic/editmetadata.cpp:1319
EditMetadataDialog::ratingSpinChanged
void ratingSpinChanged(MythUIButtonListItem *item)
Definition: mythmusic/mythmusic/editmetadata.cpp:419
IT_UNKNOWN
@ IT_UNKNOWN
Definition: musicmetadata.h:30
MusicMetadata::dumpToDatabase
void dumpToDatabase(void)
Definition: musicmetadata.cpp:672
EditMetadataDialog::~EditMetadataDialog
~EditMetadataDialog() override
Definition: editvideometadata.cpp:47
EditMetadataCommon::CreateCommon
bool CreateCommon(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:74
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:414
EditMetadataDialog::setGenre
void setGenre(const QString &genre)
Definition: mythmusic/mythmusic/editmetadata.cpp:673
MusicMetadata::setArtist
void setArtist(const QString &lartist, const QString &lartist_sort=nullptr)
Definition: musicmetadata.h:128
MusicMetadata::Hostname
QString Hostname(void)
Definition: musicmetadata.h:229
EditMetadataCommon::m_searchType
QString m_searchType
Definition: mythmusic/mythmusic/editmetadata.h:55
EditMetadataDialog::customEvent
void customEvent(QEvent *levent) override
Definition: editvideometadata.cpp:969
EditAlbumartDialog::gridItemChanged
void gridItemChanged(MythUIButtonListItem *item)
Definition: mythmusic/mythmusic/editmetadata.cpp:911
AlbumArtImages
Definition: musicmetadata.h:520
AlbumArtList
QList< AlbumArtImage * > AlbumArtList
Definition: musicmetadata.h:56
MythMainWindow::HandleMedia
bool HandleMedia(const QString &handler, const QString &mrl, const QString &plot="", const QString &title="", const QString &subtitle="", const QString &director="", int season=0, int episode=0, const QString &inetref="", int lenMins=120, const QString &year="1895", const QString &id="", bool useBookmarks=false)
Definition: mythmainwindow.cpp:1524
mythuitextedit.h
MythUICheckBox::SetCheckState
void SetCheckState(MythUIStateType::StateType state)
Definition: mythuicheckbox.cpp:66
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:692
metaio.h
EditAlbumartDialog
Definition: mythmusic/mythmusic/editmetadata.h:142
EditMetadataCommon::cleanupAndClose
void cleanupAndClose(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:187
CopyImageThread
Definition: mythmusic/mythmusic/editmetadata.cpp:1304
MusicMetadata::setAlbumId
void setAlbumId(int lalbumid)
Definition: musicmetadata.h:190
DialogCompletionEvent
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:42
EditMetadataDialog::m_genreIcon
MythUIImage * m_genreIcon
Definition: mythmusic/mythmusic/editmetadata.h:134
AlbumArtImage
Definition: musicmetadata.h:40
MusicMetadata::Compilation
bool Compilation() const
Definition: musicmetadata.h:251
EditMetadataDialog::updateGenreImage
void updateGenreImage(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:679
IT_LAST
@ IT_LAST
Definition: musicmetadata.h:36
MythUIText::SetText
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:134
mythcontext.h
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
EditMetadataDialog::searchForGenreImages
void searchForGenreImages(void)
search flickr for genre images
Definition: mythmusic/mythmusic/editmetadata.cpp:713
MythUIButtonList::Reset
void Reset() override
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuibuttonlist.cpp:114
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:105
EditAlbumartDialog::customEvent
void customEvent(QEvent *event) override
Definition: mythmusic/mythmusic/editmetadata.cpp:1098
build_compdb.action
action
Definition: build_compdb.py:9
MythUISpinBox
A widget for offering a range of numerical values where only the the bounding values and interval are...
Definition: mythuispinbox.h:17
MusicPlayer::sendAlbumArtChangedEvent
void sendAlbumArtChangedEvent(int trackID)
Definition: musicplayer.cpp:1346
IT_FRONTCOVER
@ IT_FRONTCOVER
Definition: musicmetadata.h:31
mythuibutton.h
EditAlbumartDialog::switchToMetadata
void switchToMetadata(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:978
MetadataPtrList
QList< MusicMetadata * > MetadataPtrList
Definition: musicmetadata.h:395
EditAlbumartDialog::m_coverartList
MythUIButtonList * m_coverartList
Definition: mythmusic/mythmusic/editmetadata.h:184
MusicMetadata::setYear
void setYear(int lyear)
Definition: musicmetadata.h:197
MusicData::m_all_music
AllMusic * m_all_music
Definition: musicdata.h:55
EditAlbumartDialog::startCopyImageToTag
void startCopyImageToTag(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:1222
MusicMetadata::Rating
int Rating() const
Definition: musicmetadata.h:238
EditMetadataCommon::saveToMetadata
void saveToMetadata(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:198
MythThemedMenuState::Create
bool Create(void) override
Definition: myththemedmenu.cpp:36
MusicMetadata::setCompilation
void setCompilation(bool state)
Definition: musicmetadata.h:252
EditMetadataCommon::metadataChanged
void metadataChanged(void)
EditMetadataCommon::m_doneButton
MythUIButton * m_doneButton
Definition: mythmusic/mythmusic/editmetadata.h:56
EditAlbumartDialog::updateImageGrid
void updateImageGrid(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:934
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:898
mythuicheckbox.h
MythUIImage::SetFilename
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
Definition: mythuiimage.cpp:676
MythUIType::LosingFocus
void LosingFocus()
EditMetadataDialog::keyPressEvent
bool keyPressEvent(QKeyEvent *e) override
Key event handler.
Definition: mytharchive/mytharchive/editmetadata.cpp:49
GetMythUI
MythUIHelper * GetMythUI()
Definition: mythuihelper.cpp:66
IT_INLAY
@ IT_INLAY
Definition: musicmetadata.h:34
EditMetadataCommon
Definition: mythmusic/mythmusic/editmetadata.h:18
mythuiwebbrowser.h
EditMetadataDialog::m_compArtistEdit
MythUITextEdit * m_compArtistEdit
Definition: mythmusic/mythmusic/editmetadata.h:113
EditMetadataCommon::showSaveMenu
void showSaveMenu(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:153
MThreadPool::globalInstance
static MThreadPool * globalInstance(void)
Definition: mthreadpool.cpp:306
EditAlbumartDialog::Create
bool Create(void) override
Definition: mythmusic/mythmusic/editmetadata.cpp:879
EditMetadataDialog::m_yearSpin
MythUISpinBox * m_yearSpin
Definition: editvideometadata.h:105
AlbumArtImages::dumpToDatabase
void dumpToDatabase(void)
saves or updates the image details in the DB
Definition: musicmetadata.cpp:2258
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:49
EditMetadataDialog::searchForArtistImages
void searchForArtistImages(void)
search google for artist images
Definition: mythmusic/mythmusic/editmetadata.cpp:725
EditAlbumartDialog::rescanForImages
void rescanForImages(void)
search the tracks tag and the tracks directory for images
Definition: mythmusic/mythmusic/editmetadata.cpp:1210
EditMetadataDialog::m_titleEdit
MythUITextEdit * m_titleEdit
Definition: editvideometadata.h:93
MythUISpinBox::AddSelection
void AddSelection(int value, const QString &label="")
Add a special label for a value of the spinbox, it does not need to be in the range.
Definition: mythuispinbox.cpp:95
findIcon
META_PUBLIC QString findIcon(const QString &type, const QString &name, bool ignoreCache=false)
find an image for a artist or genre
EditAlbumartDialog::showMenu
void showMenu(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:1036
ImageType
ImageType
Definition: musicmetadata.h:29
MythObservable::removeListener
void removeListener(QObject *listener)
Remove a listener to the observable.
Definition: mythobservable.cpp:55
EditMetadataDialog::albumLostFocus
void albumLostFocus(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:702
EditMetadataDialog::showMenu
void showMenu(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:469
MusicMetadata::Year
int Year() const
Definition: musicmetadata.h:196
MThreadPool::start
void start(QRunnable *runnable, const QString &debugName, int priority=0)
Definition: mthreadpool.cpp:341
EditMetadataDialog::EditMetadataDialog
EditMetadataDialog(MythScreenStack *lparent, const QString &lname, VideoMetadata *source_metadata, const VideoMetadataListManager &cache)
Definition: editvideometadata.cpp:34
EditMetadataCommon::saveToDatabase
static void saveToDatabase(void)
Definition: mythmusic/mythmusic/editmetadata.cpp:205
MythUIStateType::DisplayState
bool DisplayState(const QString &name)
Definition: mythuistatetype.cpp:84
EditMetadataDialog::m_decRatingButton
MythUIButton * m_decRatingButton
Definition: mythmusic/mythmusic/editmetadata.h:125
EditMetadataDialog::m_ratingSpin
MythUISpinBox * m_ratingSpin
Definition: mythmusic/mythmusic/editmetadata.h:121
MusicMetadata::setGenreId
void setGenreId(int lgenreid)
Definition: musicmetadata.h:193
decoder.h
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:915
AlbumArtImage::m_filename
QString m_filename
Definition: musicmetadata.h:49
MusicMetadata::DiscNumber
int DiscNumber() const
Definition: musicmetadata.h:208
musicplayer.h
AlbumArtImage::m_embedded
bool m_embedded
Definition: musicmetadata.h:53
EditMetadataDialog::fillWidgets
void fillWidgets()
Definition: editvideometadata.cpp:296