MythTV  master
themechooser.cpp
Go to the documentation of this file.
1 // C++ headers
2 #include <chrono>
3 
4 // Qt headers
5 #include <QCoreApplication>
6 #include <QRegularExpression>
7 #include <QRunnable>
8 
9 // MythTV headers
12 #include "libmythbase/mythdate.h"
15 #include "libmythbase/mythversion.h"
17 #include "libmythbase/remotefile.h"
18 #include "libmythbase/remoteutil.h"
20 #include "libmythbase/unziputil.h" // for extractZIP
26 #include "libmythui/mythuigroup.h"
27 #include "libmythui/mythuihelper.h"
28 #include "libmythui/mythuiimage.h"
31 #include "libmythui/mythuitext.h"
32 
33 // Theme Chooser headers
34 #include "themechooser.h"
35 
36 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
37 #define capturedView capturedRef
38 #endif
39 
40 #define LOC QString("ThemeChooser: ")
41 #define LOC_WARN QString("ThemeChooser, Warning: ")
42 #define LOC_ERR QString("ThemeChooser, Error: ")
43 
44 static const QRegularExpression kVersionDateRE{"\\.[0-9]{8,}.*"};
45 
49 class ThemeExtractThread : public QRunnable
50 {
51 public:
53  QString srcFile, QString destDir) : m_parent(parent),
54  m_srcFile(std::move(srcFile)),
55  m_destDir(std::move(destDir)) {}
56 
57  void run() override // QRunnable
58  {
60 
61  auto *me = new MythEvent("THEME_INSTALLED", QStringList(m_srcFile));
62  QCoreApplication::postEvent(m_parent, me);
63  }
64 
65 private:
67  QString m_srcFile;
68  QString m_destDir;
69 };
70 
76  const QString &name) : MythScreenType(parent, name)
77 {
79 
80  StorageGroup sgroup("Themes", gCoreContext->GetHostName());
81  m_userThemeDir = sgroup.GetFirstDir(true);
82 }
83 
85 {
87 }
88 
89 static bool sortThemeNames(const QFileInfo &s1, const QFileInfo &s2)
90 {
91  return s1.fileName().toLower() < s2.fileName().toLower();
92 }
93 
95 {
96  // Load the theme for this screen
97  if (!LoadWindowFromXML("settings-ui.xml", "themechooser", this))
98  return false;
99 
100  bool err = false;
101  UIUtilE::Assign(this, m_themes, "themes", &err);
102 
103  UIUtilW::Assign(this, m_preview, "preview");
104  UIUtilW::Assign(this, m_fullPreviewStateType, "fullpreviewstate");
105 
107  {
108  MythUIGroup *state =
109  dynamic_cast<MythUIGroup *>(m_fullPreviewStateType->GetChild("fullscreen"));
110  if (state)
111  {
113  dynamic_cast<MythUIText *>(state->GetChild("fullscreenname"));
115  dynamic_cast<MythUIImage *>(state->GetChild("fullscreenpreview"));
116  }
117  }
118 
119  if (err)
120  {
121  LOG(VB_GENERAL, LOG_ERR, LOC + "Cannot load screen 'themechooser'");
122  return false;
123  }
124 
126  this, qOverload<MythUIButtonListItem *>(&ThemeChooser::saveAndReload));
129 
130  BuildFocusList();
131 
133 
134  return true;
135 }
136 
138 {
139  SetBusyPopupMessage(tr("Loading Installed Themes"));
140 
141  QStringList themesSeen;
142  QDir themes(m_userThemeDir);
143  themes.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
144  themes.setSorting(QDir::Name | QDir::IgnoreCase);
145 
146  m_infoList = themes.entryInfoList();
147 
148  for (const auto &theme : qAsConst(m_infoList))
149  {
150  if (loadThemeInfo(theme))
151  {
152  themesSeen << theme.fileName();
153  m_themeStatuses[theme.fileName()] = "default";
154  }
155  }
156 
157  themes.setPath(GetThemesParentDir());
158  QFileInfoList sharedThemes = themes.entryInfoList();
159  for (const auto &sharedTheme : qAsConst(sharedThemes))
160  {
161  if ((!themesSeen.contains(sharedTheme.fileName())) &&
162  (loadThemeInfo(sharedTheme)))
163  {
164  m_infoList << sharedTheme;
165  themesSeen << sharedTheme.fileName();
166  m_themeStatuses[sharedTheme.fileName()] = "default";
167  }
168  }
169 
170  // MYTH_SOURCE_VERSION - examples v29-pre-574-g92517f5, v29-Pre, v29.1-21-ge26a33c
171  QString MythVersion(GetMythSourceVersion());
172  static const QRegularExpression trunkver{"\\Av[0-9]+-pre.*\\z", QRegularExpression::CaseInsensitiveOption};
173  static const QRegularExpression validver{
174  "\\Av[0-9]+.*\\z", QRegularExpression::CaseInsensitiveOption};
175 
176  auto match = validver.match(MythVersion);
177  if (!match.hasMatch())
178  {
179  LOG(VB_GENERAL, LOG_ERR, QString("Invalid MythTV version %1, will use themes from trunk").arg(MythVersion));
180  MythVersion = "trunk";
181  }
182  match = trunkver.match(MythVersion);
183  if (match.hasMatch())
184  MythVersion = "trunk";
185 
186  if (MythVersion == "trunk")
187  {
188  LoadVersion(MythVersion, themesSeen, true);
189  LOG(VB_GUI, LOG_INFO, QString("Loading themes for %1").arg(MythVersion));
190  }
191  else
192  {
193  MythVersion = MYTH_BINARY_VERSION; // Example: 29.20161017-1
194  // Remove the date part and the rest, eg 29.20161017-1 -> 29
195  MythVersion.remove(kVersionDateRE);
196  LOG(VB_GUI, LOG_INFO, QString("Loading themes for %1").arg(MythVersion));
197  if (LoadVersion(MythVersion, themesSeen, true))
198  {
199 
200  // If a version of the theme for this tag exists, use it...
201  // MYTH_SOURCE_VERSION - examples v29-pre-574-g92517f5, v29-Pre, v29.1-21-ge26a33c
202  static const QRegularExpression subexp{"v[0-9]+\\.([0-9]+)-*", QRegularExpression::CaseInsensitiveOption};
203  // This captures the subversion, i.e. the number after a dot
204  match = subexp.match(GetMythSourceVersion());
205  if (match.hasMatch())
206  {
207  QString subversion;
208  LOG(VB_GUI, LOG_INFO, QString("Loading version %1").arg(match.capturedView(1).toInt()));
209  for (int idx = match.capturedView(1).toInt(); idx > 0; --idx)
210  {
211  subversion = MythVersion + "." + QString::number(idx);
212  LOG(VB_GUI, LOG_INFO, QString("Loading themes for %1").arg(subversion));
213  LoadVersion(subversion, themesSeen, false);
214  }
215  }
216  else
217  {
218  LOG(VB_GENERAL, LOG_WARNING, QString("Failed to match theme for %1").arg(GetMythSourceVersion()));
219  }
220 
221  ResetBusyPopup();
222 
223  std::sort(m_infoList.begin(), m_infoList.end(), sortThemeNames);
224  }
225  else
226  {
227 
228  LOG(VB_GENERAL, LOG_INFO, QString("Failed to load themes for %1, trying trunk").arg(MythVersion));
229  MythVersion = "trunk";
230  if (!LoadVersion(MythVersion, themesSeen, true))
231  {
232  LOG(VB_GENERAL, LOG_WARNING, QString("Failed to load themes for %1").arg(MythVersion));
233  }
234  }
235  }
236 }
237 
238 bool ThemeChooser::LoadVersion(const QString &version,
239  QStringList &themesSeen, bool alert_user)
240 {
241  QString remoteThemesFile = GetConfDir();
242  remoteThemesFile.append("/tmp/themes.zip");
243  QString themeSite = QString("%1/%2")
244  .arg(gCoreContext->GetSetting("ThemeRepositoryURL",
245  "http://themes.mythtv.org/themes/repository"),
246  version);
247  QString destdir = GetCacheDir().append("/themechooser");
248  QString versiondir = QString("%1/%2").arg(destdir, version);
249  QDir remoteThemesDir(versiondir);
250 
251  int downloadFailures =
252  gCoreContext->GetNumSetting("ThemeInfoDownloadFailures", 0);
253  if (QFile::exists(remoteThemesFile))
254  {
255  QFileInfo finfo(remoteThemesFile);
256  if (finfo.lastModified().toUTC() <
257  MythDate::current().addSecs(-600))
258  {
259  LOG(VB_GUI, LOG_INFO, LOC + QString("%1 is over 10 minutes old, forcing "
260  "remote theme list download")
261  .arg(remoteThemesFile));
263  }
264 
265  if (!remoteThemesDir.exists())
266  {
268  }
269  }
270  else if (downloadFailures < 2) // (and themes.zip does not exist)
271  {
272  LOG(VB_GUI, LOG_INFO, LOC + QString("%1 does not exist, forcing remote theme "
273  "list download")
274  .arg(remoteThemesFile));
276  }
277 
279  {
280  QFile test(remoteThemesFile);
281  if (test.open(QIODevice::WriteOnly))
282  test.remove();
283  else
284  {
285  ShowOkPopup(tr("Unable to create '%1'").arg(remoteThemesFile));
286  return false;
287  }
288 
289  SetBusyPopupMessage(tr("Refreshing Downloadable Themes Information"));
290 
291  QString url = themeSite;
292  url.append("/themes.zip");
293  if (!removeThemeDir(versiondir))
294  ShowOkPopup(tr("Unable to remove '%1'").arg(versiondir));
295  QDir dir;
296  if (!dir.mkpath(destdir))
297  ShowOkPopup(tr("Unable to create '%1'").arg(destdir));
298  bool result = GetMythDownloadManager()->download(url, remoteThemesFile, true);
299 
300  LOG(VB_GUI, LOG_INFO, LOC + QString("Downloading '%1' to '%2'").arg(url, remoteThemesFile));
301 
302  SetBusyPopupMessage(tr("Extracting Downloadable Themes Information"));
303 
304  if (!result || !extractZIP(remoteThemesFile, destdir))
305  {
306  QFile::remove(remoteThemesFile);
307 
308  downloadFailures++;
309  gCoreContext->SaveSetting("ThemeInfoDownloadFailures",
310  downloadFailures);
311 
312  if (!result)
313  {
314  LOG(VB_GUI, LOG_ERR, LOC + QString("Failed to download '%1'").arg(url));
315  if (alert_user)
316  ShowOkPopup(tr("Failed to download '%1'").arg(url));
317  }
318  else
319  {
320  LOG(VB_GUI, LOG_ERR, LOC + QString("Failed to unzip '%1' to '%2'").arg(remoteThemesFile, destdir));
321  if (alert_user)
322  ShowOkPopup(tr("Failed to unzip '%1' to '%2'")
323  .arg(remoteThemesFile, destdir));
324  }
325  return false;
326  }
327  LOG(VB_GUI, LOG_INFO, LOC + QString("Unzipped '%1' to '%2'").arg(remoteThemesFile, destdir));
328  }
329 
330  QDir themes;
331  themes.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
332  themes.setSorting(QDir::Name | QDir::IgnoreCase);
333 
334  if ((QFile::exists(remoteThemesFile)) &&
335  (remoteThemesDir.exists()))
336  {
337  SetBusyPopupMessage(tr("Loading Downloadable Themes"));
338 
339  LOG(VB_GUI, LOG_INFO, LOC + QString("%1 and %2 exist, using cached remote themes list").arg(remoteThemesFile, remoteThemesDir.absolutePath()));
340 
341  QString themesPath = remoteThemesDir.absolutePath();
342  themes.setPath(themesPath);
343 
344  QFileInfoList downloadableThemes = themes.entryInfoList();
345  for (const auto &dtheme : qAsConst(downloadableThemes))
346  {
347  QString dirName = dtheme.fileName();
348  QString themeName = dirName;
349  QString remoteDir = themeSite;
350  remoteDir.append("/").append(dirName);
351  QString localDir = themes.absolutePath();
352  localDir.append("/").append(dirName);
353 
354  ThemeInfo remoteTheme(dtheme.absoluteFilePath());
355 
356  if (themesSeen.contains(dirName))
357  {
358  ThemeInfo *localTheme = m_themeNameInfos[dirName];
359 
360  themeName = remoteTheme.GetName();
361 
362  int rmtMaj = remoteTheme.GetMajorVersion();
363  int rmtMin = remoteTheme.GetMinorVersion();
364  int locMaj = localTheme->GetMajorVersion();
365  int locMin = localTheme->GetMinorVersion();
366 
367  if ((rmtMaj > locMaj) ||
368  ((rmtMaj == locMaj) &&
369  (rmtMin > locMin)))
370  {
371  if (loadThemeInfo(dtheme))
372  {
373  LOG(VB_GUI, LOG_DEBUG, LOC + QString("'%1' old version %2.%3, new version %4.%5").arg(themeName).arg(locMaj).arg(locMin).arg(rmtMaj).arg(rmtMin));
374 
375  m_infoList << dtheme;
376  m_themeStatuses[themeName] = "updateavailable";
377 
378  QFileInfo finfo(remoteTheme.GetPreviewPath());
380  remoteDir.append("/").append(finfo.fileName()),
381  localDir.append("/").append(finfo.fileName()),
382  nullptr);
383  }
384  }
385  else if ((rmtMaj == locMaj) &&
386  (rmtMin == locMin))
387  {
388  LOG(VB_GUI, LOG_DEBUG, LOC + QString("'%1' up to date (%2.%3)").arg(themeName).arg(locMaj).arg(locMin));
389 
390  m_themeStatuses[themeName] = "uptodate";
391  }
392  }
393  else
394  {
395  LOG(VB_GUI, LOG_DEBUG, LOC + QString("'%1' (%2.%3) available").arg(themeName).arg(remoteTheme.GetMajorVersion()).arg(remoteTheme.GetMinorVersion()));
396 
397  ThemeInfo *tmpTheme = loadThemeInfo(dtheme);
398  if (tmpTheme)
399  {
400  themeName = tmpTheme->GetName();
401  themesSeen << dirName;
402  m_infoList << dtheme;
403  m_themeStatuses[themeName] = "updateavailable";
404 
405  QFileInfo finfo(tmpTheme->GetPreviewPath());
407  remoteDir.append("/").append(finfo.fileName()),
408  localDir.append("/").append(finfo.fileName()),
409  nullptr);
410  }
411  }
412  }
413  return true;
414  }
415  return false;
416 }
417 
419 {
420  QString curTheme = gCoreContext->GetSetting("Theme");
421  ThemeInfo *themeinfo = nullptr;
422  ThemeInfo *curThemeInfo = nullptr;
423  MythUIButtonListItem *item = nullptr;
424 
425  m_themes->Reset();
426  for (const auto &theme : qAsConst(m_infoList))
427  {
428  if (!m_themeFileNameInfos.contains(theme.filePath()))
429  continue;
430 
431  themeinfo = m_themeFileNameInfos[theme.filePath()];
432  if (!themeinfo)
433  continue;
434 
435  QString buttonText = QString("%1 %2.%3")
436  .arg(themeinfo->GetName())
437  .arg(themeinfo->GetMajorVersion())
438  .arg(themeinfo->GetMinorVersion());
439 
440  item = new MythUIButtonListItem(m_themes, buttonText);
441  if (item)
442  {
443  if (themeinfo->GetDownloadURL().isEmpty())
444  item->DisplayState("local", "themelocation");
445  else
446  item->DisplayState("remote", "themelocation");
447 
448  item->DisplayState(themeinfo->GetAspect(), "aspectstate");
449 
450  item->DisplayState(m_themeStatuses[themeinfo->GetName()],
451  "themestatus");
452  InfoMap infomap;
453  themeinfo->ToMap(infomap);
454  item->SetTextFromMap(infomap);
455  item->SetData(QVariant::fromValue(themeinfo));
456 
457  QString thumbnail = themeinfo->GetPreviewPath();
458  // Downloadable themeinfos have thumbnail copies of their preview images
459  if (!themeinfo->GetDownloadURL().isEmpty())
460  thumbnail = thumbnail.append(".thumb.jpg");
461  item->SetImage(thumbnail);
462 
463  if (curTheme == themeinfo->GetDirectoryName())
464  curThemeInfo = themeinfo;
465  }
466  }
467 
469 
470  if (curThemeInfo)
471  m_themes->SetValueByData(QVariant::fromValue(curThemeInfo));
472 
474  if (current)
476 
477  QString testFile = m_userThemeDir + "/.test";
478  QFile test(testFile);
479  if (test.open(QIODevice::WriteOnly))
480  test.remove();
481  else
482  {
483  ShowOkPopup(tr("Error creating test file, %1 themes directory is "
484  "not writable.")
485  .arg(m_userThemeDir));
486  }
487 }
488 
489 ThemeInfo *ThemeChooser::loadThemeInfo(const QFileInfo &theme)
490 {
491  if (theme.fileName() == "default" || theme.fileName() == "default-wide")
492  return nullptr;
493 
494  ThemeInfo *themeinfo = nullptr;
495  if (theme.exists()) // local directory vs http:// or remote URL
496  themeinfo = new ThemeInfo(theme.absoluteFilePath());
497  else
498  themeinfo = new ThemeInfo(theme.filePath());
499 
500  if (!themeinfo)
501  return nullptr;
502 
503  if (themeinfo->GetName().isEmpty() || ((themeinfo->GetType() & THEME_UI) == 0))
504  {
505  delete themeinfo;
506  return nullptr;
507  }
508 
509  m_themeFileNameInfos[theme.filePath()] = themeinfo;
510  m_themeNameInfos[theme.fileName()] = themeinfo;
511 
512  return themeinfo;
513 }
514 
516 {
517  if (m_popupMenu)
518  return;
519 
520  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
521  QString label = tr("Theme Chooser Menu");
522 
523  m_popupMenu =
524  new MythDialogBox(label, popupStack, "themechoosermenupopup");
525 
527 
528  if (m_popupMenu->Create())
529  popupStack->AddScreen(m_popupMenu);
530  else
531  {
532  delete m_popupMenu;
533  m_popupMenu = nullptr;
534  return;
535  }
536 
537  m_popupMenu->SetReturnEvent(this, "popupmenu");
538 
540  {
542  {
543  m_popupMenu->AddButton(tr("Hide Fullscreen Preview"),
545  }
546  else
547  {
548  m_popupMenu->AddButton(tr("Show Fullscreen Preview"),
550  }
551  }
552 
553  m_popupMenu->AddButton(tr("Refresh Downloadable Themes"),
555 
557  if (current)
558  {
559  auto *info = current->GetData().value<ThemeInfo *>();
560 
561  if (info)
562  {
563  m_popupMenu->AddButton(tr("Select Theme"),
564  qOverload<>(&ThemeChooser::saveAndReload));
565 
566  if (info->GetPreviewPath().startsWith(m_userThemeDir))
567  m_popupMenu->AddButton(tr("Delete Theme"),
569  }
570  }
571 
572  if (gCoreContext->GetBoolSetting("ThemeUpdateNofications", true))
573  {
574  m_popupMenu->AddButton(tr("Disable Theme Update Notifications"),
576  }
577  else
578  {
579  m_popupMenu->AddButton(tr("Enable Theme Update Notifications"),
581  }
582 }
583 
584 void ThemeChooser::popupClosed(const QString &which, int result)
585 {
586  (void)which;
587  (void)result;
588 
589  m_popupMenu = nullptr;
590 }
591 
592 bool ThemeChooser::keyPressEvent(QKeyEvent *event)
593 {
594  if (GetFocusWidget()->keyPressEvent(event))
595  return true;
596 
597  QStringList actions;
598  bool handled = GetMythMainWindow()->TranslateKeyPress("Theme Chooser", event, actions);
599 
600  for (int i = 0; i < actions.size() && !handled; ++i)
601  {
602  QString action = actions[i];
603  handled = true;
604 
605  if (action == "MENU")
606  showPopupMenu();
607  else if (action == "DELETE")
608  removeTheme();
609  else if ((action == "ESCAPE") &&
611  {
613  }
614  else
615  handled = false;
616  }
617 
618  if (!handled && MythScreenType::keyPressEvent(event))
619  handled = true;
620 
621  return handled;
622 }
623 
625 {
627  {
629  {
632 
633  if (m_fullScreenName)
635 
637  m_fullPreviewShowing = false;
638  }
639  else
640  {
642  auto *info = item->GetData().value<ThemeInfo *>();
643  if (info)
644  {
646  {
647  m_fullScreenPreview->SetFilename(info->GetPreviewPath());
649  }
650 
651  if (m_fullScreenName)
652  m_fullScreenName->SetText(info->GetName());
653 
654  m_fullPreviewStateType->DisplayState("fullscreen");
655  m_fullPreviewShowing = true;
656  }
657  }
658  }
659 }
660 
662 {
663  if (gCoreContext->GetBoolSetting("ThemeUpdateNofications", true))
664  gCoreContext->SaveSettingOnHost("ThemeUpdateNofications", "0", "");
665  else
666  gCoreContext->SaveSettingOnHost("ThemeUpdateNofications", "1", "");
667 }
668 
670 {
671  LOG(VB_GUI, LOG_INFO, LOC + "Forcing remote theme list refresh");
673  gCoreContext->SaveSetting("ThemeInfoDownloadFailures", 0);
675 }
676 
678 {
680  if (current)
682 }
683 
685 {
686  auto *info = item->GetData().value<ThemeInfo *>();
687 
688  if (!info)
689  return;
690 
691  if (!info->GetDownloadURL().isEmpty())
692  {
693  QString testFile = m_userThemeDir + "/.test";
694  QFile test(testFile);
695  if (test.open(QIODevice::WriteOnly))
696  test.remove();
697  else
698  {
699  ShowOkPopup(tr("Unable to install theme, %1 themes directory is "
700  "not writable.")
701  .arg(m_userThemeDir));
702  return;
703  }
704 
705  QString downloadURL = info->GetDownloadURL();
706  LOG(VB_FILE, LOG_INFO, QString("Download url is %1").arg(downloadURL));
707  QFileInfo qfile(downloadURL);
708  QString baseName = qfile.fileName();
709 
710  if (!gCoreContext->GetSetting("ThemeDownloadURL").isEmpty())
711  {
712 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
713  QStringList tokens =
714  gCoreContext->GetSetting("ThemeDownloadURL")
715  .split(";", QString::SkipEmptyParts);
716 #else
717  QStringList tokens =
718  gCoreContext->GetSetting("ThemeDownloadURL")
719  .split(";", Qt::SkipEmptyParts);
720 #endif
721  QString origURL = downloadURL;
722  downloadURL.replace(tokens[0], tokens[1]);
723  LOG(VB_FILE, LOG_WARNING, LOC + QString("Theme download URL overridden from %1 to %2.").arg(origURL, downloadURL));
724  }
725 
726  OpenBusyPopup(tr("Downloading %1 Theme").arg(info->GetName()));
727  m_downloadTheme = info;
728 #if 0
730  "Temp", baseName);
732 #else
733  QString localFile = GetConfDir() + "/tmp/" + baseName;
734  GetMythDownloadManager()->queueDownload(downloadURL, localFile, this);
735  m_downloadFile = localFile;
737 #endif
738  }
739  else
740  {
741  gCoreContext->SaveSetting("Theme", info->GetDirectoryName());
742  GetMythMainWindow()->JumpTo("Reload Theme");
743  }
744 }
745 
747 {
748  auto *info = item->GetData().value<ThemeInfo *>();
749 
750  if (!info)
751  return;
752 
753  QFileInfo preview(info->GetPreviewPath());
754  InfoMap infomap;
755  info->ToMap(infomap);
756  SetTextFromMap(infomap);
757  if (m_preview)
758  {
759  if (preview.exists())
760  {
761  m_preview->SetFilename(info->GetPreviewPath());
762  m_preview->Load();
763  }
764  else
765  m_preview->Reset();
766  }
768  {
770  {
771  if (preview.exists())
772  {
773  m_fullScreenPreview->SetFilename(info->GetPreviewPath());
775  }
776  else
778  }
779 
780  if (m_fullScreenName)
781  m_fullScreenName->SetText(info->GetName());
782  }
783 
784  MythUIStateType *themeLocation =
785  dynamic_cast<MythUIStateType *>(GetChild("themelocation"));
786  if (themeLocation)
787  {
788  if (info->GetDownloadURL().isEmpty())
789  themeLocation->DisplayState("local");
790  else
791  themeLocation->DisplayState("remote");
792  }
793 
794  MythUIStateType *aspectState =
795  dynamic_cast<MythUIStateType *>(GetChild("aspectstate"));
796  if (aspectState)
797  aspectState->DisplayState(info->GetAspect());
798 }
799 
800 void ThemeChooser::updateProgressBar(int bytesReceived,
801  int bytesTotal)
802 {
803  MythUIProgressBar *progressBar =
804  dynamic_cast<MythUIProgressBar *>(GetChild("downloadprogressbar"));
805 
806  if (!progressBar)
807  return;
808 
809  progressBar->SetUsed(bytesReceived);
810  progressBar->SetTotal(bytesTotal);
811 }
812 
814 {
815  if (e->type() == MythEvent::MythEventMessage)
816  {
817  auto *me = dynamic_cast<MythEvent *>(e);
818  if (me == nullptr)
819  return;
820 
821 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
822  QStringList tokens = me->Message().split(" ", QString::SkipEmptyParts);
823 #else
824  QStringList tokens = me->Message().split(" ", Qt::SkipEmptyParts);
825 #endif
826 
827  if (tokens.isEmpty())
828  return;
829 
830  if (tokens[0] == "DOWNLOAD_FILE")
831  {
832  QStringList args = me->ExtraDataList();
833  if ((m_downloadState == dsIdle) ||
834  (tokens.size() != 2) ||
835  (!m_downloadTheme) ||
836  (args[1] != m_downloadFile))
837  return;
838 
839  if (tokens[1] == "UPDATE")
840  {
841  updateProgressBar(args[2].toInt(), args[3].toInt());
842  }
843  else if (tokens[1] == "FINISHED")
844  {
845  bool remoteFileIsLocal = false;
846  int fileSize = args[2].toInt();
847  int errorCode = args[4].toInt();
848 
849  CloseBusyPopup();
850 
851  QFileInfo file(m_downloadFile);
853  (m_downloadFile.startsWith("myth://")))
854  {
855  // The backend download is finished so start the
856  // frontend download
857  LOG(VB_FILE, LOG_INFO, QString("Download done MBE %1 %2").arg(errorCode).arg(fileSize));
858  if ((errorCode == 0) &&
859  (fileSize > 0))
860  {
862  QString localFile = GetConfDir() + "/tmp/" +
863  file.fileName();
864  file.setFile(localFile);
865 
866  if (file.exists())
867  {
868  remoteFileIsLocal = true;
869  m_downloadFile = localFile;
870  }
871  else
872  {
874  m_downloadFile, localFile, this);
875  OpenBusyPopup(tr("Copying %1 Theme Package")
876  .arg(m_downloadTheme->GetName()));
877  m_downloadFile = localFile;
878  return;
879  }
880  }
881  else
882  {
884  ShowOkPopup(tr("ERROR downloading theme package on master backend."));
885  }
886  }
887 
889  (file.exists()))
890  {
891  // The frontend download is finished
892  LOG(VB_FILE, LOG_INFO, QString("Download done MFE %1 %2").arg(errorCode).arg(fileSize));
893  // moved error is ok
894  if ((errorCode == 0) &&
895  (fileSize > 0))
896  {
898  auto *extractThread =
902  extractThread, "ThemeExtract");
903 
904  if (!remoteFileIsLocal)
906 
907  OpenBusyPopup(tr("Installing %1 Theme")
908  .arg(m_downloadTheme->GetName()));
909  }
910  else
911  {
913  ShowOkPopup(tr("ERROR downloading theme package from frontend."));
914  }
915  }
916  }
917  }
918  else if ((me->Message() == "THEME_INSTALLED") &&
919  (m_downloadTheme) &&
921  {
923  CloseBusyPopup();
924  QStringList args = me->ExtraDataList();
925 
926  if (!args.isEmpty() && !args[0].isEmpty())
927  QFile::remove(args[0]);
928 
929  QString event = QString("THEME_INSTALLED PATH %1")
930  .arg(m_userThemeDir +
933 
935 
936  // Send a message to ourself so we trigger a reload our next chance
937  auto *me2 = new MythEvent("THEME_RELOAD");
938  qApp->postEvent(this, me2);
939  }
940  else if ((me->Message() == "THEME_RELOAD") &&
941  (m_downloadState == dsIdle))
942  {
943  GetMythMainWindow()->JumpTo("Reload Theme");
944  }
945  }
946 }
947 
949 {
951  if (!current)
952  {
953  ShowOkPopup(tr("Error, no theme selected."));
954  return;
955  }
956 
957  auto *info = current->GetData().value<ThemeInfo *>();
958  if (!info)
959  {
960  ShowOkPopup(tr("Error, unable to find current theme."));
961  return;
962  }
963 
964  if (!info->GetPreviewPath().startsWith(m_userThemeDir))
965  {
966  ShowOkPopup(tr("%1 is not a user-installed theme and can not "
967  "be deleted.")
968  .arg(info->GetName()));
969  return;
970  }
971 
972  removeThemeDir(m_userThemeDir + info->GetDirectoryName());
973 
975 }
976 
977 bool ThemeChooser::removeThemeDir(const QString &dirname)
978 {
979  if ((!dirname.startsWith(m_userThemeDir)) &&
980  (!dirname.startsWith(GetMythUI()->GetThemeCacheDir())))
981  return true;
982 
983  QDir dir(dirname);
984 
985  if (!dir.exists())
986  return true;
987 
988  dir.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
989  QFileInfoList list = dir.entryInfoList();
990 
991  for (const auto &fi : qAsConst(list))
992  {
993  if (fi.isFile() && !fi.isSymLink())
994  {
995  if (!QFile::remove(fi.absoluteFilePath()))
996  return false;
997  }
998  else if (fi.isDir() && !fi.isSymLink())
999  {
1000  if (!removeThemeDir(fi.absoluteFilePath()))
1001  return false;
1002  }
1003  }
1004 
1005  return dir.rmdir(dirname);
1006 }
1007 
1009 
1010 ThemeUpdateChecker::ThemeUpdateChecker(void) : m_updateTimer(new QTimer(this))
1011 {
1012  QString version = GetMythSourcePath();
1013 
1014  if (!version.isEmpty() && !version.startsWith("fixes/"))
1015  {
1016  // Treat devel branches as master
1017  m_mythVersions << "trunk";
1018  }
1019  else
1020  {
1021  version = MYTH_BINARY_VERSION; // Example: 0.25.20101017-1
1022  version.remove(kVersionDateRE);
1023 
1024  // If a version of the theme for this tag exists, use it...
1025  static const QRegularExpression subexp{"v[0-9]+\\.([0-9]+)-*", QRegularExpression::CaseInsensitiveOption};
1026  auto match = subexp.match(GetMythSourceVersion());
1027  if (match.hasMatch())
1028  {
1029  for (int idx = match.capturedView(1).toInt(); idx > 0; --idx)
1030  m_mythVersions << version + "." + QString::number(idx);
1031  }
1033  }
1034 
1037  "remotethemes/themes.zip",
1038  "Temp");
1039 
1040  gCoreContext->SaveSetting("ThemeUpdateStatus", "");
1041 
1043 
1044  if (qEnvironmentVariableIsSet("MYTHTV_DEBUGMDM"))
1045  {
1046  LOG(VB_GENERAL, LOG_INFO, "Checking for theme updates every minute");
1047  m_updateTimer->start(1min);
1048  }
1049  else
1050  {
1051  LOG(VB_GENERAL, LOG_INFO, "Checking for theme updates every hour");
1052  m_updateTimer->start(1h);
1053  }
1054 
1055  // Run once 15 seconds from now
1056  QTimer::singleShot(15s, this, &ThemeUpdateChecker::checkForUpdate);
1057 }
1058 
1060 {
1061  if (m_updateTimer)
1062  {
1063  m_updateTimer->stop();
1064  delete m_updateTimer;
1065  m_updateTimer = nullptr;
1066  }
1067 }
1068 
1070 {
1071  if (GetMythUI()->GetCurrentLocation(false, true) != "mainmenu")
1072  return;
1073 
1074  ThemeInfo *localTheme = nullptr;
1075 
1077  {
1078  QStringList::iterator Iversion;
1079 
1080  for (Iversion = m_mythVersions.begin();
1081  Iversion != m_mythVersions.end(); ++Iversion)
1082  {
1083 
1084  QString remoteThemeDir =
1087  QString("remotethemes/%1/%2")
1088  .arg(*Iversion,
1089  GetMythUI()->GetThemeName()),
1090  "Temp");
1091 
1092  QString infoXML = remoteThemeDir;
1093  infoXML.append("/themeinfo.xml");
1094 
1095  LOG(VB_GUI, LOG_INFO, QString("ThemeUpdateChecker Loading '%1'").arg(infoXML));
1096 
1097  if (RemoteFile::Exists(infoXML))
1098  {
1099  int locMaj = 0;
1100  int locMin = 0;
1101 
1102  auto *remoteTheme = new ThemeInfo(remoteThemeDir);
1103  if (!remoteTheme || remoteTheme->GetType() & THEME_UNKN)
1104  {
1105  LOG(VB_GENERAL, LOG_ERR,
1106  QString("ThemeUpdateChecker::checkForUpdate(): "
1107  "Unable to create ThemeInfo for %1")
1108  .arg(infoXML));
1109  delete remoteTheme;
1110  remoteTheme = nullptr;
1111  return;
1112  }
1113 
1114  if (!localTheme)
1115  {
1116  localTheme = new ThemeInfo(GetMythUI()->GetThemeDir());
1117  if (!localTheme || localTheme->GetType() & THEME_UNKN)
1118  {
1119  LOG(VB_GENERAL, LOG_ERR,
1120  "ThemeUpdateChecker::checkForUpdate(): "
1121  "Unable to create ThemeInfo for current theme");
1122  delete localTheme;
1123  localTheme = nullptr;
1124  return;
1125  }
1126  locMaj = localTheme->GetMajorVersion();
1127  locMin = localTheme->GetMinorVersion();
1128  }
1129 
1130  int rmtMaj = remoteTheme->GetMajorVersion();
1131  int rmtMin = remoteTheme->GetMinorVersion();
1132 
1133  delete remoteTheme;
1134  remoteTheme = nullptr;
1135 
1136  if ((rmtMaj > locMaj) ||
1137  ((rmtMaj == locMaj) &&
1138  (rmtMin > locMin)))
1139  {
1141  QString("%1-%2.%3").arg(GetMythUI()->GetThemeName()).arg(rmtMaj).arg(rmtMin);
1142 
1143  QString status = gCoreContext->GetSetting("ThemeUpdateStatus");
1144  QString currentLocation = GetMythUI()->GetCurrentLocation(false, true);
1145 
1146  if ((!status.startsWith(m_lastKnownThemeVersion)) &&
1147  (currentLocation == "mainmenu"))
1148  {
1149  m_currentVersion = QString("%1.%2")
1150  .arg(locMaj)
1151  .arg(locMin);
1152  m_newVersion = QString("%1.%2").arg(rmtMaj).arg(rmtMin);
1153 
1154  gCoreContext->SaveSetting("ThemeUpdateStatus",
1155  m_lastKnownThemeVersion + " notified");
1156 
1157  QString message = tr("Version %1 of the %2 theme is now "
1158  "available in the Theme Chooser. "
1159  "The currently installed version "
1160  "is %3.")
1161  .arg(m_newVersion,
1162  GetMythUI()->GetThemeName(),
1164 
1165  ShowOkPopup(message);
1166  break;
1167  }
1168  }
1169  }
1170  }
1171  }
1172 
1173  delete localTheme;
1174 }
1175 
1176 /* vim: set expandtab tabstop=4 shiftwidth=4: */
GetThemesParentDir
QString GetThemesParentDir(void)
Definition: mythdirs.cpp:225
MythScreenType::LoadInBackground
void LoadInBackground(const QString &message="")
Definition: mythscreentype.cpp:286
build_compdb.args
args
Definition: build_compdb.py:11
MythDialogBox::SetReturnEvent
void SetReturnEvent(QObject *retobject, const QString &resultid)
Definition: mythdialogbox.cpp:301
extractZIP
bool extractZIP(QString zipFile, const QString &outDir)
Definition: unziputil.cpp:17
MythEvent::MythEventMessage
static Type MythEventMessage
Definition: mythevent.h:79
MythUIButtonList::GetItemCurrent
MythUIButtonListItem * GetItemCurrent() const
Definition: mythuibuttonlist.cpp:1587
MythScreenType::SetBusyPopupMessage
void SetBusyPopupMessage(const QString &message)
Definition: mythscreentype.cpp:345
hardwareprofile.smolt.timeout
float timeout
Definition: smolt.py:103
ThemeChooser::m_themeNameInfos
QMap< QString, ThemeInfo * > m_themeNameInfos
Definition: themechooser.h:86
MythCoreContext::GetMasterHostName
QString GetMasterHostName(void)
Definition: mythcorecontext.cpp:805
ThemeUpdateChecker::m_lastKnownThemeVersion
QString m_lastKnownThemeVersion
Definition: themechooser.h:113
MythUIButtonList::SetValueByData
void SetValueByData(const QVariant &data)
Definition: mythuibuttonlist.cpp:1539
ThemeChooser
View and select installed themes.
Definition: themechooser.h:27
mythuitext.h
ThemeChooser::m_themes
MythUIButtonList * m_themes
Definition: themechooser.h:74
mythuiprogressbar.h
kVersionDateRE
static const QRegularExpression kVersionDateRE
Definition: themechooser.cpp:44
unziputil.h
MythUIImage
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
MythUIText::Reset
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuitext.cpp:82
ThemeExtractThread::run
void run() override
Definition: themechooser.cpp:57
MythUIButtonListItem::DisplayState
void DisplayState(const QString &state, const QString &name)
Definition: mythuibuttonlist.cpp:3563
ThemeInfo::GetAspect
QString GetAspect() const
Definition: themeinfo.h:27
RemoteFile::Exists
static bool Exists(const QString &url, struct stat *fileinfo)
Definition: remotefile.cpp:454
MythUIType::GetChild
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:133
mythscreenstack.h
MythMainWindow::JumpTo
void JumpTo(const QString &Destination, bool Pop=true)
Definition: mythmainwindow.cpp:1450
MythUIImage::Load
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
Definition: mythuiimage.cpp:968
MythUIButtonList::itemSelected
void itemSelected(MythUIButtonListItem *item)
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:16
ThemeChooser::customEvent
void customEvent(QEvent *e) override
Definition: themechooser.cpp:813
GetMythSourceVersion
const char * GetMythSourceVersion()
Definition: mythversion.cpp:5
MythDownloadManager::queueDownload
void queueDownload(const QString &url, const QString &dest, QObject *caller, bool reload=false)
Adds a url to the download queue.
Definition: mythdownloadmanager.cpp:393
MythUIProgressBar::SetUsed
void SetUsed(int value)
Definition: mythuiprogressbar.cpp:69
ThemeInfo::GetMinorVersion
int GetMinorVersion() const
Definition: themeinfo.h:36
mythdialogbox.h
MythScreenStack
Definition: mythscreenstack.h:16
ThemeChooser::m_popupMenu
MythDialogBox * m_popupMenu
Definition: themechooser.h:93
ThemeChooser::refreshDownloadableThemes
void refreshDownloadableThemes(void)
Definition: themechooser.cpp:669
ThemeChooser::m_refreshDownloadableThemes
bool m_refreshDownloadableThemes
Definition: themechooser.h:83
MythScreenType::OpenBusyPopup
void OpenBusyPopup(const QString &message="")
Definition: mythscreentype.cpp:320
MythUIGroup
Create a group of widgets.
Definition: mythuigroup.h:11
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythDialogBox::Closed
void Closed(QString, int)
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
mythuistatetype.h
GetCacheDir
QString GetCacheDir(void)
Returns the base directory for all cached files.
Definition: mythdirs.cpp:234
ThemeUpdateChecker::m_newVersion
QString m_newVersion
Definition: themechooser.h:115
MythUIStateType::Reset
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuistatetype.cpp:197
mythsystemevent.h
build_compdb.file
file
Definition: build_compdb.py:55
ThemeChooser::popupClosed
void popupClosed(const QString &which, int result)
Definition: themechooser.cpp:584
MythUIImage::Reset
void Reset(void) override
Reset the image back to the default defined in the theme.
Definition: mythuiimage.cpp:645
ThemeUpdateChecker::m_updateTimer
QTimer * m_updateTimer
Definition: themechooser.h:110
ThemeChooser::updateProgressBar
void updateProgressBar(int bytesReceived, int bytesTotal)
Definition: themechooser.cpp:800
ThemeInfo::GetDownloadURL
QString GetDownloadURL() const
Definition: themeinfo.h:38
THEME_UNKN
@ THEME_UNKN
Definition: themeinfo.h:14
remoteutil.h
mythuibuttonlist.h
mythuiimage.h
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:14
MythEvent::Message
const QString & Message() const
Definition: mythevent.h:65
ThemeUpdateChecker::m_mythVersions
QStringList m_mythVersions
Definition: themechooser.h:111
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:113
ThemeExtractThread
Definition: themechooser.cpp:49
programtypes.h
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
MythObservable::addListener
void addListener(QObject *listener)
Add a listener to the observable.
Definition: mythobservable.cpp:38
ThemeChooser::ThemeChooser
ThemeChooser(MythScreenStack *parent, const QString &name="ThemeChooser")
Creates a new ThemeChooser Screen.
Definition: themechooser.cpp:75
MythScreenType::ResetBusyPopup
void ResetBusyPopup(void)
Definition: mythscreentype.cpp:351
ThemeChooser::LoadVersion
bool LoadVersion(const QString &version, QStringList &themesSeen, bool alert_user)
Definition: themechooser.cpp:238
MythUIButtonListItem
Definition: mythuibuttonlist.h:41
ThemeInfo::GetName
QString GetName() const
Definition: themeinfo.h:29
ThemeChooser::showPopupMenu
void showPopupMenu(void)
Definition: themechooser.cpp:515
MythScreenType::ReloadInBackground
void ReloadInBackground(void)
Definition: mythscreentype.cpp:314
mythdate.h
MythUIProgressBar::SetTotal
void SetTotal(int value)
Definition: mythuiprogressbar.cpp:81
mythlogging.h
MythCoreContext::GenMythURL
static QString GenMythURL(const QString &host=QString(), int port=0, QString path=QString(), const QString &storageGroup=QString())
Definition: mythcorecontext.cpp:758
GetConfDir
QString GetConfDir(void)
Definition: mythdirs.cpp:224
ThemeExtractThread::m_destDir
QString m_destDir
Definition: themechooser.cpp:68
LOC
#define LOC
Definition: themechooser.cpp:40
MythUIButtonList::itemClicked
void itemClicked(MythUIButtonListItem *item)
MythMainWindow::TranslateKeyPress
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
Definition: mythmainwindow.cpp:1104
remotefile.h
ThemeChooser::Create
bool Create(void) override
Definition: themechooser.cpp:94
MythUIProgressBar
Progress bar widget.
Definition: mythuiprogressbar.h:12
MythCoreContext::SendSystemEvent
void SendSystemEvent(const QString &msg)
Definition: mythcorecontext.cpp:1542
MythScreenType::SetFocusWidget
bool SetFocusWidget(MythUIType *widget=nullptr)
Definition: mythscreentype.cpp:118
MythDialogBox::AddButton
void AddButton(const QString &title)
Definition: mythdialogbox.h:198
MythDialogBox
Basic menu dialog, message and a list of options.
Definition: mythdialogbox.h:166
ThemeChooser::loadThemeInfo
ThemeInfo * loadThemeInfo(const QFileInfo &theme)
Definition: themechooser.cpp:489
MythDialogBox::Create
bool Create(void) override
Definition: mythdialogbox.cpp:127
ThemeChooser::m_downloadTheme
ThemeInfo * m_downloadTheme
Definition: themechooser.h:89
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:206
MythUIComposite::SetTextFromMap
virtual void SetTextFromMap(const InfoMap &infoMap)
Definition: mythuicomposite.cpp:9
ThemeUpdateChecker::checkForUpdate
void checkForUpdate(void)
Definition: themechooser.cpp:1069
ThemeChooser::Load
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
Definition: themechooser.cpp:137
MythDownloadManager::download
bool download(const QString &url, const QString &dest, bool reload=false)
Downloads a URL to a file in blocking mode.
Definition: mythdownloadmanager.cpp:430
ThemeChooser::dsDownloadingOnFrontend
@ dsDownloadingOnFrontend
Definition: themechooser.h:65
ThemeInfo::GetPreviewPath
QString GetPreviewPath() const
Definition: themeinfo.h:33
StorageGroup::GetFirstDir
QString GetFirstDir(bool appendSlash=false) const
Definition: storagegroup.cpp:189
ThemeInfo
Definition: themeinfo.h:20
storagegroup.h
ThemeChooser::dsExtractingTheme
@ dsExtractingTheme
Definition: themechooser.h:66
ThemeChooser::saveAndReload
void saveAndReload(void)
Definition: themechooser.cpp:677
RemoteFile::DeleteFile
static bool DeleteFile(const QString &url)
Definition: remotefile.cpp:411
MythUIButtonListItem::GetData
QVariant GetData()
Definition: mythuibuttonlist.cpp:3665
MythUILocation::GetCurrentLocation
QString GetCurrentLocation(bool FullPath=false, bool MainStackOnly=true)
Definition: mythuilocation.cpp:20
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:54
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:910
ThemeChooser::m_userThemeDir
QString m_userThemeDir
Definition: themechooser.h:84
UIUtilDisp::Assign
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
mythuigroup.h
GetMythSourcePath
const char * GetMythSourcePath()
Definition: mythversion.cpp:10
MythUIButtonListItem::SetTextFromMap
void SetTextFromMap(const InfoMap &infoMap, const QString &state="")
Definition: mythuibuttonlist.cpp:3285
MythCoreContext::GetBoolSetting
bool GetBoolSetting(const QString &key, bool defaultval=false)
Definition: mythcorecontext.cpp:904
ThemeExtractThread::m_parent
ThemeChooser * m_parent
Definition: themechooser.cpp:66
mythburn.themeName
string themeName
Definition: mythburn.py:218
mthreadpool.h
mythuihelper.h
ThemeUpdateChecker::~ThemeUpdateChecker
~ThemeUpdateChecker(void) override
Definition: themechooser.cpp:1059
MythCoreContext::GetMasterServerPort
static int GetMasterServerPort(void)
Returns the Master Backend control port If no master server port has been defined in the database,...
Definition: mythcorecontext.cpp:978
ThemeChooser::toggleFullscreenPreview
void toggleFullscreenPreview(void)
Definition: themechooser.cpp:624
ThemeUpdateChecker::ThemeUpdateChecker
ThemeUpdateChecker(void)
Definition: themechooser.cpp:1010
MythUIText
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:404
ThemeInfo::GetType
int GetType() const
Definition: themeinfo.h:34
themechooser.h
ThemeChooser::m_fullPreviewShowing
bool m_fullPreviewShowing
Definition: themechooser.h:77
ThemeChooser::m_downloadState
DownloadState m_downloadState
Definition: themechooser.h:91
ThemeChooser::m_themeStatuses
QMap< QString, QString > m_themeStatuses
Definition: themechooser.h:88
mythcorecontext.h
ThemeChooser::dsDownloadingOnBackend
@ dsDownloadingOnBackend
Definition: themechooser.h:64
ThemeChooser::m_themeFileNameInfos
QMap< QString, ThemeInfo * > m_themeFileNameInfos
Definition: themechooser.h:87
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:695
MythUIButtonListItem::SetImage
void SetImage(MythImage *image, const QString &name="")
Sets an image directly, should only be used in special circumstances since it bypasses the cache.
Definition: mythuibuttonlist.cpp:3429
std
Definition: mythchrono.h:23
ThemeUpdateChecker::m_currentVersion
QString m_currentVersion
Definition: themechooser.h:114
MythUIText::SetText
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:132
ThemeChooser::m_fullScreenName
MythUIText * m_fullScreenName
Definition: themechooser.h:79
ThemeInfo::GetMajorVersion
int GetMajorVersion() const
Definition: themeinfo.h:35
ThemeChooser::m_fullScreenPreview
MythUIImage * m_fullScreenPreview
Definition: themechooser.h:80
MythUIButtonList::Reset
void Reset() override
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuibuttonlist.cpp:116
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:102
StorageGroup
Definition: storagegroup.h:11
build_compdb.action
action
Definition: build_compdb.py:9
ThemeChooser::toggleThemeUpdateNotifications
static void toggleThemeUpdateNotifications(void)
Definition: themechooser.cpp:661
ThemeChooser::m_fullPreviewStateType
MythUIStateType * m_fullPreviewStateType
Definition: themechooser.h:78
ThemeUpdateChecker::m_infoPackage
QString m_infoPackage
Definition: themechooser.h:112
ThemeChooser::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: themechooser.cpp:592
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &Stackname)
Definition: mythmainwindow.cpp:320
RemoteDownloadFile
QString RemoteDownloadFile(const QString &url, const QString &storageGroup, const QString &filename)
Definition: remoteutil.cpp:605
ThemeChooser::~ThemeChooser
~ThemeChooser() override
Definition: themechooser.cpp:84
MythCoreContext::GetHostName
QString GetHostName(void)
Definition: mythcorecontext.cpp:836
ThemeExtractThread::ThemeExtractThread
ThemeExtractThread(ThemeChooser *parent, QString srcFile, QString destDir)
Definition: themechooser.cpp:52
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:879
downloadURL
static bool downloadURL(const QString &url, QByteArray *buffer, QString &finalURL)
Definition: httplivestreambuffer.cpp:94
ThemeChooser::m_downloadFile
QString m_downloadFile
Definition: themechooser.h:90
MythUIImage::SetFilename
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
Definition: mythuiimage.cpp:676
mythdownloadmanager.h
GetMythUI
MythUIHelper * GetMythUI()
Definition: mythuihelper.cpp:66
ThemeChooser::m_infoList
QFileInfoList m_infoList
Definition: themechooser.h:82
MThreadPool::globalInstance
static MThreadPool * globalInstance(void)
Definition: mthreadpool.cpp:317
mythmainwindow.h
ThemeChooser::Init
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
Definition: themechooser.cpp:418
ThemeChooser::dsIdle
@ dsIdle
Definition: themechooser.h:63
MythUIButtonListItem::SetData
void SetData(QVariant data)
Definition: mythuibuttonlist.cpp:3660
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:52
ShowOkPopup
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
Definition: mythdialogbox.cpp:562
nv_python_libs.bbciplayer.bbciplayer_api.version
string version
Definition: bbciplayer_api.py:77
THEME_UI
@ THEME_UI
Definition: themeinfo.h:15
MythCoreContext::SaveSettingOnHost
bool SaveSettingOnHost(const QString &key, const QString &newValue, const QString &host)
Definition: mythcorecontext.cpp:889
ThemeChooser::removeTheme
void removeTheme(void)
Definition: themechooser.cpp:948
ThemeInfo::GetDirectoryName
QString GetDirectoryName() const
Definition: themeinfo.h:42
ThemeInfo::ToMap
void ToMap(InfoMap &infoMap) const
Definition: themeinfo.cpp:252
MythObservable::removeListener
void removeListener(QObject *listener)
Remove a listener to the observable.
Definition: mythobservable.cpp:55
sortThemeNames
static bool sortThemeNames(const QFileInfo &s1, const QFileInfo &s2)
Definition: themechooser.cpp:89
ThemeChooser::m_preview
MythUIImage * m_preview
Definition: themechooser.h:75
MythScreenType::CloseBusyPopup
void CloseBusyPopup(void)
Definition: mythscreentype.cpp:338
MythUIStateType
This widget is used for grouping other widgets for display when a particular named state is called....
Definition: mythuistatetype.h:22
MThreadPool::start
void start(QRunnable *runnable, const QString &debugName, int priority=0)
Definition: mthreadpool.cpp:352
ThemeExtractThread::m_srcFile
QString m_srcFile
Definition: themechooser.cpp:67
MythUIStateType::DisplayState
bool DisplayState(const QString &name)
Definition: mythuistatetype.cpp:84
ThemeChooser::removeThemeDir
bool removeThemeDir(const QString &dirname)
Definition: themechooser.cpp:977
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:896
GetMythDownloadManager
MythDownloadManager * GetMythDownloadManager(void)
Gets the pointer to the MythDownloadManager singleton.
Definition: mythdownloadmanager.cpp:145
ThemeChooser::itemChanged
void itemChanged(MythUIButtonListItem *item)
Definition: themechooser.cpp:746