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