MythTV  master
editvideometadata.cpp
Go to the documentation of this file.
1 #include <algorithm>
2 
3 #include <QImageReader>
4 #include <QUrl>
5 
6 #include <mythcontext.h>
7 #include <mythdirs.h>
8 
9 #include "mythmainwindow.h"
10 #include "mythdialogbox.h"
11 #include "mythuibuttonlist.h"
12 #include "mythuitext.h"
13 #include "mythuitextedit.h"
14 #include "mythuibutton.h"
15 #include "mythuicheckbox.h"
16 #include "mythuispinbox.h"
17 #include "mythuiimage.h"
18 #include "mythuifilebrowser.h"
19 #include "mythuiimageresults.h"
20 #include "mythuihelper.h"
21 #include "mythprogressdialog.h"
22 #include "mythmiscutil.h"
23 #include "remoteutil.h"
24 #include "globals.h"
25 #include "dbaccess.h"
27 #include "videoutils.h"
28 
29 #include "editvideometadata.h"
30 #include "metadatafactory.h"
31 
32 //static const QString _Location = QObject::tr("Metadata Editor");
33 
35  const QString& lname, VideoMetadata *source_metadata,
36  const VideoMetadataListManager &cache) : MythScreenType(lparent, lname),
37  m_origMetadata(source_metadata),
38  m_metaCache(cache)
39 {
40  m_query = new MetadataDownload(this);
43 
44  m_popupStack = GetMythMainWindow()->GetStack("popup stack");
45 }
46 
48 {
49  delete m_workingMetadata;
50 }
51 
53 {
54  if (!LoadWindowFromXML("video-ui.xml", "edit_metadata", this))
55  return false;
56 
57  bool err = false;
58  UIUtilE::Assign(this, m_titleEdit, "title_edit", &err);
59  UIUtilE::Assign(this, m_subtitleEdit, "subtitle_edit", &err);
60  UIUtilE::Assign(this, m_playerEdit, "player_edit", &err);
61 
62  UIUtilE::Assign(this, m_seasonSpin, "season", &err);
63  UIUtilE::Assign(this, m_episodeSpin, "episode", &err);
64 
65 
66  UIUtilE::Assign(this, m_categoryList, "category_select", &err);
67  UIUtilE::Assign(this, m_levelList, "level_select", &err);
68  UIUtilE::Assign(this, m_childList, "child_select", &err);
69 
70  UIUtilE::Assign(this, m_browseCheck, "browse_check", &err);
71  UIUtilE::Assign(this, m_watchedCheck, "watched_check", &err);
72 
73  UIUtilE::Assign(this, m_doneButton, "done_button", &err);
74 
75  if (err)
76  {
77  LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'edit_metadata'");
78  return false;
79  }
80 
81  UIUtilW::Assign(this, m_coverartText, "coverart_text");
82  UIUtilW::Assign(this, m_screenshotText, "screenshot_text");
83  UIUtilW::Assign(this, m_bannerText, "banner_text");
84  UIUtilW::Assign(this, m_fanartText, "fanart_text");
85  UIUtilW::Assign(this, m_trailerText, "trailer_text");
86 
87  UIUtilW::Assign(this, m_coverartButton, "coverart_button");
88  UIUtilW::Assign(this, m_bannerButton, "banner_button");
89  UIUtilW::Assign(this, m_fanartButton, "fanart_button");
90  UIUtilW::Assign(this, m_screenshotButton, "screenshot_button");
91  UIUtilW::Assign(this, m_trailerButton, "trailer_button");
92 
93  UIUtilW::Assign(this, m_netBannerButton, "net_banner_button");
94  UIUtilW::Assign(this, m_netFanartButton, "net_fanart_button");
95  UIUtilW::Assign(this, m_netScreenshotButton, "net_screenshot_button");
96  UIUtilW::Assign(this, m_netCoverartButton, "net_coverart_button");
97 
98  UIUtilW::Assign(this, m_taglineEdit, "tagline_edit");
99  UIUtilW::Assign(this, m_ratingEdit, "rating_edit");
100  UIUtilW::Assign(this, m_directorEdit, "director_edit");
101  UIUtilW::Assign(this, m_inetrefEdit, "inetref_edit");
102  UIUtilW::Assign(this, m_homepageEdit, "homepage_edit");
103  UIUtilW::Assign(this, m_plotEdit, "description_edit");
104  UIUtilW::Assign(this, m_yearSpin, "year_spin");
105  UIUtilW::Assign(this, m_userRatingSpin, "userrating_spin");
106  UIUtilW::Assign(this, m_lengthSpin, "length_spin");
107 
108  UIUtilW::Assign(this, m_coverart, "coverart");
109  UIUtilW::Assign(this, m_screenshot, "screenshot");
110  UIUtilW::Assign(this, m_banner, "banner");
111  UIUtilW::Assign(this, m_fanart, "fanart");
112 
113  fillWidgets();
114 
115  BuildFocusList();
116 
117  connect(m_titleEdit, SIGNAL(valueChanged()), SLOT(SetTitle()));
119  connect(m_subtitleEdit, SIGNAL(valueChanged()), SLOT(SetSubtitle()));
121  connect(m_playerEdit, SIGNAL(valueChanged()), SLOT(SetPlayer()));
122  if (m_taglineEdit)
123  {
124  connect(m_taglineEdit, SIGNAL(valueChanged()), SLOT(SetTagline()));
126  }
127  if (m_ratingEdit)
128  {
129  connect(m_ratingEdit, SIGNAL(valueChanged()), SLOT(SetRating()));
131  }
132  if (m_directorEdit)
133  {
134  connect(m_directorEdit, SIGNAL(valueChanged()), SLOT(SetDirector()));
136  }
137  if (m_inetrefEdit)
138  connect(m_inetrefEdit, SIGNAL(valueChanged()), SLOT(SetInetRef()));
139  if (m_homepageEdit)
140  {
141  connect(m_homepageEdit, SIGNAL(valueChanged()), SLOT(SetHomepage()));
143  }
144  if (m_plotEdit)
145  {
146  connect(m_plotEdit, SIGNAL(valueChanged()), SLOT(SetPlot()));
148  }
149 
150  connect(m_seasonSpin, SIGNAL(LosingFocus()), SLOT(SetSeason()));
151  connect(m_episodeSpin, SIGNAL(LosingFocus()), SLOT(SetEpisode()));
152  if (m_yearSpin)
153  connect(m_yearSpin, SIGNAL(LosingFocus()), SLOT(SetYear()));
154  if (m_userRatingSpin)
155  connect(m_userRatingSpin, SIGNAL(LosingFocus()), SLOT(SetUserRating()));
156  if (m_lengthSpin)
157  connect(m_lengthSpin, SIGNAL(LosingFocus()), SLOT(SetLength()));
158 
159  connect(m_doneButton, SIGNAL(Clicked()), SLOT(SaveAndExit()));
160 
161  // Find Artwork locally
162  if (m_coverartButton)
163  connect(m_coverartButton, SIGNAL(Clicked()), SLOT(FindCoverArt()));
164  if (m_bannerButton)
165  connect(m_bannerButton, SIGNAL(Clicked()), SLOT(FindBanner()));
166  if (m_fanartButton)
167  connect(m_fanartButton, SIGNAL(Clicked()), SLOT(FindFanart()));
168  if (m_screenshotButton)
169  connect(m_screenshotButton, SIGNAL(Clicked()), SLOT(FindScreenshot()));
170 
171  // Find Artwork on the Internet
173  connect(m_netCoverartButton, SIGNAL(Clicked()), SLOT(FindNetCoverArt()));
174  if (m_netBannerButton)
175  connect(m_netBannerButton, SIGNAL(Clicked()), SLOT(FindNetBanner()));
176  if (m_netFanartButton)
177  connect(m_netFanartButton, SIGNAL(Clicked()), SLOT(FindNetFanart()));
179  connect(m_netScreenshotButton, SIGNAL(Clicked()), SLOT(FindNetScreenshot()));
180 
181  if (m_trailerButton)
182  connect(m_trailerButton, SIGNAL(Clicked()), SLOT(FindTrailer()));
183 
184  connect(m_browseCheck, SIGNAL(valueChanged()), SLOT(ToggleBrowse()));
185  connect(m_watchedCheck, SIGNAL(valueChanged()), SLOT(ToggleWatched()));
186 
187  connect(m_childList, SIGNAL(itemSelected(MythUIButtonListItem*)),
189  connect(m_levelList, SIGNAL(itemSelected(MythUIButtonListItem*)),
191  connect(m_categoryList, SIGNAL(itemSelected(MythUIButtonListItem*)),
193  connect(m_categoryList, SIGNAL(itemClicked(MythUIButtonListItem*)),
194  SLOT(NewCategoryPopup()));
195 
196  return true;
197 }
198 
199 namespace
200 {
201  template <typename T>
202  struct title_sort
203  {
204  bool operator()(const T &lhs, const T &rhs)
205  {
206  return naturalCompare(lhs.second, rhs.second) < 0;
207  }
208  };
209 
210  QStringList GetSupportedImageExtensionFilter()
211  {
212  QStringList ret;
213 
214  QList<QByteArray> exts = QImageReader::supportedImageFormats();
215  foreach (auto & ext, exts)
216  ret.append(QString("*.").append(ext));
217  return ret;
218  }
219 
220  void FindImagePopup(const QString &prefix, const QString &prefixAlt,
221  QObject &inst, const QString &returnEvent)
222  {
223  QString fp;
224 
225  if (prefix.startsWith("myth://"))
226  fp = prefix;
227  else
228  fp = prefix.isEmpty() ? prefixAlt : prefix;
229 
230  MythScreenStack *popupStack =
231  GetMythMainWindow()->GetStack("popup stack");
232 
233  auto *fb = new MythUIFileBrowser(popupStack, fp);
234  fb->SetNameFilter(GetSupportedImageExtensionFilter());
235  if (fb->Create())
236  {
237  fb->SetReturnEvent(&inst, returnEvent);
238  popupStack->AddScreen(fb);
239  }
240  else
241  delete fb;
242  }
243 
244  void FindVideoFilePopup(const QString &prefix, const QString &prefixAlt,
245  QObject &inst, const QString &returnEvent)
246  {
247  QString fp;
248 
249  if (prefix.startsWith("myth://"))
250  fp = prefix;
251  else
252  fp = prefix.isEmpty() ? prefixAlt : prefix;
253 
254  MythScreenStack *popupStack =
255  GetMythMainWindow()->GetStack("popup stack");
256  QStringList exts;
257 
258  const FileAssociations::association_list fa_list =
260  for (const auto & fa : fa_list)
261  exts << QString("*.%1").arg(fa.extension.toUpper());
262 
263  auto *fb = new MythUIFileBrowser(popupStack, fp);
264  fb->SetNameFilter(exts);
265  if (fb->Create())
266  {
267  fb->SetReturnEvent(&inst, returnEvent);
268  popupStack->AddScreen(fb);
269  }
270  else
271  delete fb;
272  }
273 
274  const QString CEID_COVERARTFILE = "coverartfile";
275  const QString CEID_BANNERFILE = "bannerfile";
276  const QString CEID_FANARTFILE = "fanartfile";
277  const QString CEID_SCREENSHOTFILE = "screenshotfile";
278  const QString CEID_TRAILERFILE = "trailerfile";
279  const QString CEID_NEWCATEGORY = "newcategory";
280 }
281 
282 void EditMetadataDialog::createBusyDialog(const QString& title)
283 {
284  if (m_busyPopup)
285  return;
286 
287  const QString& message = title;
288 
290  "mythvideobusydialog");
291 
292  if (m_busyPopup->Create())
294 }
295 
297 {
300 
301  m_seasonSpin->SetRange(0,9999,1,5);
303  m_episodeSpin->SetRange(0,999,1,10);
305  if (m_yearSpin)
306  {
307  m_yearSpin->SetRange(0,9999,1,100);
309  }
310  if (m_userRatingSpin)
311  {
312  m_userRatingSpin->SetRange(0,10,1,2);
314  }
315  if (m_lengthSpin)
316  {
317  m_lengthSpin->SetRange(0,999,1,15);
319  }
320 
321  // No memory leak. MythUIButtonListItem adds the new item into
322  // m_categoryList.
324  const VideoCategory::entry_list &vcl =
326  for (const auto & vc : vcl)
327  {
328  // No memory leak. MythUIButtonListItem adds the new item into
329  // m_categoryList.
330  auto *button = new MythUIButtonListItem(m_categoryList, vc.second);
331  button->SetData(vc.first);
332  }
334 
336  i <= ParentalLevel::plHigh && i.good(); ++i)
337  {
338  // No memory leak. MythUIButtonListItem adds the new item into
339  // m_levelList.
340  auto *button = new MythUIButtonListItem(m_levelList,
341  tr("Level %1").arg(i.GetLevel()));
342  button->SetData(i.GetLevel());
343  }
345 
346  //
347  // Fill the "always play this video next" option
348  // with all available videos.
349  //
350 
351  // No memory leak. MythUIButtonListItem adds the new item into
352  // m_childList.
353  new MythUIButtonListItem(m_childList,tr("None"));
354 
355  // TODO: maybe make the title list have the same sort order
356  // as elsewhere.
357  using title_list = std::vector<std::pair<unsigned int, QString> >;
359  title_list tc;
360  tc.reserve(mdl.size());
361  for (const auto & md : mdl)
362  {
363  QString title;
364  if (md->GetSeason() > 0 || md->GetEpisode() > 0)
365  {
366  title = QString("%1 %2x%3").arg(md->GetTitle())
367  .arg(QString::number(md->GetSeason()))
368  .arg(QString::number(md->GetEpisode()));
369  }
370  else
371  {
372  title = md->GetTitle();
373  }
374  tc.push_back(std::make_pair(md->GetID(), title));
375  }
376  std::sort(tc.begin(), tc.end(), title_sort<title_list::value_type>());
377 
378  for (const auto & t : tc)
379  {
380  if (t.first != m_workingMetadata->GetID())
381  {
382  auto *button = new MythUIButtonListItem(m_childList,t.second);
383  button->SetData(t.first);
384  }
385  }
386 
387  if (m_workingMetadata->GetChildID() > 0)
388  {
391  }
392 
397  if (m_coverartText)
399  if (m_screenshotText)
401  if (m_bannerText)
403  if (m_fanartText)
405  if (m_trailerText)
407 
409  if (m_taglineEdit)
411  if (m_ratingEdit)
413  if (m_directorEdit)
415  if (m_inetrefEdit)
417  if (m_homepageEdit)
419  if (m_plotEdit)
421 
422  if (m_coverart)
423  {
424  if (!m_workingMetadata->GetHost().isEmpty() &&
425  !m_workingMetadata->GetCoverFile().isEmpty() &&
426  !m_workingMetadata->GetCoverFile().startsWith("/"))
427  {
431  }
432  else
434 
435  if (!m_workingMetadata->GetCoverFile().isEmpty())
436  m_coverart->Load();
437  }
438  if (m_screenshot)
439  {
440  if (!m_workingMetadata->GetHost().isEmpty() &&
441  !m_workingMetadata->GetScreenshot().isEmpty() &&
442  !m_workingMetadata->GetScreenshot().startsWith("/"))
443  {
447  }
448  else
450 
451  if (!m_workingMetadata->GetScreenshot().isEmpty())
452  m_screenshot->Load();
453  }
454  if (m_banner)
455  {
456  if (!m_workingMetadata->GetHost().isEmpty() &&
457  !m_workingMetadata->GetBanner().isEmpty() &&
458  !m_workingMetadata->GetBanner().startsWith("/"))
459  {
463  }
464  else
466 
467  if (!m_workingMetadata->GetBanner().isEmpty())
468  m_banner->Load();
469  }
470  if (m_fanart)
471  {
472  if (!m_workingMetadata->GetHost().isEmpty() &&
473  !m_workingMetadata->GetFanart().isEmpty() &&
474  !m_workingMetadata->GetFanart().startsWith("/"))
475  {
479  }
480  else
482 
483  if (!m_workingMetadata->GetFanart().isEmpty())
484  m_fanart->Load();
485  }
486 }
487 
489 {
490  QString message = tr("Enter new category");
491 
492  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
493 
494  auto *categorydialog = new MythTextInputDialog(popupStack,message);
495 
496  if (categorydialog->Create())
497  {
498  categorydialog->SetReturnEvent(this, CEID_NEWCATEGORY);
499  popupStack->AddScreen(categorydialog);
500  }
501 
502 }
503 
504 void EditMetadataDialog::AddCategory(const QString& category)
505 {
506  int id = VideoCategory::GetCategory().add(category);
508  new MythUIButtonListItem(m_categoryList, category, id);
510 }
511 
513 {
516 
517  emit Finished();
518  Close();
519 }
520 
522 {
524 }
525 
527 {
529 }
530 
532 {
533  m_workingMetadata->SetCategoryID(item->GetData().toInt());
534 }
535 
537 {
539 }
540 
542 {
544 }
545 
547 {
549 }
550 
552 {
554 }
555 
557 {
559 }
560 
562 {
564 }
565 
567 {
569 }
570 
572 {
574 }
575 
577 {
579 }
580 
582 {
584 }
585 
587 {
589 }
590 
592 {
594 }
595 
597 {
599  SetShowLevel(ParentalLevel(item->GetData().toInt()).GetLevel());
600 }
601 
603 {
604  m_cachedChildSelection = item->GetData().toInt();
606 }
607 
609 {
611  SetBrowse(m_browseCheck->GetBooleanCheckState());
612 }
613 
615 {
617  SetWatched(m_watchedCheck->GetBooleanCheckState());
618 }
619 
621 {
622  if (!m_workingMetadata->GetHost().isEmpty())
623  {
624  QString url = generate_file_url("Coverart",
626  "");
627  FindImagePopup(url, "", *this, CEID_COVERARTFILE);
628  }
629  else
630  {
631  FindImagePopup(gCoreContext->GetSetting("VideoArtworkDir"),
632  GetConfDir() + "/MythVideo", *this, CEID_COVERARTFILE);
633  }
634 }
635 
637 {
638  if (!lookup)
639  return;
640 
641  if (m_busyPopup)
642  {
643  m_busyPopup->Close();
644  m_busyPopup = nullptr;
645  }
646 
647  auto type = lookup->GetData().value<VideoArtworkType>();
648  ArtworkList list = lookup->GetArtwork(type);
649 
650  if (list.isEmpty())
651  {
652  MythWarningNotification n(tr("No image found"), tr("Metadata Editor"));
654  return;
655  }
656  auto *resultsdialog = new ImageSearchResultsDialog(m_popupStack, list, type);
657 
658  connect(resultsdialog, SIGNAL(haveResult(ArtworkInfo, VideoArtworkType)),
660 
661  if (resultsdialog->Create())
662  m_popupStack->AddScreen(resultsdialog);
663 }
664 
666 {
667  QString msg = tr("Downloading selected artwork...");
668  createBusyDialog(msg);
669 
670  auto *lookup = new MetadataLookup();
671  lookup->SetType(kMetadataVideo);
672 
673  lookup->SetSubtype(GuessLookupType(m_workingMetadata));
674  lookup->SetHost(m_workingMetadata->GetHost());
675  lookup->SetAutomatic(true);
676  lookup->SetData(QVariant::fromValue<VideoArtworkType>(type));
677 
678  ArtworkMap downloads;
679  downloads.insert(type, info);
680  lookup->SetDownloads(downloads);
681  lookup->SetAllowOverwrites(true);
682  lookup->SetTitle(m_workingMetadata->GetTitle());
683  lookup->SetSubtitle(m_workingMetadata->GetSubtitle());
684  lookup->SetSeason(m_workingMetadata->GetSeason());
685  lookup->SetEpisode(m_workingMetadata->GetEpisode());
686  lookup->SetInetref(m_workingMetadata->GetInetRef());
687 
688  m_imageDownload->addDownloads(lookup);
689 }
690 
692 {
693  if (!lookup)
694  return;
695 
696  if (m_busyPopup)
697  {
698  m_busyPopup->Close();
699  m_busyPopup = nullptr;
700  }
701 
702  auto type = lookup->GetData().value<VideoArtworkType>();
703  ArtworkMap map = lookup->GetDownloads();
704 
705  if (map.count() >= 1)
706  {
707  ArtworkInfo info = map.value(type);
708  QString filename = info.url;
709 
710  if (type == kArtworkCoverart)
712  else if (type == kArtworkFanart)
714  else if (type == kArtworkBanner)
716  else if (type == kArtworkScreenshot)
718  }
719 }
720 
722 {
723  QString msg = tr("Searching for available artwork...");
724  createBusyDialog(msg);
725 
726  auto *lookup = new MetadataLookup();
727  lookup->SetStep(kLookupSearch);
728  lookup->SetType(kMetadataVideo);
729  lookup->SetAutomatic(true);
730  if (m_workingMetadata->GetSeason() > 0 ||
732  lookup->SetSubtype(kProbableTelevision);
733  else if (m_workingMetadata->GetSubtitle().isEmpty())
734  lookup->SetSubtype(kProbableMovie);
735  else
736  lookup->SetSubtype(kUnknownVideo);
737  lookup->SetData(QVariant::fromValue<VideoArtworkType>(type));
738 
739  lookup->SetTitle(m_workingMetadata->GetTitle());
740  lookup->SetSubtitle(m_workingMetadata->GetSubtitle());
741  lookup->SetSeason(m_workingMetadata->GetSeason());
742  lookup->SetEpisode(m_workingMetadata->GetEpisode());
743  lookup->SetInetref(m_workingMetadata->GetInetRef());
744 
745  m_query->addLookup(lookup);
746 }
747 
749 {
751 }
752 
754 {
756 }
757 
759 {
761 }
762 
764 {
766 }
767 
769 {
770  if (file.isEmpty())
771  return;
772 
773  QString origfile = file;
774 
775  if (file.startsWith("myth://"))
776  {
777  QUrl url(file);
778  file = url.path();
779  file = file.right(file.length() - 1);
780  if (!file.endsWith("/"))
782  else
783  m_workingMetadata->SetCoverFile(QString());
784  }
785  else
787 
789 
790  if (m_coverart)
791  {
792  m_coverart->SetFilename(origfile);
793  m_coverart->Load();
794  }
795 }
796 
798 {
799  if (!m_workingMetadata->GetHost().isEmpty())
800  {
801  QString url = generate_file_url("Banners",
803  "");
804  FindImagePopup(url, "", *this, CEID_BANNERFILE);
805  }
806  else
807  {
808  FindImagePopup(gCoreContext->GetSetting("mythvideo.bannerDir"),
809  GetConfDir() + "/MythVideo/Banners", *this, CEID_BANNERFILE);
810  }
811 }
812 
814 {
815  if (file.isEmpty())
816  return;
817 
818  QString origfile = file;
819 
820  if (file.startsWith("myth://"))
821  {
822  QUrl url(file);
823  file = url.path();
824  file = file.right(file.length() - 1);
825  if (!file.endsWith("/"))
827  else
828  m_workingMetadata->SetBanner(QString());
829  }
830  else
832 
834 
835  if (m_banner)
836  {
837  m_banner->SetFilename(origfile);
838  m_banner->Load();
839  }
840 }
841 
843 {
844  if (!m_workingMetadata->GetHost().isEmpty())
845  {
846  QString url = generate_file_url("Fanart",
848  "");
849  FindImagePopup(url, "", *this, CEID_FANARTFILE);
850  }
851  else
852  {
853  FindImagePopup(gCoreContext->GetSetting("mythvideo.fanartDir"),
854  GetConfDir() + "/MythVideo/Fanart", *this, CEID_FANARTFILE);
855  }
856 }
857 
859 {
860  if (file.isEmpty())
861  return;
862 
863  QString origfile = file;
864 
865  if (file.startsWith("myth://"))
866  {
867  QUrl url(file);
868  file = url.path();
869  file = file.right(file.length() - 1);
870  if (!file.endsWith("/"))
872  else
873  m_workingMetadata->SetFanart(QString());
874  }
875  else
877 
879 
880  if (m_fanart)
881  {
882  m_fanart->SetFilename(origfile);
883  m_fanart->Load();
884  }
885 }
886 
888 {
889  if (!m_workingMetadata->GetHost().isEmpty())
890  {
891  QString url = generate_file_url("Screenshots",
893  "");
894  FindImagePopup(url, "", *this, CEID_SCREENSHOTFILE);
895  }
896  else
897  {
898  FindImagePopup(gCoreContext->GetSetting("mythvideo.screenshotDir"),
899  GetConfDir() + "/MythVideo/Screenshots",
900  *this, CEID_SCREENSHOTFILE);
901  }
902 }
903 
905 {
906  if (file.isEmpty())
907  return;
908 
909  QString origfile = file;
910 
911  if (file.startsWith("myth://"))
912  {
913  QUrl url(file);
914  file = url.path();
915  file = file.right(file.length() - 1);
916  if (!file.endsWith("/"))
918  else
919  m_workingMetadata->SetScreenshot(QString());
920  }
921  else
923 
925 
926  if (m_screenshot)
927  {
928  m_screenshot->SetFilename(origfile);
929  m_screenshot->Load();
930  }
931 }
932 
934 {
935  if (!m_workingMetadata->GetHost().isEmpty())
936  {
937  QString url = generate_file_url("Trailers",
939  "");
940  FindVideoFilePopup(url, "", *this, CEID_TRAILERFILE);
941  }
942  else
943  {
944  FindVideoFilePopup(gCoreContext->GetSetting("mythvideo.TrailersDir"),
945  GetConfDir() + "/MythVideo/Trailers", *this, CEID_TRAILERFILE);
946  }
947 }
948 
950 {
951  if (file.isEmpty())
952  return;
953 
954  if (file.startsWith("myth://"))
955  {
956  QUrl url(file);
957  file = url.path();
958  file = file.right(file.length() - 1);
959  if (!file.endsWith("/"))
961  else
962  m_workingMetadata->SetTrailer(QString());
963  }
964  else
967 }
968 
970 {
971  if (levent->type() == DialogCompletionEvent::kEventType)
972  {
973  auto *dce = (DialogCompletionEvent*)(levent);
974 
975  const QString resultid = dce->GetId();
976 
977  if (resultid == CEID_COVERARTFILE)
978  SetCoverArt(dce->GetResultText());
979  else if (resultid == CEID_BANNERFILE)
980  SetBanner(dce->GetResultText());
981  else if (resultid == CEID_FANARTFILE)
982  SetFanart(dce->GetResultText());
983  else if (resultid == CEID_SCREENSHOTFILE)
984  SetScreenshot(dce->GetResultText());
985  else if (resultid == CEID_TRAILERFILE)
986  SetTrailer(dce->GetResultText());
987  else if (resultid == CEID_NEWCATEGORY)
988  AddCategory(dce->GetResultText());
989  }
990  else if (levent->type() == MetadataLookupEvent::kEventType)
991  {
992  auto *lue = (MetadataLookupEvent *)levent;
993 
994  MetadataLookupList lul = lue->m_lookupList;
995 
996  if (lul.isEmpty())
997  return;
998 
999  // There should really only be one result here.
1000  // If not, USER ERROR!
1001  if (lul.count() == 1)
1002  {
1003  OnArtworkSearchDone(lul[0]);
1004  }
1005  else
1006  {
1007  if (m_busyPopup)
1008  {
1009  m_busyPopup->Close();
1010  m_busyPopup = nullptr;
1011  }
1012  }
1013  }
1014  else if (levent->type() == MetadataLookupFailure::kEventType)
1015  {
1016  auto *luf = (MetadataLookupFailure *)levent;
1017 
1018  MetadataLookupList lul = luf->m_lookupList;
1019 
1020  if (m_busyPopup)
1021  {
1022  m_busyPopup->Close();
1023  m_busyPopup = nullptr;
1024  }
1025 
1026  if (!lul.empty())
1027  {
1028  MetadataLookup *lookup = lul[0];
1029  LOG(VB_GENERAL, LOG_INFO,
1030  QString("No results found for %1 %2 %3").arg(lookup->GetTitle())
1031  .arg(lookup->GetSeason()).arg(lookup->GetEpisode()));
1032  }
1033  }
1034  else if (levent->type() == ImageDLEvent::kEventType)
1035  {
1036  auto *ide = (ImageDLEvent *)levent;
1037 
1038  MetadataLookup *lookup = ide->m_item;
1039 
1040  if (!lookup)
1041  return;
1042 
1043  handleDownloadedImages(lookup);
1044  }
1045  else if (levent->type() == ImageDLFailureEvent::kEventType)
1046  {
1047  MythErrorNotification n(tr("Failed to retrieve image"),
1048  tr("Metadata Editor"),
1049  tr("Check logs"));
1051  }
1052 }
MythUIImage * m_screenshot
void SetHomepage(const QString &homepage)
void FindNetArt(VideoArtworkType type)
MythUIButton * m_screenshotButton
MythUICheckBox * m_watchedCheck
void SetTrailer(QString file)
void SetSubtitle(const QString &subtitle, const QString &sortSubtitle="")
int GetLength() const
ArtworkList GetArtwork(VideoArtworkType type) const
MythUIText * m_fanartText
bool GetWatched() const
void SetFanart(QString file)
void SetUserRating(float userRating)
MythUITextEdit * m_homepageEdit
const metadata_list & getList() const
MythUITextEdit * m_ratingEdit
const QString & GetPlayCommand() const
void SetTrailer(const QString &trailer)
void LosingFocus()
int GetSeason() const
const QString & GetFanart() const
EditMetadataDialog(MythScreenStack *lparent, const QString &lname, VideoMetadata *source_metadata, const VideoMetadataListManager &cache)
void SetBanner(QString file)
MythUIText * m_screenshotText
MythScreenStack * m_popupStack
MythUISpinBox * m_seasonSpin
void SetFanart(const QString &fanart)
void SetRating(const QString &rating)
void SetCategory(MythUIButtonListItem *item)
const association_list & getList() const
Definition: dbaccess.cpp:806
LookupType GuessLookupType(ProgramInfo *pginfo)
VideoArtworkType
MythUICheckBox * m_browseCheck
MythUIButton * m_netBannerButton
MythUITextEdit * m_taglineEdit
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:135
void customEvent(QEvent *levent) override
const QString & GetDirector() const
int add(const QString &name)
Definition: dbaccess.cpp:215
const QString & GetBanner() const
MythUIText * m_bannerText
const QString VIDEO_CATEGORY_UNKNOWN
Definition: globals.cpp:7
MythScreenStack * GetStack(const QString &stackname)
std::vector< file_association > association_list
Definition: dbaccess.h:154
void SetDirector(const QString &director)
MetadataImageDownload * m_imageDownload
MythUIButton * m_netFanartButton
MythUIImage * m_banner
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
void SetValue(int val) override
Definition: mythuispinbox.h:26
static VideoCategory & GetCategory()
Definition: dbaccess.cpp:488
MythUIButton * m_trailerButton
void AddCategory(const QString &category)
void handleDownloadedImages(MetadataLookup *lookup)
MythUIButton * m_netScreenshotButton
MythUIButton * m_coverartButton
void SetPlayCommand(const QString &playCommand)
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
void BuildFocusList(void)
unsigned int GetID() const
QList< ArtworkInfo > ArtworkList
void SetYear(int year)
static Type kEventType
Definition: mythdialogbox.h:57
void SetTagline(const QString &tagline)
const QString & GetTrailer() const
int GetIntValue(void) const override
Definition: mythuispinbox.h:33
MythUISpinBox * m_yearSpin
MythUITextEdit * m_titleEdit
uint GetSeason() const
QString GetTitle() const
const QString & GetHomepage() const
QString GetConfDir(void)
Definition: mythdirs.cpp:224
virtual void Close()
ParentalLevel::Level GetShowLevel() const
int GetYear() const
uint GetEpisode() const
VideoMetadata * m_workingMetadata
MetadataDownload * m_query
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.
void SetCoverFile(const QString &coverFile)
bool GetBooleanCheckState(void) const
MythUITextEdit * m_plotEdit
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
const QString & GetTagline() const
void SetMaxLength(int length)
void SetChildID(int childID)
float GetUserRating() const
void OnArtworkSearchDone(MetadataLookup *lookup)
MythUIButton * m_bannerButton
bool Create(void) override
const QString & GetPlot() const
void SetScreenshot(QString file)
void SetLevel(MythUIButtonListItem *item)
int GetEpisode() const
~EditMetadataDialog() override
int GetChildID() const
QString GetSetting(const QString &key, const QString &defaultval="")
void SetEpisode(int episode)
void addDownloads(MetadataLookup *lookup)
addLookup: Add lookup to bottom of the queue MetadataDownload::m_downloadList takes ownership of the ...
MythUIButtonList * m_levelList
MythUIBusyDialog * m_busyPopup
MythUIButton * m_fanartButton
MythUIButton * m_netCoverartButton
MythUIButtonList * m_categoryList
bool Queue(const MythNotification &notification)
Queue a notification Queue() is thread-safe and can be called from anywhere.
const QString & GetRating() const
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
void SetInetRef(const QString &inetRef)
void OnSearchListSelection(const ArtworkInfo &info, VideoArtworkType type)
int GetCategoryID() const
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
const QString & GetHost() const
MythUIButtonList * m_childList
void SetCoverArt(QString file)
void SetText(const QString &text, bool moveCursor=true)
QVariant GetData() const
void SetChild(MythUIButtonListItem *item)
static FileAssociations & getFileAssociation()
Definition: dbaccess.cpp:831
MythUISpinBox * m_episodeSpin
void createBusyDialog(const QString &title)
MythMainWindow * GetMythMainWindow(void)
void SetTitle(const QString &title, const QString &sortTitle="")
bool Create() override
Dialog prompting the user to enter a text string.
MythUISpinBox * m_lengthSpin
void SetScreenshot(const QString &screenshot)
static Type kEventType
MythUITextEdit * m_directorEdit
MythUITextEdit * m_playerEdit
const entry_list & getList()
Definition: dbaccess.cpp:240
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
void haveResult(bool ok, ArchiveItem *item)
VideoMetadata * m_origMetadata
MythUITextEdit * m_subtitleEdit
bool GetBrowse() const
void SetLength(int length)
void SetCheckState(MythUIStateType::StateType state)
void SetSeason(int season)
QString generate_file_url(const QString &storage_group, const QString &host, const QString &path)
Definition: videoutils.h:65
const QString & GetScreenshot() const
std::vector< entry > entry_list
Definition: dbaccess.h:16
DownloadMap GetDownloads() const
const QString & GetSubtitle() const
const VideoMetadataListManager & m_metaCache
const QString & GetCoverFile() const
MythUIText * m_coverartText
QMultiMap< VideoArtworkType, ArtworkInfo > ArtworkMap
Screen in which all other widgets are contained and rendered.
const QString & GetInetRef() const
void CheckedSet(MythUIStateType *uiItem, const QString &value)
Definition: videoutils.cpp:44
MythUIImage * m_coverart
const QString & GetTitle() const
void addLookup(MetadataLookup *lookup)
addLookup: Add lookup to bottom of the queue MetadataDownload::m_lookupList takes ownership of the gi...
void SetBanner(const QString &banner)
MythUIButton * m_doneButton
int naturalCompare(const QString &_a, const QString &_b, Qt::CaseSensitivity caseSensitivity)
void SetPlot(const QString &plot)
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:41
MythUIText * m_trailerText
void SetCategoryID(int id)
QString GetText(void) const
MythUIImage * m_fanart
MythNotificationCenter * GetNotificationCenter(void)
void SetValueByData(const QVariant &data)
std::list< VideoMetadataPtr > metadata_list
MythUITextEdit * m_inetrefEdit
MythUISpinBox * m_userRatingSpin
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:41