MythTV  master
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  const 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  const 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  if (m_artistIcon)
564  {
565  QString file = findIcon("artist", artist.toLower(), true);
566  if (!file.isEmpty())
567  {
569  m_artistIcon->Load();
570  }
571  else
572  {
573  m_artistIcon->Reset();
574  }
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  if (m_albumIcon)
632  {
633  QString file = s_metadata->getAlbumArtFile();
634  if (!file.isEmpty())
635  {
637  m_albumIcon->Load();
638  }
639  else
640  {
641  m_albumIcon->Reset();
642  }
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 
684  if (m_genreIcon)
685  {
686  QString file = findIcon("genre", genre.toLower(), true);
687  if (!file.isEmpty())
688  {
690  m_genreIcon->Load();
691  }
692  else
693  {
694  m_genreIcon->Reset();
695  }
696  }
697 }
698 
700 {
702 }
703 
705 {
707 }
708 
710 {
712 }
713 
716 {
717  QString genre= s_metadata->Genre().replace(' ', '+');
718  genre = QUrl::toPercentEncoding(genre, "+");
719 
720  QUrl url("http://www.flickr.com/search/groups/?w=908425%40N22&m=pool&q=" + genre, QUrl::TolerantMode);
721 
722  m_searchType = "genre";
723  GetMythMainWindow()->HandleMedia("WebBrowser", url.toString(), GetConfDir() + "/MythMusic/", "genre.jpg");
724 }
725 
728 {
729  QString artist = s_metadata->Artist().replace(' ', '+');
730  artist = QUrl::toPercentEncoding(artist, "+");
731 
732  QUrl url("http://www.google.co.uk/images?q=" + artist, QUrl::TolerantMode);
733 
734  m_searchType = "artist";
735  GetMythMainWindow()->HandleMedia("WebBrowser", url.toString(), GetConfDir() + "/MythMusic/", "artist.jpg");
736 }
737 
738 void EditMetadataDialog::customEvent(QEvent *event)
739 {
740  if (event->type() == DialogCompletionEvent::kEventType)
741  {
742  auto *dce = dynamic_cast<DialogCompletionEvent*>(event);
743  // make sure the user didn't ESCAPE out of the menu
744  if ((dce == nullptr) || (dce->GetResult() < 0))
745  return;
746 
747  QString resultid = dce->GetId();
748  QString resulttext = dce->GetResultText();
749 
750 
751  if (resultid == "optionsmenu")
752  {
753  if (resulttext == tr("Edit Albumart Images"))
755  else if (resulttext == tr("Search Internet For Genre Image"))
756  {
757  updateMetadata();
759  }
760  else if (resulttext == tr("Search Internet For Artist Image"))
761  {
762  updateMetadata();
764  }
765  else if (resulttext == tr("Search Internet For Album Image"))
766  {
767  updateMetadata();
768  searchForAlbumImages();
769  }
770  else if (resulttext == tr("Check Track Length"))
771  {
772  QStringList strList;
773  strList << "MUSIC_CALC_TRACK_LENGTH"
774  << s_metadata->Hostname()
775  << QString::number(s_metadata->ID());
776 
777  auto *thread = new SendStringListThread(strList);
778  MThreadPool::globalInstance()->start(thread, "Send MUSIC_CALC_TRACK_LENGTH");
779 
780  ShowOkPopup(tr("Asked the backend to check the tracks length"));
781  }
782  }
783  }
784  else if (event->type() == MythEvent::kMythEventMessage)
785  {
786  auto *me = dynamic_cast<MythEvent *>(event);
787  if (me == nullptr)
788  return;
789  QStringList tokens = me->Message().split(" ", Qt::SkipEmptyParts);
790 
791  if (!tokens.isEmpty())
792  {
793  if (tokens[0] == "BROWSER_DOWNLOAD_FINISHED")
794  {
795  QStringList args = me->ExtraDataList();
796  const QString& oldFilename = args[1];
797  int fileSize = args[2].toInt();
798  int errorCode = args[4].toInt();
799 
800  if ((errorCode != 0) || (fileSize == 0))
801  return;
802 
803  QString newFilename;
804 
805  if (m_searchType == "artist")
806  {
807  QString cleanName = fixFilename(s_metadata->Artist().toLower());
808  QString file = QString("Icons/%1/%2.jpg").arg("artist", cleanName);
810  0, file, "MusicArt");
811  }
812  else if (m_searchType == "genre")
813  {
814  QString cleanName = fixFilename(s_metadata->Genre().toLower());
815  QString file = QString("Icons/%1/%2.jpg").arg("genre", cleanName);
817  0, file, "MusicArt");
818  }
819  else if (m_searchType == "album")
820  {
821  // move the image from the MythMusic config dir to the tracks
822  // dir in the 'Music' storage group
823  newFilename = s_metadata->Filename();
824  newFilename = newFilename.section( '/', 0, -2);
825  newFilename = newFilename + '/' + oldFilename.section( '/', -1, -1);
826  }
827  else
828  {
829  LOG(VB_GENERAL, LOG_ERR, QString("Got unknown search type '%1' "
830  "in BROWSER_DOWNLOAD_FINISHED event")
831  .arg(m_searchType));
832  return;
833  }
834 
835  RemoteFile::CopyFile(oldFilename, newFilename, true);
836  QFile::remove(oldFilename);
837 
838  if (m_searchType == "album")
839  scanForImages();
840 
841  // force the icons to update
845 
846  s_metadata->getAlbumArtImages()->dumpToDatabase();
847  // force a reload of the images for any tracks affected
849  for (int x = 0; x < allMusic->count(); x++)
850  {
851  if ((allMusic->at(x)->ID() == s_sourceMetadata->ID()) ||
852  (allMusic->at(x)->getDirectoryId() == s_sourceMetadata->getDirectoryId()))
853  {
854  allMusic->at(x)->reloadAlbumArtImages();
855  gPlayer->sendAlbumArtChangedEvent(allMusic->at(x)->ID());
856  }
857  }
858  }
859  }
860  }
861 }
862 
864 // EditAlbumartDialog
865 
867  : EditMetadataCommon(parent, "EditAlbumartDialog")
868 {
869  gCoreContext->addListener(this);
870 }
871 
873 {
875 }
876 
878 {
879  if (! LoadWindowFromXML("music-ui.xml", "editalbumart", this))
880  return false;
881 
882  bool err = CreateCommon();
883 
884  UIUtilE::Assign(this, m_coverartList, "coverartlist", &err);
885  UIUtilE::Assign(this, m_imagetypeText, "imagetypetext", &err);
886  UIUtilE::Assign(this, m_imagefilenameText, "imagefilenametext", &err);
887  UIUtilE::Assign(this, m_coverartImage, "coverartimage", &err);
888 
889  UIUtilE::Assign(this, m_metadataButton, "metadatabutton", &err);
890 
891  if (err)
892  {
893  LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'editalbumart'");
894  return false;
895  }
896 
897  updateImageGrid();
898 
901 
903 
904  BuildFocusList();
905 
906  return true;
907 }
908 
910 {
911  if (!item)
912  return;
913 
914  if (m_coverartImage)
915  {
916  auto *image = item->GetData().value<AlbumArtImage*>();
917  if (image)
918  {
919  m_coverartImage->SetFilename(image->m_filename);
921  if (m_imagetypeText)
924  {
925  QFileInfo fi(image->m_filename);
926  m_imagefilenameText->SetText(fi.fileName());
927  }
928  }
929  }
930 }
931 
933 {
935 
937 
938  for (auto *art : std::as_const(*albumArtList))
939  {
940  auto *item = new MythUIButtonListItem(m_coverartList,
941  AlbumArtImages::getTypeName(art->m_imageType),
942  QVariant::fromValue(art));
943  item->SetImage(art->m_filename);
944  QString state = art->m_embedded ? "tag" : "file";
945  item->DisplayState(state, "locationstate");
946  }
947 }
948 
949 bool EditAlbumartDialog::keyPressEvent(QKeyEvent *event)
950 {
951  if (GetFocusWidget() && GetFocusWidget()->keyPressEvent(event))
952  return true;
953 
954  QStringList actions;
955  bool handled = GetMythMainWindow()->TranslateKeyPress("Music", event, actions);
956 
957  for (int i = 0; i < actions.size() && !handled; i++)
958  {
959  const QString& action = actions[i];
960  handled = true;
961 
962  if (action == "MENU")
963  showMenu();
964  else if (action == "INFO")
965  showTypeMenu();
966  else
967  handled = false;
968  }
969 
970  if (!handled && EditMetadataCommon::keyPressEvent(event))
971  handled = true;
972 
973  return handled;
974 }
975 
977 {
979 
980  auto *editDialog = new EditMetadataDialog(mainStack);
981 
982  if (!editDialog->Create())
983  {
984  delete editDialog;
985  return;
986  }
987 
988  mainStack->AddScreen(editDialog);
989 
990  Close();
991 }
992 
993 void EditAlbumartDialog::showTypeMenu(bool changeType)
994 {
995  if (changeType && m_coverartList->GetCount() == 0)
996  return;
997 
998  QString label;
999 
1000  if (changeType)
1001  label = tr("Change Image Type");
1002  else
1003  label = tr("What image type do you want to use for this image?");
1004 
1005  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
1006 
1007  auto *menu = new MythDialogBox(label, popupStack, "typemenu");
1008 
1009  if (!menu->Create())
1010  {
1011  delete menu;
1012  return;
1013  }
1014 
1015  ImageType imageType = IT_UNKNOWN;
1016  if (changeType)
1017  menu->SetReturnEvent(this, "changetypemenu");
1018  else
1019  {
1020  menu->SetReturnEvent(this, "asktypemenu");
1022  }
1023 
1024  menu->AddButtonV(AlbumArtImages::getTypeName(IT_UNKNOWN), QVariant::fromValue((int)IT_UNKNOWN), false, (imageType == IT_UNKNOWN));
1025  menu->AddButtonV(AlbumArtImages::getTypeName(IT_FRONTCOVER), QVariant::fromValue((int)IT_FRONTCOVER), false, (imageType == IT_FRONTCOVER));
1026  menu->AddButtonV(AlbumArtImages::getTypeName(IT_BACKCOVER), QVariant::fromValue((int)IT_BACKCOVER), false, (imageType == IT_BACKCOVER));
1027  menu->AddButtonV(AlbumArtImages::getTypeName(IT_CD), QVariant::fromValue((int)IT_CD), false, (imageType == IT_CD));
1028  menu->AddButtonV(AlbumArtImages::getTypeName(IT_INLAY), QVariant::fromValue((int)IT_INLAY), false, (imageType == IT_INLAY));
1029  menu->AddButtonV(AlbumArtImages::getTypeName(IT_ARTIST), QVariant::fromValue((int)IT_ARTIST), false, (imageType == IT_ARTIST));
1030 
1031  popupStack->AddScreen(menu);
1032 }
1033 
1035 {
1036  QString label = tr("Options");
1037 
1038  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
1039 
1040  auto *menu = new MythDialogBox(label, popupStack, "optionsmenu");
1041 
1042  if (!menu->Create())
1043  {
1044  delete menu;
1045  return;
1046  }
1047 
1048  menu->SetReturnEvent(this, "optionsmenu");
1049 
1050  menu->AddButton(tr("Edit Metadata"));
1051  menu->AddButton(tr("Rescan For Images"));
1052 
1053 
1054  menu->AddButton(tr("Search Internet For Images"));
1055 
1056  MetaIO *tagger = MetaIO::createTagger(s_metadata->Filename(false));
1057 
1059  {
1060  menu->AddButton(tr("Change Image Type"), nullptr, true);
1061 
1062  if (GetMythDB()->GetBoolSetting("AllowTagWriting", false))
1063  {
1065  if (item)
1066  {
1067  auto *image = item->GetData().value<AlbumArtImage*>();
1068  if (image)
1069  {
1070  if (!image->m_embedded)
1071  {
1072  if (tagger && tagger->supportsEmbeddedImages())
1073  menu->AddButton(tr("Copy Selected Image To Tag"));
1074  }
1075  else
1076  {
1077  if (tagger && tagger->supportsEmbeddedImages())
1078  menu->AddButton(tr("Remove Selected Image From Tag"));
1079  }
1080  }
1081  }
1082  }
1083  }
1084 
1085  if (GetMythDB()->GetBoolSetting("AllowTagWriting", false))
1086  {
1087  if (tagger && tagger->supportsEmbeddedImages())
1088  menu->AddButton(tr("Copy Image To Tag"));
1089  }
1090 
1091  delete tagger;
1092 
1093  popupStack->AddScreen(menu);
1094 }
1095 
1097 {
1098  if (event->type() == DialogCompletionEvent::kEventType)
1099  {
1100  auto *dce = dynamic_cast<DialogCompletionEvent*>(event);
1101  // make sure the user didn't ESCAPE out of the menu
1102  if ((dce == nullptr) || (dce->GetResult() < 0))
1103  return;
1104 
1105  QString resultid = dce->GetId();
1106  QString resulttext = dce->GetResultText();
1107 
1108  if (resultid == "changetypemenu")
1109  {
1110  int type = dce->GetData().toInt();
1111 
1112  if ((type >= IT_UNKNOWN) && (type < IT_LAST))
1113  {
1114  // get selected image in list
1116  if (item)
1117  {
1119  auto *image = item->GetData().value<AlbumArtImage*>();
1120  if (image)
1121  {
1122  QStringList strList("MUSIC_TAG_CHANGEIMAGE");
1123  strList << s_metadata->Hostname()
1124  << QString::number(s_metadata->ID())
1125  << QString::number(image->m_imageType)
1126  << QString::number(type);
1127 
1129 
1130  m_albumArtChanged = true;
1131 
1132  gridItemChanged(item);
1133  }
1134  }
1135  }
1136  }
1137  else if (resultid == "asktypemenu")
1138  {
1139  int type = dce->GetData().toInt();
1140 
1141  if ((type >= IT_UNKNOWN) && (type < IT_LAST))
1143  }
1144  else if (resultid == "optionsmenu")
1145  {
1146  if (resulttext == tr("Edit Metadata"))
1147  switchToMetadata();
1148  else if (resulttext == tr("Rescan For Images"))
1149  rescanForImages();
1150  else if (resulttext == tr("Search Internet For Images"))
1152  else if (resulttext == tr("Change Image Type"))
1153  showTypeMenu();
1154  else if (resulttext == tr("Copy Selected Image To Tag"))
1156  else if (resulttext == tr("Remove Selected Image From Tag"))
1158  else if (resulttext == tr("Copy Image To Tag"))
1160  }
1161  else if (resultid == "imagelocation")
1162  {
1163  m_imageFilename = resulttext;
1164 
1165  // save directory location for next time
1166  QFileInfo fi(m_imageFilename);
1167  gCoreContext->SaveSetting("MusicLastImageLocation", fi.canonicalPath());
1168 
1169  showTypeMenu(false);
1170  }
1171  }
1172  else if (event->type() == MythEvent::kMythEventMessage)
1173  {
1174  auto *me = dynamic_cast<MythEvent *>(event);
1175  if (me == nullptr)
1176  return;
1177  QStringList tokens = me->Message().split(" ", Qt::SkipEmptyParts);
1178 
1179  if (!tokens.isEmpty())
1180  {
1181  if (tokens[0] == "BROWSER_DOWNLOAD_FINISHED")
1182  rescanForImages();
1183  else if (tokens[0] == "MUSIC_ALBUMART_CHANGED")
1184  {
1185  if (tokens.size() >= 2)
1186  {
1187  auto songID = (MusicMetadata::IdType)tokens[1].toInt();
1188 
1189  if (s_metadata->ID() == songID)
1190  {
1191  // force all the image to reload
1192  for (uint x = 0; x < s_metadata->getAlbumArtImages()->getImageCount(); x++)
1194 
1195  updateImageGrid();
1196  }
1197  }
1198  }
1199  }
1200  }
1201 }
1202 
1205 {
1206  // scan the tracks directory and tag for any images
1207  scanForImages();
1208 
1209  updateImageGrid();
1210 
1212  if (albumArt->getImageCount() > 0)
1213  m_albumArtChanged = true;
1214 }
1215 
1217 {
1218  QString lastLocation = gCoreContext->GetSetting("MusicLastImageLocation", "/");
1219 
1220  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
1221  auto *fb = new MythUIFileBrowser(popupStack, lastLocation);
1222 
1223  fb->SetTypeFilter(QDir::AllDirs | QDir::Files | QDir::Readable);
1224 
1225  QStringList filters;
1226  filters << "*.png" << "*.jpg" << "*.jpeg" << "*.gif";
1227  fb->SetNameFilter(filters);
1228 
1229  if (fb->Create())
1230  {
1231  fb->SetReturnEvent(this, "imagelocation");
1232  popupStack->AddScreen(fb);
1233  }
1234  else
1235  {
1236  delete fb;
1237  }
1238 }
1239 
1241 {
1242  AlbumArtImage image;
1243  image.m_filename = m_imageFilename;
1244  image.m_imageType = imageType;
1245 
1246  doCopyImageToTag(&image);
1247 }
1248 
1250 {
1252  if (item)
1253  {
1254  auto *image = item->GetData().value<AlbumArtImage*>();
1255  if (image)
1256  doCopyImageToTag(image);
1257  }
1258 }
1259 
1261 {
1263  if (item)
1264  {
1265  auto *image = item->GetData().value<AlbumArtImage*>();
1266  if (image)
1267  {
1268  QString msg = tr("Are you sure you want to permanently remove this image from the tag?");
1270  }
1271  }
1272 }
1273 
1275 {
1276  if (!doIt)
1277  return;
1278 
1280  if (item)
1281  {
1282  auto *image = item->GetData().value<AlbumArtImage*>();
1283  if (image)
1284  {
1285  // ask the backend to remove the image from the tracks tag
1286  QStringList strList("MUSIC_TAG_REMOVEIMAGE");
1287  strList << s_metadata->Hostname()
1288  << QString::number(s_metadata->ID())
1289  << QString::number(image->m_id);
1290 
1292 
1293  removeCachedImage(image);
1294  rescanForImages();
1295  }
1296  }
1297 }
1298 
1300 {
1301  public:
1302  explicit CopyImageThread(QStringList strList) :
1303  MThread("CopyImage"), m_strList(std::move(strList)) {}
1304 
1305  void run() override // MThread
1306  {
1307  RunProlog();
1309  RunEpilog();
1310  }
1311 
1312  QStringList getResult(void) { return m_strList; }
1313 
1314  private:
1315  QStringList m_strList;
1316 };
1317 
1319 {
1320  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
1321  auto *busy = new MythUIBusyDialog(tr("Copying image to tag..."),
1322  popupStack, "copyimagebusydialog");
1323 
1324  if (busy->Create())
1325  {
1326  popupStack->AddScreen(busy, false);
1327  }
1328  else
1329  {
1330  delete busy;
1331  busy = nullptr;
1332  }
1333 
1334  // copy the image to the tracks host
1335  QFileInfo fi(image->m_filename);
1336  QString saveFilename = MythCoreContext::GenMythURL(s_metadata->Hostname(), 0,
1337  QString("AlbumArt/") + fi.fileName(),
1338  "MusicArt");
1339 
1340  RemoteFile::CopyFile(image->m_filename, saveFilename, true);
1341 
1342  // ask the backend to add the image to the tracks tag
1343  QStringList strList("MUSIC_TAG_ADDIMAGE");
1344  strList << s_metadata->Hostname()
1345  << QString::number(s_metadata->ID())
1346  << fi.fileName()
1347  << QString::number(image->m_imageType);
1348 
1349  auto *copyThread = new CopyImageThread(strList);
1350  copyThread->start();
1351 
1352  while (copyThread->isRunning())
1353  {
1354  qApp->processEvents();
1355  const struct timespec onems {0, 1000000};
1356  nanosleep(&onems, nullptr);
1357  }
1358 
1359  strList = copyThread->getResult();
1360 
1361  delete copyThread;
1362 
1363  if (busy)
1364  busy->Close();
1365 
1366  removeCachedImage(image);
1367 
1368  rescanForImages();
1369 }
1370 
1372 {
1373  if (!image->m_embedded)
1374  return;
1375 
1377 }
CopyImageThread::CopyImageThread
CopyImageThread(QStringList strList)
Definition: editmetadata.cpp:1302
MythUIButton::Clicked
void Clicked()
EditMetadataDialog::m_searchGenreButton
MythUIButton * m_searchGenreButton
Definition: editmetadata.h:132
build_compdb.args
args
Definition: build_compdb.py:11
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:317
EditMetadataDialog::m_incRatingButton
MythUIButton * m_incRatingButton
Definition: 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:161
gPlayer
MusicPlayer * gPlayer
Definition: musicplayer.cpp:37
MusicMetadata::Filename
QString Filename(bool find=true)
Definition: musicmetadata.cpp:962
MythUIButtonList::GetItemCurrent
MythUIButtonListItem * GetItemCurrent() const
Definition: mythuibuttonlist.cpp:1614
AlbumArtImage::m_imageType
ImageType m_imageType
Definition: musicmetadata.h:51
EditMetadataCommon::updateMetadata
void updateMetadata(void)
Definition: editmetadata.cpp:111
MythCoreContext::GetMasterHostName
QString GetMasterHostName(void)
Definition: mythcorecontext.cpp:811
EditMetadataDialog::m_trackSpin
MythUISpinBox * m_trackSpin
Definition: editmetadata.h:121
mythuitext.h
MythEvent::kMythEventMessage
static const Type kMythEventMessage
Definition: mythevent.h:79
DialogCompletionEvent::GetId
QString GetId()
Definition: mythdialogbox.h:52
MusicMetadata::Genre
QString Genre() const
Definition: musicmetadata.h:174
editmetadata.h
EditAlbumartDialog::EditAlbumartDialog
EditAlbumartDialog(MythScreenStack *parent)
Definition: editmetadata.cpp:866
EditMetadataDialog::updateRating
void updateRating(void)
Definition: editmetadata.cpp:432
EditAlbumartDialog::copySelectedImageToTag
void copySelectedImageToTag(void)
Definition: editmetadata.cpp:1249
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:1379
EditMetadataDialog::m_searchArtistButton
MythUIButton * m_searchArtistButton
Definition: editmetadata.h:129
EditMetadataDialog::Create
bool Create() override
Definition: editvideometadata.cpp:54
EditMetadataDialog::m_ratingState
MythUIStateType * m_ratingState
Definition: editmetadata.h:125
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:383
MusicMetadata::getAlbumArtImages
AlbumArtImages * getAlbumArtImages(void)
Definition: musicmetadata.cpp:1368
EditMetadataDialog::m_artistIcon
MythUIImage * m_artistIcon
Definition: editmetadata.h:134
MusicMetadata::setDiscNumber
void setDiscNumber(int discnum)
Definition: musicmetadata.h:209
MusicMetadata::CompilationArtist
QString CompilationArtist() const
Definition: musicmetadata.h:137
MusicMetadata::fillFieldList
static QStringList fillFieldList(const QString &field)
Definition: musicmetadata.cpp:1220
EditMetadataDialog::m_discSpin
MythUISpinBox * m_discSpin
Definition: editmetadata.h:122
MetaIO::createTagger
static MetaIO * createTagger(const QString &filename)
Finds an appropriate tagger for the given file.
Definition: metaio.cpp:25
AlbumArtImages::getImageList
AlbumArtList * getImageList(void)
Definition: musicmetadata.h:534
EditMetadataCommon::s_sourceMetadata
static MusicMetadata * s_sourceMetadata
Definition: editmetadata.h:54
MythUIType::GetChild
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:138
MusicMetadata::setArtistId
void setArtistId(int lartistid)
Definition: musicmetadata.h:183
MythUIImage::Load
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
Definition: mythuiimage.cpp:971
EditMetadataDialog::checkClicked
void checkClicked(bool state)
Definition: editmetadata.cpp:517
MythUISearchDialog::haveResult
void haveResult(QString)
EditMetadataCommon::searchForAlbumImages
void searchForAlbumImages(void)
search Google for images
Definition: editmetadata.cpp:265
EditMetadataCommon::scanForImages
static void scanForImages(void)
Definition: editmetadata.cpp:280
IT_LAST
@ IT_LAST
Definition: musicmetadata.h:36
MusicMetadata::setTrack
void setTrack(int ltrack)
Definition: musicmetadata.h:199
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: editmetadata.cpp:699
EditMetadataDialog::genreLostFocus
void genreLostFocus(void)
Definition: editmetadata.cpp:709
EditMetadataDialog::m_albumIcon
MythUIImage * m_albumIcon
Definition: editmetadata.h:135
mythdialogbox.h
MythScreenStack
Definition: mythscreenstack.h:16
mythdbcon.h
MetaIO
Definition: metaio.h:17
IT_UNKNOWN
@ IT_UNKNOWN
Definition: musicmetadata.h:30
EditMetadataCommon::EditMetadataCommon
EditMetadataCommon(MythScreenStack *parent, MusicMetadata *source_metadata, const QString &name)
Definition: editmetadata.cpp:42
MusicMetadata::ID
IdType ID() const
Definition: musicmetadata.h:217
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:151
EditAlbumartDialog::doCopyImageToTag
void doCopyImageToTag(const AlbumArtImage *image)
Definition: editmetadata.cpp:1318
EditMetadataDialog::m_albumartButton
MythUIButton * m_albumartButton
Definition: editmetadata.h:140
MusicMetadata::Track
int Track() const
Definition: musicmetadata.h:198
genres.h
MusicMetadata::setRating
void setRating(int lrating)
Definition: musicmetadata.h:241
EditMetadataDialog::setArtist
void setArtist(const QString &artist)
Definition: editmetadata.cpp:553
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
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
MusicMetadata
Definition: musicmetadata.h:80
IT_CD
@ IT_CD
Definition: musicmetadata.h:33
EditMetadataDialog::updateArtistImage
void updateArtistImage(void)
Definition: editmetadata.cpp:559
AlbumArtImages::guessImageType
static ImageType guessImageType(const QString &filename)
Definition: musicmetadata.cpp:2194
GetMythDB
MythDB * GetMythDB(void)
Definition: mythdb.cpp:50
IT_FRONTCOVER
@ IT_FRONTCOVER
Definition: musicmetadata.h:31
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:644
MusicMetadata::Artist
QString Artist() const
Definition: musicmetadata.h:125
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:1679
EditMetadataCommon::hasMetadataChanged
static bool hasMetadataChanged(void)
Definition: 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:1496
EditMetadataDialog::incRating
void incRating(void)
Definition: editmetadata.cpp:408
EditAlbumartDialog::showTypeMenu
void showTypeMenu(bool changeType=true)
Definition: editmetadata.cpp:993
EditAlbumartDialog::removeCachedImage
static void removeCachedImage(const AlbumArtImage *image)
Definition: editmetadata.cpp:1371
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:110
AllMusic::getAllMetadata
MetadataPtrList * getAllMetadata(void)
Definition: musicmetadata.h:446
MythUICheckBox::toggled
void toggled(bool)
MythUIButtonListItem::SetText
void SetText(const QString &text, const QString &name="", const QString &state="")
Definition: mythuibuttonlist.cpp:3319
MythObservable::addListener
void addListener(QObject *listener)
Add a listener to the observable.
Definition: mythobservable.cpp:38
EditMetadataDialog::setAlbum
void setAlbum(const QString &album)
Definition: editmetadata.cpp:623
EditMetadataDialog::decRating
void decRating(void)
Definition: editmetadata.cpp:414
MythUIButtonListItem
Definition: mythuibuttonlist.h:41
MetaIO::supportsEmbeddedImages
virtual bool supportsEmbeddedImages(void)
Does the tag support embedded cover art.
Definition: metaio.h:58
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: editmetadata.cpp:1305
MythUITextEdit::SetText
void SetText(const QString &text, bool moveCursor=true)
Definition: mythuitextedit.cpp:198
AlbumArtImages::getImageCount
uint getImageCount()
Definition: musicmetadata.h:530
EditAlbumartDialog::doRemoveImageFromTag
void doRemoveImageFromTag(bool doIt)
Definition: editmetadata.cpp:1274
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:256
EditMetadataCommon::s_metadataOnly
static bool s_metadataOnly
Definition: editmetadata.h:52
EditAlbumartDialog::m_coverartImage
MythUIImage * m_coverartImage
Definition: 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:1111
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: editmetadata.cpp:598
MythDialogBox
Basic menu dialog, message and a list of options.
Definition: mythdialogbox.h:166
IT_INLAY
@ IT_INLAY
Definition: musicmetadata.h:34
menu
static MythThemedMenu * menu
Definition: mythtv-setup.cpp:58
MythUISpinBox::GetIntValue
int GetIntValue(void) const override
Definition: mythuispinbox.h:33
EditMetadataDialog::m_searchCompArtistButton
MythUIButton * m_searchCompArtistButton
Definition: editmetadata.h:130
EditMetadataCommon::~EditMetadataCommon
~EditMetadataCommon(void) override
Definition: editmetadata.cpp:54
MusicMetadata::setGenre
void setGenre(const QString &lgenre)
Definition: musicmetadata.h:175
EditMetadataCommon::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: editmetadata.cpp:86
EditMetadataDialog::searchCompilationArtist
void searchCompilationArtist(void) const
Definition: editmetadata.cpp:578
EditMetadataCommon::s_metadata
static MusicMetadata * s_metadata
Definition: editmetadata.h:53
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:203
EditMetadataDialog::m_compilationCheck
MythUICheckBox * m_compilationCheck
Definition: editmetadata.h:138
hardwareprofile.scan.rating
def rating(profile, smoonURL, gate)
Definition: scan.py:37
EditAlbumartDialog::~EditAlbumartDialog
~EditAlbumartDialog() override
Definition: editmetadata.cpp:872
AlbumArtImages::getImageAt
AlbumArtImage * getImageAt(uint index)
Definition: musicmetadata.cpp:2151
MusicMetadata::setTitle
void setTitle(const QString &ltitle, const QString &ltitle_sort=nullptr)
Definition: musicmetadata.h:163
EditMetadataDialog::switchToAlbumArt
void switchToAlbumArt(void)
Definition: editmetadata.cpp:498
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
EditMetadataDialog::m_searchAlbumButton
MythUIButton * m_searchAlbumButton
Definition: editmetadata.h:131
EditMetadataCommon::m_albumArtChanged
bool m_albumArtChanged
Definition: editmetadata.h:56
AlbumArtImages::scanForImages
void scanForImages(void)
Definition: musicmetadata.cpp:2037
EditMetadataDialog
Definition: editvideometadata.h:19
EditMetadataCommon::saveAll
void saveAll(void)
Definition: 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:508
EditAlbumartDialog::m_imagefilenameText
MythUIText * m_imagefilenameText
Definition: editmetadata.h:185
EditAlbumartDialog::m_imagetypeText
MythUIText * m_imagetypeText
Definition: 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: editmetadata.cpp:1312
EditMetadataDialog::searchGenre
void searchGenre(void) const
Definition: editmetadata.cpp:646
MusicMetadata::getDirectoryId
int getDirectoryId()
Definition: musicmetadata.cpp:451
MythUIBusyDialog
Definition: mythprogressdialog.h:36
EditAlbumartDialog::m_metadataButton
MythUIButton * m_metadataButton
Definition: editmetadata.h:180
mythuifilebrowser.h
EditMetadataDialog::searchAlbum
void searchAlbum(void) const
Definition: editmetadata.cpp:603
AlbumArtImages::getTypeName
static QString getTypeName(ImageType type)
Definition: musicmetadata.cpp:2160
MythUIButtonListItem::GetData
QVariant GetData()
Definition: mythuibuttonlist.cpp:3715
EditMetadataDialog::updateAlbumImage
void updateAlbumImage(void)
Definition: editmetadata.cpp:629
MusicPlayer::sendMetadataChangedEvent
void sendMetadataChangedEvent(int trackID)
Definition: musicplayer.cpp:1355
uint
unsigned int uint
Definition: compat.h:81
EditMetadataDialog::m_albumEdit
MythUITextEdit * m_albumEdit
Definition: editmetadata.h:116
EditAlbumartDialog::copyImageToTag
void copyImageToTag(ImageType imageType)
Definition: editmetadata.cpp:1240
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
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: editmetadata.cpp:1260
RemoteFile::CopyFile
static bool CopyFile(const QString &src, const QString &dst, bool overwrite=false, bool verify=false)
Definition: remotefile.cpp:586
EditMetadataDialog::searchArtist
void searchArtist(void) const
Definition: 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: editmetadata.h:114
EditMetadataDialog::m_genreEdit
MythUITextEdit * m_genreEdit
Definition: editmetadata.h:118
MythUIType::Hide
void Hide(void)
Definition: mythuitype.cpp:1139
EditMetadataCommon::setSaveMetadataOnly
void setSaveMetadataOnly(void)
Definition: editmetadata.cpp:237
MusicMetadata::Album
QString Album() const
Definition: musicmetadata.h:149
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: editmetadata.cpp:949
MusicMetadata::setCompilationArtist
void setCompilationArtist(const QString &lcompilation_artist, const QString &lcompilation_artist_sort=nullptr)
Definition: musicmetadata.h:139
mthreadpool.h
mythuihelper.h
EditAlbumartDialog::m_imageFilename
QString m_imageFilename
Definition: editmetadata.h:175
CopyImageThread::m_strList
QStringList m_strList
Definition: editmetadata.cpp:1315
EditMetadataDialog::ratingSpinChanged
void ratingSpinChanged(MythUIButtonListItem *item)
Definition: editmetadata.cpp:420
MusicMetadata::dumpToDatabase
void dumpToDatabase(void)
Definition: musicmetadata.cpp:668
EditMetadataDialog::~EditMetadataDialog
~EditMetadataDialog() override
Definition: editvideometadata.cpp:49
EditMetadataCommon::CreateCommon
bool CreateCommon(void)
Definition: editmetadata.cpp:75
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:401
EditMetadataDialog::setGenre
void setGenre(const QString &genre)
Definition: editmetadata.cpp:674
MusicMetadata::setArtist
void setArtist(const QString &lartist, const QString &lartist_sort=nullptr)
Definition: musicmetadata.h:127
MusicMetadata::Hostname
QString Hostname(void)
Definition: musicmetadata.h:229
EditMetadataCommon::m_searchType
QString m_searchType
Definition: editmetadata.h:57
EditMetadataDialog::customEvent
void customEvent(QEvent *levent) override
Definition: editvideometadata.cpp:993
EditAlbumartDialog::gridItemChanged
void gridItemChanged(MythUIButtonListItem *item)
Definition: editmetadata.cpp:909
AlbumArtImages
Definition: musicmetadata.h:519
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:687
metaio.h
EditAlbumartDialog
Definition: editmetadata.h:143
IT_BACKCOVER
@ IT_BACKCOVER
Definition: musicmetadata.h:32
EditMetadataCommon::cleanupAndClose
void cleanupAndClose(void)
Definition: editmetadata.cpp:188
CopyImageThread
Definition: editmetadata.cpp:1299
MusicMetadata::setAlbumId
void setAlbumId(int lalbumid)
Definition: musicmetadata.h:189
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: editmetadata.h:136
AlbumArtImage
Definition: musicmetadata.h:39
MusicMetadata::Compilation
bool Compilation() const
Definition: musicmetadata.h:251
EditMetadataDialog::updateGenreImage
void updateGenreImage(void)
Definition: editmetadata.cpp:680
MythUIText::SetText
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:115
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: editmetadata.cpp:715
DialogCompletionEvent::kEventType
static const Type kEventType
Definition: mythdialogbox.h:57
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:104
EditAlbumartDialog::customEvent
void customEvent(QEvent *event) override
Definition: editmetadata.cpp:1096
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:1367
mythuibutton.h
EditAlbumartDialog::switchToMetadata
void switchToMetadata(void)
Definition: editmetadata.cpp:976
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &Stackname)
Definition: mythmainwindow.cpp:322
MetadataPtrList
QList< MusicMetadata * > MetadataPtrList
Definition: musicmetadata.h:395
EditAlbumartDialog::m_coverartList
MythUIButtonList * m_coverartList
Definition: editmetadata.h:183
MusicMetadata::setYear
void setYear(int lyear)
Definition: musicmetadata.h:196
MusicData::m_all_music
AllMusic * m_all_music
Definition: musicdata.h:56
EditAlbumartDialog::startCopyImageToTag
void startCopyImageToTag(void)
Definition: editmetadata.cpp:1216
MusicMetadata::Rating
int Rating() const
Definition: musicmetadata.h:238
EditMetadataCommon::saveToMetadata
void saveToMetadata(void)
Definition: editmetadata.cpp:199
MythThemedMenuState::Create
bool Create(void) override
Definition: myththemedmenu.cpp:34
MusicMetadata::setCompilation
void setCompilation(bool state)
Definition: musicmetadata.h:252
EditMetadataCommon::metadataChanged
void metadataChanged(void)
EditMetadataCommon::m_doneButton
MythUIButton * m_doneButton
Definition: editmetadata.h:58
EditAlbumartDialog::updateImageGrid
void updateImageGrid(void)
Definition: editmetadata.cpp:932
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: editmetadata.cpp:49
GetMythUI
MythUIHelper * GetMythUI()
Definition: mythuihelper.cpp:66
EditMetadataCommon
Definition: editmetadata.h:19
EditMetadataDialog::m_compArtistEdit
MythUITextEdit * m_compArtistEdit
Definition: editmetadata.h:115
IT_ARTIST
@ IT_ARTIST
Definition: musicmetadata.h:35
EditMetadataCommon::showSaveMenu
void showSaveMenu(void)
Definition: editmetadata.cpp:154
MThreadPool::globalInstance
static MThreadPool * globalInstance(void)
Definition: mthreadpool.cpp:307
EditAlbumartDialog::Create
bool Create(void) override
Definition: editmetadata.cpp:877
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:2270
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:52
ImageType
ImageType
Definition: musicmetadata.h:28
EditMetadataDialog::searchForArtistImages
void searchForArtistImages(void)
search google for artist images
Definition: editmetadata.cpp:727
EditAlbumartDialog::rescanForImages
void rescanForImages(void)
search the tracks tag and the tracks directory for images
Definition: editmetadata.cpp:1204
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:566
EditAlbumartDialog::showMenu
void showMenu(void)
Definition: editmetadata.cpp:1034
MythObservable::removeListener
void removeListener(QObject *listener)
Remove a listener to the observable.
Definition: mythobservable.cpp:55
EditMetadataDialog::albumLostFocus
void albumLostFocus(void)
Definition: editmetadata.cpp:704
EditMetadataDialog::showMenu
void showMenu(void)
Definition: editmetadata.cpp:470
MusicMetadata::Year
int Year() const
Definition: musicmetadata.h:195
MThreadPool::start
void start(QRunnable *runnable, const QString &debugName, int priority=0)
Definition: mthreadpool.cpp:342
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: editmetadata.cpp:206
MythUIStateType::DisplayState
bool DisplayState(const QString &name)
Definition: mythuistatetype.cpp:84
EditMetadataDialog::m_decRatingButton
MythUIButton * m_decRatingButton
Definition: editmetadata.h:127
EditMetadataDialog::m_ratingSpin
MythUISpinBox * m_ratingSpin
Definition: editmetadata.h:123
MusicMetadata::setGenreId
void setGenreId(int lgenreid)
Definition: musicmetadata.h:192
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:208
musicplayer.h
AlbumArtImage::m_embedded
bool m_embedded
Definition: musicmetadata.h:53
EditMetadataDialog::fillWidgets
void fillWidgets()
Definition: editvideometadata.cpp:302