MythTV  master
myththemedmenu.cpp
Go to the documentation of this file.
1 
2 #include "myththemedmenu.h"
3 
4 // QT headers
5 #include <QCoreApplication>
6 #include <QDir>
7 #include <QKeyEvent>
8 #include <QDomDocument>
9 #include <QFile>
10 #include <QFileInfo>
11 #include <QTextStream>
12 
13 // libmythui headers
14 #include "mythmainwindow.h"
15 #include "mythdialogbox.h"
16 #include "mythgesture.h"
17 #include "mythuitext.h"
18 #include "mythuistatetype.h"
19 #include "xmlparsebase.h"
20 #include "mythsystemlegacy.h"
21 #include "mythuihelper.h"
22 #include "lcddevice.h"
23 #include "mythcorecontext.h"
24 
25 // libmythbase headers
26 #include "mythlogging.h"
27 #include "mythdb.h"
28 #include "mythdirs.h"
29 #include "mythmedia.h"
30 #include "mythversion.h"
31 #include "mythdate.h"
32 
33 // libmythbase headers
34 #include "mythplugin.h"
35 
37  const QString &name)
38  : MythScreenType(parent, name),
39  m_callback(nullptr), m_callbackdata(nullptr),
40  m_killable(false), m_loaded(false), m_titleState(nullptr),
41  m_watermarkState(nullptr), m_buttonList(nullptr), m_descriptionText(nullptr)
42 {
43 }
44 
46 {
47  if (!LoadWindowFromXML("menu-ui.xml", "mainmenu", this))
48  return false;
49 
50  m_titleState = dynamic_cast<MythUIStateType *> (GetChild("titles"));
51  m_watermarkState = dynamic_cast<MythUIStateType *> (GetChild("watermarks"));
52  m_buttonList = dynamic_cast<MythUIButtonList *> (GetChild("menu"));
53  m_descriptionText = dynamic_cast<MythUIText *> (GetChild("description"));
54 
55  if (!m_buttonList)
56  {
57  LOG(VB_GENERAL, LOG_ERR, "Missing 'menu' buttonlist.");
58  return false;
59  }
60 
61  m_loaded = true;
62 
63  return true;
64 }
65 
67 {
68  MythThemedMenuState *st = dynamic_cast<MythThemedMenuState *>(base);
69  if (!st)
70  {
71  LOG(VB_GENERAL, LOG_INFO, "ERROR, bad parsing");
72  return;
73  }
74 
75  m_loaded = st->m_loaded;
76 
78 
79  m_titleState = dynamic_cast<MythUIStateType *> (GetChild("titles"));
80  m_watermarkState = dynamic_cast<MythUIStateType *> (GetChild("watermarks"));
81  m_buttonList = dynamic_cast<MythUIButtonList *> (GetChild("menu"));
82  m_descriptionText = dynamic_cast<MythUIText *> (GetChild("description"));
83 }
84 
86 
100 MythThemedMenu::MythThemedMenu(const QString &/*cdir*/, const QString &menufile,
101  MythScreenStack *parent, const QString &name,
102  bool /*allowreorder*/, MythThemedMenuState *state)
103  : MythThemedMenuState(parent, name),
104  m_state(state), m_allocedstate(false), m_foundtheme(false),
105  m_ignorekeys(false), m_wantpop(false), m_menuPopup(nullptr)
106 {
107  if (!m_state)
108  {
109  m_state = new MythThemedMenuState(parent, "themedmenustate");
110  m_allocedstate = true;
111  }
112 
113  SetMenuTheme(menufile);
114 }
115 
123 void MythThemedMenu::SetMenuTheme(const QString &menufile)
124 {
125  if (!m_state->m_loaded)
126  {
127  if (m_state->Create())
128  m_foundtheme = true;
129  }
130  else
131  m_foundtheme = true;
132 
133  if (!m_foundtheme)
134  return;
135 
136  CopyFrom(m_state);
137 
138  connect(m_buttonList, SIGNAL(itemSelected(MythUIButtonListItem*)),
140  connect(m_buttonList, SIGNAL(itemClicked(MythUIButtonListItem*)),
142 
143  if (!parseMenu(menufile))
144  m_foundtheme = false;
145 }
146 
148 {
149  if (m_allocedstate)
150  delete m_state;
151 }
152 
156 {
157  return m_foundtheme;
158 }
159 
161 void MythThemedMenu::getCallback(void (**lcallback)(void *, QString &),
162  void **data)
163 {
164  *lcallback = m_state->m_callback;
165  *data = m_state->m_callbackdata;
166 }
167 
169 void MythThemedMenu::setCallback(void (*lcallback)(void *, QString &),
170  void *data)
171 {
172  m_state->m_callback = lcallback;
173  m_state->m_callbackdata = data;
174 }
175 
177 {
178  m_state->m_killable = true;
179 }
180 
182 {
183  return m_selection;
184 }
185 
187 {
188  ThemedButton button = item->GetData().value<ThemedButton>();
189  if (m_watermarkState)
190  {
191  if (!(m_watermarkState->DisplayState(button.type)))
193  }
194 
195  if (m_descriptionText)
197 }
198 
204 bool MythThemedMenu::keyPressEvent(QKeyEvent *event)
205 {
206  if (m_ignorekeys)
207  return false;
208 
209  m_ignorekeys = true;
210 
212  if (type && type->keyPressEvent(event))
213  {
214  m_ignorekeys = false;
215  return true;
216  }
217 
218  QStringList actions;
219  bool handled = false;
220 
221  handled = GetMythMainWindow()->TranslateKeyPress("Main Menu", event,
222  actions);
223 
224  for (int i = 0; i < actions.size() && !handled; i++)
225  {
226  QString action = actions[i];
227  handled = true;
228 
229  if (action == "ESCAPE" ||
230  action == "EXIT" ||
231  action == "EXITPROMPT" ||
232  action == "STANDBYMODE")
233  {
234  bool callbacks = m_state->m_callback;
235  bool lastScreen = (GetMythMainWindow()->GetMainStack()
236  ->TotalScreens() == 1);
237  QString menuaction = "UPMENU";
238  QString selExit = "EXITING_APP_PROMPT";
239 
240  if (action == "EXIT")
241  selExit = "EXITING_APP";
242  else if (action == "STANDBYMODE")
243  selExit = "STANDBY_MODE";
244 
245  if (!m_allocedstate)
246  handleAction(menuaction);
247  else if (m_state->m_killable)
248  {
249  m_wantpop = true;
250  if (callbacks)
251  {
252  QString sel = "EXITING_MENU";
254  }
255 
256  if (lastScreen)
257  {
258  if (callbacks)
260  QCoreApplication::exit();
261  }
262  }
263  else if ((action == "EXIT" || action == "EXITPROMPT" ||
264  action == "STANDBYMODE" ||
265  (action == "ESCAPE" &&
266  (QCoreApplication::applicationName() ==
267  MYTH_APPNAME_MYTHTV_SETUP))) && lastScreen)
268  {
269  if (callbacks)
271  else
272  {
273  QCoreApplication::exit();
274  m_wantpop = true;
275  }
276  }
277  }
278  else if (action == "HELP")
279  {
280  aboutScreen();
281  }
282  else if (action == "EJECT")
283  {
285  }
286  else
287  handled = false;
288  }
289 
290  if (!handled && MythScreenType::keyPressEvent(event))
291  handled = true;
292 
293  m_ignorekeys = false;
294 
295  if (m_wantpop)
297 
298  return handled;
299 }
300 
302 {
305 }
306 
308 {
309  if (m_menuPopup)
310  return;
311 
312  int override_menu = GetMythDB()->GetNumSetting("OverrideExitMenu");
313  QString label = tr("System Menu");
315  m_menuPopup = new MythDialogBox(label, mainStack, "menuPopup");
316 
317  if (m_menuPopup->Create())
318  mainStack->AddScreen(m_menuPopup);
319 
320  m_menuPopup->SetReturnEvent(this, "popmenu");
321 
322  // HACK Implement a better check for this
323  if (QCoreApplication::applicationName() == MYTH_APPNAME_MYTHFRONTEND)
324  m_menuPopup->AddButton(tr("Enter standby mode"), QVariant("standby"));
325 
326  // don't show the exit application option if standby option is enabled
327  if (override_menu != 7)
328  m_menuPopup->AddButton(tr("Exit application"), QVariant("exit"));
329 
330  switch (override_menu)
331  {
332  case 2:
333  case 4:
334  // shutdown
335  m_menuPopup->AddButton(tr("Shutdown"), QVariant("shutdown"));
336  break;
337  case 5:
338  // reboot
339  m_menuPopup->AddButton(tr("Reboot"), QVariant("reboot"));
340  break;
341  case 3:
342  case 6:
343  // both
344  m_menuPopup->AddButton(tr("Shutdown"), QVariant("shutdown"));
345  m_menuPopup->AddButton(tr("Reboot"), QVariant("reboot"));
346  break;
347  case 0:
348  case 7:
349  default:
350  break;
351  }
352 
353  m_menuPopup->AddButton(tr("About"), QVariant("about"));
354 }
355 
357 {
358  QString distro_line;
359 
360  QFile file("/etc/os_myth_release");
361  if (file.open(QFile::ReadOnly))
362  {
363  QTextStream t( &file ); // use a text stream
364  distro_line = t.readLine();
365  file.close();
366  }
367 
368  QString label = tr("Revision: %1\n Branch: %2\n %3")
369  .arg(MYTH_SOURCE_VERSION)
370  .arg(MYTH_SOURCE_PATH)
371  .arg(distro_line);
372 
374  m_menuPopup = new MythDialogBox(label, mainStack, "version_dialog");
375  if (m_menuPopup->Create())
376  mainStack->AddScreen(m_menuPopup);
377 
378  m_menuPopup->SetReturnEvent(this, "version");
379  m_menuPopup->AddButton(tr("Ok"));
380 
381 }
382 
383 void MythThemedMenu::customEvent(QEvent *event)
384 {
385  if (event->type() == DialogCompletionEvent::kEventType)
386  {
388 
389  QString resultid = dce->GetId();
390  //int buttonnum = dce->GetResult();
391  QString halt_cmd = GetMythDB()->GetSetting("HaltCommand");
392  QString reboot_cmd = GetMythDB()->GetSetting("RebootCommand");
393 
394  if (resultid == "popmenu")
395  {
396  QString action = dce->GetData().toString();
397  if (action == "shutdown")
398  {
399  if (!halt_cmd.isEmpty())
400  myth_system(halt_cmd);
401  }
402  else if (action == "reboot")
403  {
404  if (!reboot_cmd.isEmpty())
405  myth_system(reboot_cmd);
406  }
407  else if (action == "about")
408  {
409  aboutScreen();
410  }
411  else if (action == "standby")
412  {
413  QString arg("standby_mode");
415  }
416  else if (action == "exit")
417  {
418  QString arg("exiting_app");
420  }
421  }
422  else if (resultid == "password")
423  {
424  QString text = dce->GetResultText();
426  ThemedButton button = item->GetData().value<ThemedButton>();
427  QString password = GetMythDB()->GetSetting(button.password);
428  if (text == password)
429  {
430  QString timestamp_setting = QString("%1Time").arg(button.password);
431  QDateTime curr_time = MythDate::current();
432  QString last_time_stamp =
434  GetMythDB()->SaveSetting(timestamp_setting, last_time_stamp);
435  buttonAction(item, true);
436  }
437  }
438 
439  m_menuPopup = nullptr;
440  }
441 }
442 
448 void MythThemedMenu::parseThemeButton(QDomElement &element)
449 {
450  QString type;
451  QString text;
452  QStringList action;
453  QString alttext;
454  QString description;
455  QString password;
456 
457  bool addit = true;
458 
459  for (QDomNode child = element.firstChild(); !child.isNull();
460  child = child.nextSibling())
461  {
462  QDomElement info = child.toElement();
463  if (!info.isNull())
464  {
465  if (info.tagName() == "type")
466  {
467  type = getFirstText(info);
468  }
469  else if (info.tagName() == "text")
470  {
471  if (text.isEmpty() &&
472  info.attribute("lang","").isEmpty())
473  {
474  text = qApp->translate("ThemeUI",
475  parseText(info).toUtf8() );
476  }
477  else if (info.attribute("lang","").toLower() ==
479  {
480  text = parseText(info);
481  }
482  else if (info.attribute("lang","").toLower() ==
484  {
485  text = parseText(info);
486  }
487  }
488  else if (info.tagName() == "alttext")
489  {
490  if (alttext.isEmpty() &&
491  info.attribute("lang","").isEmpty())
492  {
493  alttext = qApp->translate("ThemeUI",
494  parseText(info).toUtf8());
495  }
496  else if (info.attribute("lang","").toLower() ==
498  {
499  alttext = parseText(info);
500  }
501  else if (info.attribute("lang","").toLower() ==
503  {
504  alttext = parseText(info);
505  }
506  }
507  else if (info.tagName() == "action")
508  {
509  action += getFirstText(info);
510  }
511  else if (info.tagName() == "depends")
512  {
513  addit = findDepends(getFirstText(info));
514  }
515  else if (info.tagName() == "dependsexec")
516  {
517  addit = findDependsExec(getFirstText(info));
518  }
519  else if (info.tagName() == "dependssetting")
520  {
521  addit = GetMythDB()->GetNumSetting(getFirstText(info));
522  }
523  else if (info.tagName() == "dependjumppoint")
524  {
526  getFirstText(info));
527  }
528  else if (info.tagName() == "dependswindow")
529  {
530  QString xmlFile = info.attribute("xmlfile", "");
531  QString windowName = getFirstText(info);
532  if (xmlFile.isEmpty() || windowName.isEmpty())
533  addit = false;
534  else
535  addit = XMLParseBase::WindowExists(xmlFile, windowName);
536  }
537  else if (info.tagName() == "description")
538  {
539  if (description.isEmpty() &&
540  info.attribute("lang","").isEmpty())
541  {
542  description = qApp->translate("ThemeUI",
543  getFirstText(info).toUtf8());
544  }
545  else if (info.attribute("lang","").toLower() ==
547  {
548  description = getFirstText(info);
549  }
550  else if (info.attribute("lang","").toLower() ==
552  {
553  description = getFirstText(info);
554  }
555  }
556  else if (info.tagName() == "password")
557  {
558  password = getFirstText(info);
559  }
560  else
561  {
562  LOG(VB_GENERAL, LOG_ERR,
563  QString("MythThemedMenu: Unknown tag %1 in button")
564  .arg(info.tagName()));
565  }
566  }
567  }
568 
569  if (text.isEmpty())
570  {
571  LOG(VB_GENERAL, LOG_ERR, "MythThemedMenu: Missing 'text' in button");
572  return;
573  }
574 
575  if (action.empty())
576  {
577  LOG(VB_GENERAL, LOG_ERR, "MythThemedMenu: Missing 'action' in button");
578  return;
579  }
580 
581  if (addit)
582  addButton(type, text, alttext, action, description, password);
583 }
584 
598 bool MythThemedMenu::parseMenu(const QString &menuname)
599 {
600  QString filename = findMenuFile(menuname);
601 
602  QDomDocument doc;
603  QFile f(filename);
604 
605  if (!f.exists() || !f.open(QIODevice::ReadOnly))
606  {
607  LOG(VB_GENERAL, LOG_ERR, QString("MythThemedMenu: Couldn't read "
608  "menu file %1").arg(menuname));
609 
610  if (menuname != "mainmenu.xml")
611  ShowOkPopup(tr("MythTV could not locate the menu file %1")
612  .arg(menuname));
613  return false;
614  }
615 
616  QString errorMsg;
617  int errorLine = 0;
618  int errorColumn = 0;
619 
620  if (!doc.setContent(&f, false, &errorMsg, &errorLine, &errorColumn))
621  {
622  LOG(VB_GENERAL, LOG_ERR,
623  QString("Error parsing: %1\nat line: %2 column: %3 msg: %4").
624  arg(filename).arg(errorLine).arg(errorColumn).arg(errorMsg));
625  f.close();
626 
627  if (menuname != "mainmenu.xml")
628  ShowOkPopup(tr("The menu file %1 is incomplete.")
629  .arg(menuname));
630  return false;
631  }
632 
633  f.close();
634 
635  LOG(VB_GUI, LOG_INFO, QString("Loading menu theme from %1").arg(filename));
636 
637  QDomElement docElem = doc.documentElement();
638 
639  m_menumode = docElem.attribute("name", "MAIN");
640 
641  QDomNode n = docElem.firstChild();
642  while (!n.isNull())
643  {
644  QDomElement e = n.toElement();
645  if (!e.isNull())
646  {
647  if (e.tagName() == "button")
648  {
649  parseThemeButton(e);
650  }
651  else
652  {
653  LOG(VB_GENERAL, LOG_ERR,
654  QString("MythThemedMenu: Unknown element %1")
655  .arg(e.tagName()));
656  return false;
657  }
658  }
659  n = n.nextSibling();
660  }
661 
662  if (m_buttonList->GetCount() == 0)
663  {
664  LOG(VB_GENERAL, LOG_ERR,
665  QString("MythThemedMenu: No buttons for menu %1").arg(menuname));
666  return false;
667  }
668 
670 
671  if (m_titleState)
672  {
675  }
676 
677  m_selection.clear();
678  return true;
679 }
680 
697 void MythThemedMenu::addButton(const QString &type, const QString &text,
698  const QString &alttext,
699  const QStringList &action,
700  const QString &description,
701  const QString &password)
702 {
703  ThemedButton newbutton;
704  newbutton.type = type;
705  newbutton.action = action;
706  newbutton.text = text;
707  newbutton.alttext = alttext;
708  newbutton.description = description;
709  newbutton.password = password;
710 
711  if (m_watermarkState)
713 
714  MythUIButtonListItem *listbuttonitem =
716  qVariantFromValue(newbutton));
717 
718  listbuttonitem->DisplayState(type, "icon");
719  listbuttonitem->SetText(description, "description");
720 }
721 
723 {
724  ThemedButton button = item->GetData().value<ThemedButton>();
725 
726  QString password;
727  if (!skipPass)
728  password = button.password;
729 
730  QStringList::Iterator it = button.action.begin();
731  for (; it != button.action.end(); it++)
732  {
733  if (handleAction(*it, password))
734  break;
735  }
736 }
737 
743 QString MythThemedMenu::findMenuFile(const QString &menuname)
744 {
745  QString testdir = GetConfDir() + '/' + menuname;
746  QFile file(testdir);
747  if (file.exists())
748  return testdir;
749  else
750  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
751 
752  testdir = GetMythUI()->GetMenuThemeDir() + '/' + menuname;
753  file.setFileName(testdir);
754  if (file.exists())
755  return testdir;
756  else
757  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
758 
759  testdir = GetMythUI()->GetThemeDir() + '/' + menuname;
760  file.setFileName(testdir);
761  if (file.exists())
762  return testdir;
763  else
764  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
765 
766  testdir = GetShareDir() + menuname;
767  file.setFileName(testdir);
768  if (file.exists())
769  return testdir;
770  else
771  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
772 
773  testdir = "../mythfrontend/" + menuname;
774  file.setFileName(testdir);
775  if (file.exists())
776  return testdir;
777  else
778  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
779 
780  testdir = GetShareDir() + "themes/defaultmenu/" + menuname;
781  file.setFileName(testdir);
782  if (file.exists())
783  return testdir;
784  else
785  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
786 
787  return QString();
788 }
789 
796 bool MythThemedMenu::handleAction(const QString &action, const QString &password)
797 {
799 
800  if (!password.isEmpty() && !checkPinCode(password))
801  return true;
802 
803  if (action.startsWith("EXEC "))
804  {
805  QString rest = action.right(action.length() - 5);
806  if (cbs && cbs->exec_program)
807  cbs->exec_program(rest);
808 
809  return false;
810  }
811  else if (action.startsWith("EXECTV "))
812  {
813  QString rest = action.right(action.length() - 7).trimmed();
814  if (cbs && cbs->exec_program_tv)
815  cbs->exec_program_tv(rest);
816  }
817  else if (action.startsWith("MENU "))
818  {
819  QString menu = action.right(action.length() - 5);
820 
821  MythScreenStack *stack = GetScreenStack();
822 
823  MythThemedMenu *newmenu = new MythThemedMenu("", menu, stack, menu,
824  false, m_state);
825  if (newmenu->foundTheme())
826  stack->AddScreen(newmenu);
827  else
828  delete newmenu;
829  }
830  else if (action.startsWith("UPMENU"))
831  {
832  m_wantpop = true;
833  }
834  else if (action.startsWith("CONFIGPLUGIN"))
835  {
836  QString rest = action.right(action.length() - 13);
837  if (cbs && cbs->configplugin)
838  cbs->configplugin(rest);
839  }
840  else if (action.startsWith("PLUGIN"))
841  {
842  QString rest = action.right(action.length() - 7);
843  if (cbs && cbs->plugin)
844  cbs->plugin(rest);
845  }
846  else if (action.startsWith("SHUTDOWN"))
847  {
848  if (m_allocedstate)
849  {
850  m_wantpop = true;
851  }
852  }
853  else if (action.startsWith("EJECT"))
854  {
855  if (cbs && cbs->eject)
856  cbs->eject();
857  }
858  else if (action.startsWith("JUMP "))
859  {
860  QString rest = action.right(action.length() - 5);
861  GetMythMainWindow()->JumpTo(rest, false);
862  }
863  else if (action.startsWith("MEDIA "))
864  {
865  // the format is MEDIA HANDLER URL
866  // TODO: allow spaces in the url
867  QStringList list = action.simplified().split(' ');
868  if (list.size() >= 3)
869  GetMythMainWindow()->HandleMedia(list[1], list[2]);
870  }
871  else
872  {
874  if (m_state->m_callback)
876  else
877  LOG(VB_GENERAL, LOG_ERR, "Unknown menu action: " + action);
878  }
879 
880  return true;
881 }
882 
883 bool MythThemedMenu::findDepends(const QString &fileList)
884 {
885  QStringList files = fileList.split(" ");
886  MythPluginManager *pluginManager = gCoreContext->GetPluginManager();
887 
888  for (QStringList::Iterator it = files.begin(); it != files.end(); ++it )
889  {
890  QString filename = findMenuFile(*it);
891  if (!filename.isEmpty() && filename.endsWith(".xml"))
892  return true;
893 
894  // Has plugin by this name been successfully loaded
895  MythPlugin *plugin = pluginManager->GetPlugin(*it);
896  if (plugin)
897  return true;
898  }
899 
900  return false;
901 }
902 
903 bool MythThemedMenu::findDependsExec(const QString &filename)
904 {
905  QFileInfo filename_info(filename);
906 
907  if (filename_info.exists() && filename_info.isFile() && filename_info.isExecutable())
908  return true;
909 
910  return false;
911 }
912 
919 bool MythThemedMenu::checkPinCode(const QString &password_setting)
920 {
921  QString timestamp_setting = QString("%1Time").arg(password_setting);
922  QDateTime curr_time = MythDate::current();
923  QString last_time_stamp = GetMythDB()->GetSetting(timestamp_setting);
924  QString password = GetMythDB()->GetSetting(password_setting);
925 
926  // Password empty? Then skip asking for it
927  if (password.isEmpty())
928  return true;
929 
930  if (last_time_stamp.length() < 1)
931  {
932  LOG(VB_GENERAL, LOG_ERR,
933  "MythThemedMenu: Could not read password/pin time stamp.\n"
934  "This is only an issue if it happens repeatedly.");
935  }
936  else
937  {
938  QDateTime last_time = MythDate::fromString(last_time_stamp);
939  if (!last_time.isValid() || last_time.secsTo(curr_time) < 120)
940  {
941  last_time_stamp = MythDate::toString(
942  curr_time, MythDate::kDatabase);
943  GetMythDB()->SaveSetting(timestamp_setting, last_time_stamp);
944  return true;
945  }
946  }
947 
948  LOG(VB_GENERAL, LOG_INFO, QString("Using Password: %1")
949  .arg(password_setting));
950 
951  QString text = tr("Enter password:");
952  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
953  MythTextInputDialog *dialog =
954  new MythTextInputDialog(popupStack, text, FilterNone, true);
955 
956  if (dialog->Create())
957  {
958  dialog->SetReturnEvent(this, "password");
959  popupStack->AddScreen(dialog);
960  }
961  else
962  delete dialog;
963 
964  return false;
965 }
966 
971 {
972  if (!event)
973  return;
974 
975  MythMediaDevice *device = event->getDevice();
976 
977  if (!device)
978  return;
979 
980  MythMediaType type = device->getMediaType();
981  MythMediaStatus status = device->getStatus();
982 
983  if ((status & ~MEDIASTAT_USEABLE) &&
984  (status & ~MEDIASTAT_MOUNTED))
985  return;
986 
987  switch (type)
988  {
989  case MEDIATYPE_DVD :
990  // DVD Available
991  break;
992  case MEDIATYPE_BD :
993  // Blu-ray Available
994  break;
995  default :
996  return;
997  }
998 }
MythMediaType getMediaType() const
Definition: mythmedia.h:91
QString GetLanguageAndVariant(void)
Returns the user-set language and variant.
virtual void aboutToShow(void)
MythScreenStack * GetScreenStack() const
bool parseMenu(const QString &menuname)
Parse the themebuttons to be added based on the name of the menu file provided.
int TotalScreens() const
bool findDepends(const QString &fileList)
MythMediaType
Definition: mythmedia.h:24
void CopyFrom(MythUIType *) override
Copy this widgets state from another.
bool findDependsExec(const QString &filename)
bool TranslateKeyPress(const QString &context, QKeyEvent *e, QStringList &actions, bool allowJumps=true)
Get a list of actions for a keypress in the given context.
MythConfirmationDialog * ShowOkPopup(const QString &message, QObject *parent, const char *slot, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
void customEvent(QEvent *event) override
MythUIButtonList * m_buttonList
MythThemedMenuState(MythScreenStack *parent, const QString &name)
Basic menu dialog, message and a list of options.
void SetMenuTheme(const QString &menufile)
Loads the main UI theme, and a menu theme.
void addButton(const QString &type, const QString &text, const QString &alttext, const QStringList &action, const QString &description, const QString &password)
Create a new MythThemedButton based on the MythThemedMenuState m_state and the type,...
QString alttext
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:168
void mediaEvent(MythMediaEvent *event) override
Media/Device status event handler, received from MythMediaMonitor.
void setCallback(void(*lcallback)(void *, QString &), void *data)
Set the themed menus callback function and data for that function.
MythScreenStack * GetStack(const QString &stackname)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythScreenStack * GetMainStack()
bool Create(void) override
static MythThemedMenu * menu
QString GetThemeDir(void)
The base class on which all widgets and screens are based.
Definition: mythuitype.h:63
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
void ShowMenu() override
MythDialogBox * m_menuPopup
static Type kEventType
Definition: mythdialogbox.h:50
static void(* m_callback)(void *, QString &)
bool keyPressEvent(QKeyEvent *e) override
keyboard/LIRC event handler.
int GetNumSetting(const QString &key, int defaultval)
Definition: mythdb.cpp:563
void(* exec_program)(const QString &cmd)
Definition: mythuihelper.h:34
#define MYTH_APPNAME_MYTHTV_SETUP
QString GetConfDir(void)
Definition: mythdirs.cpp:224
void setKillable(void)
static bool WindowExists(const QString &xmlfile, const QString &windowname)
void AddButton(const QString &title, QVariant data=0, bool newMenu=false, bool setCurrent=false)
bool Create(void) override
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
MythPluginManager * GetPluginManager(void)
VERBOSE_PREAMBLE false
Definition: verbosedefs.h:85
A C++ ripoff of the stroke library for MythTV.
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
void SetReturnEvent(QObject *retobject, const QString &resultid)
MythUIStateType * m_watermarkState
static QString getFirstText(QDomElement &element)
unsigned char t
Definition: ParseText.cpp:340
QString password
QString GetShareDir(void)
Definition: mythdirs.cpp:222
QString GetMenuThemeDir(void)
void(* configplugin)(const QString &cmd)
Definition: mythuihelper.h:36
void SetText(const QString &text, const QString &name="", const QString &state="")
MythUIStateType * m_titleState
void JumpTo(const QString &destination, bool pop=true)
const char * name
Definition: ParseText.cpp:339
uint myth_system(const QString &command, uint flags, uint timeout)
MythPlugin * GetPlugin(const QString &plugname)
Definition: mythplugin.cpp:231
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:101
MythUIHelper * GetMythUI()
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
MythUIText * m_descriptionText
QString GetSetting(const QString &_key, const QString &defaultval)
Definition: mythdb.cpp:362
MythUIType * GetFocusWidget(void) const
bool checkPinCode(const QString &password_setting)
Queries the user for a password to enter a part of MythTV restricted by a password.
void aboutToShow(void) override
static QString parseText(QDomElement &element)
MythMainWindow * GetMythMainWindow(void)
Dialog prompting the user to enter a text string.
#define MYTH_SOURCE_PATH
Definition: version.h:3
bool keyPressEvent(QKeyEvent *) override
Key event handler.
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
Themed menu class, used for main menus in MythTV frontend.
#define MYTH_APPNAME_MYTHFRONTEND
void SetLCDTitles(const QString &title, const QString &columnList="")
virtual void PopScreen(MythScreenType *screen=nullptr, bool allowFade=true, bool deleteScreen=true)
MythScreenStack * m_ScreenStack
bool DestinationExists(const QString &destination) const
void(* eject)(void)
Definition: mythuihelper.h:38
void SetReturnEvent(QObject *retobject, const QString &resultid)
void(* m_callback)(void *, QString &)
QString description
bool handleAction(const QString &action, const QString &password=QString())
Handle a MythTV action for the Menus.
void(* plugin)(const QString &cmd)
Definition: mythuihelper.h:37
QStringList action
QString getSelection(void)
bool DisplayState(const QString &name)
bool foundTheme(void)
Returns true iff a theme has been found by a previous call to SetMenuTheme().
Default UTC, database format.
Definition: mythdate.h:24
void EnsureStateLoaded(const QString &name)
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
MythThemedMenu(const QString &cdir, const QString &menufile, MythScreenStack *parent, const QString &name, bool allowreorder=false, MythThemedMenuState *state=nullptr)
Creates a themed menu.
void SaveSetting(const QString &key, int newValue)
Definition: mythdb.cpp:243
MythThemedMenuState * m_state
QString findMenuFile(const QString &menuname)
Locates the appropriate menu file from which to parse the menu.
MythMediaStatus
Definition: mythmedia.h:12
void setButtonActive(MythUIButtonListItem *item)
MythDB * GetMythDB(void)
Definition: mythdb.cpp:46
void getCallback(void(**lcallback)(void *, QString &), void **data)
Get the themed menus callback function and data for that function.
void(* exec_program_tv)(const QString &cmd)
Definition: mythuihelper.h:35
bool HandleMedia(const QString &handler, const QString &mrl, const QString &plot="", const QString &title="", const QString &subtitle="", const QString &director="", int season=0, int episode=0, const QString &inetref="", int lenMins=120, const QString &year="1895", const QString &id="", bool useBookmarks=false)
Screen in which all other widgets are contained and rendered.
QString GetLanguage(void)
Returns two character ISO-639 language descriptor for UI language.
void parseThemeButton(QDomElement &element)
Parses the element's tags and set the ThemeButton's type, text, depends, and action,...
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:37
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:155
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
Definition: mythdate.cpp:30
void DisplayState(const QString &state, const QString &name)
#define MYTH_SOURCE_VERSION
Definition: version.h:2
MythUIMenuCallbacks * GetMenuCBs(void)
void buttonAction(MythUIButtonListItem *item, bool skipPass=false)
MythMediaStatus getStatus() const
Definition: mythmedia.h:70
MythUIButtonListItem * GetItemCurrent() const
bool Create(void) override