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  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  {
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  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  (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 = qApp->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 = qApp->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  {
629  parseThemeButton(e);
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  qVariantFromValue(newbutton));
696 
697  listbuttonitem->DisplayState(type, "icon");
698  listbuttonitem->SetText(description, "description");
699 }
700 
702 {
703  ThemedButton button = item->GetData().value<ThemedButton>();
704 
705  QString password;
706  if (!skipPass)
707  password = button.password;
708 
709  QStringList::Iterator it = button.action.begin();
710  for (; it != button.action.end(); it++)
711  {
712  if (handleAction(*it, password))
713  break;
714  }
715 }
716 
722 QString MythThemedMenu::findMenuFile(const QString &menuname)
723 {
724  QString testdir = GetConfDir() + '/' + menuname;
725  QFile file(testdir);
726  if (file.exists())
727  return testdir;
728  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
729 
730  testdir = GetMythUI()->GetMenuThemeDir() + '/' + menuname;
731  file.setFileName(testdir);
732  if (file.exists())
733  return testdir;
734  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
735 
736  testdir = GetMythUI()->GetThemeDir() + '/' + menuname;
737  file.setFileName(testdir);
738  if (file.exists())
739  return testdir;
740  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
741 
742  testdir = GetShareDir() + menuname;
743  file.setFileName(testdir);
744  if (file.exists())
745  return testdir;
746  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
747 
748  testdir = "../mythfrontend/" + menuname;
749  file.setFileName(testdir);
750  if (file.exists())
751  return testdir;
752  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
753 
754  testdir = GetShareDir() + "themes/defaultmenu/" + menuname;
755  file.setFileName(testdir);
756  if (file.exists())
757  return testdir;
758  LOG(VB_FILE, LOG_DEBUG, "No menu file " + testdir);
759 
760  return QString();
761 }
762 
769 bool MythThemedMenu::handleAction(const QString &action, const QString &password)
770 {
772 
773  if (!password.isEmpty() && !checkPinCode(password))
774  return true;
775 
776  if (action.startsWith("EXEC "))
777  {
778  QString rest = action.right(action.length() - 5);
779  if (cbs && cbs->exec_program)
780  cbs->exec_program(rest);
781 
782  return false;
783  }
784  if (action.startsWith("EXECTV "))
785  {
786  QString rest = action.right(action.length() - 7).trimmed();
787  if (cbs && cbs->exec_program_tv)
788  cbs->exec_program_tv(rest);
789  }
790  else if (action.startsWith("MENU "))
791  {
792  QString menu = action.right(action.length() - 5);
793 
794  MythScreenStack *stack = GetScreenStack();
795 
796  auto *newmenu = new MythThemedMenu("", menu, stack, menu, false, m_state);
797  if (newmenu->foundTheme())
798  stack->AddScreen(newmenu);
799  else
800  delete newmenu;
801  }
802  else if (action.startsWith("UPMENU"))
803  {
804  m_wantpop = true;
805  }
806  else if (action.startsWith("CONFIGPLUGIN"))
807  {
808  QString rest = action.right(action.length() - 13);
809  if (cbs && cbs->configplugin)
810  cbs->configplugin(rest);
811  }
812  else if (action.startsWith("PLUGIN"))
813  {
814  QString rest = action.right(action.length() - 7);
815  if (cbs && cbs->plugin)
816  cbs->plugin(rest);
817  }
818  else if (action.startsWith("SHUTDOWN"))
819  {
820  if (m_allocedstate)
821  {
822  m_wantpop = true;
823  }
824  }
825  else if (action.startsWith("EJECT"))
826  {
827  if (cbs && cbs->eject)
828  cbs->eject();
829  }
830  else if (action.startsWith("JUMP "))
831  {
832  QString rest = action.right(action.length() - 5);
833  GetMythMainWindow()->JumpTo(rest, false);
834  }
835  else if (action.startsWith("MEDIA "))
836  {
837  // the format is MEDIA HANDLER URL
838  // TODO: allow spaces in the url
839  QStringList list = action.simplified().split(' ');
840  if (list.size() >= 3)
841  GetMythMainWindow()->HandleMedia(list[1], list[2]);
842  }
843  else
844  {
846  if (m_state->m_callback)
848  else
849  LOG(VB_GENERAL, LOG_ERR, "Unknown menu action: " + action);
850  }
851 
852  return true;
853 }
854 
855 bool MythThemedMenu::findDepends(const QString &fileList)
856 {
857  QStringList files = fileList.split(" ");
858  MythPluginManager *pluginManager = gCoreContext->GetPluginManager();
859 
860  for (QStringList::Iterator it = files.begin(); it != files.end(); ++it )
861  {
862  QString filename = findMenuFile(*it);
863  if (!filename.isEmpty() && filename.endsWith(".xml"))
864  return true;
865 
866  // Has plugin by this name been successfully loaded
867  MythPlugin *plugin = pluginManager->GetPlugin(*it);
868  if (plugin)
869  return true;
870  }
871 
872  return false;
873 }
874 
876 {
877  QFileInfo filename_info(filename);
878 
879  return filename_info.exists() && filename_info.isFile() && filename_info.isExecutable();
880 }
881 
888 bool MythThemedMenu::checkPinCode(const QString &password_setting)
889 {
890  QString timestamp_setting = QString("%1Time").arg(password_setting);
891  QDateTime curr_time = MythDate::current();
892  QString last_time_stamp = GetMythDB()->GetSetting(timestamp_setting);
893  QString password = GetMythDB()->GetSetting(password_setting);
894 
895  // Password empty? Then skip asking for it
896  if (password.isEmpty())
897  return true;
898 
899  if (last_time_stamp.length() < 1)
900  {
901  LOG(VB_GENERAL, LOG_ERR,
902  "MythThemedMenu: Could not read password/pin time stamp.\n"
903  "This is only an issue if it happens repeatedly.");
904  }
905  else
906  {
907  QDateTime last_time = MythDate::fromString(last_time_stamp);
908  if (!last_time.isValid() || last_time.secsTo(curr_time) < 120)
909  {
910  last_time_stamp = MythDate::toString(
911  curr_time, MythDate::kDatabase);
912  GetMythDB()->SaveSetting(timestamp_setting, last_time_stamp);
913  return true;
914  }
915  }
916 
917  LOG(VB_GENERAL, LOG_INFO, QString("Using Password: %1")
918  .arg(password_setting));
919 
920  QString text = tr("Enter password:");
921  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
922  auto *dialog = new MythTextInputDialog(popupStack, text, FilterNone, true);
923 
924  if (dialog->Create())
925  {
926  dialog->SetReturnEvent(this, "password");
927  popupStack->AddScreen(dialog);
928  }
929  else
930  delete dialog;
931 
932  return false;
933 }
934 
939 {
940  if (!event)
941  return;
942 
943  MythMediaDevice *device = event->getDevice();
944 
945  if (!device)
946  return;
947 
948  MythMediaType type = device->getMediaType();
949  MythMediaStatus status = device->getStatus();
950 
951  if ((status & ~MEDIASTAT_USEABLE) &&
952  (status & ~MEDIASTAT_MOUNTED))
953  return;
954 
955  switch (type)
956  {
957  case MEDIATYPE_DVD :
958  case MEDIATYPE_BD :
959  // DVD or Blu-ray Available
960  break;
961  default :
962  return;
963  }
964 }
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
void CopyFrom(MythUIType *) override
Copy this widgets state from another.
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
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.
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)
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:555
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:215
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
#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().
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
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
MythUIMenuCallbacks * GetMenuCBs(void)
void buttonAction(MythUIButtonListItem *item, bool skipPass=false)
MythMediaStatus getStatus() const
Definition: mythmedia.h:70
MythUIButtonListItem * GetItemCurrent() const
bool Create(void) override