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