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  for (QList<QByteArray>::iterator p = exts.begin(); p != exts.end(); ++p)
216  {
217  ret.append(QString("*.").append(*p));
218  }
219 
220  return ret;
221  }
222 
223  void FindImagePopup(const QString &prefix, const QString &prefixAlt,
224  QObject &inst, const QString &returnEvent)
225  {
226  QString fp;
227 
228  if (prefix.startsWith("myth://"))
229  fp = prefix;
230  else
231  fp = prefix.isEmpty() ? prefixAlt : prefix;
232 
233  MythScreenStack *popupStack =
234  GetMythMainWindow()->GetStack("popup stack");
235 
236  auto *fb = new MythUIFileBrowser(popupStack, fp);
237  fb->SetNameFilter(GetSupportedImageExtensionFilter());
238  if (fb->Create())
239  {
240  fb->SetReturnEvent(&inst, returnEvent);
241  popupStack->AddScreen(fb);
242  }
243  else
244  delete fb;
245  }
246 
247  void FindVideoFilePopup(const QString &prefix, const QString &prefixAlt,
248  QObject &inst, const QString &returnEvent)
249  {
250  QString fp;
251 
252  if (prefix.startsWith("myth://"))
253  fp = prefix;
254  else
255  fp = prefix.isEmpty() ? prefixAlt : prefix;
256 
257  MythScreenStack *popupStack =
258  GetMythMainWindow()->GetStack("popup stack");
259  QStringList exts;
260 
261  const FileAssociations::association_list fa_list =
263  for (auto p = fa_list.cbegin(); p != fa_list.cend(); ++p)
264  {
265  exts << QString("*.%1").arg(p->extension.toUpper());
266  }
267 
268  auto *fb = new MythUIFileBrowser(popupStack, fp);
269  fb->SetNameFilter(exts);
270  if (fb->Create())
271  {
272  fb->SetReturnEvent(&inst, returnEvent);
273  popupStack->AddScreen(fb);
274  }
275  else
276  delete fb;
277  }
278 
279  const QString CEID_COVERARTFILE = "coverartfile";
280  const QString CEID_BANNERFILE = "bannerfile";
281  const QString CEID_FANARTFILE = "fanartfile";
282  const QString CEID_SCREENSHOTFILE = "screenshotfile";
283  const QString CEID_TRAILERFILE = "trailerfile";
284  const QString CEID_NEWCATEGORY = "newcategory";
285 }
286 
287 void EditMetadataDialog::createBusyDialog(const QString& title)
288 {
289  if (m_busyPopup)
290  return;
291 
292  const QString& message = title;
293 
295  "mythvideobusydialog");
296 
297  if (m_busyPopup->Create())
299 }
300 
302 {
305 
306  m_seasonSpin->SetRange(0,9999,1,5);
308  m_episodeSpin->SetRange(0,999,1,10);
310  if (m_yearSpin)
311  {
312  m_yearSpin->SetRange(0,9999,1,100);
314  }
315  if (m_userRatingSpin)
316  {
317  m_userRatingSpin->SetRange(0,10,1,2);
319  }
320  if (m_lengthSpin)
321  {
322  m_lengthSpin->SetRange(0,999,1,15);
324  }
325 
326  // No memory leak. MythUIButtonListItem adds the new item into
327  // m_categoryList.
329  const VideoCategory::entry_list &vcl =
331  for (auto p = vcl.cbegin(); p != vcl.cend(); ++p)
332  {
333  // No memory leak. MythUIButtonListItem adds the new item into
334  // m_categoryList.
335  auto *button = new MythUIButtonListItem(m_categoryList, p->second);
336  button->SetData(p->first);
337  }
339 
341  i <= ParentalLevel::plHigh && i.good(); ++i)
342  {
343  // No memory leak. MythUIButtonListItem adds the new item into
344  // m_levelList.
345  auto *button = new MythUIButtonListItem(m_levelList,
346  tr("Level %1").arg(i.GetLevel()));
347  button->SetData(i.GetLevel());
348  }
350 
351  //
352  // Fill the "always play this video next" option
353  // with all available videos.
354  //
355 
356  // No memory leak. MythUIButtonListItem adds the new item into
357  // m_childList.
358  new MythUIButtonListItem(m_childList,tr("None"));
359 
360  // TODO: maybe make the title list have the same sort order
361  // as elsewhere.
362  using title_list = std::vector<std::pair<unsigned int, QString> >;
364  title_list tc;
365  tc.reserve(mdl.size());
366  for (auto p = mdl.cbegin(); p != mdl.cend(); ++p)
367  {
368  QString title;
369  if ((*p)->GetSeason() > 0 || (*p)->GetEpisode() > 0)
370  title = QString("%1 %2x%3").arg((*p)->GetTitle())
371  .arg(QString::number((*p)->GetSeason()))
372  .arg(QString::number((*p)->GetEpisode()));
373  else
374  title = (*p)->GetTitle();
375  tc.push_back(std::make_pair((*p)->GetID(), title));
376  }
377  std::sort(tc.begin(), tc.end(), title_sort<title_list::value_type>());
378 
379  for (title_list::const_iterator p = tc.begin(); p != tc.end(); ++p)
380  {
381  if (p->first != m_workingMetadata->GetID())
382  {
383  auto *button = new MythUIButtonListItem(m_childList,p->second);
384  button->SetData(p->first);
385  }
386  }
387 
388  if (m_workingMetadata->GetChildID() > 0)
389  {
392  }
393 
398  if (m_coverartText)
400  if (m_screenshotText)
402  if (m_bannerText)
404  if (m_fanartText)
406  if (m_trailerText)
408 
410  if (m_taglineEdit)
412  if (m_ratingEdit)
414  if (m_directorEdit)
416  if (m_inetrefEdit)
418  if (m_homepageEdit)
420  if (m_plotEdit)
422 
423  if (m_coverart)
424  {
425  if (!m_workingMetadata->GetHost().isEmpty() &&
426  !m_workingMetadata->GetCoverFile().isEmpty() &&
427  !m_workingMetadata->GetCoverFile().startsWith("/"))
428  {
432  }
433  else
435 
436  if (!m_workingMetadata->GetCoverFile().isEmpty())
437  m_coverart->Load();
438  }
439  if (m_screenshot)
440  {
441  if (!m_workingMetadata->GetHost().isEmpty() &&
442  !m_workingMetadata->GetScreenshot().isEmpty() &&
443  !m_workingMetadata->GetScreenshot().startsWith("/"))
444  {
448  }
449  else
451 
452  if (!m_workingMetadata->GetScreenshot().isEmpty())
453  m_screenshot->Load();
454  }
455  if (m_banner)
456  {
457  if (!m_workingMetadata->GetHost().isEmpty() &&
458  !m_workingMetadata->GetBanner().isEmpty() &&
459  !m_workingMetadata->GetBanner().startsWith("/"))
460  {
464  }
465  else
467 
468  if (!m_workingMetadata->GetBanner().isEmpty())
469  m_banner->Load();
470  }
471  if (m_fanart)
472  {
473  if (!m_workingMetadata->GetHost().isEmpty() &&
474  !m_workingMetadata->GetFanart().isEmpty() &&
475  !m_workingMetadata->GetFanart().startsWith("/"))
476  {
480  }
481  else
483 
484  if (!m_workingMetadata->GetFanart().isEmpty())
485  m_fanart->Load();
486  }
487 }
488 
490 {
491  QString message = tr("Enter new category");
492 
493  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
494 
495  auto *categorydialog = new MythTextInputDialog(popupStack,message);
496 
497  if (categorydialog->Create())
498  {
499  categorydialog->SetReturnEvent(this, CEID_NEWCATEGORY);
500  popupStack->AddScreen(categorydialog);
501  }
502 
503 }
504 
505 void EditMetadataDialog::AddCategory(const QString& category)
506 {
507  int id = VideoCategory::GetCategory().add(category);
509  new MythUIButtonListItem(m_categoryList, category, id);
511 }
512 
514 {
517 
518  emit Finished();
519  Close();
520 }
521 
523 {
525 }
526 
528 {
530 }
531 
533 {
534  m_workingMetadata->SetCategoryID(item->GetData().toInt());
535 }
536 
538 {
540 }
541 
543 {
545 }
546 
548 {
550 }
551 
553 {
555 }
556 
558 {
560 }
561 
563 {
565 }
566 
568 {
570 }
571 
573 {
575 }
576 
578 {
580 }
581 
583 {
585 }
586 
588 {
590 }
591 
593 {
595 }
596 
598 {
600  SetShowLevel(ParentalLevel(item->GetData().toInt()).GetLevel());
601 }
602 
604 {
605  cachedChildSelection = item->GetData().toInt();
607 }
608 
610 {
612  SetBrowse(m_browseCheck->GetBooleanCheckState());
613 }
614 
616 {
618  SetWatched(m_watchedCheck->GetBooleanCheckState());
619 }
620 
622 {
623  if (!m_workingMetadata->GetHost().isEmpty())
624  {
625  QString url = generate_file_url("Coverart",
627  "");
628  FindImagePopup(url,"",
629  *this, CEID_COVERARTFILE);
630  }
631  else
632  FindImagePopup(gCoreContext->GetSetting("VideoArtworkDir"),
633  GetConfDir() + "/MythVideo",
634  *this, CEID_COVERARTFILE);
635 }
636 
638 {
639  if (!lookup)
640  return;
641 
642  if (m_busyPopup)
643  {
644  m_busyPopup->Close();
645  m_busyPopup = nullptr;
646  }
647 
648  auto type = lookup->GetData().value<VideoArtworkType>();
649  ArtworkList list = lookup->GetArtwork(type);
650 
651  if (list.isEmpty())
652  {
653  MythWarningNotification n(tr("No image found"), tr("Metadata Editor"));
655  return;
656  }
657  auto *resultsdialog = new ImageSearchResultsDialog(m_popupStack, list, type);
658 
659  connect(resultsdialog, SIGNAL(haveResult(ArtworkInfo, VideoArtworkType)),
661 
662  if (resultsdialog->Create())
663  m_popupStack->AddScreen(resultsdialog);
664 }
665 
667 {
668  QString msg = tr("Downloading selected artwork...");
669  createBusyDialog(msg);
670 
671  auto *lookup = new MetadataLookup();
672  lookup->SetType(kMetadataVideo);
673 
674  lookup->SetSubtype(GuessLookupType(m_workingMetadata));
675  lookup->SetHost(m_workingMetadata->GetHost());
676  lookup->SetAutomatic(true);
677  lookup->SetData(qVariantFromValue<VideoArtworkType>(type));
678 
679  ArtworkMap downloads;
680  downloads.insert(type, info);
681  lookup->SetDownloads(downloads);
682  lookup->SetAllowOverwrites(true);
683  lookup->SetTitle(m_workingMetadata->GetTitle());
684  lookup->SetSubtitle(m_workingMetadata->GetSubtitle());
685  lookup->SetSeason(m_workingMetadata->GetSeason());
686  lookup->SetEpisode(m_workingMetadata->GetEpisode());
687  lookup->SetInetref(m_workingMetadata->GetInetRef());
688 
689  m_imageDownload->addDownloads(lookup);
690 }
691 
693 {
694  if (!lookup)
695  return;
696 
697  if (m_busyPopup)
698  {
699  m_busyPopup->Close();
700  m_busyPopup = nullptr;
701  }
702 
703  auto type = lookup->GetData().value<VideoArtworkType>();
704  ArtworkMap map = lookup->GetDownloads();
705 
706  if (map.count() >= 1)
707  {
708  ArtworkInfo info = map.value(type);
709  QString filename = info.url;
710 
711  if (type == kArtworkCoverart)
713  else if (type == kArtworkFanart)
715  else if (type == kArtworkBanner)
717  else if (type == kArtworkScreenshot)
719  }
720 }
721 
723 {
724  QString msg = tr("Searching for available artwork...");
725  createBusyDialog(msg);
726 
727  auto *lookup = new MetadataLookup();
728  lookup->SetStep(kLookupSearch);
729  lookup->SetType(kMetadataVideo);
730  lookup->SetAutomatic(true);
731  if (m_workingMetadata->GetSeason() > 0 ||
733  lookup->SetSubtype(kProbableTelevision);
734  else if (m_workingMetadata->GetSubtitle().isEmpty())
735  lookup->SetSubtype(kProbableMovie);
736  else
737  lookup->SetSubtype(kUnknownVideo);
738  lookup->SetData(qVariantFromValue<VideoArtworkType>(type));
739 
740  lookup->SetTitle(m_workingMetadata->GetTitle());
741  lookup->SetSubtitle(m_workingMetadata->GetSubtitle());
742  lookup->SetSeason(m_workingMetadata->GetSeason());
743  lookup->SetEpisode(m_workingMetadata->GetEpisode());
744  lookup->SetInetref(m_workingMetadata->GetInetRef());
745 
746  m_query->addLookup(lookup);
747 }
748 
750 {
752 }
753 
755 {
757 }
758 
760 {
762 }
763 
765 {
767 }
768 
770 {
771  if (file.isEmpty())
772  return;
773 
774  QString origfile = file;
775 
776  if (file.startsWith("myth://"))
777  {
778  QUrl url(file);
779  file = url.path();
780  file = file.right(file.length() - 1);
781  if (!file.endsWith("/"))
783  else
784  m_workingMetadata->SetCoverFile(QString());
785  }
786  else
788 
790 
791  if (m_coverart)
792  {
793  m_coverart->SetFilename(origfile);
794  m_coverart->Load();
795  }
796 }
797 
799 {
800  if (!m_workingMetadata->GetHost().isEmpty())
801  {
802  QString url = generate_file_url("Banners",
804  "");
805  FindImagePopup(url,"",
806  *this, CEID_BANNERFILE);
807  }
808  else
809  FindImagePopup(gCoreContext->GetSetting("mythvideo.bannerDir"),
810  GetConfDir() + "/MythVideo/Banners",
811  *this, CEID_BANNERFILE);
812 }
813 
815 {
816  if (file.isEmpty())
817  return;
818 
819  QString origfile = file;
820 
821  if (file.startsWith("myth://"))
822  {
823  QUrl url(file);
824  file = url.path();
825  file = file.right(file.length() - 1);
826  if (!file.endsWith("/"))
828  else
829  m_workingMetadata->SetBanner(QString());
830  }
831  else
833 
835 
836  if (m_banner)
837  {
838  m_banner->SetFilename(origfile);
839  m_banner->Load();
840  }
841 }
842 
844 {
845  if (!m_workingMetadata->GetHost().isEmpty())
846  {
847  QString url = generate_file_url("Fanart",
849  "");
850  FindImagePopup(url,"",
851  *this, CEID_FANARTFILE);
852  }
853  else
854  FindImagePopup(gCoreContext->GetSetting("mythvideo.fanartDir"),
855  GetConfDir() + "/MythVideo/Fanart",
856  *this, CEID_FANARTFILE);
857 }
858 
860 {
861  if (file.isEmpty())
862  return;
863 
864  QString origfile = file;
865 
866  if (file.startsWith("myth://"))
867  {
868  QUrl url(file);
869  file = url.path();
870  file = file.right(file.length() - 1);
871  if (!file.endsWith("/"))
873  else
874  m_workingMetadata->SetFanart(QString());
875  }
876  else
878 
880 
881  if (m_fanart)
882  {
883  m_fanart->SetFilename(origfile);
884  m_fanart->Load();
885  }
886 }
887 
889 {
890  if (!m_workingMetadata->GetHost().isEmpty())
891  {
892  QString url = generate_file_url("Screenshots",
894  "");
895  FindImagePopup(url,"",
896  *this, CEID_SCREENSHOTFILE);
897  }
898  else
899  FindImagePopup(gCoreContext->GetSetting("mythvideo.screenshotDir"),
900  GetConfDir() + "/MythVideo/Screenshots",
901  *this, CEID_SCREENSHOTFILE);
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,"",
941  *this, CEID_TRAILERFILE);
942  }
943  else
944  FindVideoFilePopup(gCoreContext->GetSetting("mythvideo.TrailersDir"),
945  GetConfDir() + "/MythVideo/Trailers",
946  *this, CEID_TRAILERFILE);
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)
const association_list & getList() const
Definition: dbaccess.cpp:807
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:153
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:50
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 SetLevel(MythUIButtonListItem *)
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(const 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)
int GetEpisode() const
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 SetChild(MythUIButtonListItem *)
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
static FileAssociations & getFileAssociation()
Definition: dbaccess.cpp:832
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
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
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:15
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:37
MythUIText * m_trailerText
void SetCategoryID(int id)
void SetCategory(MythUIButtonListItem *)
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