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  MythThemedMenuState *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  ThemedButton button = item->GetData().value<ThemedButton>();
178  if (m_watermarkState)
179  {
180  if (!(m_watermarkState->DisplayState(button.type)))
182  }
183 
184  if (m_descriptionText)
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  {
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  ThemedButton 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 = qApp->translate("ThemeUI",
464  parseText(info).toUtf8() );
465  }
466  else if (info.attribute("lang","").toLower() ==
468  {
469  text = parseText(info);
470  }
471  else if (info.attribute("lang","").toLower() ==
473  {
474  text = parseText(info);
475  }
476  }
477  else if (info.tagName() == "alttext")
478  {
479  if (alttext.isEmpty() &&
480  info.attribute("lang","").isEmpty())
481  {
482  alttext = qApp->translate("ThemeUI",
483  parseText(info).toUtf8());
484  }
485  else if (info.attribute("lang","").toLower() ==
487  {
488  alttext = parseText(info);
489  }
490  else if (info.attribute("lang","").toLower() ==
492  {
493  alttext = parseText(info);
494  }
495  }
496  else if (info.tagName() == "action")
497  {
498  action += getFirstText(info);
499  }
500  else if (info.tagName() == "depends")
501  {
502  addit = findDepends(getFirstText(info));
503  }
504  else if (info.tagName() == "dependsexec")
505  {
506  addit = findDependsExec(getFirstText(info));
507  }
508  else if (info.tagName() == "dependssetting")
509  {
510  addit = GetMythDB()->GetBoolSetting(getFirstText(info));
511  }
512  else if (info.tagName() == "dependjumppoint")
513  {
515  getFirstText(info));
516  }
517  else if (info.tagName() == "dependswindow")
518  {
519  QString xmlFile = info.attribute("xmlfile", "");
520  QString windowName = getFirstText(info);
521  if (xmlFile.isEmpty() || windowName.isEmpty())
522  addit = false;
523  else
524  addit = XMLParseBase::WindowExists(xmlFile, windowName);
525  }
526  else if (info.tagName() == "description")
527  {
528  if (description.isEmpty() &&
529  info.attribute("lang","").isEmpty())
530  {
531  description = qApp->translate("ThemeUI",
532  getFirstText(info).toUtf8());
533  }
534  else if (info.attribute("lang","").toLower() ==
536  {
537  description = getFirstText(info);
538  }
539  else if (info.attribute("lang","").toLower() ==
541  {
542  description = getFirstText(info);
543  }
544  }
545  else if (info.tagName() == "password")
546  {
547  password = getFirstText(info);
548  }
549  else
550  {
551  LOG(VB_GENERAL, LOG_ERR,
552  QString("MythThemedMenu: Unknown tag %1 in button")
553  .arg(info.tagName()));
554  }
555  }
556  }
557 
558  if (text.isEmpty())
559  {
560  LOG(VB_GENERAL, LOG_ERR, "MythThemedMenu: Missing 'text' in button");
561  return;
562  }
563 
564  if (action.empty())
565  {
566  LOG(VB_GENERAL, LOG_ERR, "MythThemedMenu: Missing 'action' in button");
567  return;
568  }
569 
570  if (addit)
571  addButton(type, text, alttext, action, description, password);
572 }
573 
587 bool MythThemedMenu::parseMenu(const QString &menuname)
588 {
589  QString filename = findMenuFile(menuname);
590 
591  QDomDocument doc;
592  QFile f(filename);
593 
594  if (!f.exists() || !f.open(QIODevice::ReadOnly))
595  {
596  LOG(VB_GENERAL, LOG_ERR, QString("MythThemedMenu: Couldn't read "
597  "menu file %1").arg(menuname));
598 
599  if (menuname != "mainmenu.xml")
600  ShowOkPopup(tr("MythTV could not locate the menu file %1")
601  .arg(menuname));
602  return false;
603  }
604 
605  QString errorMsg;
606  int errorLine = 0;
607  int errorColumn = 0;
608 
609  if (!doc.setContent(&f, false, &errorMsg, &errorLine, &errorColumn))
610  {
611  LOG(VB_GENERAL, LOG_ERR,
612  QString("Error parsing: %1\nat line: %2 column: %3 msg: %4").
613  arg(filename).arg(errorLine).arg(errorColumn).arg(errorMsg));
614  f.close();
615 
616  if (menuname != "mainmenu.xml")
617  ShowOkPopup(tr("The menu file %1 is incomplete.")
618  .arg(menuname));
619  return false;
620  }
621 
622  f.close();
623 
624  LOG(VB_GUI, LOG_INFO, QString("Loading menu theme from %1").arg(filename));
625 
626  QDomElement docElem = doc.documentElement();
627 
628  m_menumode = docElem.attribute("name", "MAIN");
629 
630  QDomNode n = docElem.firstChild();
631  while (!n.isNull())
632  {
633  QDomElement e = n.toElement();
634  if (!e.isNull())
635  {
636  if (e.tagName() == "button")
637  {
638  parseThemeButton(e);
639  }
640  else
641  {
642  LOG(VB_GENERAL, LOG_ERR,
643  QString("MythThemedMenu: Unknown element %1")
644  .arg(e.tagName()));
645  return false;
646  }
647  }
648  n = n.nextSibling();
649  }
650 
651  if (m_buttonList->GetCount() == 0)
652  {
653  LOG(VB_GENERAL, LOG_ERR,
654  QString("MythThemedMenu: No buttons for menu %1").arg(menuname));
655  return false;
656  }
657 
659 
660  if (m_titleState)
661  {
664  }
665 
666  m_selection.clear();
667  return true;
668 }
669 
686 void MythThemedMenu::addButton(const QString &type, const QString &text,
687  const QString &alttext,
688  const QStringList &action,
689  const QString &description,
690  const QString &password)
691 {
692  ThemedButton newbutton;
693  newbutton.type = type;
694  newbutton.action = action;
695  newbutton.text = text;
696  newbutton.alttext = alttext;
697  newbutton.description = description;
698  newbutton.password = password;
699 
700  if (m_watermarkState)
702 
703  MythUIButtonListItem *listbuttonitem =
705  qVariantFromValue(newbutton));
706 
707  listbuttonitem->DisplayState(type, "icon");
708  listbuttonitem->SetText(description, "description");
709 }
710 
712 {
713  ThemedButton button = item->GetData().value<ThemedButton>();
714 
715  QString password;
716  if (!skipPass)
717  password = button.password;
718 
719  QStringList::Iterator it = button.action.begin();
720  for (; it != button.action.end(); it++)
721  {
722  if (handleAction(*it, password))
723  break;
724  }
725 }
726 
732 QString MythThemedMenu::findMenuFile(const QString &menuname)
733 {
734  QString testdir = GetConfDir() + '/' + menuname;
735  QFile file(testdir);
736  if (file.exists())
737  return testdir;
738  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
739 
740  testdir = GetMythUI()->GetMenuThemeDir() + '/' + menuname;
741  file.setFileName(testdir);
742  if (file.exists())
743  return testdir;
744  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
745 
746  testdir = GetMythUI()->GetThemeDir() + '/' + menuname;
747  file.setFileName(testdir);
748  if (file.exists())
749  return testdir;
750  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
751 
752  testdir = GetShareDir() + menuname;
753  file.setFileName(testdir);
754  if (file.exists())
755  return testdir;
756  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
757 
758  testdir = "../mythfrontend/" + menuname;
759  file.setFileName(testdir);
760  if (file.exists())
761  return testdir;
762  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
763 
764  testdir = GetShareDir() + "themes/defaultmenu/" + menuname;
765  file.setFileName(testdir);
766  if (file.exists())
767  return testdir;
768  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
769 
770  return QString();
771 }
772 
779 bool MythThemedMenu::handleAction(const QString &action, const QString &password)
780 {
782 
783  if (!password.isEmpty() && !checkPinCode(password))
784  return true;
785 
786  if (action.startsWith("EXEC "))
787  {
788  QString rest = action.right(action.length() - 5);
789  if (cbs && cbs->exec_program)
790  cbs->exec_program(rest);
791 
792  return false;
793  }
794  if (action.startsWith("EXECTV "))
795  {
796  QString rest = action.right(action.length() - 7).trimmed();
797  if (cbs && cbs->exec_program_tv)
798  cbs->exec_program_tv(rest);
799  }
800  else if (action.startsWith("MENU "))
801  {
802  QString menu = action.right(action.length() - 5);
803 
804  MythScreenStack *stack = GetScreenStack();
805 
806  MythThemedMenu *newmenu = new MythThemedMenu("", menu, stack, menu,
807  false, m_state);
808  if (newmenu->foundTheme())
809  stack->AddScreen(newmenu);
810  else
811  delete newmenu;
812  }
813  else if (action.startsWith("UPMENU"))
814  {
815  m_wantpop = true;
816  }
817  else if (action.startsWith("CONFIGPLUGIN"))
818  {
819  QString rest = action.right(action.length() - 13);
820  if (cbs && cbs->configplugin)
821  cbs->configplugin(rest);
822  }
823  else if (action.startsWith("PLUGIN"))
824  {
825  QString rest = action.right(action.length() - 7);
826  if (cbs && cbs->plugin)
827  cbs->plugin(rest);
828  }
829  else if (action.startsWith("SHUTDOWN"))
830  {
831  if (m_allocedstate)
832  {
833  m_wantpop = true;
834  }
835  }
836  else if (action.startsWith("EJECT"))
837  {
838  if (cbs && cbs->eject)
839  cbs->eject();
840  }
841  else if (action.startsWith("JUMP "))
842  {
843  QString rest = action.right(action.length() - 5);
844  GetMythMainWindow()->JumpTo(rest, false);
845  }
846  else if (action.startsWith("MEDIA "))
847  {
848  // the format is MEDIA HANDLER URL
849  // TODO: allow spaces in the url
850  QStringList list = action.simplified().split(' ');
851  if (list.size() >= 3)
852  GetMythMainWindow()->HandleMedia(list[1], list[2]);
853  }
854  else
855  {
857  if (m_state->m_callback)
859  else
860  LOG(VB_GENERAL, LOG_ERR, "Unknown menu action: " + action);
861  }
862 
863  return true;
864 }
865 
866 bool MythThemedMenu::findDepends(const QString &fileList)
867 {
868  QStringList files = fileList.split(" ");
869  MythPluginManager *pluginManager = gCoreContext->GetPluginManager();
870 
871  for (QStringList::Iterator it = files.begin(); it != files.end(); ++it )
872  {
873  QString filename = findMenuFile(*it);
874  if (!filename.isEmpty() && filename.endsWith(".xml"))
875  return true;
876 
877  // Has plugin by this name been successfully loaded
878  MythPlugin *plugin = pluginManager->GetPlugin(*it);
879  if (plugin)
880  return true;
881  }
882 
883  return false;
884 }
885 
886 bool MythThemedMenu::findDependsExec(const QString &filename)
887 {
888  QFileInfo filename_info(filename);
889 
890  return filename_info.exists() && filename_info.isFile() && filename_info.isExecutable();
891 }
892 
899 bool MythThemedMenu::checkPinCode(const QString &password_setting)
900 {
901  QString timestamp_setting = QString("%1Time").arg(password_setting);
902  QDateTime curr_time = MythDate::current();
903  QString last_time_stamp = GetMythDB()->GetSetting(timestamp_setting);
904  QString password = GetMythDB()->GetSetting(password_setting);
905 
906  // Password empty? Then skip asking for it
907  if (password.isEmpty())
908  return true;
909 
910  if (last_time_stamp.length() < 1)
911  {
912  LOG(VB_GENERAL, LOG_ERR,
913  "MythThemedMenu: Could not read password/pin time stamp.\n"
914  "This is only an issue if it happens repeatedly.");
915  }
916  else
917  {
918  QDateTime last_time = MythDate::fromString(last_time_stamp);
919  if (!last_time.isValid() || last_time.secsTo(curr_time) < 120)
920  {
921  last_time_stamp = MythDate::toString(
922  curr_time, MythDate::kDatabase);
923  GetMythDB()->SaveSetting(timestamp_setting, last_time_stamp);
924  return true;
925  }
926  }
927 
928  LOG(VB_GENERAL, LOG_INFO, QString("Using Password: %1")
929  .arg(password_setting));
930 
931  QString text = tr("Enter password:");
932  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
933  MythTextInputDialog *dialog =
934  new MythTextInputDialog(popupStack, text, FilterNone, true);
935 
936  if (dialog->Create())
937  {
938  dialog->SetReturnEvent(this, "password");
939  popupStack->AddScreen(dialog);
940  }
941  else
942  delete dialog;
943 
944  return false;
945 }
946 
951 {
952  if (!event)
953  return;
954 
955  MythMediaDevice *device = event->getDevice();
956 
957  if (!device)
958  return;
959 
960  MythMediaType type = device->getMediaType();
961  MythMediaStatus status = device->getStatus();
962 
963  if ((status & ~MEDIASTAT_USEABLE) &&
964  (status & ~MEDIASTAT_MOUNTED))
965  return;
966 
967  switch (type)
968  {
969  case MEDIATYPE_DVD :
970  // DVD Available
971  break;
972  case MEDIATYPE_BD :
973  // Blu-ray Available
974  break;
975  default :
976  return;
977  }
978 }
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:136
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
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)
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:329
QString password
QString GetShareDir(void)
Definition: mythdirs.cpp:222
bool GetBoolSetting(const QString &key, bool defaultval)
Definition: mythdb.cpp:555
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:328
uint myth_system(const QString &command, uint flags, uint timeout)
MythPlugin * GetPlugin(const QString &plugname)
Definition: mythplugin.cpp:217
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.
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)
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:132
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
Definition: mythdate.cpp:30
void DisplayState(const QString &state, const QString &name)
MythUIMenuCallbacks * GetMenuCBs(void)
void buttonAction(MythUIButtonListItem *item, bool skipPass=false)
MythMediaStatus getStatus() const
Definition: mythmedia.h:70
MythUIButtonListItem * GetItemCurrent() const
bool Create(void) override