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 {
38  if (!LoadWindowFromXML("menu-ui.xml", "mainmenu", this))
39  return false;
40 
41  m_titleState = dynamic_cast<MythUIStateType *> (GetChild("titles"));
42  m_watermarkState = dynamic_cast<MythUIStateType *> (GetChild("watermarks"));
43  m_buttonList = dynamic_cast<MythUIButtonList *> (GetChild("menu"));
44  m_descriptionText = dynamic_cast<MythUIText *> (GetChild("description"));
45 
46  if (!m_buttonList)
47  {
48  LOG(VB_GENERAL, LOG_ERR, "Missing 'menu' buttonlist.");
49  return false;
50  }
51 
52  m_loaded = true;
53 
54  return true;
55 }
56 
58 {
59  auto *st = dynamic_cast<MythThemedMenuState *>(base);
60  if (!st)
61  {
62  LOG(VB_GENERAL, LOG_INFO, "ERROR, bad parsing");
63  return;
64  }
65 
66  m_loaded = st->m_loaded;
67 
69 
70  m_titleState = dynamic_cast<MythUIStateType *> (GetChild("titles"));
71  m_watermarkState = dynamic_cast<MythUIStateType *> (GetChild("watermarks"));
72  m_buttonList = dynamic_cast<MythUIButtonList *> (GetChild("menu"));
73  m_descriptionText = dynamic_cast<MythUIText *> (GetChild("description"));
74 }
75 
77 
91 MythThemedMenu::MythThemedMenu(const QString &/*cdir*/, const QString &menufile,
92  MythScreenStack *parent, const QString &name,
93  bool /*allowreorder*/, MythThemedMenuState *state)
94  : MythThemedMenuState(parent, name), m_state(state)
95 {
96  if (!m_state)
97  {
98  m_state = new MythThemedMenuState(parent, "themedmenustate");
99  m_allocedstate = true;
100  }
101 
102  SetMenuTheme(menufile);
103 }
104 
112 void MythThemedMenu::SetMenuTheme(const QString &menufile)
113 {
114  if (!m_state->m_loaded)
115  {
116  if (m_state->Create())
117  m_foundtheme = true;
118  }
119  else
120  m_foundtheme = true;
121 
122  if (!m_foundtheme)
123  return;
124 
125  CopyFrom(m_state);
126 
127  connect(m_buttonList, SIGNAL(itemSelected(MythUIButtonListItem*)),
129  connect(m_buttonList, SIGNAL(itemClicked(MythUIButtonListItem*)),
131 
132  if (!parseMenu(menufile))
133  m_foundtheme = false;
134 }
135 
137 {
138  if (m_allocedstate)
139  delete m_state;
140 }
141 
145 {
146  return m_foundtheme;
147 }
148 
150 void MythThemedMenu::getCallback(void (**lcallback)(void *, QString &),
151  void **data)
152 {
153  *lcallback = m_state->m_callback;
154  *data = m_state->m_callbackdata;
155 }
156 
158 void MythThemedMenu::setCallback(void (*lcallback)(void *, QString &),
159  void *data)
160 {
161  m_state->m_callback = lcallback;
162  m_state->m_callbackdata = data;
163 }
164 
166 {
167  m_state->m_killable = true;
168 }
169 
171 {
172  return m_selection;
173 }
174 
176 {
177  auto button = item->GetData().value<ThemedButton>();
178  if (m_watermarkState)
179  {
180  if (!(m_watermarkState->DisplayState(button.type)))
182  }
183 
184  if (m_descriptionText)
185  m_descriptionText->SetText(button.description);
186 }
187 
193 bool MythThemedMenu::keyPressEvent(QKeyEvent *event)
194 {
195  if (m_ignorekeys)
196  return false;
197 
198  m_ignorekeys = true;
199 
201  if (type && type->keyPressEvent(event))
202  {
203  m_ignorekeys = false;
204  return true;
205  }
206 
207  QStringList actions;
208  bool handled = false;
209 
210  handled = GetMythMainWindow()->TranslateKeyPress("Main Menu", event,
211  actions);
212 
213  for (int i = 0; i < actions.size() && !handled; i++)
214  {
215  QString action = actions[i];
216  handled = true;
217 
218  if (action == "ESCAPE" ||
219  action == "EXIT" ||
220  action == "EXITPROMPT" ||
221  action == "STANDBYMODE")
222  {
223  bool callbacks = m_state->m_callback;
224  bool lastScreen = (GetMythMainWindow()->GetMainStack()
225  ->TotalScreens() == 1);
226  QString menuaction = "UPMENU";
227  QString selExit = "EXITING_APP_PROMPT";
228 
229  if (action == "EXIT")
230  selExit = "EXITING_APP";
231  else if (action == "STANDBYMODE")
232  selExit = "STANDBY_MODE";
233 
234  if (!m_allocedstate)
235  handleAction(menuaction);
236  else if (m_state->m_killable)
237  {
238  m_wantpop = true;
239  if (callbacks)
240  {
241  QString sel = "EXITING_MENU";
243  }
244 
245  if (lastScreen)
246  {
247  if (callbacks)
249  QCoreApplication::exit();
250  }
251  }
252  else if ((action == "EXIT" || action == "EXITPROMPT" ||
253  action == "STANDBYMODE" ||
254  (action == "ESCAPE" &&
255  (QCoreApplication::applicationName() ==
256  MYTH_APPNAME_MYTHTV_SETUP))) && lastScreen)
257  {
258  if (callbacks)
260  else
261  {
262  QCoreApplication::exit();
263  m_wantpop = true;
264  }
265  }
266  }
267  else if (action == "HELP")
268  {
269  aboutScreen();
270  }
271  else if (action == "EJECT")
272  {
274  }
275  else
276  handled = false;
277  }
278 
279  if (!handled && MythScreenType::keyPressEvent(event))
280  handled = true;
281 
282  m_ignorekeys = false;
283 
284  if (m_wantpop)
286 
287  return handled;
288 }
289 
291 {
294 }
295 
297 {
298  if (m_menuPopup)
299  return;
300 
301  int override_menu = GetMythDB()->GetNumSetting("OverrideExitMenu");
302  QString label = tr("System Menu");
304  m_menuPopup = new MythDialogBox(label, mainStack, "menuPopup");
305 
306  if (m_menuPopup->Create())
307  mainStack->AddScreen(m_menuPopup);
308 
309  m_menuPopup->SetReturnEvent(this, "popmenu");
310 
311  // HACK Implement a better check for this
312  if (QCoreApplication::applicationName() == MYTH_APPNAME_MYTHFRONTEND)
313  m_menuPopup->AddButton(tr("Enter standby mode"), QVariant("standby"));
314 
315  // don't show the exit application option if standby option is enabled
316  if (override_menu != 7)
317  m_menuPopup->AddButton(tr("Exit application"), QVariant("exit"));
318 
319  switch (override_menu)
320  {
321  case 2:
322  case 4:
323  // shutdown
324  m_menuPopup->AddButton(tr("Shutdown"), QVariant("shutdown"));
325  break;
326  case 5:
327  // reboot
328  m_menuPopup->AddButton(tr("Reboot"), QVariant("reboot"));
329  break;
330  case 3:
331  case 6:
332  // both
333  m_menuPopup->AddButton(tr("Shutdown"), QVariant("shutdown"));
334  m_menuPopup->AddButton(tr("Reboot"), QVariant("reboot"));
335  break;
336  case 0:
337  case 7:
338  default:
339  break;
340  }
341 
342  m_menuPopup->AddButton(tr("About"), QVariant("about"));
343 }
344 
346 {
347  QString distro_line;
348 
349  QFile file("/etc/os_myth_release");
350  if (file.open(QFile::ReadOnly))
351  {
352  QTextStream t( &file ); // use a text stream
353  distro_line = t.readLine();
354  file.close();
355  }
356 
357  QString label = tr("Revision: %1\n Branch: %2\n %3")
358  .arg(MYTH_SOURCE_VERSION)
359  .arg(MYTH_SOURCE_PATH)
360  .arg(distro_line);
361 
363  m_menuPopup = new MythDialogBox(label, mainStack, "version_dialog");
364  if (m_menuPopup->Create())
365  mainStack->AddScreen(m_menuPopup);
366 
367  m_menuPopup->SetReturnEvent(this, "version");
368  m_menuPopup->AddButton(tr("Ok"));
369 
370 }
371 
372 void MythThemedMenu::customEvent(QEvent *event)
373 {
374  if (event->type() == DialogCompletionEvent::kEventType)
375  {
376  auto *dce = (DialogCompletionEvent*)(event);
377 
378  QString resultid = dce->GetId();
379  //int buttonnum = dce->GetResult();
380  QString halt_cmd = GetMythDB()->GetSetting("HaltCommand");
381  QString reboot_cmd = GetMythDB()->GetSetting("RebootCommand");
382 
383  if (resultid == "popmenu")
384  {
385  QString action = dce->GetData().toString();
386  if (action == "shutdown")
387  {
388  if (!halt_cmd.isEmpty())
389  myth_system(halt_cmd);
390  }
391  else if (action == "reboot")
392  {
393  if (!reboot_cmd.isEmpty())
394  myth_system(reboot_cmd);
395  }
396  else if (action == "about")
397  {
398  aboutScreen();
399  }
400  else if (action == "standby")
401  {
402  QString arg("standby_mode");
404  }
405  else if (action == "exit")
406  {
407  QString arg("exiting_app");
409  }
410  }
411  else if (resultid == "password")
412  {
413  QString text = dce->GetResultText();
415  auto button = item->GetData().value<ThemedButton>();
416  QString password = GetMythDB()->GetSetting(button.password);
417  if (text == password)
418  {
419  QString timestamp_setting = QString("%1Time").arg(button.password);
420  QDateTime curr_time = MythDate::current();
421  QString last_time_stamp =
423  GetMythDB()->SaveSetting(timestamp_setting, last_time_stamp);
424  buttonAction(item, true);
425  }
426  }
427 
428  m_menuPopup = nullptr;
429  }
430 }
431 
437 void MythThemedMenu::parseThemeButton(QDomElement &element)
438 {
439  QString type;
440  QString text;
441  QStringList action;
442  QString alttext;
443  QString description;
444  QString password;
445 
446  bool addit = true;
447 
448  for (QDomNode child = element.firstChild(); !child.isNull();
449  child = child.nextSibling())
450  {
451  QDomElement info = child.toElement();
452  if (!info.isNull())
453  {
454  if (info.tagName() == "type")
455  {
456  type = getFirstText(info);
457  }
458  else if (info.tagName() == "text")
459  {
460  if (text.isEmpty() &&
461  info.attribute("lang","").isEmpty())
462  {
463  text = QCoreApplication::translate("ThemeUI",
464  parseText(info).toUtf8() );
465  }
466  else if ((info.attribute("lang","").toLower() ==
468  (info.attribute("lang","").toLower() ==
470  {
471  text = parseText(info);
472  }
473  }
474  else if (info.tagName() == "alttext")
475  {
476  if (alttext.isEmpty() &&
477  info.attribute("lang","").isEmpty())
478  {
479  alttext = QCoreApplication::translate("ThemeUI",
480  parseText(info).toUtf8());
481  }
482  else if ((info.attribute("lang","").toLower() ==
484  (info.attribute("lang","").toLower() ==
486  {
487  alttext = parseText(info);
488  }
489  }
490  else if (info.tagName() == "action")
491  {
492  action += getFirstText(info);
493  }
494  else if (info.tagName() == "depends")
495  {
496  addit = findDepends(getFirstText(info));
497  }
498  else if (info.tagName() == "dependsexec")
499  {
500  addit = findDependsExec(getFirstText(info));
501  }
502  else if (info.tagName() == "dependssetting")
503  {
504  addit = GetMythDB()->GetBoolSetting(getFirstText(info));
505  }
506  else if (info.tagName() == "dependjumppoint")
507  {
509  getFirstText(info));
510  }
511  else if (info.tagName() == "dependswindow")
512  {
513  QString xmlFile = info.attribute("xmlfile", "");
514  QString windowName = getFirstText(info);
515  if (xmlFile.isEmpty() || windowName.isEmpty())
516  addit = false;
517  else
518  addit = XMLParseBase::WindowExists(xmlFile, windowName);
519  }
520  else if (info.tagName() == "description")
521  {
522  if (description.isEmpty() &&
523  info.attribute("lang","").isEmpty())
524  {
525  description = QCoreApplication::translate("ThemeUI",
526  getFirstText(info).toUtf8());
527  }
528  else if ((info.attribute("lang","").toLower() ==
530  (info.attribute("lang","").toLower() ==
532  {
533  description = getFirstText(info);
534  }
535  }
536  else if (info.tagName() == "password")
537  {
538  password = getFirstText(info);
539  }
540  else
541  {
542  LOG(VB_GENERAL, LOG_ERR,
543  QString("MythThemedMenu: Unknown tag %1 in button")
544  .arg(info.tagName()));
545  }
546  }
547  }
548 
549  if (text.isEmpty())
550  {
551  LOG(VB_GENERAL, LOG_ERR, "MythThemedMenu: Missing 'text' in button");
552  return;
553  }
554 
555  if (action.empty())
556  {
557  LOG(VB_GENERAL, LOG_ERR, "MythThemedMenu: Missing 'action' in button");
558  return;
559  }
560 
561  if (addit)
562  addButton(type, text, alttext, action, description, password);
563 }
564 
578 bool MythThemedMenu::parseMenu(const QString &menuname)
579 {
580  QString filename = findMenuFile(menuname);
581 
582  QDomDocument doc;
583  QFile f(filename);
584 
585  if (!f.exists() || !f.open(QIODevice::ReadOnly))
586  {
587  LOG(VB_GENERAL, LOG_ERR, QString("MythThemedMenu: Couldn't read "
588  "menu file %1").arg(menuname));
589 
590  if (menuname != "mainmenu.xml")
591  ShowOkPopup(tr("MythTV could not locate the menu file %1")
592  .arg(menuname));
593  return false;
594  }
595 
596  QString errorMsg;
597  int errorLine = 0;
598  int errorColumn = 0;
599 
600  if (!doc.setContent(&f, false, &errorMsg, &errorLine, &errorColumn))
601  {
602  LOG(VB_GENERAL, LOG_ERR,
603  QString("Error parsing: %1\nat line: %2 column: %3 msg: %4").
604  arg(filename).arg(errorLine).arg(errorColumn).arg(errorMsg));
605  f.close();
606 
607  if (menuname != "mainmenu.xml")
608  ShowOkPopup(tr("The menu file %1 is incomplete.")
609  .arg(menuname));
610  return false;
611  }
612 
613  f.close();
614 
615  LOG(VB_GUI, LOG_INFO, QString("Loading menu theme from %1").arg(filename));
616 
617  QDomElement docElem = doc.documentElement();
618 
619  m_menumode = docElem.attribute("name", "MAIN");
620 
621  QDomNode n = docElem.firstChild();
622  while (!n.isNull())
623  {
624  QDomElement e = n.toElement();
625  if (!e.isNull())
626  {
627  if (e.tagName() == "button")
628  {
630  }
631  else
632  {
633  LOG(VB_GENERAL, LOG_ERR,
634  QString("MythThemedMenu: Unknown element %1")
635  .arg(e.tagName()));
636  return false;
637  }
638  }
639  n = n.nextSibling();
640  }
641 
642  if (m_buttonList->GetCount() == 0)
643  {
644  LOG(VB_GENERAL, LOG_ERR,
645  QString("MythThemedMenu: No buttons for menu %1").arg(menuname));
646  return false;
647  }
648 
650 
651  if (m_titleState)
652  {
655  }
656 
657  m_selection.clear();
658  return true;
659 }
660 
677 void MythThemedMenu::addButton(const QString &type, const QString &text,
678  const QString &alttext,
679  const QStringList &action,
680  const QString &description,
681  const QString &password)
682 {
683  ThemedButton newbutton;
684  newbutton.type = type;
685  newbutton.action = action;
686  newbutton.text = text;
687  newbutton.alttext = alttext;
688  newbutton.description = description;
689  newbutton.password = password;
690 
691  if (m_watermarkState)
693 
694  auto *listbuttonitem = new MythUIButtonListItem(m_buttonList, text,
695  QVariant::fromValue(newbutton));
696 
697  listbuttonitem->DisplayState(type, "icon");
698  listbuttonitem->SetText(description, "description");
699 }
700 
702 {
703  auto button = item->GetData().value<ThemedButton>();
704 
705  QString password;
706  if (!skipPass)
707  password = button.password;
708 
709  for (const auto & act : qAsConst(button.action))
710  {
711  if (handleAction(act, password))
712  break;
713  }
714 }
715 
721 QString MythThemedMenu::findMenuFile(const QString &menuname)
722 {
723  QString testdir = GetConfDir() + '/' + menuname;
724  QFile file(testdir);
725  if (file.exists())
726  return testdir;
727  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
728 
729  testdir = GetMythUI()->GetMenuThemeDir() + '/' + menuname;
730  file.setFileName(testdir);
731  if (file.exists())
732  return testdir;
733  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
734 
735  testdir = GetMythUI()->GetThemeDir() + '/' + menuname;
736  file.setFileName(testdir);
737  if (file.exists())
738  return testdir;
739  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
740 
741  testdir = GetShareDir() + menuname;
742  file.setFileName(testdir);
743  if (file.exists())
744  return testdir;
745  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
746 
747  testdir = "../mythfrontend/" + menuname;
748  file.setFileName(testdir);
749  if (file.exists())
750  return testdir;
751  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
752 
753  testdir = GetShareDir() + "themes/defaultmenu/" + menuname;
754  file.setFileName(testdir);
755  if (file.exists())
756  return testdir;
757  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
758 
759  return QString();
760 }
761 
768 bool MythThemedMenu::handleAction(const QString &action, const QString &password)
769 {
771 
772  if (!password.isEmpty() && !checkPinCode(password))
773  return true;
774 
775  if (action.startsWith("EXEC "))
776  {
777  QString rest = action.right(action.length() - 5);
778  if (cbs && cbs->exec_program)
779  cbs->exec_program(rest);
780 
781  return false;
782  }
783  if (action.startsWith("EXECTV "))
784  {
785  QString rest = action.right(action.length() - 7).trimmed();
786  if (cbs && cbs->exec_program_tv)
787  cbs->exec_program_tv(rest);
788  }
789  else if (action.startsWith("MENU "))
790  {
791  QString menu = action.right(action.length() - 5);
792 
793  MythScreenStack *stack = GetScreenStack();
794 
795  auto *newmenu = new MythThemedMenu("", menu, stack, menu, false, m_state);
796  if (newmenu->foundTheme())
797  stack->AddScreen(newmenu);
798  else
799  delete newmenu;
800  }
801  else if (action.startsWith("UPMENU"))
802  {
803  m_wantpop = true;
804  }
805  else if (action.startsWith("CONFIGPLUGIN"))
806  {
807  QString rest = action.right(action.length() - 13);
808  if (cbs && cbs->configplugin)
809  cbs->configplugin(rest);
810  }
811  else if (action.startsWith("PLUGIN"))
812  {
813  QString rest = action.right(action.length() - 7);
814  if (cbs && cbs->plugin)
815  cbs->plugin(rest);
816  }
817  else if (action.startsWith("SHUTDOWN"))
818  {
819  if (m_allocedstate)
820  {
821  m_wantpop = true;
822  }
823  }
824  else if (action.startsWith("EJECT"))
825  {
826  if (cbs && cbs->eject)
827  cbs->eject();
828  }
829  else if (action.startsWith("JUMP "))
830  {
831  QString rest = action.right(action.length() - 5);
832  GetMythMainWindow()->JumpTo(rest, false);
833  }
834  else if (action.startsWith("MEDIA "))
835  {
836  // the format is MEDIA HANDLER URL
837  // TODO: allow spaces in the url
838  QStringList list = action.simplified().split(' ');
839  if (list.size() >= 3)
840  GetMythMainWindow()->HandleMedia(list[1], list[2]);
841  }
842  else
843  {
845  if (m_state->m_callback)
847  else
848  LOG(VB_GENERAL, LOG_ERR, "Unknown menu action: " + action);
849  }
850 
851  return true;
852 }
853 
854 bool MythThemedMenu::findDepends(const QString &fileList)
855 {
856  QStringList files = fileList.split(" ");
857  MythPluginManager *pluginManager = gCoreContext->GetPluginManager();
858 
859  for (const auto & file : qAsConst(files))
860  {
861  QString filename = findMenuFile(file);
862  if (!filename.isEmpty() && filename.endsWith(".xml"))
863  return true;
864 
865  // Has plugin by this name been successfully loaded
866  MythPlugin *plugin = pluginManager->GetPlugin(file);
867  if (plugin)
868  return true;
869  }
870 
871  return false;
872 }
873 
875 {
876  QFileInfo filename_info(filename);
877 
878  return filename_info.exists() && filename_info.isFile() && filename_info.isExecutable();
879 }
880 
887 bool MythThemedMenu::checkPinCode(const QString &password_setting)
888 {
889  QString timestamp_setting = QString("%1Time").arg(password_setting);
890  QDateTime curr_time = MythDate::current();
891  QString last_time_stamp = GetMythDB()->GetSetting(timestamp_setting);
892  QString password = GetMythDB()->GetSetting(password_setting);
893 
894  // Password empty? Then skip asking for it
895  if (password.isEmpty())
896  return true;
897 
898  if (last_time_stamp.length() < 1)
899  {
900  LOG(VB_GENERAL, LOG_ERR,
901  "MythThemedMenu: Could not read password/pin time stamp.\n"
902  "This is only an issue if it happens repeatedly.");
903  }
904  else
905  {
906  QDateTime last_time = MythDate::fromString(last_time_stamp);
907  if (!last_time.isValid() || last_time.secsTo(curr_time) < 120)
908  {
909  last_time_stamp = MythDate::toString(
910  curr_time, MythDate::kDatabase);
911  GetMythDB()->SaveSetting(timestamp_setting, last_time_stamp);
912  return true;
913  }
914  }
915 
916  LOG(VB_GENERAL, LOG_INFO, QString("Using Password: %1")
917  .arg(password_setting));
918 
919  QString text = tr("Enter password:");
920  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
921  auto *dialog = new MythTextInputDialog(popupStack, text, FilterNone, true);
922 
923  if (dialog->Create())
924  {
925  dialog->SetReturnEvent(this, "password");
926  popupStack->AddScreen(dialog);
927  }
928  else
929  delete dialog;
930 
931  return false;
932 }
933 
938 {
939  if (!event)
940  return;
941 
942  MythMediaDevice *device = event->getDevice();
943 
944  if (!device)
945  return;
946 
947  MythMediaType type = device->getMediaType();
948  MythMediaStatus status = device->getStatus();
949 
950  if ((status & ~MEDIASTAT_USEABLE) &&
951  (status & ~MEDIASTAT_MOUNTED))
952  return;
953 
954  switch (type)
955  {
956  case MEDIATYPE_DVD :
957  case MEDIATYPE_BD :
958  // DVD or Blu-ray Available
959  break;
960  default :
961  return;
962  }
963 }
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
static bool findDepends(const QString &fileList)
MythMediaType
Definition: mythmedia.h:24
static 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
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
Definition: mythdate.cpp:30
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:135
void mediaEvent(MythMediaEvent *event) override
Media/Device status event handler, received from MythMediaMonitor.
QDomDocument doc("MYTHARCHIVEITEM")
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:57
bool keyPressEvent(QKeyEvent *e) override
keyboard/LIRC event handler.
int GetNumSetting(const QString &key, int defaultval)
Definition: mythdb.cpp:572
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)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
MythPluginManager * GetPluginManager(void)
Default UTC, database format.
Definition: mythdate.h:24
A C++ ripoff of the stroke library for MythTV.
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
MythUIStateType * m_watermarkState
static QString getFirstText(QDomElement &element)
QString password
QString GetShareDir(void)
Definition: mythdirs.cpp:222
bool GetBoolSetting(const QString &key, bool defaultval)
Definition: mythdb.cpp:564
QString GetMenuThemeDir(void)
void(* configplugin)(const QString &cmd)
Definition: mythuihelper.h:36
MythUIStateType * m_titleState
void JumpTo(const QString &destination, bool pop=true)
uint myth_system(const QString &command, uint flags, uint timeout)
MythPlugin * GetPlugin(const QString &plugname)
Definition: mythplugin.cpp:212
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:370
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)
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Dialog prompting the user to enter a text string.
#define MYTH_APPNAME_MYTHFRONTEND
void SetLCDTitles(const QString &title, const QString &columnList="")
bool foundTheme(void) const
Returns true iff a theme has been found by a previous call to SetMenuTheme().
virtual void PopScreen(MythScreenType *screen=nullptr, bool allowFade=true, bool deleteScreen=true)
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
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)
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
static QString findMenuFile(const QString &menuname)
Locates the appropriate menu file from which to parse the menu.
MythMediaStatus
Definition: mythmedia.h:12
~MythThemedMenu() override
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)
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:41
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:130
MythUIMenuCallbacks * GetMenuCBs(void)
void buttonAction(MythUIButtonListItem *item, bool skipPass=false)
MythMediaStatus getStatus() const
Definition: mythmedia.h:70
MythUIButtonListItem * GetItemCurrent() const
bool Create(void) override
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23