MythTV  master
mythmainwindow.cpp
Go to the documentation of this file.
1 #include "mythmainwindow.h"
3 
4 // C headers
5 #include <cmath>
6 
7 // C++ headers
8 #include <algorithm>
9 #include <chrono>
10 #include <utility>
11 #include <vector>
12 
13 // QT
14 #include <QWaitCondition>
15 #include <QApplication>
16 #include <QHash>
17 #include <QFile>
18 #include <QDir>
19 #include <QEvent>
20 #include <QKeyEvent>
21 #include <QKeySequence>
22 #include <QSize>
23 #include <QWindow>
24 
25 // Platform headers
26 #include "unistd.h"
27 
28 // libmythbase headers
29 #include "mythdb.h"
30 #include "mythlogging.h"
31 #include "mythevent.h"
32 #include "mythdirs.h"
33 #include "compat.h"
34 #include "mythcorecontext.h"
35 #include "mythmedia.h"
36 #include "mythmiscutil.h"
37 #include "mythdate.h"
38 
39 // libmythui headers
40 #include "myththemebase.h"
41 #include "mythudplistener.h"
42 #include "mythrender_base.h"
43 #include "mythuistatetracker.h"
44 #include "mythuiactions.h"
45 #include "mythrect.h"
46 #include "mythdisplay.h"
47 #include "mythscreentype.h"
48 #include "mythpainter.h"
49 #include "mythpainterwindow.h"
50 #include "mythgesture.h"
51 #include "mythuihelper.h"
52 #include "mythdialogbox.h"
53 #include "mythscreensaver.h"
55 
56 
57 #ifdef Q_OS_ANDROID
58 #include <QtAndroid>
59 #endif
60 
61 static constexpr std::chrono::milliseconds GESTURE_TIMEOUT { 1s };
62 static constexpr std::chrono::minutes STANDBY_TIMEOUT { 90min };
63 static constexpr std::chrono::milliseconds LONGPRESS_INTERVAL { 1s };
64 
65 #define LOC QString("MythMainWindow: ")
66 
67 static MythMainWindow *mainWin = nullptr;
68 static QMutex mainLock;
69 
78 {
79  if (mainWin)
80  return mainWin;
81 
82  QMutexLocker lock(&mainLock);
83 
84  if (!mainWin)
85  {
86  mainWin = new MythMainWindow(UseDB);
88  }
89 
90  return mainWin;
91 }
92 
94 {
95  if (gCoreContext)
96  gCoreContext->SetGUIObject(nullptr);
97  delete mainWin;
98  mainWin = nullptr;
99 }
100 
102 {
104 }
105 
107 {
108  return mainWin != nullptr;
109 }
110 
112 {
114 }
115 
117 {
119 }
120 
122 {
124  return nullptr;
126 }
127 
129 {
131 
132  // Switch to desired GUI resolution
133  if (m_display->UsingVideoModes())
134  m_display->SwitchToGUI(true);
135 
138 
140 
141  setObjectName("mainwindow");
142 
143  m_priv->m_allowInput = false;
144 
145  // This prevents database errors from RegisterKey() when there is no DB:
146  m_priv->m_useDB = UseDB;
147 
148  //Init();
149 
150  m_priv->m_exitingtomain = false;
151  m_priv->m_popwindows = true;
152  m_priv->m_exitMenuCallback = nullptr;
154  m_priv->m_mediaDeviceForCallback = nullptr;
155  m_priv->m_escapekey = Qt::Key_Escape;
156  m_priv->m_mainStack = nullptr;
157 
158  installEventFilter(this);
159 
161 
162  InitKeys();
163 
164  m_priv->m_gestureTimer = new QTimer(this);
166  m_priv->m_hideMouseTimer = new QTimer(this);
167  m_priv->m_hideMouseTimer->setSingleShot(true);
168  m_priv->m_hideMouseTimer->setInterval(3s);
170  m_priv->m_allowInput = true;
172  m_refreshTimer.setInterval(17ms);
173  m_refreshTimer.start();
174  setUpdatesEnabled(true);
175 
177  Qt::BlockingQueuedConnection);
179  Qt::BlockingQueuedConnection);
180 #ifdef Q_OS_ANDROID
181  connect(qApp, &QApplication::applicationStateChanged, this, &MythMainWindow::OnApplicationStateChange);
182 #endif
183 
184  // We need to listen for playback start/end events
185  gCoreContext->addListener(this);
186 
187  // Idle timer setup
188  m_idleTime =
189  gCoreContext->GetDurSetting<std::chrono::minutes>("FrontendIdleTimeout",
191  if (m_idleTime < 0min)
192  m_idleTime = 0min;
193  m_idleTimer.setInterval(m_idleTime);
195  if (m_idleTime > 0min)
196  m_idleTimer.start();
197 
199  if (m_screensaver)
200  {
204  }
205 }
206 
208 {
209  delete m_screensaver;
210 
211  if (gCoreContext != nullptr)
213 
215 
216  while (!m_priv->m_stackList.isEmpty())
217  {
218  MythScreenStack *stack = m_priv->m_stackList.back();
219  m_priv->m_stackList.pop_back();
220 
221  if (stack == m_priv->m_mainStack)
222  m_priv->m_mainStack = nullptr;
223 
224  delete stack;
225  }
226 
227  delete m_themeBase;
228 
229  while (!m_priv->m_keyContexts.isEmpty())
230  {
231  KeyContext *context = *m_priv->m_keyContexts.begin();
232  m_priv->m_keyContexts.erase(m_priv->m_keyContexts.begin());
233  delete context;
234  }
235 
236  delete m_deviceHandler;
237  delete m_priv->m_nc;
238 
240 
241  // N.B. we always call this to ensure the desktop mode is restored
242  // in case the setting was changed
244  delete m_display;
245 
246  delete m_priv;
247 }
248 
250 {
251  return m_display;
252 }
253 
255 {
256  return m_painter;
257 }
258 
260 {
261  return m_priv->m_nc;
262 }
263 
265 {
266  return m_painterWin;
267 }
268 
270 {
271  if (m_painterWin)
272  {
273  m_painterWin->show();
274  m_painterWin->raise();
275  }
276 }
277 
279 {
280  if (m_painterWin)
281  {
282  m_painterWin->clearMask();
284  m_painterWin->hide();
285  }
286 }
287 
289 {
290  return m_painterWin->GetRenderDevice();
291 }
292 
294 {
295  m_priv->m_stackList.push_back(Stack);
296  if (Main)
297  m_priv->m_mainStack = Stack;
298 }
299 
301 {
302  MythScreenStack *stack = m_priv->m_stackList.back();
303  m_priv->m_stackList.pop_back();
304  if (stack == m_priv->m_mainStack)
305  m_priv->m_mainStack = nullptr;
306  delete stack;
307 }
308 
310 {
311  return m_priv->m_stackList.size();
312 }
313 
315 {
316  return m_priv->m_mainStack;
317 }
318 
319 MythScreenStack *MythMainWindow::GetStack(const QString& Stackname)
320 {
321  for (auto * widget : qAsConst(m_priv->m_stackList))
322  if (widget->objectName() == Stackname)
323  return widget;
324  return nullptr;
325 }
326 
328 {
329  if (Position >= 0 && Position < m_priv->m_stackList.size())
330  return m_priv->m_stackList.at(Position);
331  return nullptr;
332 }
333 
335 {
336  if (!(m_painterWin && updatesEnabled()))
337  return;
338 
339  bool redraw = false;
340 
341  if (!m_repaintRegion.isEmpty())
342  redraw = true;
343 
344  // The call to GetDrawOrder can apparently alter m_stackList.
345  // NOLINTNEXTLINE(modernize-loop-convert,readability-qualified-auto) // both, qt6
346  for (auto it = m_priv->m_stackList.begin(); it != m_priv->m_stackList.end(); ++it)
347  {
348  QVector<MythScreenType *> drawList;
349  (*it)->GetDrawOrder(drawList);
350 
351  for (auto *screen : qAsConst(drawList))
352  {
353  screen->Pulse();
354 
355  if (screen->NeedsRedraw())
356  {
357  QRegion topDirty = screen->GetDirtyArea();
358  screen->ResetNeedsRedraw();
359  m_repaintRegion = m_repaintRegion.united(topDirty);
360  redraw = true;
361  }
362  }
363  }
364 
365  if (redraw && !m_painterWin->RenderIsShared())
366  m_painterWin->update(m_repaintRegion);
367 
368  for (auto *widget : qAsConst(m_priv->m_stackList))
369  widget->ScheduleInitIfNeeded();
370 }
371 
373 {
374  if (!(m_painterWin && updatesEnabled()))
375  return;
376 
377  if (Event)
378  m_repaintRegion = m_repaintRegion.united(Event->region());
379 
380  if (!m_painter->SupportsClipping())
381  {
383  }
384  else
385  {
386  // Ensure that the region is not larger than the screen which
387  // can happen with bad themes
389 
390  // Check for any widgets that have been updated since we built
391  // the dirty region list in ::animate()
392  // The call to GetDrawOrder can apparently alter m_stackList.
393  // NOLINTNEXTLINE(modernize-loop-convert,readability-qualified-auto) // both, qt6
394  for (auto it = m_priv->m_stackList.begin(); it != m_priv->m_stackList.end(); ++it)
395  {
396  QVector<MythScreenType *> redrawList;
397  (*it)->GetDrawOrder(redrawList);
398 
399  for (const auto *screen : qAsConst(redrawList))
400  {
401  if (screen->NeedsRedraw())
402  {
403  for (const QRect& wrect: screen->GetDirtyArea())
404  {
405  bool foundThisRect = false;
406  for (const QRect& drect: m_repaintRegion)
407  {
408  // Can't use QRegion::contains because it only
409  // checks for overlap. QRect::contains checks
410  // if fully contained.
411  if (drect.contains(wrect))
412  {
413  foundThisRect = true;
414  break;
415  }
416  }
417 
418  if (!foundThisRect)
419  return;
420  }
421  }
422  }
423  }
424  }
425 
427  Draw();
428 
429  m_repaintRegion = QRegion();
430 }
431 
433 {
434  if (!Painter)
435  Painter = m_painter;
436  if (!Painter)
437  return;
438 
439  Painter->Begin(m_painterWin);
440 
441  if (!Painter->SupportsClipping())
442  m_repaintRegion = QRegion(m_uiScreenRect);
443 
444  for (const QRect& rect : m_repaintRegion)
445  {
446  if (rect.width() == 0 || rect.height() == 0)
447  continue;
448 
449  if (rect != m_uiScreenRect)
450  Painter->SetClipRect(rect);
451 
452  // The call to GetDrawOrder can apparently alter m_stackList.
453  // NOLINTNEXTLINE(modernize-loop-convert,readability-qualified-auto) // both, qt6
454  for (auto it = m_priv->m_stackList.begin(); it != m_priv->m_stackList.end(); ++it)
455  {
456  QVector<MythScreenType *> redrawList;
457  (*it)->GetDrawOrder(redrawList);
458  for (auto *screen : qAsConst(redrawList))
459  screen->Draw(Painter, 0, 0, 255, rect);
460  }
461  }
462 
463  Painter->End();
464  m_repaintRegion = QRegion();
465 }
466 
467 // virtual
468 QPaintEngine *MythMainWindow::paintEngine() const
469 {
470  return testAttribute(Qt::WA_PaintOnScreen) ? nullptr : QWidget::paintEngine();
471 }
472 
474 {
475  if (Event->spontaneous())
476  {
477  auto * key = new QKeyEvent(QEvent::KeyPress, m_priv->m_escapekey, Qt::NoModifier);
478  QCoreApplication::postEvent(this, key);
479  Event->ignore();
480  return;
481  }
482 
483  QWidget::closeEvent(Event);
484 }
485 
486 void MythMainWindow::GrabWindow(QImage& Image)
487 {
488  WId winid = 0;
489  auto * active = QApplication::activeWindow();
490  if (active)
491  {
492  winid = active->winId();
493  }
494  else
495  {
496  // According to the following we page, you "just pass 0 as the
497  // window id, indicating that we want to grab the entire screen".
498  //
499  // https://doc.qt.io/qt-5/qtwidgets-desktop-screenshot-example.html#screenshot-class-implementation
500  winid = 0;
501  }
502 
503  auto * display = GetMythMainWindow()->GetDisplay();
504  if (auto * screen = display->GetCurrentScreen(); screen)
505  {
506  QPixmap image = screen->grabWindow(winid);
507  Image = image.toImage();
508  }
509 }
510 
511 /* This is required to allow a screenshot to be requested by another thread
512  * other than the UI thread, and to wait for the screenshot before returning.
513  * It is used by mythweb for the remote access screenshots
514  */
515 void MythMainWindow::DoRemoteScreenShot(const QString& Filename, int Width, int Height)
516 {
517  // This will be running in the UI thread, as is required by QPixmap
518  QStringList args;
519  args << QString::number(Width);
520  args << QString::number(Height);
521  args << Filename;
523  QCoreApplication::sendEvent(this, &me);
524 }
525 
526 void MythMainWindow::RemoteScreenShot(QString Filename, int Width, int Height)
527 {
528  // This will be running in a non-UI thread and is used to trigger a
529  // function in the UI thread, and waits for completion of that handler
530  emit SignalRemoteScreenShot(std::move(Filename), Width, Height);
531 }
532 
533 bool MythMainWindow::SaveScreenShot(const QImage& Image, QString Filename)
534 {
535  if (Filename.isEmpty())
536  {
537  QString fpath = GetMythDB()->GetSetting("ScreenShotPath", "/tmp");
538  Filename = QString("%1/myth-screenshot-%2.png")
540  }
541 
542  QString extension = Filename.section('.', -1, -1);
543  if (extension == "jpg")
544  extension = "JPEG";
545  else
546  extension = "PNG";
547 
548  LOG(VB_GENERAL, LOG_INFO, QString("Saving screenshot to %1 (%2x%3)")
549  .arg(Filename).arg(Image.width()).arg(Image.height()));
550 
551  if (Image.save(Filename, extension.toLatin1(), 100))
552  {
553  LOG(VB_GENERAL, LOG_INFO, "MythMainWindow::screenShot succeeded");
554  return true;
555  }
556 
557  LOG(VB_GENERAL, LOG_INFO, "MythMainWindow::screenShot Failed!");
558  return false;
559 }
560 
561 bool MythMainWindow::ScreenShot(int Width, int Height, QString Filename)
562 {
563  QImage img;
564  GrabWindow(img);
565  if (Width <= 0)
566  Width = img.width();
567  if (Height <= 0)
568  Height = img.height();
569  img = img.scaled(Width, Height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
570  return SaveScreenShot(img, std::move(Filename));
571 }
572 
574 {
575  if (HasMythMainWindow())
577 }
578 
580 {
581  if (HasMythMainWindow())
583 }
584 
586 {
587  if (HasMythMainWindow())
589 }
590 
592 {
593  if (HasMythMainWindow())
594  {
595  MythMainWindow* window = GetMythMainWindow();
596  if (window->m_screensaver)
597  return window->m_screensaver->Asleep();
598  }
599  return false;
600 }
601 
603 {
604  if (HasMythMainWindow())
606  return false;
607 }
608 
610 {
611  if (!updatesEnabled() && (Event->type() == QEvent::UpdateRequest))
612  m_priv->m_pendingUpdate = true;
613 
614  if (Event->type() == QEvent::Show && !Event->spontaneous())
615  QCoreApplication::postEvent(this, new QEvent(MythEvent::kMythPostShowEventType));
616 
618  {
619  raise();
620  activateWindow();
621  return true;
622  }
623 
624  if ((Event->type() == QEvent::WindowActivate) || (Event->type() == QEvent::WindowDeactivate))
626 
627  return QWidget::event(Event);
628 }
629 
631 {
634  QApplication::setStyle("Windows");
635 }
636 
637 void MythMainWindow::Init(bool MayReInit)
638 {
639  LoadQtConfig();
640  m_display->SetWidget(nullptr);
641  m_priv->m_useDB = ! gCoreContext->GetDB()->SuppressDBMessages();
642 
643  if (!(MayReInit || m_priv->m_firstinit))
644  return;
645 
646  // Set window border based on fullscreen attribute
647  Qt::WindowFlags flags = Qt::Window;
648 
650  bool inwindow = m_wantWindow && !m_qtFullScreen;
651  bool fullscreen = m_wantFullScreen && !GeometryIsOverridden();
652 
653  // On Compiz/Unit, when the window is fullscreen and frameless changing
654  // screen position ends up stuck. Adding a border temporarily prevents this
655  setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
656 
657  if (!inwindow)
658  {
659  LOG(VB_GENERAL, LOG_INFO, "Using Frameless Window");
660  flags |= Qt::FramelessWindowHint;
661  }
662 
663  // Workaround Qt/Windows playback bug?
664 #ifdef _WIN32
665  flags |= Qt::MSWindowsOwnDC;
666 #endif
667 
668  // NOTE if running fullscreen AND windowed (i.e. borders etc) then we do not
669  // have any idea at this time of the size of the borders/decorations.
670  // Typically, on linux, this means we create the UI slightly larger than
671  // required - as X adds the decorations at a later point.
672 
673  if (fullscreen && !inwindow)
674  {
675  LOG(VB_GENERAL, LOG_INFO, "Using Full Screen Window");
676  if (m_priv->m_firstinit)
677  {
678  // During initialization, we force being fullscreen using setWindowState
679  // otherwise, in ubuntu's unity, the side bar often stays visible
680  setWindowState(Qt::WindowFullScreen);
681  }
682  }
683  else
684  {
685  // reset type
686  setWindowState(Qt::WindowNoState);
687  }
688 
690  flags |= Qt::WindowStaysOnTopHint;
691 
692  setWindowFlags(flags);
693 
694  // SetWidget may move the widget into a new screen.
695  m_display->SetWidget(this);
696  QTimer::singleShot(1s, this, &MythMainWindow::DelayedAction);
697 
698  // Ensure we have latest screen bounds if we have moved
700  SetUIScreenRect({{0, 0}, m_screenRect.size()});
702  Show();
703 
704  // The window is sometimes not created until Show has been called - so try
705  // MythDisplay::setWidget again to ensure we listen for QScreen changes
706  m_display->SetWidget(this);
707 
708  if (!GetMythDB()->GetBoolSetting("HideMouseCursor", false))
709  setMouseTracking(true); // Required for mouse cursor auto-hide
710  // Set cursor call must come after Show() to work on some systems.
711  ShowMouseCursor(false);
712 
713  move(m_screenRect.topLeft());
714 
715  if (m_painterWin)
716  {
718  m_painterWin = nullptr;
719  }
720 
721  if (m_painter)
722  {
724  m_painter = nullptr;
725  }
726 
727  QString warningmsg;
728  if (!m_painter && !m_painterWin)
730 
731  if (!m_painterWin)
732  {
733  LOG(VB_GENERAL, LOG_ERR, "MythMainWindow failed to create a painter window.");
734  return;
735  }
736 
737  if (m_painter && m_painter->GetName() != "Qt")
738  {
739  setAttribute(Qt::WA_NoSystemBackground);
740  setAutoFillBackground(false);
741  }
742 
745 
746  // Redraw the window now to avoid race conditions in EGLFS (Qt5.4) if a
747  // 2nd window (e.g. TVPlayback) is created before this is redrawn.
748 #ifdef Q_OS_ANDROID
749 # define EARLY_SHOW_PLATFORM_NAME_CHECK "android"
750 #else
751 # define EARLY_SHOW_PLATFORM_NAME_CHECK "egl"
752 #endif
753  if (QGuiApplication::platformName().contains(EARLY_SHOW_PLATFORM_NAME_CHECK))
754  QCoreApplication::processEvents();
755 
756  if (!GetMythDB()->GetBoolSetting("HideMouseCursor", false))
757  m_painterWin->setMouseTracking(true); // Required for mouse cursor auto-hide
758 
760  if (m_themeBase)
761  m_themeBase->Reload();
762  else
763  m_themeBase = new MythThemeBase(this);
764 
765  if (!m_priv->m_nc)
767 
768  emit SignalWindowReady();
769 
770  if (!warningmsg.isEmpty())
771  {
772  MythNotification notification(warningmsg, "");
773  m_priv->m_nc->Queue(notification);
774  }
775 }
776 
778 {
780  Show();
781 
782 #ifdef Q_OS_ANDROID
783  QtAndroid::hideSplashScreen();
784 #endif
785 }
786 
788 {
789  RegisterKey("Global", ACTION_UP, QT_TRANSLATE_NOOP("MythControls",
790  "Up Arrow"), "Up");
791  RegisterKey("Global", ACTION_DOWN, QT_TRANSLATE_NOOP("MythControls",
792  "Down Arrow"), "Down");
793  RegisterKey("Global", ACTION_LEFT, QT_TRANSLATE_NOOP("MythControls",
794  "Left Arrow"), "Left");
795  RegisterKey("Global", ACTION_RIGHT, QT_TRANSLATE_NOOP("MythControls",
796  "Right Arrow"), "Right");
797  RegisterKey("Global", "NEXT", QT_TRANSLATE_NOOP("MythControls",
798  "Move to next widget"), "Tab");
799  RegisterKey("Global", "PREVIOUS", QT_TRANSLATE_NOOP("MythControls",
800  "Move to preview widget"), "Backtab");
801  RegisterKey("Global", ACTION_SELECT, QT_TRANSLATE_NOOP("MythControls",
802  "Select"), "Return,Enter,Space");
803  RegisterKey("Global", "BACKSPACE", QT_TRANSLATE_NOOP("MythControls",
804  "Backspace"), "Backspace");
805  RegisterKey("Global", "ESCAPE", QT_TRANSLATE_NOOP("MythControls",
806  "Escape"), "Esc");
807  RegisterKey("Global", "MENU", QT_TRANSLATE_NOOP("MythControls",
808  "Pop-up menu"), "M,Meta+Enter");
809  RegisterKey("Global", "INFO", QT_TRANSLATE_NOOP("MythControls",
810  "More information"), "I");
811  RegisterKey("Global", "DELETE", QT_TRANSLATE_NOOP("MythControls",
812  "Delete"), "D");
813  RegisterKey("Global", "EDIT", QT_TRANSLATE_NOOP("MythControls",
814  "Edit"), "E");
815  RegisterKey("Global", ACTION_SCREENSHOT, QT_TRANSLATE_NOOP("MythControls",
816  "Save screenshot"), "");
817  RegisterKey("Global", ACTION_HANDLEMEDIA, QT_TRANSLATE_NOOP("MythControls",
818  "Play a media resource"), "");
819 
820  RegisterKey("Global", "PAGEUP", QT_TRANSLATE_NOOP("MythControls",
821  "Page Up"), "PgUp");
822  RegisterKey("Global", "PAGEDOWN", QT_TRANSLATE_NOOP("MythControls",
823  "Page Down"), "PgDown");
824  RegisterKey("Global", "PAGETOP", QT_TRANSLATE_NOOP("MythControls",
825  "Page to top of list"), "");
826  RegisterKey("Global", "PAGEMIDDLE", QT_TRANSLATE_NOOP("MythControls",
827  "Page to middle of list"), "");
828  RegisterKey("Global", "PAGEBOTTOM", QT_TRANSLATE_NOOP("MythControls",
829  "Page to bottom of list"), "");
830 
831  RegisterKey("Global", "PREVVIEW", QT_TRANSLATE_NOOP("MythControls",
832  "Previous View"), "Home");
833  RegisterKey("Global", "NEXTVIEW", QT_TRANSLATE_NOOP("MythControls",
834  "Next View"), "End");
835 
836  RegisterKey("Global", "HELP", QT_TRANSLATE_NOOP("MythControls",
837  "Help"), "F1");
838  RegisterKey("Global", "EJECT", QT_TRANSLATE_NOOP("MythControls"
839  ,"Eject Removable Media"), "");
840 
841  RegisterKey("Global", "CUT", QT_TRANSLATE_NOOP("MythControls",
842  "Cut text from textedit"), "Ctrl+X");
843  RegisterKey("Global", "COPY", QT_TRANSLATE_NOOP("MythControls"
844  ,"Copy text from textedit"), "Ctrl+C");
845  RegisterKey("Global", "PASTE", QT_TRANSLATE_NOOP("MythControls",
846  "Paste text into textedit"), "Ctrl+V");
847  RegisterKey("Global", "NEWLINE", QT_TRANSLATE_NOOP("MythControls",
848  "Insert newline into textedit"), "Ctrl+Return");
849  RegisterKey("Global", "UNDO", QT_TRANSLATE_NOOP("MythControls",
850  "Undo"), "Ctrl+Z");
851  RegisterKey("Global", "REDO", QT_TRANSLATE_NOOP("MythControls",
852  "Redo"), "Ctrl+Y");
853  RegisterKey("Global", "SEARCH", QT_TRANSLATE_NOOP("MythControls",
854  "Show incremental search dialog"), "Ctrl+S");
855 
856  RegisterKey("Global", ACTION_0, QT_TRANSLATE_NOOP("MythControls","0"), "0");
857  RegisterKey("Global", ACTION_1, QT_TRANSLATE_NOOP("MythControls","1"), "1");
858  RegisterKey("Global", ACTION_2, QT_TRANSLATE_NOOP("MythControls","2"), "2");
859  RegisterKey("Global", ACTION_3, QT_TRANSLATE_NOOP("MythControls","3"), "3");
860  RegisterKey("Global", ACTION_4, QT_TRANSLATE_NOOP("MythControls","4"), "4");
861  RegisterKey("Global", ACTION_5, QT_TRANSLATE_NOOP("MythControls","5"), "5");
862  RegisterKey("Global", ACTION_6, QT_TRANSLATE_NOOP("MythControls","6"), "6");
863  RegisterKey("Global", ACTION_7, QT_TRANSLATE_NOOP("MythControls","7"), "7");
864  RegisterKey("Global", ACTION_8, QT_TRANSLATE_NOOP("MythControls","8"), "8");
865  RegisterKey("Global", ACTION_9, QT_TRANSLATE_NOOP("MythControls","9"), "9");
866 
867  RegisterKey("Global", ACTION_TVPOWERON, QT_TRANSLATE_NOOP("MythControls",
868  "Turn the display on"), "");
869  RegisterKey("Global", ACTION_TVPOWEROFF, QT_TRANSLATE_NOOP("MythControls",
870  "Turn the display off"), "");
871 
872  RegisterKey("Global", "SYSEVENT01", QT_TRANSLATE_NOOP("MythControls",
873  "Trigger System Key Event #1"), "");
874  RegisterKey("Global", "SYSEVENT02", QT_TRANSLATE_NOOP("MythControls",
875  "Trigger System Key Event #2"), "");
876  RegisterKey("Global", "SYSEVENT03", QT_TRANSLATE_NOOP("MythControls",
877  "Trigger System Key Event #3"), "");
878  RegisterKey("Global", "SYSEVENT04", QT_TRANSLATE_NOOP("MythControls",
879  "Trigger System Key Event #4"), "");
880  RegisterKey("Global", "SYSEVENT05", QT_TRANSLATE_NOOP("MythControls",
881  "Trigger System Key Event #5"), "");
882  RegisterKey("Global", "SYSEVENT06", QT_TRANSLATE_NOOP("MythControls",
883  "Trigger System Key Event #6"), "");
884  RegisterKey("Global", "SYSEVENT07", QT_TRANSLATE_NOOP("MythControls",
885  "Trigger System Key Event #7"), "");
886  RegisterKey("Global", "SYSEVENT08", QT_TRANSLATE_NOOP("MythControls",
887  "Trigger System Key Event #8"), "");
888  RegisterKey("Global", "SYSEVENT09", QT_TRANSLATE_NOOP("MythControls",
889  "Trigger System Key Event #9"), "");
890  RegisterKey("Global", "SYSEVENT10", QT_TRANSLATE_NOOP("MythControls",
891  "Trigger System Key Event #10"), "");
892 
893  // these are for the html viewer widget (MythUIWebBrowser)
894  RegisterKey("Browser", "ZOOMIN", QT_TRANSLATE_NOOP("MythControls",
895  "Zoom in on browser window"), ".,>");
896  RegisterKey("Browser", "ZOOMOUT", QT_TRANSLATE_NOOP("MythControls",
897  "Zoom out on browser window"), ",,<");
898  RegisterKey("Browser", "TOGGLEINPUT", QT_TRANSLATE_NOOP("MythControls",
899  "Toggle where keyboard input goes to"), "F1");
900 
901  RegisterKey("Browser", "MOUSEUP", QT_TRANSLATE_NOOP("MythControls",
902  "Move mouse pointer up"), "2");
903  RegisterKey("Browser", "MOUSEDOWN", QT_TRANSLATE_NOOP("MythControls",
904  "Move mouse pointer down"), "8");
905  RegisterKey("Browser", "MOUSELEFT", QT_TRANSLATE_NOOP("MythControls",
906  "Move mouse pointer left"), "4");
907  RegisterKey("Browser", "MOUSERIGHT", QT_TRANSLATE_NOOP("MythControls",
908  "Move mouse pointer right"), "6");
909  RegisterKey("Browser", "MOUSELEFTBUTTON", QT_TRANSLATE_NOOP("MythControls",
910  "Mouse Left button click"), "5");
911 
912  RegisterKey("Browser", "PAGEDOWN", QT_TRANSLATE_NOOP("MythControls",
913  "Scroll down half a page"), "9");
914  RegisterKey("Browser", "PAGEUP", QT_TRANSLATE_NOOP("MythControls",
915  "Scroll up half a page"), "3");
916  RegisterKey("Browser", "PAGELEFT", QT_TRANSLATE_NOOP("MythControls",
917  "Scroll left half a page"), "7");
918  RegisterKey("Browser", "PAGERIGHT", QT_TRANSLATE_NOOP("MythControls",
919  "Scroll right half a page"), "1");
920 
921  RegisterKey("Browser", "NEXTLINK", QT_TRANSLATE_NOOP("MythControls",
922  "Move selection to next link"), "Z");
923  RegisterKey("Browser", "PREVIOUSLINK", QT_TRANSLATE_NOOP("MythControls",
924  "Move selection to previous link"), "Q");
925  RegisterKey("Browser", "FOLLOWLINK", QT_TRANSLATE_NOOP("MythControls",
926  "Follow selected link"), "Return,Space,Enter");
927  RegisterKey("Browser", "HISTORYBACK", QT_TRANSLATE_NOOP("MythControls",
928  "Go back to previous page"), "R,Backspace");
929  RegisterKey("Browser", "HISTORYFORWARD", QT_TRANSLATE_NOOP("MythControls",
930  "Go forward to previous page"), "F");
931 
932  RegisterKey("Main Menu", "EXITPROMPT", QT_TRANSLATE_NOOP("MythControls",
933  "Display System Exit Prompt"), "Esc");
934  RegisterKey("Main Menu", "EXIT", QT_TRANSLATE_NOOP("MythControls",
935  "System Exit"), "");
936  RegisterKey("Main Menu", "STANDBYMODE",QT_TRANSLATE_NOOP("MythControls",
937  "Enter Standby Mode"), "");
938  RegisterKey("Long Press", "LONGPRESS1",QT_TRANSLATE_NOOP("MythControls",
939  "Up to 16 Keys that allow Long Press"), "");
940  RegisterKey("Long Press", "LONGPRESS2",QT_TRANSLATE_NOOP("MythControls",
941  "Up to 16 Keys that allow Long Press"), "");
942  RegisterKey("Long Press", "LONGPRESS3",QT_TRANSLATE_NOOP("MythControls",
943  "Up to 16 Keys that allow Long Press"), "");
944  RegisterKey("Long Press", "LONGPRESS4",QT_TRANSLATE_NOOP("MythControls",
945  "Up to 16 Keys that allow Long Press"), "");
946 }
947 
949 {
950  ClearKeyContext("Global");
951  ClearKeyContext("Browser");
952  ClearKeyContext("Main Menu");
953  InitKeys();
954 }
955 
957 {
961 }
962 
964 {
965  bool inwindow = m_wantWindow && !m_qtFullScreen;
966  bool fullscreen = m_wantFullScreen && !GeometryIsOverridden();
967  if (fullscreen && !inwindow && !m_priv->m_firstinit)
968  showFullScreen();
969  else
970  show();
971  m_priv->m_firstinit = false;
972 }
973 
974 void MythMainWindow::MoveResize(QRect& Geometry)
975 {
976  setFixedSize(Geometry.size());
977  setGeometry(Geometry);
978  if (m_painterWin)
979  {
980  m_painterWin->setFixedSize(Geometry.size());
981  m_painterWin->setGeometry(0, 0, Geometry.width(), Geometry.height());
982  }
983 }
984 
986 {
987  QMutexLocker locker(&m_priv->m_drawDisableLock);
989  if (m_priv->m_drawDisabledDepth && updatesEnabled())
990  SetDrawEnabled(false);
991  return m_priv->m_drawDisabledDepth;
992 }
993 
995 {
996  QMutexLocker locker(&m_priv->m_drawDisableLock);
998  {
1000  if (!m_priv->m_drawDisabledDepth && !updatesEnabled())
1001  SetDrawEnabled(true);
1002  }
1003  return m_priv->m_drawDisabledDepth;
1004 }
1005 
1007 {
1008  if (!gCoreContext->IsUIThread())
1009  {
1010  emit SignalSetDrawEnabled(Enable);
1011  return;
1012  }
1013 
1014  setUpdatesEnabled(Enable);
1015  if (Enable)
1016  {
1017  if (m_priv->m_pendingUpdate)
1018  {
1019  QApplication::postEvent(this, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority);
1020  m_priv->m_pendingUpdate = false;
1021  }
1023  }
1024  else
1025  {
1027  }
1028 }
1029 
1031 {
1032  for (auto *widget : qAsConst(m_priv->m_stackList))
1033  {
1034  if (Enable)
1035  widget->EnableEffects();
1036  else
1037  widget->DisableEffects();
1038  }
1039 }
1040 
1042 {
1043  return m_priv->m_exitingtomain;
1044 }
1045 
1047 {
1048  bool jumpdone = !(m_priv->m_popwindows);
1049 
1050  m_priv->m_exitingtomain = true;
1051 
1052  MythScreenStack *toplevel = GetMainStack();
1053  if (toplevel && m_priv->m_popwindows)
1054  {
1055  MythScreenType *screen = toplevel->GetTopScreen();
1056  if (screen && screen->objectName() != QString("mainmenu"))
1057  {
1058  MythEvent xe("EXIT_TO_MENU");
1059  gCoreContext->dispatch(xe);
1060  if (screen->objectName() == QString("video playback window"))
1061  {
1062  auto *me = new MythEvent("EXIT_TO_MENU");
1063  QCoreApplication::postEvent(screen, me);
1064  }
1065  else
1066  {
1067  auto *key = new QKeyEvent(QEvent::KeyPress, m_priv->m_escapekey,
1068  Qt::NoModifier);
1069  QCoreApplication::postEvent(this, key);
1071  // Notifications have their own stack. We need to continue
1072  // the propagation of the escape here if there are notifications.
1073  int num = nc->DisplayedNotifications();
1074  if (num > 0)
1075  QCoreApplication::postEvent(
1076  this, new QEvent(MythEvent::kExitToMainMenuEventType));
1077  }
1078  return;
1079  }
1080  jumpdone = true;
1081  }
1082 
1083  if (jumpdone)
1084  {
1085  m_priv->m_exitingtomain = false;
1086  m_priv->m_popwindows = true;
1088  {
1089  void (*callback)(void) = m_priv->m_exitMenuCallback;
1090  m_priv->m_exitMenuCallback = nullptr;
1091  callback();
1092  }
1094  {
1097  m_priv->m_mediaDeviceForCallback = nullptr;
1098  callback(mediadevice);
1099  }
1100  }
1101 }
1102 
1113 bool MythMainWindow::TranslateKeyPress(const QString& Context, QKeyEvent* Event,
1114  QStringList& Actions, bool AllowJumps)
1115 {
1116  Actions.clear();
1117 
1118  // Special case for custom QKeyEvent where the action is embedded directly
1119  // in the QKeyEvent text property. Used by MythFEXML http extension
1120  if (Event->key() == 0 && !Event->text().isEmpty() && Event->modifiers() == Qt::NoModifier)
1121  {
1122  QString action = Event->text();
1123  // check if it is a jumppoint
1124  if (!m_priv->m_destinationMap.contains(action))
1125  {
1126  Actions.append(action);
1127  return false;
1128  }
1129 
1130  if (AllowJumps)
1131  {
1132  // This does not filter the jump based on the current location but
1133  // is consistent with handling of other actions that do not need
1134  // a keybinding. The network control code tries to match
1135  // GetCurrentLocation with the jumppoint but matching is utterly
1136  // inconsistent e.g. mainmenu<->Main Menu, Playback<->Live TV
1137  JumpTo(action);
1138  return true;
1139  }
1140 
1141  return false;
1142  }
1143 
1145 
1146  QStringList localActions;
1147  auto * keycontext = m_priv->m_keyContexts.value(Context);
1148  if (AllowJumps && (m_priv->m_jumpMap.count(keynum) > 0) &&
1149  (!m_priv->m_jumpMap[keynum]->m_localAction.isEmpty()) &&
1150  keycontext && (keycontext->GetMapping(keynum, localActions)))
1151  {
1152  if (localActions.contains(m_priv->m_jumpMap[keynum]->m_localAction))
1153  AllowJumps = false;
1154  }
1155 
1156  if (AllowJumps && m_priv->m_jumpMap.count(keynum) > 0 &&
1157  !m_priv->m_jumpMap[keynum]->m_exittomain && m_priv->m_exitMenuCallback == nullptr)
1158  {
1159  void (*callback)(void) = m_priv->m_jumpMap[keynum]->m_callback;
1160  callback();
1161  return true;
1162  }
1163 
1164  if (AllowJumps &&
1165  m_priv->m_jumpMap.count(keynum) > 0 && m_priv->m_exitMenuCallback == nullptr)
1166  {
1167  m_priv->m_exitingtomain = true;
1168  m_priv->m_exitMenuCallback = m_priv->m_jumpMap[keynum]->m_callback;
1169  QCoreApplication::postEvent(
1170  this, new QEvent(MythEvent::kExitToMainMenuEventType));
1171  return true;
1172  }
1173 
1174  if (keycontext)
1175  keycontext->GetMapping(keynum, Actions);
1176 
1177  if (Context != "Global")
1178  {
1179  auto * keycontextG = m_priv->m_keyContexts.value("Global");
1180  if (keycontextG)
1181  keycontextG->GetMapping(keynum, Actions);
1182  }
1183 
1184  return false;
1185 }
1186 
1187 void MythMainWindow::ClearKey(const QString& Context, const QString& Action)
1188 {
1189  auto * keycontext = m_priv->m_keyContexts.value(Context);
1190  if (keycontext == nullptr)
1191  return;
1192 
1193  QMutableMapIterator<int, QStringList> it(keycontext->m_actionMap);
1194  while (it.hasNext())
1195  {
1196  it.next();
1197  QStringList list = it.value();
1198  list.removeAll(Action);
1199  if (list.isEmpty())
1200  it.remove();
1201  }
1202 }
1203 
1204 void MythMainWindow::ClearKeyContext(const QString& Context)
1205 {
1206  auto * keycontext = m_priv->m_keyContexts.value(Context);
1207  if (keycontext != nullptr)
1208  keycontext->m_actionMap.clear();
1209 }
1210 
1211 void MythMainWindow::BindKey(const QString& Context, const QString& Action, const QString& Key)
1212 {
1213  auto * keycontext = m_priv->m_keyContexts.value(Context);
1214  if (keycontext == nullptr)
1215  {
1216  keycontext = new KeyContext();
1217  if (keycontext == nullptr)
1218  return;
1219  m_priv->m_keyContexts.insert(Context, keycontext);
1220  }
1221 
1222  QKeySequence keyseq(Key);
1223  for (unsigned int i = 0; i < static_cast<uint>(keyseq.count()); i++)
1224  {
1225 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
1226  int keynum = keyseq[i];
1227 #else
1228  int keynum = keyseq[i].toCombined();
1229 #endif
1230 
1231  QStringList dummyaction("");
1232  if (keycontext->GetMapping(keynum, dummyaction))
1233  {
1234  LOG(VB_GENERAL, LOG_WARNING, QString("Key %1 is bound to multiple actions in context %2.")
1235  .arg(Key, Context));
1236  }
1237 
1238  keycontext->AddMapping(keynum, Action);
1239 #if 0
1240  LOG(VB_GENERAL, LOG_DEBUG, QString("Binding: %1 to action: %2 (%3)")
1241  .arg(Key).arg(Action).arg(Context));
1242 #endif
1243 
1244  if (Action == "ESCAPE" && Context == "Global" && i == 0)
1245  m_priv->m_escapekey = keynum;
1246  }
1247 }
1248 
1249 void MythMainWindow::RegisterKey(const QString& Context, const QString& Action,
1250  const QString& Description, const QString& Key)
1251 {
1252  QString keybind = Key;
1253 
1254  MSqlQuery query(MSqlQuery::InitCon());
1255 
1256  if (m_priv->m_useDB && query.isConnected())
1257  {
1258  query.prepare("SELECT keylist, description FROM keybindings WHERE "
1259  "context = :CONTEXT AND action = :ACTION AND "
1260  "hostname = :HOSTNAME ;");
1261  query.bindValue(":CONTEXT", Context);
1262  query.bindValue(":ACTION", Action);
1263  query.bindValue(":HOSTNAME", GetMythDB()->GetHostName());
1264 
1265  if (query.exec() && query.next())
1266  {
1267  keybind = query.value(0).toString();
1268  QString db_description = query.value(1).toString();
1269 
1270  // Update keybinding description if changed
1271  if (db_description != Description)
1272  {
1273  LOG(VB_GENERAL, LOG_NOTICE,
1274  "Updating keybinding description...");
1275  query.prepare(
1276  "UPDATE keybindings "
1277  "SET description = :DESCRIPTION "
1278  "WHERE context = :CONTEXT AND "
1279  " action = :ACTION AND "
1280  " hostname = :HOSTNAME");
1281 
1282  query.bindValue(":DESCRIPTION", Description);
1283  query.bindValue(":CONTEXT", Context);
1284  query.bindValue(":ACTION", Action);
1285  query.bindValue(":HOSTNAME", GetMythDB()->GetHostName());
1286 
1287  if (!query.exec() && !(GetMythDB()->SuppressDBMessages()))
1288  {
1289  MythDB::DBError("Update Keybinding", query);
1290  }
1291  }
1292  }
1293  else
1294  {
1295  const QString& inskey = keybind;
1296 
1297  query.prepare("INSERT INTO keybindings (context, action, "
1298  "description, keylist, hostname) VALUES "
1299  "( :CONTEXT, :ACTION, :DESCRIPTION, :KEYLIST, "
1300  ":HOSTNAME );");
1301  query.bindValue(":CONTEXT", Context);
1302  query.bindValue(":ACTION", Action);
1303  query.bindValue(":DESCRIPTION", Description);
1304  query.bindValue(":KEYLIST", inskey);
1305  query.bindValue(":HOSTNAME", GetMythDB()->GetHostName());
1306 
1307  if (!query.exec() && !(GetMythDB()->SuppressDBMessages()))
1308  {
1309  MythDB::DBError("Insert Keybinding", query);
1310  }
1311  }
1312  }
1313 
1314  BindKey(Context, Action, keybind);
1315  m_priv->m_actionText[Context][Action] = Description;
1316 }
1317 
1318 QString MythMainWindow::GetKey(const QString& Context, const QString& Action)
1319 {
1320  MSqlQuery query(MSqlQuery::InitCon());
1321  if (!query.isConnected())
1322  return "?";
1323 
1324  query.prepare("SELECT keylist "
1325  "FROM keybindings "
1326  "WHERE context = :CONTEXT AND "
1327  " action = :ACTION AND "
1328  " hostname = :HOSTNAME");
1329  query.bindValue(":CONTEXT", Context);
1330  query.bindValue(":ACTION", Action);
1331  query.bindValue(":HOSTNAME", GetMythDB()->GetHostName());
1332 
1333  if (!query.exec() || !query.isActive() || !query.next())
1334  return "?";
1335 
1336  return query.value(0).toString();
1337 }
1338 
1339 QString MythMainWindow::GetActionText(const QString& Context,
1340  const QString& Action) const
1341 {
1342  if (m_priv->m_actionText.contains(Context))
1343  {
1344  QHash<QString, QString> entry = m_priv->m_actionText.value(Context);
1345  if (entry.contains(Action))
1346  return entry.value(Action);
1347  }
1348  return "";
1349 }
1350 
1351 void MythMainWindow::ClearJump(const QString& Destination)
1352 {
1353  // make sure that the jump point exists (using [] would add it)
1354  if (!m_priv->m_destinationMap.contains(Destination))
1355  {
1356  LOG(VB_GENERAL, LOG_ERR, "Cannot clear ficticious jump point" + Destination);
1357  return;
1358  }
1359 
1360  QMutableMapIterator<int, JumpData*> it(m_priv->m_jumpMap);
1361  while (it.hasNext())
1362  {
1363  it.next();
1364  JumpData *jd = it.value();
1365  if (jd->m_destination == Destination)
1366  it.remove();
1367  }
1368 }
1369 
1370 
1371 void MythMainWindow::BindJump(const QString& Destination, const QString& Key)
1372 {
1373  // make sure the jump point exists
1374  if (!m_priv->m_destinationMap.contains(Destination))
1375  {
1376  LOG(VB_GENERAL, LOG_ERR, "Cannot bind to ficticious jump point" + Destination);
1377  return;
1378  }
1379 
1380  QKeySequence keyseq(Key);
1381 
1382  for (unsigned int i = 0; i < static_cast<uint>(keyseq.count()); i++)
1383  {
1384 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
1385  int keynum = keyseq[i];
1386 #else
1387  int keynum = keyseq[i].toCombined();
1388 #endif
1389 
1390  if (m_priv->m_jumpMap.count(keynum) == 0)
1391  {
1392 #if 0
1393  LOG(VB_GENERAL, LOG_DEBUG, QString("Binding: %1 to JumpPoint: %2")
1394  .arg(keybind).arg(destination));
1395 #endif
1396 
1397  m_priv->m_jumpMap[keynum] = &m_priv->m_destinationMap[Destination];
1398  }
1399  else
1400  {
1401  LOG(VB_GENERAL, LOG_WARNING, QString("Key %1 is already bound to a jump point.")
1402  .arg(Key));
1403  }
1404  }
1405 #if 0
1406  else
1407  LOG(VB_GENERAL, LOG_DEBUG,
1408  QString("JumpPoint: %2 exists, no keybinding") .arg(destination));
1409 #endif
1410 }
1411 
1412 void MythMainWindow::RegisterJump(const QString& Destination, const QString& Description,
1413  const QString& Key, void (*Callback)(void),
1414  bool Exittomain, QString LocalAction)
1415 {
1416  QString keybind = Key;
1417 
1418  MSqlQuery query(MSqlQuery::InitCon());
1419  if (query.isConnected())
1420  {
1421  query.prepare("SELECT keylist FROM jumppoints WHERE destination = :DEST and hostname = :HOST ;");
1422  query.bindValue(":DEST", Destination);
1423  query.bindValue(":HOST", GetMythDB()->GetHostName());
1424  if (query.exec() && query.next())
1425  {
1426  keybind = query.value(0).toString();
1427  }
1428  else
1429  {
1430  const QString& inskey = keybind;
1431 
1432  query.prepare("INSERT INTO jumppoints (destination, description, "
1433  "keylist, hostname) VALUES ( :DEST, :DESC, :KEYLIST, "
1434  ":HOST );");
1435  query.bindValue(":DEST", Destination);
1436  query.bindValue(":DESC", Description);
1437  query.bindValue(":KEYLIST", inskey);
1438  query.bindValue(":HOST", GetMythDB()->GetHostName());
1439  if (!query.exec() || !query.isActive())
1440  MythDB::DBError("Insert Jump Point", query);
1441  }
1442  }
1443 
1444  JumpData jd = { Callback, Destination, Description, Exittomain, std::move(LocalAction) };
1445  m_priv->m_destinationMap[Destination] = jd;
1446  BindJump(Destination, keybind);
1447 }
1448 
1450 {
1451  QList<QString> destinations = m_priv->m_destinationMap.keys();
1452  QList<QString>::Iterator it;
1453  for (it = destinations.begin(); it != destinations.end(); ++it)
1454  ClearJump(*it);
1455 }
1456 
1457 void MythMainWindow::JumpTo(const QString& Destination, bool Pop)
1458 {
1459  if (m_priv->m_destinationMap.count(Destination) > 0 && m_priv->m_exitMenuCallback == nullptr)
1460  {
1461  m_priv->m_exitingtomain = true;
1462  m_priv->m_popwindows = Pop;
1463  m_priv->m_exitMenuCallback = m_priv->m_destinationMap[Destination].m_callback;
1464  QCoreApplication::postEvent(
1465  this, new QEvent(MythEvent::kExitToMainMenuEventType));
1466  return;
1467  }
1468 }
1469 
1470 bool MythMainWindow::DestinationExists(const QString& Destination) const
1471 {
1472  return m_priv->m_destinationMap.count(Destination) > 0;
1473 }
1474 
1476 {
1477  return m_priv->m_destinationMap.keys();
1478 }
1479 
1480 void MythMainWindow::RegisterMediaPlugin(const QString& Name, const QString& Desc,
1481  MediaPlayCallback Func)
1482 {
1483  if (m_priv->m_mediaPluginMap.count(Name) == 0)
1484  {
1485  LOG(VB_GENERAL, LOG_NOTICE, QString("Registering %1 as a media playback plugin.")
1486  .arg(Name));
1487  m_priv->m_mediaPluginMap[Name] = { Desc, Func };
1488  }
1489  else
1490  {
1491  LOG(VB_GENERAL, LOG_NOTICE, QString("%1 is already registered as a media playback plugin.")
1492  .arg(Name));
1493  }
1494 }
1495 
1496 bool MythMainWindow::HandleMedia(const QString& Handler, const QString& Mrl,
1497  const QString& Plot, const QString& Title,
1498  const QString& Subtitle,
1499  const QString& Director, int Season,
1500  int Episode, const QString& Inetref,
1501  std::chrono::minutes LenMins, const QString& Year,
1502  const QString& Id, bool UseBookmarks)
1503 {
1504  QString lhandler(Handler);
1505  if (lhandler.isEmpty())
1506  lhandler = "Internal";
1507 
1508  // Let's see if we have a plugin that matches the handler name...
1509  if (m_priv->m_mediaPluginMap.contains(lhandler))
1510  {
1511  m_priv->m_mediaPluginMap[lhandler].second(Mrl, Plot, Title, Subtitle,
1512  Director, Season, Episode,
1513  Inetref, LenMins, Year, Id,
1514  UseBookmarks);
1515  return true;
1516  }
1517 
1518  return false;
1519 }
1520 
1522 {
1524 }
1525 
1527 {
1528  m_priv->m_allowInput = Allow;
1529 }
1530 
1532 {
1533  // complete the stroke if its our first timeout
1534  if (m_priv->m_gesture.Recording())
1535  m_priv->m_gesture.Stop(true);
1536 
1537  // get the last gesture
1538  auto * event = m_priv->m_gesture.GetGesture();
1539  if (event->GetGesture() < MythGestureEvent::Click)
1540  QCoreApplication::postEvent(this, event);
1541 }
1542 
1543 // Return code = true to skip further processing, false to continue
1544 // sNewEvent: Caller must pass in a QScopedPointer that will be used
1545 // to delete a new event if one is created.
1546 bool MythMainWindow::KeyLongPressFilter(QEvent** Event, QScopedPointer<QEvent>& NewEvent)
1547 {
1548  auto * keyevent = dynamic_cast<QKeyEvent*>(*Event);
1549  if (!keyevent)
1550  return false;
1551  int keycode = keyevent->key();
1552  // Ignore unknown key codes
1553  if (keycode == 0)
1554  return false;
1555 
1556  QEvent *newevent = nullptr;
1557  switch ((*Event)->type())
1558  {
1559  case QEvent::KeyPress:
1560  {
1561  // Check if we are in the middle of a long press
1562  if (keycode == m_priv->m_longPressKeyCode)
1563  {
1564  if (std::chrono::milliseconds(keyevent->timestamp()) - m_priv->m_longPressTime < LONGPRESS_INTERVAL
1565  || m_priv->m_longPressTime == 0ms)
1566  {
1567  // waiting for release of key.
1568  return true; // discard the key press
1569  }
1570 
1571  // expired log press - generate long key
1572  newevent = new QKeyEvent(QEvent::KeyPress, keycode,
1573  keyevent->modifiers() | Qt::MetaModifier, keyevent->nativeScanCode(),
1574  keyevent->nativeVirtualKey(), keyevent->nativeModifiers(),
1575  keyevent->text(), false,1);
1576  *Event = newevent;
1577  NewEvent.reset(newevent);
1578  m_priv->m_longPressTime = 0ms; // indicate we have generated the long press
1579  return false;
1580  }
1581  // If we got a keycode different from the long press keycode it
1582  // may have been injected by a jump point. Ignore it.
1583  if (m_priv->m_longPressKeyCode != 0)
1584  return false;
1585 
1586  // Process start of possible new long press.
1588  QStringList actions;
1589  bool handled = TranslateKeyPress("Long Press", keyevent, actions,false);
1590  if (handled)
1591  {
1592  // This shoudl never happen,, because we passed in false
1593  // to say do not process jump points and yet it returned true
1594  // to say it processed a jump point.
1595  LOG(VB_GUI, LOG_ERR, QString("TranslateKeyPress Long Press Invalid Response"));
1596  return true;
1597  }
1598  if (!actions.empty() && actions[0].startsWith("LONGPRESS"))
1599  {
1600  // Beginning of a press
1601  m_priv->m_longPressKeyCode = keycode;
1602  m_priv->m_longPressTime = std::chrono::milliseconds(keyevent->timestamp());
1603  return true; // discard the key press
1604  }
1605  break;
1606  }
1607  case QEvent::KeyRelease:
1608  {
1609  if (keycode == m_priv->m_longPressKeyCode)
1610  {
1611  if (keyevent->isAutoRepeat())
1612  return true;
1613  if (m_priv->m_longPressTime > 0ms)
1614  {
1615  // short press or non-repeating keyboard - generate key
1616  Qt::KeyboardModifiers modifier = Qt::NoModifier;
1617  if (std::chrono::milliseconds(keyevent->timestamp()) - m_priv->m_longPressTime >= LONGPRESS_INTERVAL)
1618  {
1619  // non-repeatng keyboard
1620  modifier = Qt::MetaModifier;
1621  }
1622  newevent = new QKeyEvent(QEvent::KeyPress, keycode,
1623  keyevent->modifiers() | modifier, keyevent->nativeScanCode(),
1624  keyevent->nativeVirtualKey(), keyevent->nativeModifiers(),
1625  keyevent->text(), false,1);
1626  *Event = newevent;
1627  NewEvent.reset(newevent);
1629  return false;
1630  }
1631 
1632  // end of long press
1634  return true;
1635  }
1636  break;
1637  }
1638  default:
1639  break;
1640  }
1641  return false;
1642 }
1643 
1644 bool MythMainWindow::eventFilter(QObject* Watched, QEvent* Event)
1645 {
1646  /* Don't let anything through if input is disallowed. */
1647  if (!m_priv->m_allowInput)
1648  return true;
1649 
1650  QScopedPointer<QEvent> newevent(nullptr);
1651  if (KeyLongPressFilter(&Event, newevent))
1652  return true;
1653 
1654  switch (Event->type())
1655  {
1656  case QEvent::KeyPress:
1657  {
1658  ResetIdleTimer();
1659  auto * event = dynamic_cast<QKeyEvent*>(Event);
1660 
1661  // Work around weird GCC run-time bug. Only manifest on Mac OS X
1662  if (!event)
1663  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
1664  event = static_cast<QKeyEvent*>(Event);
1665 
1666 #ifdef Q_OS_LINUX
1667  // Fixups for _some_ linux native codes that QT doesn't know
1668  if (event && event->key() <= 0)
1669  {
1670  int keycode = 0;
1671  switch (event->nativeScanCode())
1672  {
1673  case 209: // XF86AudioPause
1674  keycode = Qt::Key_MediaPause;
1675  break;
1676  default:
1677  break;
1678  }
1679 
1680  if (keycode > 0)
1681  {
1682  auto * key = new QKeyEvent(QEvent::KeyPress, keycode, event->modifiers());
1683  if (auto * target = GetTarget(*key); target)
1684  QCoreApplication::postEvent(target, key);
1685  else
1686  QCoreApplication::postEvent(this, key);
1687  return true;
1688  }
1689  }
1690 #endif
1691 
1692  // NOLINTNEXTLINE(readability-qualified-auto) // qt6
1693  for (auto it = m_priv->m_stackList.end() - 1; it != m_priv->m_stackList.begin() - 1; --it)
1694  {
1695  if (auto * top = (*it)->GetTopScreen(); top)
1696  {
1697  if (top->keyPressEvent(event))
1698  return true;
1699  // Note: The following break prevents keypresses being
1700  // sent to windows below popups
1701  if ((*it)->objectName() == "popup stack")
1702  break;
1703  }
1704  }
1705  break;
1706  }
1707  case QEvent::MouseButtonPress:
1708  {
1709  ResetIdleTimer();
1710  ShowMouseCursor(true);
1711  if (!m_priv->m_gesture.Recording())
1712  {
1713  m_priv->m_gesture.Start();
1714  auto * mouseEvent = dynamic_cast<QMouseEvent*>(Event);
1715  if (!mouseEvent)
1716  return MythUIScreenBounds::eventFilter(Watched, Event);
1717  m_priv->m_gesture.Record(mouseEvent->pos(), mouseEvent->button());
1718  /* start a single shot timer */
1720  return true;
1721  }
1722  break;
1723  }
1724  case QEvent::MouseButtonRelease:
1725  {
1726  ResetIdleTimer();
1727  ShowMouseCursor(true);
1728  if (m_priv->m_gestureTimer->isActive())
1729  m_priv->m_gestureTimer->stop();
1730 
1731  if (m_priv->m_gesture.Recording())
1732  {
1733  m_priv->m_gesture.Stop();
1734  auto * gesture = m_priv->m_gesture.GetGesture();
1735  QPoint point { -1, -1 };
1736  auto * mouseevent = dynamic_cast<QMouseEvent*>(Event);
1737  if (mouseevent)
1738  {
1739  point = mouseevent->pos();
1740  gesture->SetPosition(point);
1741  }
1742 
1743  // Handle clicks separately
1744  if (gesture->GetGesture() == MythGestureEvent::Click)
1745  {
1746  if (!mouseevent)
1747  return MythUIScreenBounds::eventFilter(Watched, Event);
1748 
1749  // NOLINTNEXTLINE(readability-qualified-auto) // qt6
1750  for (auto it = m_priv->m_stackList.end() - 1; it != m_priv->m_stackList.begin() - 1; --it)
1751  {
1752  auto * screen = (*it)->GetTopScreen();
1753  if (!screen || !screen->ContainsPoint(point))
1754  continue;
1755 
1756  if (screen->gestureEvent(gesture))
1757  break;
1758  // Note: The following break prevents clicks being
1759  // sent to windows below popups
1760  //
1761  // we want to permit this in some cases, e.g.
1762  // when the music miniplayer is on screen or a
1763  // non-interactive alert/news scroller. So these
1764  // things need to be in a third or more stack
1765  if ((*it)->objectName() == "popup stack")
1766  break;
1767  }
1768  delete gesture;
1769  }
1770  else
1771  {
1772  bool handled = false;
1773 
1774  if (!mouseevent)
1775  {
1776  QCoreApplication::postEvent(this, gesture);
1777  return true;
1778  }
1779 
1780  // NOLINTNEXTLINE(readability-qualified-auto) // qt6
1781  for (auto it = m_priv->m_stackList.end() - 1; it != m_priv->m_stackList.begin() - 1; --it)
1782  {
1783  MythScreenType *screen = (*it)->GetTopScreen();
1784  if (!screen || !screen->ContainsPoint(point))
1785  continue;
1786 
1787  if (screen->gestureEvent(gesture))
1788  {
1789  handled = true;
1790  break;
1791  }
1792  // Note: The following break prevents clicks being
1793  // sent to windows below popups
1794  //
1795  // we want to permit this in some cases, e.g.
1796  // when the music miniplayer is on screen or a
1797  // non-interactive alert/news scroller. So these
1798  // things need to be in a third or more stack
1799  if ((*it)->objectName() == "popup stack")
1800  break;
1801  }
1802 
1803  if (handled)
1804  delete gesture;
1805  else
1806  QCoreApplication::postEvent(this, gesture);
1807  }
1808 
1809  return true;
1810  }
1811  break;
1812  }
1813  case QEvent::MouseMove:
1814  {
1815  ResetIdleTimer();
1816  ShowMouseCursor(true);
1817  if (m_priv->m_gesture.Recording())
1818  {
1819  // Reset the timer
1820  m_priv->m_gestureTimer->stop();
1822  auto * mouseevent = dynamic_cast<QMouseEvent*>(Event);
1823  if (!mouseevent)
1824  return MythUIScreenBounds::eventFilter(Watched, Event);
1825  m_priv->m_gesture.Record(mouseevent->pos(), mouseevent->button());
1826  return true;
1827  }
1828  break;
1829  }
1830  case QEvent::Wheel:
1831  {
1832  ResetIdleTimer();
1833  ShowMouseCursor(true);
1834  auto * wheel = dynamic_cast<QWheelEvent*>(Event);
1835  if (wheel == nullptr)
1836  return MythUIScreenBounds::eventFilter(Watched, Event);
1837  int delta = wheel->angleDelta().y();
1838  if (delta>0)
1839  {
1840  wheel->accept();
1841  auto *key = new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);
1842  if (auto * target = GetTarget(*key); target)
1843  QCoreApplication::postEvent(target, key);
1844  else
1845  QCoreApplication::postEvent(this, key);
1846  }
1847  if (delta < 0)
1848  {
1849  wheel->accept();
1850  auto * key = new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);
1851  if (auto * target = GetTarget(*key); !target)
1852  QCoreApplication::postEvent(target, key);
1853  else
1854  QCoreApplication::postEvent(this, key);
1855  }
1856  break;
1857  }
1858  default:
1859  break;
1860  }
1861 
1862  return MythUIScreenBounds::eventFilter(Watched, Event);
1863 }
1864 
1866 {
1867  if (Event->type() == MythGestureEvent::kEventType)
1868  {
1869  auto * gesture = dynamic_cast<MythGestureEvent*>(Event);
1870  if (gesture == nullptr)
1871  return;
1872  if (auto * toplevel = GetMainStack(); toplevel)
1873  if (auto * screen = toplevel->GetTopScreen(); screen)
1874  screen->gestureEvent(gesture);
1875  LOG(VB_GUI, LOG_DEBUG, QString("Gesture: %1 (Button: %2)")
1876  .arg(gesture->GetName(), gesture->GetButtonName()));
1877  }
1879  {
1880  ExitToMainMenu();
1881  }
1882  else if (Event->type() == ExternalKeycodeEvent::kEventType)
1883  {
1884  auto * event = dynamic_cast<ExternalKeycodeEvent *>(Event);
1885  if (event == nullptr)
1886  return;
1887  auto * key = new QKeyEvent(QEvent::KeyPress, event->getKeycode(), Qt::NoModifier);
1888  if (auto * target = GetTarget(*key); target)
1889  QCoreApplication::sendEvent(target, key);
1890  else
1891  QCoreApplication::sendEvent(this, key);
1892  }
1893  else if (Event->type() == MythMediaEvent::kEventType)
1894  {
1895  auto *me = dynamic_cast<MythMediaEvent*>(Event);
1896  if (me == nullptr)
1897  return;
1898 
1899  // A listener based system might be more efficient, but we should never
1900  // have that many screens open at once so impact should be minimal.
1901  //
1902  // This approach is simpler for everyone to follow. Plugin writers
1903  // don't have to worry about adding their screens to the list because
1904  // all screens receive media events.
1905  //
1906  // Events are even sent to hidden or backgrounded screens, this avoids
1907  // the need for those to poll for changes when they become visible again
1908  // however this needs to be kept in mind if media changes trigger
1909  // actions which would not be appropriate when the screen doesn't have
1910  // focus. It is the programmers responsibility to ignore events when
1911  // necessary.
1912  for (auto * widget : qAsConst(m_priv->m_stackList))
1913  {
1914  QVector<MythScreenType*> screenList;
1915  widget->GetScreenList(screenList);
1916  for (auto * screen : qAsConst(screenList))
1917  if (screen)
1918  screen->mediaEvent(me);
1919  }
1920 
1921  // Debugging
1922  if (MythMediaDevice* device = me->getDevice(); device)
1923  {
1924  LOG(VB_GENERAL, LOG_DEBUG, QString("Media Event: %1 - %2")
1925  .arg(device->getDevicePath()).arg(device->getStatus()));
1926  }
1927  }
1928  else if (Event->type() == MythEvent::kPushDisableDrawingEventType)
1929  {
1930  PushDrawDisabled();
1931  }
1932  else if (Event->type() == MythEvent::kPopDisableDrawingEventType)
1933  {
1934  PopDrawDisabled();
1935  }
1936  else if (Event->type() == MythEvent::kLockInputDevicesEventType)
1937  {
1938  m_deviceHandler->IgnoreKeys(true);
1939  PauseIdleTimer(true);
1940  }
1941  else if (Event->type() == MythEvent::kUnlockInputDevicesEventType)
1942  {
1943  m_deviceHandler->IgnoreKeys(false);
1944  PauseIdleTimer(false);
1945  }
1946  else if (Event->type() == MythEvent::kDisableUDPListenerEventType)
1947  {
1949  }
1950  else if (Event->type() == MythEvent::kEnableUDPListenerEventType)
1951  {
1953  }
1954  else if (Event->type() == MythEvent::MythEventMessage)
1955  {
1956  auto * event = dynamic_cast<MythEvent *>(Event);
1957  if (event == nullptr)
1958  return;
1959 
1960  QString message = event->Message();
1961  if (message.startsWith(ACTION_HANDLEMEDIA))
1962  {
1963  if (event->ExtraDataCount() == 1)
1964  HandleMedia("Internal", event->ExtraData(0));
1965  else if (event->ExtraDataCount() >= 11)
1966  {
1967  bool usebookmark = true;
1968  if (event->ExtraDataCount() >= 12)
1969  usebookmark = (event->ExtraData(11).toInt() != 0);
1970  HandleMedia("Internal", event->ExtraData(0),
1971  event->ExtraData(1), event->ExtraData(2),
1972  event->ExtraData(3), event->ExtraData(4),
1973  event->ExtraData(5).toInt(), event->ExtraData(6).toInt(),
1974  event->ExtraData(7), std::chrono::minutes(event->ExtraData(8).toInt()),
1975  event->ExtraData(9), event->ExtraData(10),
1976  usebookmark);
1977  }
1978  else
1979  {
1980  LOG(VB_GENERAL, LOG_ERR, "Failed to handle media");
1981  }
1982  }
1983  else if (message.startsWith(ACTION_SCREENSHOT))
1984  {
1985  int width = 0;
1986  int height = 0;
1987  QString filename;
1988  if (event->ExtraDataCount() >= 2)
1989  {
1990  width = event->ExtraData(0).toInt();
1991  height = event->ExtraData(1).toInt();
1992  if (event->ExtraDataCount() == 3)
1993  filename = event->ExtraData(2);
1994  }
1995  ScreenShot(width, height, filename);
1996  }
1997  else if (message == ACTION_GETSTATUS)
1998  {
1999  QVariantMap state;
2000  state.insert("state", "idle");
2001  state.insert("menutheme", GetMythDB()->GetSetting("menutheme", "defaultmenu"));
2002  state.insert("currentlocation", GetMythUI()->GetCurrentLocation());
2004  }
2005  else if (message == "CLEAR_SETTINGS_CACHE")
2006  {
2007  // update the idle time
2008  m_idleTime =
2009  gCoreContext->GetDurSetting<std::chrono::minutes>("FrontendIdleTimeout",
2010  STANDBY_TIMEOUT);
2011 
2012  if (m_idleTime < 0min)
2013  m_idleTime = 0min;
2014  m_idleTimer.stop();
2015  if (m_idleTime > 0min)
2016  {
2017  m_idleTimer.setInterval(m_idleTime);
2018  m_idleTimer.start();
2019  LOG(VB_GENERAL, LOG_INFO, QString("Updating the frontend idle time to: %1 mins").arg(m_idleTime.count()));
2020  }
2021  else
2022  {
2023  LOG(VB_GENERAL, LOG_INFO, "Frontend idle timeout is disabled");
2024  }
2025  }
2026  else if (message == "NOTIFICATION")
2027  {
2028  MythNotification mn(*event);
2030  return;
2031  }
2032  else if (message == "RECONNECT_SUCCESS" && m_priv->m_standby)
2033  {
2034  // If the connection to the master backend has just been (re-)established
2035  // but we're in standby, make sure the backend is not blocked from
2036  // shutting down.
2038  }
2039  }
2040  else if (Event->type() == MythEvent::MythUserMessage)
2041  {
2042  if (auto * event = dynamic_cast<MythEvent *>(Event); event != nullptr)
2043  if (const QString& message = event->Message(); !message.isEmpty())
2044  ShowOkPopup(message);
2045  }
2046  else if (Event->type() == MythNotificationCenterEvent::kEventType)
2047  {
2049  }
2050 }
2051 
2052 QObject* MythMainWindow::GetTarget(QKeyEvent& Key)
2053 {
2054  auto * target = QWidget::keyboardGrabber();
2055  if (!target)
2056  {
2057  if (auto * widget = QApplication::focusWidget(); widget && widget->isEnabled())
2058  {
2059  target = widget;
2060  // Yes this is special code for handling the
2061  // the escape key.
2062  if (Key.key() == m_priv->m_escapekey && widget->topLevelWidget())
2063  target = widget->topLevelWidget();
2064  }
2065  }
2066 
2067  if (!target)
2068  target = this;
2069  return target;
2070 }
2071 
2073 {
2075 }
2076 
2078 {
2079  if (Show && GetMythDB()->GetBoolSetting("HideMouseCursor", false))
2080  return;
2081 
2082  // Set cursor call must come after Show() to work on some systems.
2083  setCursor(Show ? (Qt::ArrowCursor) : (Qt::BlankCursor));
2084  if (Show)
2085  m_priv->m_hideMouseTimer->start();
2086 }
2087 
2089 {
2090  ShowMouseCursor(false);
2091 }
2092 
2096 void MythMainWindow::DisableIdleTimer(bool DisableIdle)
2097 {
2098  if ((m_priv->m_disableIdle = DisableIdle))
2099  m_idleTimer.stop();
2100  else
2101  m_idleTimer.start();
2102 }
2103 
2108 {
2109  if (m_priv->m_disableIdle)
2110  return;
2111 
2112  if (m_idleTime == 0min || !m_idleTimer.isActive() || (m_priv->m_standby && m_priv->m_enteringStandby))
2113  return;
2114 
2115  if (m_priv->m_standby)
2116  ExitStandby(false);
2117 
2118  m_idleTimer.start();
2119 }
2120 
2125 {
2126  if (m_priv->m_disableIdle)
2127  return;
2128 
2129  // don't do anything if the idle timer is disabled
2130  if (m_idleTime == 0min)
2131  return;
2132 
2133  if (Pause)
2134  {
2135  LOG(VB_GENERAL, LOG_NOTICE, "Suspending idle timer");
2136  m_idleTimer.stop();
2137  }
2138  else
2139  {
2140  LOG(VB_GENERAL, LOG_NOTICE, "Resuming idle timer");
2141  m_idleTimer.start();
2142  }
2143 
2144  // ResetIdleTimer();
2145 }
2146 
2148 {
2149  if (m_priv->m_disableIdle)
2150  return;
2151 
2152  m_priv->m_enteringStandby = false;
2153 
2154  if (m_idleTime > 0min && !m_priv->m_standby)
2155  {
2156  LOG(VB_GENERAL, LOG_NOTICE,
2157  QString("Entering standby mode after %1 minutes of inactivity").arg(m_idleTime.count()));
2158  EnterStandby(false);
2159  if (gCoreContext->GetNumSetting("idleTimeoutSecs", 0) > 0)
2160  {
2161  m_priv->m_enteringStandby = true;
2162  JumpTo("Standby Mode");
2163  }
2164  }
2165 }
2166 
2168 {
2169  if (Manual && m_priv->m_enteringStandby)
2170  m_priv->m_enteringStandby = false;
2171 
2172  if (m_priv->m_standby)
2173  return;
2174 
2175  // We've manually entered standby mode and we want to pause the timer
2176  // to prevent it being Reset
2177  if (Manual)
2178  {
2179  PauseIdleTimer(true);
2180  LOG(VB_GENERAL, LOG_NOTICE, QString("Entering standby mode"));
2181  }
2182 
2183  m_priv->m_standby = true;
2185 
2186  QVariantMap state;
2187  state.insert("state", "standby");
2188  state.insert("menutheme", GetMythDB()->GetSetting("menutheme", "defaultmenu"));
2189  state.insert("currentlocation", GetMythUI()->GetCurrentLocation());
2191 
2192  // Cache WOL settings in case DB goes down
2193  QString masterserver = gCoreContext->GetSetting("MasterServerName");
2194  gCoreContext->GetSettingOnHost("BackendServerAddr", masterserver);
2196  gCoreContext->GetSetting("WOLbackendCommand", "");
2197 
2198  // While in standby do not attempt to wake the backend
2199  gCoreContext->SetWOLAllowed(false);
2200 }
2201 
2203 {
2205  return;
2206 
2207  if (Manual)
2208  PauseIdleTimer(false);
2209  else if (gCoreContext->GetNumSetting("idleTimeoutSecs", 0) > 0)
2210  JumpTo("Main Menu");
2211 
2212  if (!m_priv->m_standby)
2213  return;
2214 
2215  LOG(VB_GENERAL, LOG_NOTICE, "Leaving standby mode");
2216  m_priv->m_standby = false;
2217 
2218  // We may attempt to wake the backend
2219  gCoreContext->SetWOLAllowed(true);
2221 
2222  QVariantMap state;
2223  state.insert("state", "idle");
2224  state.insert("menutheme", GetMythDB()->GetSetting("menutheme", "defaultmenu"));
2225  state.insert("currentlocation", GetMythUI()->GetCurrentLocation());
2227 }
2228 
2230 {
2231  LOG(VB_GENERAL, LOG_NOTICE, QString("Application State Changed to %1").arg(State));
2232  switch (State)
2233  {
2234  case Qt::ApplicationState::ApplicationActive:
2235  PopDrawDisabled();
2236  break;
2237  case Qt::ApplicationState::ApplicationSuspended:
2238  PushDrawDisabled();
2239  break;
2240  default:
2241  break;
2242  }
2243 }
2244 /* vim: set expandtab tabstop=4 shiftwidth=4: */
MythUIScreenBounds::m_alwaysOnTop
bool m_alwaysOnTop
Definition: mythuiscreenbounds.h:50
MythMainWindow::BindJump
void BindJump(const QString &Destination, const QString &Key)
Definition: mythmainwindow.cpp:1371
MSqlQuery::isActive
bool isActive(void) const
Definition: mythdbcon.h:212
MythCoreContext::SetWOLAllowed
void SetWOLAllowed(bool allow)
Definition: mythcorecontext.cpp:653
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:802
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:124
build_compdb.args
args
Definition: build_compdb.py:11
MythPainterWindow::DestroyPainters
static void DestroyPainters(MythPainterWindow *&PaintWin, MythPainter *&Painter)
Definition: mythpainterwindow.cpp:132
MythUIStateTracker::SetState
static void SetState(const QVariantMap &NewState)
Definition: mythuistatetracker.cpp:24
ACTION_UP
#define ACTION_UP
Definition: mythuiactions.h:16
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:314
mythrect.h
mythevent.h
MythMainWindow::m_idleTimer
QTimer m_idleTimer
Definition: mythmainwindow.h:174
MythEvent::kLockInputDevicesEventType
static Type kLockInputDevicesEventType
Definition: mythevent.h:85
MythDate::toString
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:80
MythEvent::MythEventMessage
static Type MythEventMessage
Definition: mythevent.h:78
ACTION_3
#define ACTION_3
Definition: mythuiactions.h:7
hardwareprofile.smolt.timeout
float timeout
Definition: smolt.py:103
MythMainWindow::closeEvent
void closeEvent(QCloseEvent *Event) override
Definition: mythmainwindow.cpp:473
MythInputDeviceHandler::MainWindowReady
void MainWindowReady(void)
Definition: mythinputdevicehandler.cpp:200
MythMainWindow::Init
void Init(bool MayReInit=true)
Definition: mythmainwindow.cpp:637
MythNotificationCenter::ProcessQueue
void ProcessQueue(void)
ProcessQueue will be called by the GUI event handler and will process all queued MythNotifications an...
Definition: mythnotificationcenter.cpp:1356
MythMainWindow::ReinitDone
void ReinitDone()
Definition: mythmainwindow.cpp:956
MythMainWindow::OnApplicationStateChange
void OnApplicationStateChange(Qt::ApplicationState State)
Definition: mythmainwindow.cpp:2229
MythDisplay::SwitchToDesktop
void SwitchToDesktop()
Return the screen to the original desktop video mode.
Definition: mythdisplay.cpp:675
MythMainWindowPrivate::m_mediaDeviceForCallback
MythMediaDevice * m_mediaDeviceForCallback
Definition: mythmainwindowprivate.h:69
GESTURE_TIMEOUT
static constexpr std::chrono::milliseconds GESTURE_TIMEOUT
Definition: mythmainwindow.cpp:61
MythMainWindow::SignalDisableScreensaver
void SignalDisableScreensaver()
MythMainWindowPrivate::m_pendingUpdate
bool m_pendingUpdate
Definition: mythmainwindowprivate.h:84
ACTION_6
#define ACTION_6
Definition: mythuiactions.h:10
mythdb.h
MythPainter::SupportsClipping
virtual bool SupportsClipping(void)=0
MythMainWindowPrivate::m_longPressKeyCode
int m_longPressKeyCode
Definition: mythmainwindowprivate.h:88
ACTION_DOWN
#define ACTION_DOWN
Definition: mythuiactions.h:17
MythMainWindow::SaveScreenShot
static bool SaveScreenShot(const QImage &Image, QString Filename="")
Definition: mythmainwindow.cpp:533
MythCoreContext::AllowShutdown
void AllowShutdown(void)
Definition: mythcorecontext.cpp:634
ACTION_0
#define ACTION_0
Definition: mythuiactions.h:4
MythGesture::Recording
bool Recording()
Determine if the stroke is being recorded.
Definition: mythgesture.cpp:142
MythUIScreenBounds::UpdateScreenSettings
void UpdateScreenSettings(MythDisplay *mDisplay)
Definition: mythuiscreenbounds.cpp:141
MythMainWindow::SignalWindowReady
void SignalWindowReady()
LONGPRESS_INTERVAL
static constexpr std::chrono::milliseconds LONGPRESS_INTERVAL
Definition: mythmainwindow.cpp:63
MythEvent::kPushDisableDrawingEventType
static Type kPushDisableDrawingEventType
Definition: mythevent.h:83
MythGesture::Start
void Start()
Start recording.
Definition: mythgesture.cpp:151
MythMainWindowPrivate::m_gestureTimer
QTimer * m_gestureTimer
Definition: mythmainwindowprivate.h:75
MythUIScreenBounds::m_wantFullScreen
bool m_wantFullScreen
Definition: mythuiscreenbounds.h:48
MythMainWindow::MythMainWindow
MythMainWindow(bool UseDB=true)
Definition: mythmainwindow.cpp:128
MythMainWindowPrivate::m_useDB
bool m_useDB
To allow or prevent database access.
Definition: mythmainwindowprivate.h:59
MythInputDeviceHandler::Action
void Action(const QString &Action)
Definition: mythinputdevicehandler.cpp:179
MythMainWindow::GetStackCount
int GetStackCount()
Definition: mythmainwindow.cpp:309
MythMainWindow::JumpTo
void JumpTo(const QString &Destination, bool Pop=true)
Definition: mythmainwindow.cpp:1457
MythMainWindowPrivate::m_disableIdle
bool m_disableIdle
Definition: mythmainwindowprivate.h:82
MythMainWindow::getMainWindow
static MythMainWindow * getMainWindow(bool UseDB=true)
Return the existing main window, or create one.
Definition: mythmainwindow.cpp:77
MythUIScreenBounds::m_qtFullScreen
bool m_qtFullScreen
Definition: mythuiscreenbounds.h:49
MythEvent::kPopDisableDrawingEventType
static Type kPopDisableDrawingEventType
Definition: mythevent.h:84
MythMainWindow::ClearAllJumps
void ClearAllJumps()
Definition: mythmainwindow.cpp:1449
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:16
MythMainWindowPrivate::m_stackList
QVector< MythScreenStack * > m_stackList
Definition: mythmainwindowprivate.h:72
MythDate::kScreenShotFilename
@ kScreenShotFilename
"yyyy-MM-ddThh-mm-ss.zzz"
Definition: mythdate.h:29
mythdialogbox.h
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:201
MythScreenStack
Definition: mythscreenstack.h:16
MythMainWindow::RestoreScreensaver
static void RestoreScreensaver()
Definition: mythmainwindow.cpp:573
ACTION_2
#define ACTION_2
Definition: mythuiactions.h:6
MythMainWindow::ShowMouseCursor
void ShowMouseCursor(bool Show)
Definition: mythmainwindow.cpp:2077
MythMainWindow::ReloadKeys
void ReloadKeys()
Definition: mythmainwindow.cpp:948
MythMainWindowPrivate::m_popwindows
bool m_popwindows
Definition: mythmainwindowprivate.h:57
MythNotification
Definition: mythnotification.h:29
MythMainWindow::LoadQtConfig
static void LoadQtConfig()
Definition: mythmainwindow.cpp:630
MythMainWindowPrivate::m_exitingtomain
bool m_exitingtomain
Definition: mythmainwindowprivate.h:56
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
MythMainWindowPrivate::m_longPressTime
std::chrono::milliseconds m_longPressTime
Definition: mythmainwindowprivate.h:89
MythMainWindowPrivate::m_exitMenuMediaDeviceCallback
void(* m_exitMenuMediaDeviceCallback)(MythMediaDevice *mediadevice)
Definition: mythmainwindowprivate.h:68
MythCoreContext::IsUIThread
bool IsUIThread(void)
Definition: mythcorecontext.cpp:1372
MythScreenSaverControl::Reset
void Reset()
MythMainWindow::HandleTVAction
void HandleTVAction(const QString &Action)
Definition: mythmainwindow.cpp:1521
MythMainWindow::Show
void Show()
Definition: mythmainwindow.cpp:963
MythMainWindowPrivate::m_mediaPluginMap
QMap< QString, MythMediaCallback > m_mediaPluginMap
Definition: mythmainwindowprivate.h:64
MythMainWindow::customEvent
void customEvent(QEvent *Event) override
Definition: mythmainwindow.cpp:1865
MythMainWindow::ResetIdleTimer
void ResetIdleTimer()
Reset the idle timeout timer.
Definition: mythmainwindow.cpp:2107
STANDBY_TIMEOUT
static constexpr std::chrono::minutes STANDBY_TIMEOUT
Definition: mythmainwindow.cpp:62
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
mythinputdevicehandler.h
MythMainWindow::ClearJump
void ClearJump(const QString &Destination)
Definition: mythmainwindow.cpp:1351
MythPainterWindow::CreatePainters
static QString CreatePainters(MythMainWindow *MainWin, MythPainterWindow *&PaintWin, MythPainter *&Paint)
Definition: mythpainterwindow.cpp:53
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:44
show
static void show(uint8_t *buf, int length)
Definition: ringbuffer.cpp:339
MythMainWindowPrivate::m_actionText
QHash< QString, QHash< QString, QString > > m_actionText
Definition: mythmainwindowprivate.h:65
MythMainWindow::DoRemoteScreenShot
void DoRemoteScreenShot(const QString &Filename, int Width, int Height)
Definition: mythmainwindow.cpp:515
MythMainWindow::RegisterKey
void RegisterKey(const QString &Context, const QString &Action, const QString &Description, const QString &Key)
Definition: mythmainwindow.cpp:1249
GetMythDB
MythDB * GetMythDB(void)
Definition: mythdb.cpp:46
MythMainWindow::RegisterMediaPlugin
void RegisterMediaPlugin(const QString &Name, const QString &Desc, MediaPlayCallback Func)
Definition: mythmainwindow.cpp:1480
MythMainWindow::Draw
void Draw(MythPainter *Painter=nullptr)
Definition: mythmainwindow.cpp:432
mythdirs.h
ACTION_SCREENSHOT
#define ACTION_SCREENSHOT
Definition: mythuiactions.h:22
MythScreenSaverControl::Restore
void Restore()
MythMainWindow::GetRenderDevice
MythRender * GetRenderDevice()
Definition: mythmainwindow.cpp:288
MythMainWindowPrivate::m_hideMouseTimer
QTimer * m_hideMouseTimer
Definition: mythmainwindowprivate.h:76
MythMainWindow::GetPainter
MythPainter * GetPainter()
Definition: mythmainwindow.cpp:254
MythMainWindow::PopScreenStack
void PopScreenStack()
Definition: mythmainwindow.cpp:300
MythMainWindow::m_oldPainterWin
MythPainterWindow * m_oldPainterWin
Definition: mythmainwindow.h:171
mythmainwindowprivate.h
HasMythMainWindow
bool HasMythMainWindow(void)
Definition: mythmainwindow.cpp:106
MythMainWindow::SignalSetDrawEnabled
void SignalSetDrawEnabled(bool Enable)
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
MythEvent::Message
const QString & Message() const
Definition: mythevent.h:65
MythMainWindow::HandleMedia
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="", std::chrono::minutes LenMins=2h, const QString &Year="1895", const QString &Id="", bool UseBookmarks=false)
Definition: mythmainwindow.cpp:1496
MythMediaEvent::kEventType
static Type kEventType
Definition: mythmedia.h:193
MythMainWindowPrivate::TranslateKeyNum
static int TranslateKeyNum(QKeyEvent *Event)
Definition: mythmainwindowprivate.cpp:8
MythEvent::MythUserMessage
static Type MythUserMessage
Definition: mythevent.h:79
MythMainWindow::ClearKey
void ClearKey(const QString &Context, const QString &Action)
Definition: mythmainwindow.cpp:1187
Action
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:40
MythMainWindow::AddScreenStack
void AddScreenStack(MythScreenStack *Stack, bool Main=false)
Definition: mythmainwindow.cpp:293
MythMainWindow::SetEffectsEnabled
void SetEffectsEnabled(bool Enable)
Definition: mythmainwindow.cpp:1030
MythEvent::kExitToMainMenuEventType
static Type kExitToMainMenuEventType
Definition: mythevent.h:81
mythpainterwindow.h
MythObservable::addListener
void addListener(QObject *listener)
Add a listener to the observable.
Definition: mythobservable.cpp:38
MythMainWindow::DisableIdleTimer
void DisableIdleTimer(bool DisableIdle=true)
Disable the idle timeout timer.
Definition: mythmainwindow.cpp:2096
MythMainWindow::GetDisplay
MythDisplay * GetDisplay()
Definition: mythmainwindow.cpp:249
MythMainWindow::DisableScreensaver
static void DisableScreensaver()
Definition: mythmainwindow.cpp:579
MythMainWindow::SignalRestoreScreensaver
void SignalRestoreScreensaver()
MythMainWindow::GetKey
static QString GetKey(const QString &Context, const QString &Action)
Definition: mythmainwindow.cpp:1318
MythThemeBase
Definition: myththemebase.h:11
ExternalKeycodeEvent
Definition: mythevent.h:104
MythMainWindow::KeyLongPressFilter
bool KeyLongPressFilter(QEvent **Event, QScopedPointer< QEvent > &NewEvent)
Definition: mythmainwindow.cpp:1546
ACTION_8
#define ACTION_8
Definition: mythuiactions.h:12
MythGesture::Stop
void Stop(bool Timeout=false)
Stop recording.
Definition: mythgesture.cpp:163
mythdate.h
MythMainWindow::SetDrawEnabled
void SetDrawEnabled(bool Enable)
Definition: mythmainwindow.cpp:1006
mythrender_base.h
MythScreenSaverControl::Asleep
bool Asleep()
Definition: mythscreensaver.cpp:80
MythMainWindow::m_screensaver
MythScreenSaverControl * m_screensaver
Definition: mythmainwindow.h:173
MythMainWindowPrivate::m_exitMenuCallback
void(* m_exitMenuCallback)(void)
Definition: mythmainwindowprivate.h:67
mythdisplay.h
mythlogging.h
MythMainWindow::HideMouseTimeout
void HideMouseTimeout()
Definition: mythmainwindow.cpp:2088
MythMainWindowPrivate
Definition: mythmainwindowprivate.h:47
MythMainWindow::TranslateKeyPress
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
Definition: mythmainwindow.cpp:1113
MythMainWindow::event
bool event(QEvent *Event) override
Definition: mythmainwindow.cpp:609
ACTION_TVPOWEROFF
#define ACTION_TVPOWEROFF
Definition: mythuiactions.h:24
ACTION_HANDLEMEDIA
#define ACTION_HANDLEMEDIA
Definition: mythuiactions.h:21
ACTION_RIGHT
#define ACTION_RIGHT
Definition: mythuiactions.h:19
MythMainWindow::destroyMainWindow
static void destroyMainWindow()
Definition: mythmainwindow.cpp:93
MythInputDeviceHandler
A wrapper around sundry external input devices.
Definition: mythinputdevicehandler.h:18
MythMainWindowPrivate::m_destinationMap
QMap< QString, JumpData > m_destinationMap
Definition: mythmainwindowprivate.h:63
MythMainWindow::m_themeBase
MythThemeBase * m_themeBase
Definition: mythmainwindow.h:167
Event
Event details.
Definition: zmdefines.h:26
MythMainWindowPrivate::m_drawDisabledDepth
uint m_drawDisabledDepth
Definition: mythmainwindowprivate.h:78
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
compat.h
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:200
MythMainWindow::HidePainterWindow
void HidePainterWindow()
Definition: mythmainwindow.cpp:278
MythMainWindow::ExitToMainMenu
void ExitToMainMenu()
Definition: mythmainwindow.cpp:1046
MythCoreContext::GetDurSetting
std::enable_if_t< std::chrono::__is_duration< T >::value, T > GetDurSetting(const QString &key, T defaultval=T::zero())
Definition: mythcorecontext.h:170
mythscreensaver.h
MythMediaEvent
Definition: mythmedia.h:183
MythMainWindowPrivate::m_keyContexts
QHash< QString, KeyContext * > m_keyContexts
Definition: mythmainwindowprivate.h:61
MythMainWindow::ShowPainterWindow
void ShowPainterWindow()
Definition: mythmainwindow.cpp:269
State
State
Definition: zmserver.h:68
MythMainWindow::DestinationExists
bool DestinationExists(const QString &Destination) const
Definition: mythmainwindow.cpp:1470
DestroyMythMainWindow
void DestroyMythMainWindow(void)
Definition: mythmainwindow.cpp:111
MythNotificationCenter::DisplayedNotifications
int DisplayedNotifications(void) const
Returns number of notifications currently displayed.
Definition: mythnotificationcenter.cpp:1413
MythDisplay::SetWidget
void SetWidget(QWidget *MainWindow)
Set the QWidget and QWindow in use.
Definition: mythdisplay.cpp:245
MythCoreContext::GetDB
MythDB * GetDB(void)
Definition: mythcorecontext.cpp:1783
mythmedia.h
MythUIScreenBounds::m_screenRect
QRect m_screenRect
Definition: mythuiscreenbounds.h:44
MythUIScreenBounds::SetUIScreenRect
void SetUIScreenRect(QRect Rect)
Definition: mythuiscreenbounds.cpp:200
MythMainWindowPrivate::m_drawDisableLock
QMutex m_drawDisableLock
Definition: mythmainwindowprivate.h:77
MythMainWindow::RemoteScreenShot
void RemoteScreenShot(QString Filename, int Width, int Height)
Definition: mythmainwindow.cpp:526
MythScreenSaverControl
Controls all instances of the screensaver.
Definition: mythscreensaver.h:33
MythGesture::Record
bool Record(QPoint Point, Qt::MouseButton Button)
Record a point.
Definition: mythgesture.cpp:331
MythMainWindow::eventFilter
bool eventFilter(QObject *Watched, QEvent *Event) override
Definition: mythmainwindow.cpp:1644
ACTION_SELECT
#define ACTION_SELECT
Definition: mythuiactions.h:15
MythMainWindow::Animate
void Animate()
Definition: mythmainwindow.cpp:334
JumpData::m_destination
QString m_destination
Definition: mythmainwindowprivate.h:39
MythGestureEvent::Click
@ Click
Definition: mythgesture.h:77
MythGestureEvent::SetPosition
void SetPosition(QPoint Position)
Definition: mythgesture.h:86
MythMainWindowPrivate::m_escapekey
int m_escapekey
Definition: mythmainwindowprivate.h:71
MythInputDeviceHandler::Reset
void Reset(void)
Definition: mythinputdevicehandler.cpp:156
MythEvent::kDisableUDPListenerEventType
static Type kDisableUDPListenerEventType
Definition: mythevent.h:88
MythMainWindow::GetPaintWindow
QWidget * GetPaintWindow()
Definition: mythmainwindow.cpp:264
mythpainter.h
MythMainWindow::RegisterJump
void RegisterJump(const QString &Destination, const QString &Description, const QString &Key, void(*Callback)(void), bool Exittomain=true, QString LocalAction="")
Definition: mythmainwindow.cpp:1412
MythMainWindow::IsTopScreenInitialized
static bool IsTopScreenInitialized()
Definition: mythmainwindow.cpp:602
JumpData
Definition: mythmainwindowprivate.h:36
MythMainWindow::SignalRemoteScreenShot
void SignalRemoteScreenShot(QString Filename, int Width, int Height)
MSqlQuery::isConnected
bool isConnected(void) const
Only updated once during object creation.
Definition: mythdbcon.h:134
uint
unsigned int uint
Definition: compat.h:144
ACTION_9
#define ACTION_9
Definition: mythuiactions.h:13
ACTION_TVPOWERON
#define ACTION_TVPOWERON
Definition: mythuiactions.h:25
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:60
MythPainterWindow::GetRenderDevice
MythRender * GetRenderDevice()
Definition: mythpainterwindow.cpp:160
mythuistatetracker.h
MythMainWindow::GetStackAt
MythScreenStack * GetStackAt(int Position)
Definition: mythmainwindow.cpp:327
MythDisplay
Definition: mythdisplay.h:22
MythMainWindow::EnumerateDestinations
QStringList EnumerateDestinations() const
Definition: mythmainwindow.cpp:1475
ACTION_4
#define ACTION_4
Definition: mythuiactions.h:8
MythMainWindow::m_refreshTimer
QTimer m_refreshTimer
Definition: mythmainwindow.h:166
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:936
mythgesture.h
A C++ ripoff of the stroke library for MythTV.
MythMainWindowPrivate::m_enteringStandby
bool m_enteringStandby
Definition: mythmainwindowprivate.h:81
ACTION_1
#define ACTION_1
Definition: mythuiactions.h:5
MythPainter::End
virtual void End()
Definition: mythpainter.h:53
MythMainWindow::PushDrawDisabled
uint PushDrawDisabled()
Definition: mythmainwindow.cpp:985
MythMainWindow::m_priv
MythMainWindowPrivate * m_priv
Definition: mythmainwindow.h:163
MythMainWindow::GetCurrentNotificationCenter
MythNotificationCenter * GetCurrentNotificationCenter()
Definition: mythmainwindow.cpp:259
MythMainWindow::m_idleTime
std::chrono::minutes m_idleTime
Definition: mythmainwindow.h:175
MythPainter::GetName
virtual QString GetName(void)=0
MythUDP::EnableUDPListener
static void EnableUDPListener(bool Enable=true)
Definition: mythudplistener.cpp:173
mythuihelper.h
MythCoreContext::GetMasterServerPort
static int GetMasterServerPort(void)
Returns the Master Backend control port If no master server port has been defined in the database,...
Definition: mythcorecontext.cpp:1004
ACTION_7
#define ACTION_7
Definition: mythuiactions.h:11
MythUIScreenBounds::InitScreenBounds
void InitScreenBounds()
Definition: mythuiscreenbounds.cpp:129
MythMainWindow::~MythMainWindow
~MythMainWindow() override
Definition: mythmainwindow.cpp:207
MythMainWindow::paintEngine
QPaintEngine * paintEngine() const override
Definition: mythmainwindow.cpp:468
MythUIScreenBounds::m_wantWindow
bool m_wantWindow
Definition: mythuiscreenbounds.h:47
mythmiscutil.h
MythEvent::kUnlockInputDevicesEventType
static Type kUnlockInputDevicesEventType
Definition: mythevent.h:86
MythScreenSaverControl::Disable
void Disable()
MythUIScreenBounds::WindowIsAlwaysFullscreen
static bool WindowIsAlwaysFullscreen()
Return true if the current platform only supports fullscreen windows.
Definition: mythuiscreenbounds.cpp:114
MythMainWindow::GetTarget
QObject * GetTarget(QKeyEvent &Key)
Definition: mythmainwindow.cpp:2052
mythcorecontext.h
MythMainWindow::EnterStandby
void EnterStandby(bool Manual=true)
Definition: mythmainwindow.cpp:2167
mainLock
static QMutex mainLock
Definition: mythmainwindow.cpp:68
MythRender
Definition: mythrender_base.h:23
MediaPlayCallback
int(*)(const QString &, const QString &, const QString &, const QString &, const QString &, int, int, const QString &, std::chrono::minutes, const QString &, const QString &, bool) MediaPlayCallback
Definition: mythmainwindow.h:26
MythPainter
Definition: mythpainter.h:32
MythDisplay::SwitchToGUI
bool SwitchToGUI(bool Wait=false)
Switches to the GUI resolution.
Definition: mythdisplay.cpp:768
MythMainWindow::InitKeys
void InitKeys()
Definition: mythmainwindow.cpp:787
MythMainWindow::m_display
MythDisplay * m_display
Definition: mythmainwindow.h:164
MythCoreContext::ResetLanguage
void ResetLanguage(void)
Definition: mythcorecontext.cpp:1817
myththemebase.h
MythMainWindow::PopDrawDisabled
uint PopDrawDisabled()
Definition: mythmainwindow.cpp:994
mythudplistener.h
Name
Definition: channelsettings.cpp:46
MythCoreContext::GetSettingOnHost
QString GetSettingOnHost(const QString &key, const QString &host, const QString &defaultval="")
Definition: mythcorecontext.cpp:950
MythMainWindow::IsScreensaverAsleep
static bool IsScreensaverAsleep()
Definition: mythmainwindow.cpp:591
ACTION_GETSTATUS
#define ACTION_GETSTATUS
Definition: mythuiactions.h:27
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:878
MythMainWindow::m_repaintRegion
QRegion m_repaintRegion
Definition: mythmainwindow.h:165
MythMainWindowPrivate::m_allowInput
bool m_allowInput
Definition: mythmainwindowprivate.h:83
MythMainWindow::m_deviceHandler
MythInputDeviceHandler * m_deviceHandler
Definition: mythmainwindow.h:172
GetNotificationCenter
MythNotificationCenter * GetNotificationCenter(void)
Definition: mythmainwindow.cpp:121
MythGestureEvent::kEventType
static Type kEventType
Definition: mythgesture.h:91
MythUIThemeCache::UpdateImageCache
void UpdateImageCache()
Definition: mythuithemecache.cpp:60
MythEvent::kMythPostShowEventType
static Type kMythPostShowEventType
Definition: mythevent.h:82
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:101
MythUIType::ContainsPoint
bool ContainsPoint(QPoint point) const
Check if the given point falls within this widgets area.
Definition: mythuitype.cpp:1394
build_compdb.action
action
Definition: build_compdb.py:9
ACTION_LEFT
#define ACTION_LEFT
Definition: mythuiactions.h:18
MythMainWindow::MouseTimeout
void MouseTimeout()
Definition: mythmainwindow.cpp:1531
MythMainWindowPrivate::m_jumpMap
QMap< int, JumpData * > m_jumpMap
Definition: mythmainwindowprivate.h:62
MythMainWindowPrivate::m_gesture
MythGesture m_gesture
Definition: mythmainwindowprivate.h:74
MythMainWindow::DelayedAction
void DelayedAction()
Definition: mythmainwindow.cpp:777
MythMainWindow::IsExitingToMain
bool IsExitingToMain() const
Definition: mythmainwindow.cpp:1041
MythMainWindowPrivate::m_firstinit
bool m_firstinit
Definition: mythmainwindowprivate.h:86
MythScreenType::gestureEvent
bool gestureEvent(MythGestureEvent *event) override
Mouse click/movement handler, receives mouse gesture events from the QCoreApplication event loop.
Definition: mythscreentype.cpp:439
MythPainter::SetClipRect
virtual void SetClipRect(QRect clipRect)
Definition: mythpainter.cpp:46
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &Stackname)
Definition: mythmainwindow.cpp:319
ExternalKeycodeEvent::kEventType
static Type kEventType
Definition: mythevent.h:112
MythThemeBase::Reload
void Reload()
Definition: myththemebase.cpp:36
ACTION_5
#define ACTION_5
Definition: mythuiactions.h:9
MythGesture::GetGesture
MythGestureEvent * GetGesture() const
Complete the gesture event of the last completed stroke.
Definition: mythgesture.cpp:190
KeyContext
Definition: mythmainwindowprivate.h:12
MythMainWindow::ClearKeyContext
void ClearKeyContext(const QString &Context)
Definition: mythmainwindow.cpp:1204
MythMainWindow::SignalResetScreensaver
void SignalResetScreensaver()
mythuiactions.h
MythMediaDevice
Definition: mythmedia.h:48
MythNotificationCenter::GetInstance
static MythNotificationCenter * GetInstance(void)
returns the MythNotificationCenter singleton
Definition: mythnotificationcenter.cpp:1320
MythMainWindow::m_oldPainter
MythPainter * m_oldPainter
Definition: mythmainwindow.h:169
MythPainterWindow::RenderIsShared
bool RenderIsShared()
Definition: mythpainterwindow.cpp:165
MythGestureEvent
A custom event that represents a mouse gesture.
Definition: mythgesture.h:39
MythMainWindow::m_painterWin
MythPainterWindow * m_painterWin
Definition: mythmainwindow.h:170
MythMainWindow::MoveResize
void MoveResize(QRect &Geometry)
Definition: mythmainwindow.cpp:974
MythDisplay::UsingVideoModes
virtual bool UsingVideoModes()
Definition: mythdisplay.h:30
MythCoreContext::BlockShutdown
void BlockShutdown(void)
Definition: mythcorecontext.cpp:620
MythNotificationCenter
Definition: mythnotificationcenter.h:40
GetMythPainter
MythPainter * GetMythPainter(void)
Definition: mythmainwindow.cpp:116
MythMainWindow::GrabWindow
static void GrabWindow(QImage &Image)
Definition: mythmainwindow.cpp:486
MythMainWindow::ResetScreensaver
static void ResetScreensaver()
Definition: mythmainwindow.cpp:585
MythMainWindow::AllowInput
void AllowInput(bool Allow)
Definition: mythmainwindow.cpp:1526
MythUIThemeCache::ClearThemeCacheDir
void ClearThemeCacheDir()
Definition: mythuithemecache.cpp:55
mythburn.usebookmark
bool usebookmark
Definition: mythburn.py:179
MythMainWindow::IdleTimeout
void IdleTimeout()
Definition: mythmainwindow.cpp:2147
MythInputDeviceHandler::Event
void Event(QEvent *Event) const
Definition: mythinputdevicehandler.cpp:163
GetMythUI
MythUIHelper * GetMythUI()
Definition: mythuihelper.cpp:66
MythMainWindow::ScreenShot
static bool ScreenShot(int Width=0, int Height=0, QString Filename="")
Definition: mythmainwindow.cpp:561
build_compdb.filename
filename
Definition: build_compdb.py:21
MythMainWindow::RestartInputHandlers
void RestartInputHandlers()
Definition: mythmainwindow.cpp:2072
MythMainWindowPrivate::m_mainStack
MythScreenStack * m_mainStack
Definition: mythmainwindowprivate.h:73
mythmainwindow.h
MythMainWindowPrivate::m_standby
bool m_standby
Definition: mythmainwindowprivate.h:80
MythMainWindow::m_painter
MythPainter * m_painter
Definition: mythmainwindow.h:168
MythScreenType::IsInitialized
bool IsInitialized(void) const
Has Init() been called on this screen?
Definition: mythscreentype.cpp:359
MythCoreContext::dispatch
void dispatch(const MythEvent &event)
Definition: mythcorecontext.cpp:1749
MythMainWindow::GetActionText
QString GetActionText(const QString &Context, const QString &Action) const
Definition: mythmainwindow.cpp:1339
ShowOkPopup
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
Definition: mythdialogbox.cpp:558
MythPainter::Begin
virtual void Begin(QPaintDevice *)
Definition: mythpainter.h:52
MythMainWindow::BindKey
void BindKey(const QString &Context, const QString &Action, const QString &Key)
Definition: mythmainwindow.cpp:1211
MythMainWindow::ExitStandby
void ExitStandby(bool Manual=true)
Definition: mythmainwindow.cpp:2202
MythObservable::removeListener
void removeListener(QObject *listener)
Remove a listener to the observable.
Definition: mythobservable.cpp:55
MythDisplay::Create
static MythDisplay * Create(MythMainWindow *MainWindow)
Create a MythDisplay object appropriate for the current platform.
Definition: mythdisplay.cpp:80
mainWin
static MythMainWindow * mainWin
Definition: mythmainwindow.cpp:67
MythMainWindowPrivate::m_nc
MythNotificationCenter * m_nc
Definition: mythmainwindowprivate.h:79
MythMainWindow
Definition: mythmainwindow.h:35
EARLY_SHOW_PLATFORM_NAME_CHECK
#define EARLY_SHOW_PLATFORM_NAME_CHECK
MythMainWindow::drawScreen
void drawScreen(QPaintEvent *Event=nullptr)
Definition: mythmainwindow.cpp:372
MythCoreContext::SetGUIObject
void SetGUIObject(QObject *gui)
Definition: mythcorecontext.cpp:1763
mythscreentype.h
MythUIScreenBounds::GeometryIsOverridden
static bool GeometryIsOverridden()
Definition: mythuiscreenbounds.cpp:19
MythUIScreenBounds::m_uiScreenRect
QRect m_uiScreenRect
Definition: mythuiscreenbounds.h:43
MythNotificationCenterEvent::kEventType
static Type kEventType
Definition: mythnotificationcenter.h:30
MythMainWindow::PauseIdleTimer
void PauseIdleTimer(bool Pause)
Pause the idle timeout timer.
Definition: mythmainwindow.cpp:2124
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:922
MythUDP::StopUDPListener
static void StopUDPListener()
Definition: mythudplistener.cpp:213
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:827
MythInputDeviceHandler::IgnoreKeys
void IgnoreKeys(bool Ignore)
Definition: mythinputdevicehandler.cpp:188
MythScreenStack::GetTopScreen
virtual MythScreenType * GetTopScreen(void) const
Definition: mythscreenstack.cpp:180
MythEvent::kEnableUDPListenerEventType
static Type kEnableUDPListenerEventType
Definition: mythevent.h:89
MythNotificationCenter::Queue
bool Queue(const MythNotification &notification)
Queue a notification Queue() is thread-safe and can be called from anywhere.
Definition: mythnotificationcenter.cpp:1351