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 <QInputMethodEvent>
23 #include <QSize>
24 #include <QWindow>
25 
26 // Platform headers
27 #include "unistd.h"
28 
29 // libmythbase headers
30 #include "libmythbase/compat.h"
32 #include "libmythbase/mythdate.h"
33 #include "libmythbase/mythdb.h"
34 #include "libmythbase/mythdirs.h"
35 #include "libmythbase/mythevent.h"
37 #include "libmythbase/mythmedia.h"
39 
40 // libmythui headers
41 #include "myththemebase.h"
42 #include "mythudplistener.h"
43 #include "mythrender_base.h"
44 #include "mythuistatetracker.h"
45 #include "mythuiactions.h"
46 #include "mythrect.h"
47 #include "mythdisplay.h"
48 #include "mythscreentype.h"
49 #include "mythpainter.h"
50 #include "mythpainterwindow.h"
51 #include "mythgesture.h"
52 #include "mythuihelper.h"
53 #include "mythdialogbox.h"
54 #include "mythscreensaver.h"
56 
57 
58 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
59 #ifdef Q_OS_ANDROID
60 #include <QtAndroid>
61 #endif
62 #endif
63 
64 static constexpr std::chrono::milliseconds GESTURE_TIMEOUT { 1s };
65 static constexpr std::chrono::minutes STANDBY_TIMEOUT { 90min };
66 static constexpr std::chrono::milliseconds LONGPRESS_INTERVAL { 1s };
67 
68 #define LOC QString("MythMainWindow: ")
69 
70 static MythMainWindow *s_mainWin = nullptr;
71 static QMutex s_mainLock;
72 
81 {
82  if (s_mainWin)
83  return s_mainWin;
84 
85  QMutexLocker lock(&s_mainLock);
86 
87  if (!s_mainWin)
88  {
89  s_mainWin = new MythMainWindow(UseDB);
91  }
92 
93  return s_mainWin;
94 }
95 
97 {
98  if (gCoreContext)
99  gCoreContext->SetGUIObject(nullptr);
100  delete s_mainWin;
101  s_mainWin = nullptr;
102 }
103 
105 {
107 }
108 
110 {
111  return s_mainWin != nullptr;
112 }
113 
115 {
117 }
118 
120 {
122 }
123 
125 {
127  return nullptr;
129 }
130 
132  : m_display(MythDisplay::Create(this))
133 {
134  // Switch to desired GUI resolution
135  if (m_display->UsingVideoModes())
136  m_display->SwitchToGUI(true);
137 
140 
142 
143  setObjectName("mainwindow");
144 
145  m_priv->m_allowInput = false;
146 
147  // This prevents database errors from RegisterKey() when there is no DB:
148  m_priv->m_useDB = UseDB;
149 
150  //Init();
151 
152  m_priv->m_exitingtomain = false;
153  m_priv->m_popwindows = true;
154  m_priv->m_exitMenuCallback = nullptr;
156  m_priv->m_mediaDeviceForCallback = nullptr;
157  m_priv->m_escapekey = Qt::Key_Escape;
158  m_priv->m_mainStack = nullptr;
159 
160  installEventFilter(this);
161 
163 
164  InitKeys();
165 
166  m_priv->m_gestureTimer = new QTimer(this);
168  m_priv->m_hideMouseTimer = new QTimer(this);
169  m_priv->m_hideMouseTimer->setSingleShot(true);
170  m_priv->m_hideMouseTimer->setInterval(3s);
172  m_priv->m_allowInput = true;
174  m_refreshTimer.setInterval(17ms);
175  m_refreshTimer.start();
176  setUpdatesEnabled(true);
177 
179  Qt::BlockingQueuedConnection);
181  Qt::BlockingQueuedConnection);
182 #ifdef Q_OS_ANDROID
183  connect(qApp, &QApplication::applicationStateChanged, this, &MythMainWindow::OnApplicationStateChange);
184 #endif
185 
186  // We need to listen for playback start/end events
187  gCoreContext->addListener(this);
188 
189  // Idle timer setup
190  m_idleTime =
191  gCoreContext->GetDurSetting<std::chrono::minutes>("FrontendIdleTimeout",
193  if (m_idleTime < 0min)
194  m_idleTime = 0min;
195  m_idleTimer.setInterval(m_idleTime);
197  if (m_idleTime > 0min)
198  m_idleTimer.start();
199 
201  if (m_screensaver)
202  {
206  }
207 }
208 
210 {
211  delete m_screensaver;
212 
213  if (gCoreContext != nullptr)
215 
217 
218  while (!m_priv->m_stackList.isEmpty())
219  {
220  MythScreenStack *stack = m_priv->m_stackList.back();
221  m_priv->m_stackList.pop_back();
222 
223  if (stack == m_priv->m_mainStack)
224  m_priv->m_mainStack = nullptr;
225 
226  delete stack;
227  }
228 
229  delete m_themeBase;
230 
231  for (auto iter = m_priv->m_keyContexts.begin();
232  iter != m_priv->m_keyContexts.end();
233  iter = m_priv->m_keyContexts.erase(iter))
234  {
235  KeyContext *context = *iter;
236  delete context;
237  }
238 
239  delete m_deviceHandler;
240  delete m_priv->m_nc;
241 
243 
244  // N.B. we always call this to ensure the desktop mode is restored
245  // in case the setting was changed
247  delete m_display;
248 
249  delete m_priv;
250 }
251 
253 {
254  return m_display;
255 }
256 
258 {
259  return m_painter;
260 }
261 
263 {
264  return m_priv->m_nc;
265 }
266 
268 {
269  return m_painterWin;
270 }
271 
273 {
274  if (m_painterWin)
275  {
276  m_painterWin->show();
277  m_painterWin->raise();
278  }
279 }
280 
282 {
283  if (m_painterWin)
284  {
285  m_painterWin->clearMask();
287  m_painterWin->hide();
288  }
289 }
290 
292 {
293  return m_painterWin->GetRenderDevice();
294 }
295 
297 {
298  m_priv->m_stackList.push_back(Stack);
299  if (Main)
300  m_priv->m_mainStack = Stack;
301 }
302 
304 {
305  MythScreenStack *stack = m_priv->m_stackList.back();
306  m_priv->m_stackList.pop_back();
307  if (stack == m_priv->m_mainStack)
308  m_priv->m_mainStack = nullptr;
309  delete stack;
310 }
311 
313 {
314  return m_priv->m_stackList.size();
315 }
316 
318 {
319  return m_priv->m_mainStack;
320 }
321 
322 MythScreenStack *MythMainWindow::GetStack(const QString& Stackname)
323 {
324  for (auto * widget : std::as_const(m_priv->m_stackList))
325  if (widget->objectName() == Stackname)
326  return widget;
327  return nullptr;
328 }
329 
331 {
332  if (Position >= 0 && Position < m_priv->m_stackList.size())
333  return m_priv->m_stackList.at(Position);
334  return nullptr;
335 }
336 
338 {
339  if (!(m_painterWin && updatesEnabled()))
340  return;
341 
342  bool redraw = false;
343 
344  if (!m_repaintRegion.isEmpty())
345  redraw = true;
346 
347  // The call to GetDrawOrder can apparently alter m_stackList.
348  // NOLINTNEXTLINE(modernize-loop-convert,readability-qualified-auto) // both, qt6
349  for (auto it = m_priv->m_stackList.begin(); it != m_priv->m_stackList.end(); ++it)
350  {
351  QVector<MythScreenType *> drawList;
352  (*it)->GetDrawOrder(drawList);
353 
354  for (auto *screen : std::as_const(drawList))
355  {
356  screen->Pulse();
357 
358  if (screen->NeedsRedraw())
359  {
360  QRegion topDirty = screen->GetDirtyArea();
361  screen->ResetNeedsRedraw();
362  m_repaintRegion = m_repaintRegion.united(topDirty);
363  redraw = true;
364  }
365  }
366  }
367 
368  if (redraw && !m_painterWin->RenderIsShared())
369  m_painterWin->update(m_repaintRegion);
370 
371  for (auto *widget : std::as_const(m_priv->m_stackList))
372  widget->ScheduleInitIfNeeded();
373 }
374 
376 {
377  if (!(m_painterWin && updatesEnabled()))
378  return;
379 
380  if (Event)
381  m_repaintRegion = m_repaintRegion.united(Event->region());
382 
383  if (!m_painter->SupportsClipping())
384  {
386  }
387  else
388  {
389  // Ensure that the region is not larger than the screen which
390  // can happen with bad themes
392 
393  // Check for any widgets that have been updated since we built
394  // the dirty region list in ::animate()
395  // The call to GetDrawOrder can apparently alter m_stackList.
396  // NOLINTNEXTLINE(modernize-loop-convert,readability-qualified-auto) // both, qt6
397  for (auto it = m_priv->m_stackList.begin(); it != m_priv->m_stackList.end(); ++it)
398  {
399  QVector<MythScreenType *> redrawList;
400  (*it)->GetDrawOrder(redrawList);
401 
402  for (const auto *screen : std::as_const(redrawList))
403  {
404  if (screen->NeedsRedraw())
405  {
406  for (const QRect& wrect: screen->GetDirtyArea())
407  {
408  bool foundThisRect = false;
409  for (const QRect& drect: m_repaintRegion)
410  {
411  // Can't use QRegion::contains because it only
412  // checks for overlap. QRect::contains checks
413  // if fully contained.
414  if (drect.contains(wrect))
415  {
416  foundThisRect = true;
417  break;
418  }
419  }
420 
421  if (!foundThisRect)
422  return;
423  }
424  }
425  }
426  }
427  }
428 
430  Draw();
431 
432  m_repaintRegion = QRegion();
433 }
434 
436 {
437  if (!Painter)
438  Painter = m_painter;
439  if (!Painter)
440  return;
441 
442  Painter->Begin(m_painterWin);
443 
444  if (!Painter->SupportsClipping())
445  m_repaintRegion = QRegion(m_uiScreenRect);
446 
447  for (const QRect& rect : m_repaintRegion)
448  {
449  if (rect.width() == 0 || rect.height() == 0)
450  continue;
451 
452  if (rect != m_uiScreenRect)
453  Painter->SetClipRect(rect);
454 
455  // The call to GetDrawOrder can apparently alter m_stackList.
456  // NOLINTNEXTLINE(modernize-loop-convert,readability-qualified-auto) // both, qt6
457  for (auto it = m_priv->m_stackList.begin(); it != m_priv->m_stackList.end(); ++it)
458  {
459  QVector<MythScreenType *> redrawList;
460  (*it)->GetDrawOrder(redrawList);
461  for (auto *screen : std::as_const(redrawList))
462  screen->Draw(Painter, 0, 0, 255, rect);
463  }
464  }
465 
466  Painter->End();
467  m_repaintRegion = QRegion();
468 }
469 
470 // virtual
471 QPaintEngine *MythMainWindow::paintEngine() const
472 {
473  return testAttribute(Qt::WA_PaintOnScreen) ? nullptr : QWidget::paintEngine();
474 }
475 
477 {
478  if (Event->spontaneous())
479  {
480  auto * key = new QKeyEvent(QEvent::KeyPress, m_priv->m_escapekey, Qt::NoModifier);
481  QCoreApplication::postEvent(this, key);
482  Event->ignore();
483  return;
484  }
485 
486  QWidget::closeEvent(Event);
487 }
488 
489 void MythMainWindow::GrabWindow(QImage& Image)
490 {
491  WId winid = 0;
492  auto * active = QApplication::activeWindow();
493  if (active)
494  {
495  winid = active->winId();
496  }
497  else
498  {
499  // According to the following we page, you "just pass 0 as the
500  // window id, indicating that we want to grab the entire screen".
501  //
502  // https://doc.qt.io/qt-5/qtwidgets-desktop-screenshot-example.html#screenshot-class-implementation
503  winid = 0;
504  }
505 
506  auto * display = GetMythMainWindow()->GetDisplay();
507  if (auto * screen = display->GetCurrentScreen(); screen)
508  {
509  QPixmap image = screen->grabWindow(winid);
510  Image = image.toImage();
511  }
512 }
513 
514 /* This is required to allow a screenshot to be requested by another thread
515  * other than the UI thread, and to wait for the screenshot before returning.
516  * It is used by mythweb for the remote access screenshots
517  */
518 void MythMainWindow::DoRemoteScreenShot(const QString& Filename, int Width, int Height)
519 {
520  // This will be running in the UI thread, as is required by QPixmap
521  QStringList args;
522  args << QString::number(Width);
523  args << QString::number(Height);
524  args << Filename;
526  QCoreApplication::sendEvent(this, &me);
527 }
528 
529 void MythMainWindow::RemoteScreenShot(QString Filename, int Width, int Height)
530 {
531  // This will be running in a non-UI thread and is used to trigger a
532  // function in the UI thread, and waits for completion of that handler
533  emit SignalRemoteScreenShot(std::move(Filename), Width, Height);
534 }
535 
536 bool MythMainWindow::SaveScreenShot(const QImage& Image, QString Filename)
537 {
538  if (Filename.isEmpty())
539  {
540  QString fpath = GetMythDB()->GetSetting("ScreenShotPath", "/tmp");
541  Filename = QString("%1/myth-screenshot-%2.png")
543  }
544 
545  QString extension = Filename.section('.', -1, -1);
546  if (extension == "jpg")
547  extension = "JPEG";
548  else
549  extension = "PNG";
550 
551  LOG(VB_GENERAL, LOG_INFO, QString("Saving screenshot to %1 (%2x%3)")
552  .arg(Filename).arg(Image.width()).arg(Image.height()));
553 
554  if (Image.save(Filename, extension.toLatin1(), 100))
555  {
556  LOG(VB_GENERAL, LOG_INFO, "MythMainWindow::screenShot succeeded");
557  return true;
558  }
559 
560  LOG(VB_GENERAL, LOG_INFO, "MythMainWindow::screenShot Failed!");
561  return false;
562 }
563 
564 bool MythMainWindow::ScreenShot(int Width, int Height, QString Filename)
565 {
566  QImage img;
567  GrabWindow(img);
568  if (Width <= 0)
569  Width = img.width();
570  if (Height <= 0)
571  Height = img.height();
572  img = img.scaled(Width, Height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
573  return SaveScreenShot(img, std::move(Filename));
574 }
575 
577 {
578  if (HasMythMainWindow())
580 }
581 
583 {
584  if (HasMythMainWindow())
586 }
587 
589 {
590  if (HasMythMainWindow())
592 }
593 
595 {
596  if (HasMythMainWindow())
597  {
598  MythMainWindow* window = GetMythMainWindow();
599  if (window->m_screensaver)
600  return window->m_screensaver->Asleep();
601  }
602  return false;
603 }
604 
606 {
607  if (HasMythMainWindow())
609  return false;
610 }
611 
613 {
614  if (!updatesEnabled() && (Event->type() == QEvent::UpdateRequest))
615  m_priv->m_pendingUpdate = true;
616 
617  if (Event->type() == QEvent::Show && !Event->spontaneous())
618  QCoreApplication::postEvent(this, new QEvent(MythEvent::kMythPostShowEventType));
619 
621  {
622  raise();
623  activateWindow();
624  return true;
625  }
626 
627  if ((Event->type() == QEvent::WindowActivate) || (Event->type() == QEvent::WindowDeactivate))
629 
630  return QWidget::event(Event);
631 }
632 
634 {
638  QApplication::setStyle("Windows");
639 }
640 
641 void MythMainWindow::Init(bool MayReInit)
642 {
643  LoadQtConfig();
644  m_display->SetWidget(nullptr);
645  m_priv->m_useDB = ! gCoreContext->GetDB()->SuppressDBMessages();
646 
647  if (!(MayReInit || m_priv->m_firstinit))
648  return;
649 
650  // Set window border based on fullscreen attribute
651  Qt::WindowFlags flags = Qt::Window;
652 
654  bool inwindow = m_wantWindow && !m_qtFullScreen;
655  bool fullscreen = m_wantFullScreen && !GeometryIsOverridden();
656 
657  // On Compiz/Unit, when the window is fullscreen and frameless changing
658  // screen position ends up stuck. Adding a border temporarily prevents this
659  setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
660 
661  if (!inwindow)
662  {
663  LOG(VB_GENERAL, LOG_INFO, "Using Frameless Window");
664  flags |= Qt::FramelessWindowHint;
665  }
666 
667  // Workaround Qt/Windows playback bug?
668 #ifdef _WIN32
669  flags |= Qt::MSWindowsOwnDC;
670 #endif
671 
672  // NOTE if running fullscreen AND windowed (i.e. borders etc) then we do not
673  // have any idea at this time of the size of the borders/decorations.
674  // Typically, on linux, this means we create the UI slightly larger than
675  // required - as X adds the decorations at a later point.
676 
677  if (fullscreen && !inwindow)
678  {
679  LOG(VB_GENERAL, LOG_INFO, "Using Full Screen Window");
680  if (m_priv->m_firstinit)
681  {
682  // During initialization, we force being fullscreen using setWindowState
683  // otherwise, in ubuntu's unity, the side bar often stays visible
684  setWindowState(Qt::WindowFullScreen);
685  }
686  }
687  else
688  {
689  // reset type
690  setWindowState(Qt::WindowNoState);
691  }
692 
694  flags |= Qt::WindowStaysOnTopHint;
695 
696  setWindowFlags(flags);
697 
698  // SetWidget may move the widget into a new screen.
699  m_display->SetWidget(this);
700  QTimer::singleShot(1s, this, &MythMainWindow::DelayedAction);
701 
702  // Ensure we have latest screen bounds if we have moved
704  SetUIScreenRect({{0, 0}, m_screenRect.size()});
706  Show();
707 
708  // The window is sometimes not created until Show has been called - so try
709  // MythDisplay::setWidget again to ensure we listen for QScreen changes
710  m_display->SetWidget(this);
711 
712  if (!GetMythDB()->GetBoolSetting("HideMouseCursor", false))
713  setMouseTracking(true); // Required for mouse cursor auto-hide
714  // Set cursor call must come after Show() to work on some systems.
715  ShowMouseCursor(false);
716 
717  move(m_screenRect.topLeft());
718 
719  if (m_painterWin || m_painter)
720  {
721  LOG(VB_GENERAL, LOG_INFO, "Destroying painter and painter window");
723  }
724 
725  QString warningmsg = MythPainterWindow::CreatePainters(this, m_painterWin, m_painter);
726  if (!warningmsg.isEmpty())
727  {
728  LOG(VB_GENERAL, LOG_WARNING, warningmsg);
729  }
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  setAttribute(Qt::WA_InputMethodEnabled);
743 
746 
747  // Redraw the window now to avoid race conditions in EGLFS (Qt5.4) if a
748  // 2nd window (e.g. TVPlayback) is created before this is redrawn.
749 #ifdef Q_OS_ANDROID
750  static const QLatin1String EARLY_SHOW_PLATFORM_NAME_CHECK { "android" };
751 #else
752  static const QLatin1String EARLY_SHOW_PLATFORM_NAME_CHECK { "egl" };
753 #endif
754  if (QGuiApplication::platformName().contains(EARLY_SHOW_PLATFORM_NAME_CHECK))
755  QCoreApplication::processEvents();
756 
757  if (!GetMythDB()->GetBoolSetting("HideMouseCursor", false))
758  m_painterWin->setMouseTracking(true); // Required for mouse cursor auto-hide
759 
761  if (m_themeBase)
762  m_themeBase->Reload();
763  else
764  m_themeBase = new MythThemeBase(this);
765 
766  if (!m_priv->m_nc)
768 
769  emit SignalWindowReady();
770 
771  if (!warningmsg.isEmpty())
772  {
773  MythNotification notification(warningmsg, "");
774  m_priv->m_nc->Queue(notification);
775  }
776 }
777 
779 {
781  Show();
782 
783 #ifdef Q_OS_ANDROID
784 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
785  QtAndroid::hideSplashScreen();
786 #else
787  QNativeInterface::QAndroidApplication::hideSplashScreen();
788 #endif
789 #endif
790 }
791 
793 {
794  RegisterKey("Global", ACTION_UP, QT_TRANSLATE_NOOP("MythControls",
795  "Up Arrow"), "Up");
796  RegisterKey("Global", ACTION_DOWN, QT_TRANSLATE_NOOP("MythControls",
797  "Down Arrow"), "Down");
798  RegisterKey("Global", ACTION_LEFT, QT_TRANSLATE_NOOP("MythControls",
799  "Left Arrow"), "Left");
800  RegisterKey("Global", ACTION_RIGHT, QT_TRANSLATE_NOOP("MythControls",
801  "Right Arrow"), "Right");
802  RegisterKey("Global", "NEXT", QT_TRANSLATE_NOOP("MythControls",
803  "Move to next widget"), "Tab");
804  RegisterKey("Global", "PREVIOUS", QT_TRANSLATE_NOOP("MythControls",
805  "Move to preview widget"), "Backtab");
806  RegisterKey("Global", ACTION_SELECT, QT_TRANSLATE_NOOP("MythControls",
807  "Select"), "Return,Enter,Space");
808  RegisterKey("Global", "BACKSPACE", QT_TRANSLATE_NOOP("MythControls",
809  "Backspace"), "Backspace");
810  RegisterKey("Global", "ESCAPE", QT_TRANSLATE_NOOP("MythControls",
811  "Escape"), "Esc,Back");
812  RegisterKey("Global", "MENU", QT_TRANSLATE_NOOP("MythControls",
813  "Pop-up menu"), "M,Meta+Enter,Ctrl+M,Menu");
814  RegisterKey("Global", "INFO", QT_TRANSLATE_NOOP("MythControls",
815  "More information"), "I,Ctrl+I,Home Page");
816  RegisterKey("Global", "DELETE", QT_TRANSLATE_NOOP("MythControls",
817  "Delete"), "D,Ctrl+E");
818  RegisterKey("Global", "EDIT", QT_TRANSLATE_NOOP("MythControls",
819  "Edit"), "E");
820  RegisterKey("Global", ACTION_SCREENSHOT, QT_TRANSLATE_NOOP("MythControls",
821  "Save screenshot"), "");
822  RegisterKey("Global", ACTION_HANDLEMEDIA, QT_TRANSLATE_NOOP("MythControls",
823  "Play a media resource"), "");
824 
825  RegisterKey("Global", "PAGEUP", QT_TRANSLATE_NOOP("MythControls",
826  "Page Up"), "PgUp");
827  RegisterKey("Global", "PAGEDOWN", QT_TRANSLATE_NOOP("MythControls",
828  "Page Down"), "PgDown");
829  RegisterKey("Global", "PAGETOP", QT_TRANSLATE_NOOP("MythControls",
830  "Page to top of list"), "");
831  RegisterKey("Global", "PAGEMIDDLE", QT_TRANSLATE_NOOP("MythControls",
832  "Page to middle of list"), "");
833  RegisterKey("Global", "PAGEBOTTOM", QT_TRANSLATE_NOOP("MythControls",
834  "Page to bottom of list"), "");
835 
836  RegisterKey("Global", "PREVVIEW", QT_TRANSLATE_NOOP("MythControls",
837  "Previous View"), "Home,Media Previous");
838  RegisterKey("Global", "NEXTVIEW", QT_TRANSLATE_NOOP("MythControls",
839  "Next View"), "End,Media Next");
840 
841  RegisterKey("Global", "HELP", QT_TRANSLATE_NOOP("MythControls",
842  "Help"), "F1");
843  RegisterKey("Global", "EJECT", QT_TRANSLATE_NOOP("MythControls"
844  ,"Eject Removable Media"), "");
845 
846  RegisterKey("Global", "CUT", QT_TRANSLATE_NOOP("MythControls",
847  "Cut text from textedit"), "Ctrl+X");
848  RegisterKey("Global", "COPY", QT_TRANSLATE_NOOP("MythControls"
849  ,"Copy text from textedit"), "Ctrl+C");
850  RegisterKey("Global", "PASTE", QT_TRANSLATE_NOOP("MythControls",
851  "Paste text into textedit"), "Ctrl+V");
852  RegisterKey("Global", "NEWLINE", QT_TRANSLATE_NOOP("MythControls",
853  "Insert newline into textedit"), "Ctrl+Return");
854  RegisterKey("Global", "UNDO", QT_TRANSLATE_NOOP("MythControls",
855  "Undo"), "Ctrl+Z");
856  RegisterKey("Global", "REDO", QT_TRANSLATE_NOOP("MythControls",
857  "Redo"), "Ctrl+Y");
858  RegisterKey("Global", "SEARCH", QT_TRANSLATE_NOOP("MythControls",
859  "Show incremental search dialog"), "Ctrl+S,Search");
860 
861  RegisterKey("Global", ACTION_0, QT_TRANSLATE_NOOP("MythControls","0"), "0");
862  RegisterKey("Global", ACTION_1, QT_TRANSLATE_NOOP("MythControls","1"), "1");
863  RegisterKey("Global", ACTION_2, QT_TRANSLATE_NOOP("MythControls","2"), "2");
864  RegisterKey("Global", ACTION_3, QT_TRANSLATE_NOOP("MythControls","3"), "3");
865  RegisterKey("Global", ACTION_4, QT_TRANSLATE_NOOP("MythControls","4"), "4");
866  RegisterKey("Global", ACTION_5, QT_TRANSLATE_NOOP("MythControls","5"), "5");
867  RegisterKey("Global", ACTION_6, QT_TRANSLATE_NOOP("MythControls","6"), "6");
868  RegisterKey("Global", ACTION_7, QT_TRANSLATE_NOOP("MythControls","7"), "7");
869  RegisterKey("Global", ACTION_8, QT_TRANSLATE_NOOP("MythControls","8"), "8");
870  RegisterKey("Global", ACTION_9, QT_TRANSLATE_NOOP("MythControls","9"), "9");
871 
872  RegisterKey("Global", ACTION_TVPOWERON, QT_TRANSLATE_NOOP("MythControls",
873  "Turn the display on"), "");
874  RegisterKey("Global", ACTION_TVPOWEROFF, QT_TRANSLATE_NOOP("MythControls",
875  "Turn the display off"), "");
876 
877  RegisterKey("Global", "SYSEVENT01", QT_TRANSLATE_NOOP("MythControls",
878  "Trigger System Key Event #1"), "");
879  RegisterKey("Global", "SYSEVENT02", QT_TRANSLATE_NOOP("MythControls",
880  "Trigger System Key Event #2"), "");
881  RegisterKey("Global", "SYSEVENT03", QT_TRANSLATE_NOOP("MythControls",
882  "Trigger System Key Event #3"), "");
883  RegisterKey("Global", "SYSEVENT04", QT_TRANSLATE_NOOP("MythControls",
884  "Trigger System Key Event #4"), "");
885  RegisterKey("Global", "SYSEVENT05", QT_TRANSLATE_NOOP("MythControls",
886  "Trigger System Key Event #5"), "");
887  RegisterKey("Global", "SYSEVENT06", QT_TRANSLATE_NOOP("MythControls",
888  "Trigger System Key Event #6"), "");
889  RegisterKey("Global", "SYSEVENT07", QT_TRANSLATE_NOOP("MythControls",
890  "Trigger System Key Event #7"), "");
891  RegisterKey("Global", "SYSEVENT08", QT_TRANSLATE_NOOP("MythControls",
892  "Trigger System Key Event #8"), "");
893  RegisterKey("Global", "SYSEVENT09", QT_TRANSLATE_NOOP("MythControls",
894  "Trigger System Key Event #9"), "");
895  RegisterKey("Global", "SYSEVENT10", QT_TRANSLATE_NOOP("MythControls",
896  "Trigger System Key Event #10"), "");
897 
898  // these are for the html viewer widget (MythUIWebBrowser)
899  RegisterKey("Browser", "ZOOMIN", QT_TRANSLATE_NOOP("MythControls",
900  "Zoom in on browser window"), ".,>,Ctrl+F,Media Fast Forward");
901  RegisterKey("Browser", "ZOOMOUT", QT_TRANSLATE_NOOP("MythControls",
902  "Zoom out on browser window"), ",,<,Ctrl+B,Media Rewind");
903  RegisterKey("Browser", "TOGGLEINPUT", QT_TRANSLATE_NOOP("MythControls",
904  "Toggle where keyboard input goes to"), "F1");
905 
906  RegisterKey("Browser", "MOUSEUP", QT_TRANSLATE_NOOP("MythControls",
907  "Move mouse pointer up"), "2");
908  RegisterKey("Browser", "MOUSEDOWN", QT_TRANSLATE_NOOP("MythControls",
909  "Move mouse pointer down"), "8");
910  RegisterKey("Browser", "MOUSELEFT", QT_TRANSLATE_NOOP("MythControls",
911  "Move mouse pointer left"), "4");
912  RegisterKey("Browser", "MOUSERIGHT", QT_TRANSLATE_NOOP("MythControls",
913  "Move mouse pointer right"), "6");
914  RegisterKey("Browser", "MOUSELEFTBUTTON", QT_TRANSLATE_NOOP("MythControls",
915  "Mouse Left button click"), "5");
916 
917  RegisterKey("Browser", "PAGEDOWN", QT_TRANSLATE_NOOP("MythControls",
918  "Scroll down half a page"), "9");
919  RegisterKey("Browser", "PAGEUP", QT_TRANSLATE_NOOP("MythControls",
920  "Scroll up half a page"), "3");
921  RegisterKey("Browser", "PAGELEFT", QT_TRANSLATE_NOOP("MythControls",
922  "Scroll left half a page"), "7");
923  RegisterKey("Browser", "PAGERIGHT", QT_TRANSLATE_NOOP("MythControls",
924  "Scroll right half a page"), "1");
925 
926  RegisterKey("Browser", "NEXTLINK", QT_TRANSLATE_NOOP("MythControls",
927  "Move selection to next link"), "Z");
928  RegisterKey("Browser", "PREVIOUSLINK", QT_TRANSLATE_NOOP("MythControls",
929  "Move selection to previous link"), "Q");
930  RegisterKey("Browser", "FOLLOWLINK", QT_TRANSLATE_NOOP("MythControls",
931  "Follow selected link"), "Return,Space,Enter");
932  RegisterKey("Browser", "HISTORYBACK", QT_TRANSLATE_NOOP("MythControls",
933  "Go back to previous page"), "R,Backspace");
934  RegisterKey("Browser", "HISTORYFORWARD", QT_TRANSLATE_NOOP("MythControls",
935  "Go forward to previous page"), "F");
936 
937  RegisterKey("Main Menu", "EXITPROMPT", QT_TRANSLATE_NOOP("MythControls",
938  "Display System Exit Prompt"), "Esc,Back");
939  RegisterKey("Main Menu", "EXIT", QT_TRANSLATE_NOOP("MythControls",
940  "System Exit"), "");
941  RegisterKey("Main Menu", "STANDBYMODE",QT_TRANSLATE_NOOP("MythControls",
942  "Enter Standby Mode"), "");
943  RegisterKey("Long Press", "LONGPRESS1",QT_TRANSLATE_NOOP("MythControls",
944  "Up to 16 Keys that allow Long Press"), "");
945  RegisterKey("Long Press", "LONGPRESS2",QT_TRANSLATE_NOOP("MythControls",
946  "Up to 16 Keys that allow Long Press"), "");
947  RegisterKey("Long Press", "LONGPRESS3",QT_TRANSLATE_NOOP("MythControls",
948  "Up to 16 Keys that allow Long Press"), "");
949  RegisterKey("Long Press", "LONGPRESS4",QT_TRANSLATE_NOOP("MythControls",
950  "Up to 16 Keys that allow Long Press"), "");
951 }
952 
954 {
955  ClearKeyContext("Global");
956  ClearKeyContext("Browser");
957  ClearKeyContext("Main Menu");
958  InitKeys();
959 }
960 
962 {
963  bool inwindow = m_wantWindow && !m_qtFullScreen;
964  bool fullscreen = m_wantFullScreen && !GeometryIsOverridden();
965  if (fullscreen && !inwindow && !m_priv->m_firstinit)
966  showFullScreen();
967  else
968  show();
969  m_priv->m_firstinit = false;
970 }
971 
972 void MythMainWindow::MoveResize(QRect& Geometry)
973 {
974  setFixedSize(Geometry.size());
975  setGeometry(Geometry);
976  if (m_painterWin)
977  {
978  m_painterWin->setFixedSize(Geometry.size());
979  m_painterWin->setGeometry(0, 0, Geometry.width(), Geometry.height());
980  }
981 }
982 
984 {
985  QMutexLocker locker(&m_priv->m_drawDisableLock);
987  if (m_priv->m_drawDisabledDepth && updatesEnabled())
988  SetDrawEnabled(false);
989  return m_priv->m_drawDisabledDepth;
990 }
991 
993 {
994  QMutexLocker locker(&m_priv->m_drawDisableLock);
996  {
998  if (!m_priv->m_drawDisabledDepth && !updatesEnabled())
999  SetDrawEnabled(true);
1000  }
1001  return m_priv->m_drawDisabledDepth;
1002 }
1003 
1005 {
1006  if (!gCoreContext->IsUIThread())
1007  {
1008  emit SignalSetDrawEnabled(Enable);
1009  return;
1010  }
1011 
1012  setUpdatesEnabled(Enable);
1013  if (Enable)
1014  {
1015  if (m_priv->m_pendingUpdate)
1016  {
1017  QApplication::postEvent(this, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority);
1018  m_priv->m_pendingUpdate = false;
1019  }
1021  }
1022  else
1023  {
1025  }
1026 }
1027 
1029 {
1030  for (auto *widget : std::as_const(m_priv->m_stackList))
1031  {
1032  if (Enable)
1033  widget->EnableEffects();
1034  else
1035  widget->DisableEffects();
1036  }
1037 }
1038 
1040 {
1041  return m_priv->m_exitingtomain;
1042 }
1043 
1045 {
1046  bool jumpdone = !(m_priv->m_popwindows);
1047 
1048  m_priv->m_exitingtomain = true;
1049 
1050  MythScreenStack *toplevel = GetMainStack();
1051  if (toplevel && m_priv->m_popwindows)
1052  {
1053  MythScreenType *screen = toplevel->GetTopScreen();
1054  if (screen && screen->objectName() != QString("mainmenu"))
1055  {
1056  MythEvent xe("EXIT_TO_MENU");
1057  gCoreContext->dispatch(xe);
1058  if (screen->objectName() == QString("video playback window"))
1059  {
1060  auto *me = new MythEvent("EXIT_TO_MENU");
1061  QCoreApplication::postEvent(screen, me);
1062  }
1063  else
1064  {
1065  auto *key = new QKeyEvent(QEvent::KeyPress, m_priv->m_escapekey,
1066  Qt::NoModifier);
1067  QCoreApplication::postEvent(this, key);
1069  // Notifications have their own stack. We need to continue
1070  // the propagation of the escape here if there are notifications.
1071  int num = nc->DisplayedNotifications();
1072  if (num > 0)
1073  QCoreApplication::postEvent(
1074  this, new QEvent(MythEvent::kExitToMainMenuEventType));
1075  }
1076  return;
1077  }
1078  jumpdone = true;
1079  }
1080 
1081  if (jumpdone)
1082  {
1083  m_priv->m_exitingtomain = false;
1084  m_priv->m_popwindows = true;
1086  {
1087  void (*callback)(void) = m_priv->m_exitMenuCallback;
1088  m_priv->m_exitMenuCallback = nullptr;
1089  callback();
1090  }
1092  {
1095  m_priv->m_mediaDeviceForCallback = nullptr;
1096  callback(mediadevice);
1097  }
1098  }
1099 }
1100 
1111 bool MythMainWindow::TranslateKeyPress(const QString& Context, QKeyEvent* Event,
1112  QStringList& Actions, bool AllowJumps)
1113 {
1114  Actions.clear();
1115 
1116  // Special case for custom QKeyEvent where the action is embedded directly
1117  // in the QKeyEvent text property. Used by MythFEXML http extension
1118  if (Event && Event->key() == 0 &&
1119  !Event->text().isEmpty() &&
1120  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  QVector<MythScreenStack *>::const_reverse_iterator it;
1693  for (it = m_priv->m_stackList.rbegin(); it != m_priv->m_stackList.rend(); 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::InputMethod:
1708  {
1709  ResetIdleTimer();
1710  auto *ie = dynamic_cast<QInputMethodEvent*>(Event);
1711  if (!ie)
1712  return MythUIScreenBounds::eventFilter(Watched, Event);
1713  QWidget *widget = QApplication::focusWidget();
1714  if (widget)
1715  {
1716  ie->accept();
1717  if (widget->isEnabled())
1718  QCoreApplication::instance()->notify(widget, ie);
1719  break;
1720  }
1721  QVector<MythScreenStack *>::const_reverse_iterator it;
1722  for (it = m_priv->m_stackList.rbegin(); it != m_priv->m_stackList.rend(); it++)
1723  {
1724  MythScreenType *top = (*it)->GetTopScreen();
1725  if (top == nullptr)
1726  continue;
1727  if (top->inputMethodEvent(ie))
1728  return true;
1729  // Note: The following break prevents keypresses being
1730  // sent to windows below popups
1731  if ((*it)->objectName() == "popup stack")
1732  break;
1733  }
1734  break;
1735  }
1736  case QEvent::MouseButtonPress:
1737  {
1738  ResetIdleTimer();
1739  ShowMouseCursor(true);
1740  if (!m_priv->m_gesture.Recording())
1741  {
1742  m_priv->m_gesture.Start();
1743  auto * mouseEvent = dynamic_cast<QMouseEvent*>(Event);
1744  if (!mouseEvent)
1745  return MythUIScreenBounds::eventFilter(Watched, Event);
1746  m_priv->m_gesture.Record(mouseEvent->pos(), mouseEvent->button());
1747  /* start a single shot timer */
1749  return true;
1750  }
1751  break;
1752  }
1753  case QEvent::MouseButtonRelease:
1754  {
1755  ResetIdleTimer();
1756  ShowMouseCursor(true);
1757  if (m_priv->m_gestureTimer->isActive())
1758  m_priv->m_gestureTimer->stop();
1759 
1760  if (m_priv->m_gesture.Recording())
1761  {
1762  m_priv->m_gesture.Stop();
1763  auto * gesture = m_priv->m_gesture.GetGesture();
1764  QPoint point { -1, -1 };
1765  auto * mouseevent = dynamic_cast<QMouseEvent*>(Event);
1766  if (mouseevent)
1767  {
1768  point = mouseevent->pos();
1769  gesture->SetPosition(point);
1770  }
1771 
1772  // Handle clicks separately
1773  if (gesture->GetGesture() == MythGestureEvent::Click)
1774  {
1775  if (!mouseevent)
1776  return MythUIScreenBounds::eventFilter(Watched, Event);
1777 
1778  QVector<MythScreenStack *>::const_reverse_iterator it;
1779  for (it = m_priv->m_stackList.rbegin(); it != m_priv->m_stackList.rend(); it++)
1780  {
1781  auto * screen = (*it)->GetTopScreen();
1782  if (!screen || !screen->ContainsPoint(point))
1783  continue;
1784 
1785  if (screen->gestureEvent(gesture))
1786  break;
1787  // Note: The following break prevents clicks being
1788  // sent to windows below popups
1789  //
1790  // we want to permit this in some cases, e.g.
1791  // when the music miniplayer is on screen or a
1792  // non-interactive alert/news scroller. So these
1793  // things need to be in a third or more stack
1794  if ((*it)->objectName() == "popup stack")
1795  break;
1796  }
1797  delete gesture;
1798  }
1799  else
1800  {
1801  bool handled = false;
1802 
1803  if (!mouseevent)
1804  {
1805  QCoreApplication::postEvent(this, gesture);
1806  return true;
1807  }
1808 
1809  QVector<MythScreenStack *>::const_reverse_iterator it;
1810  for (it = m_priv->m_stackList.rbegin(); it != m_priv->m_stackList.rend(); it++)
1811  {
1812  MythScreenType *screen = (*it)->GetTopScreen();
1813  if (!screen || !screen->ContainsPoint(point))
1814  continue;
1815 
1816  if (screen->gestureEvent(gesture))
1817  {
1818  handled = true;
1819  break;
1820  }
1821  // Note: The following break prevents clicks being
1822  // sent to windows below popups
1823  //
1824  // we want to permit this in some cases, e.g.
1825  // when the music miniplayer is on screen or a
1826  // non-interactive alert/news scroller. So these
1827  // things need to be in a third or more stack
1828  if ((*it)->objectName() == "popup stack")
1829  break;
1830  }
1831 
1832  if (handled)
1833  delete gesture;
1834  else
1835  QCoreApplication::postEvent(this, gesture);
1836  }
1837 
1838  return true;
1839  }
1840  break;
1841  }
1842  case QEvent::MouseMove:
1843  {
1844  ResetIdleTimer();
1845  ShowMouseCursor(true);
1846  if (m_priv->m_gesture.Recording())
1847  {
1848  // Reset the timer
1849  m_priv->m_gestureTimer->stop();
1851  auto * mouseevent = dynamic_cast<QMouseEvent*>(Event);
1852  if (!mouseevent)
1853  return MythUIScreenBounds::eventFilter(Watched, Event);
1854  m_priv->m_gesture.Record(mouseevent->pos(), mouseevent->button());
1855  return true;
1856  }
1857  break;
1858  }
1859  case QEvent::Wheel:
1860  {
1861  ResetIdleTimer();
1862  ShowMouseCursor(true);
1863  auto * wheel = dynamic_cast<QWheelEvent*>(Event);
1864  if (wheel == nullptr)
1865  return MythUIScreenBounds::eventFilter(Watched, Event);
1866  int delta = wheel->angleDelta().y();
1867  if (delta>0)
1868  {
1869  wheel->accept();
1870  auto *key = new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);
1871  if (auto * target = GetTarget(*key); target)
1872  QCoreApplication::postEvent(target, key);
1873  else
1874  QCoreApplication::postEvent(this, key);
1875  }
1876  if (delta < 0)
1877  {
1878  wheel->accept();
1879  auto * key = new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);
1880  if (auto * target = GetTarget(*key); !target)
1881  QCoreApplication::postEvent(target, key);
1882  else
1883  QCoreApplication::postEvent(this, key);
1884  }
1885  break;
1886  }
1887  default:
1888  break;
1889  }
1890 
1891  return MythUIScreenBounds::eventFilter(Watched, Event);
1892 }
1893 
1895 {
1896  if (Event->type() == MythGestureEvent::kEventType)
1897  {
1898  auto * gesture = dynamic_cast<MythGestureEvent*>(Event);
1899  if (gesture == nullptr)
1900  return;
1901  if (auto * toplevel = GetMainStack(); toplevel)
1902  if (auto * screen = toplevel->GetTopScreen(); screen)
1903  screen->gestureEvent(gesture);
1904  LOG(VB_GUI, LOG_DEBUG, QString("Gesture: %1 (Button: %2)")
1905  .arg(gesture->GetName(), gesture->GetButtonName()));
1906  }
1908  {
1909  ExitToMainMenu();
1910  }
1911  else if (Event->type() == ExternalKeycodeEvent::kEventType)
1912  {
1913  auto * event = dynamic_cast<ExternalKeycodeEvent *>(Event);
1914  if (event == nullptr)
1915  return;
1916  auto * key = new QKeyEvent(QEvent::KeyPress, event->getKeycode(), Qt::NoModifier);
1917  if (auto * target = GetTarget(*key); target)
1918  QCoreApplication::sendEvent(target, key);
1919  else
1920  QCoreApplication::sendEvent(this, key);
1921  }
1922  else if (Event->type() == MythMediaEvent::kEventType)
1923  {
1924  auto *me = dynamic_cast<MythMediaEvent*>(Event);
1925  if (me == nullptr)
1926  return;
1927 
1928  // A listener based system might be more efficient, but we should never
1929  // have that many screens open at once so impact should be minimal.
1930  //
1931  // This approach is simpler for everyone to follow. Plugin writers
1932  // don't have to worry about adding their screens to the list because
1933  // all screens receive media events.
1934  //
1935  // Events are even sent to hidden or backgrounded screens, this avoids
1936  // the need for those to poll for changes when they become visible again
1937  // however this needs to be kept in mind if media changes trigger
1938  // actions which would not be appropriate when the screen doesn't have
1939  // focus. It is the programmers responsibility to ignore events when
1940  // necessary.
1941  for (auto * widget : std::as_const(m_priv->m_stackList))
1942  {
1943  QVector<MythScreenType*> screenList;
1944  widget->GetScreenList(screenList);
1945  for (auto * screen : std::as_const(screenList))
1946  if (screen)
1947  screen->mediaEvent(me);
1948  }
1949 
1950  // Debugging
1951  if (MythMediaDevice* device = me->getDevice(); device)
1952  {
1953  LOG(VB_GENERAL, LOG_DEBUG, QString("Media Event: %1 - %2")
1954  .arg(device->getDevicePath()).arg(device->getStatus()));
1955  }
1956  }
1957  else if (Event->type() == MythEvent::kPushDisableDrawingEventType)
1958  {
1959  PushDrawDisabled();
1960  }
1961  else if (Event->type() == MythEvent::kPopDisableDrawingEventType)
1962  {
1963  PopDrawDisabled();
1964  }
1965  else if (Event->type() == MythEvent::kLockInputDevicesEventType)
1966  {
1967  m_deviceHandler->IgnoreKeys(true);
1968  PauseIdleTimer(true);
1969  }
1970  else if (Event->type() == MythEvent::kUnlockInputDevicesEventType)
1971  {
1972  m_deviceHandler->IgnoreKeys(false);
1973  PauseIdleTimer(false);
1974  }
1975  else if (Event->type() == MythEvent::kDisableUDPListenerEventType)
1976  {
1978  }
1979  else if (Event->type() == MythEvent::kEnableUDPListenerEventType)
1980  {
1982  }
1983  else if (Event->type() == MythEvent::kMythEventMessage)
1984  {
1985  auto * event = dynamic_cast<MythEvent *>(Event);
1986  if (event == nullptr)
1987  return;
1988 
1989  QString message = event->Message();
1990  if (message.startsWith(ACTION_HANDLEMEDIA))
1991  {
1992  if (event->ExtraDataCount() == 1)
1993  HandleMedia("Internal", event->ExtraData(0));
1994  else if (event->ExtraDataCount() >= 11)
1995  {
1996  bool usebookmark = true;
1997  if (event->ExtraDataCount() >= 12)
1998  usebookmark = (event->ExtraData(11).toInt() != 0);
1999  HandleMedia("Internal", event->ExtraData(0),
2000  event->ExtraData(1), event->ExtraData(2),
2001  event->ExtraData(3), event->ExtraData(4),
2002  event->ExtraData(5).toInt(), event->ExtraData(6).toInt(),
2003  event->ExtraData(7), std::chrono::minutes(event->ExtraData(8).toInt()),
2004  event->ExtraData(9), event->ExtraData(10),
2005  usebookmark);
2006  }
2007  else
2008  {
2009  LOG(VB_GENERAL, LOG_ERR, "Failed to handle media");
2010  }
2011  }
2012  else if (message.startsWith(ACTION_SCREENSHOT))
2013  {
2014  int width = 0;
2015  int height = 0;
2016  QString filename;
2017  if (event->ExtraDataCount() >= 2)
2018  {
2019  width = event->ExtraData(0).toInt();
2020  height = event->ExtraData(1).toInt();
2021  if (event->ExtraDataCount() == 3)
2022  filename = event->ExtraData(2);
2023  }
2024  ScreenShot(width, height, filename);
2025  }
2026  else if (message == ACTION_GETSTATUS)
2027  {
2028  QVariantMap state;
2029  state.insert("state", "idle");
2030  state.insert("menutheme", GetMythDB()->GetSetting("menutheme", "defaultmenu"));
2031  state.insert("currentlocation", GetMythUI()->GetCurrentLocation());
2033  }
2034  else if (message == "CLEAR_SETTINGS_CACHE")
2035  {
2036  // update the idle time
2037  m_idleTime =
2038  gCoreContext->GetDurSetting<std::chrono::minutes>("FrontendIdleTimeout",
2039  STANDBY_TIMEOUT);
2040 
2041  if (m_idleTime < 0min)
2042  m_idleTime = 0min;
2043  m_idleTimer.stop();
2044  if (m_idleTime > 0min)
2045  {
2046  m_idleTimer.setInterval(m_idleTime);
2047  m_idleTimer.start();
2048  LOG(VB_GENERAL, LOG_INFO, QString("Updating the frontend idle time to: %1 mins").arg(m_idleTime.count()));
2049  }
2050  else
2051  {
2052  LOG(VB_GENERAL, LOG_INFO, "Frontend idle timeout is disabled");
2053  }
2054  }
2055  else if (message == "NOTIFICATION")
2056  {
2057  MythNotification mn(*event);
2059  return;
2060  }
2061  else if (message == "RECONNECT_SUCCESS" && m_priv->m_standby)
2062  {
2063  // If the connection to the master backend has just been (re-)established
2064  // but we're in standby, make sure the backend is not blocked from
2065  // shutting down.
2067  }
2068  }
2069  else if (Event->type() == MythEvent::kMythUserMessage)
2070  {
2071  if (auto * event = dynamic_cast<MythEvent *>(Event); event != nullptr)
2072  if (const QString& message = event->Message(); !message.isEmpty())
2073  ShowOkPopup(message);
2074  }
2075  else if (Event->type() == MythNotificationCenterEvent::kEventType)
2076  {
2078  }
2079 }
2080 
2081 QObject* MythMainWindow::GetTarget(QKeyEvent& Key)
2082 {
2083  auto * target = QWidget::keyboardGrabber();
2084  if (!target)
2085  {
2086  if (auto * widget = QApplication::focusWidget(); widget && widget->isEnabled())
2087  {
2088  target = widget;
2089  // Yes this is special code for handling the
2090  // the escape key.
2091  if (Key.key() == m_priv->m_escapekey && widget->topLevelWidget())
2092  target = widget->topLevelWidget();
2093  }
2094  }
2095 
2096  if (!target)
2097  target = this;
2098  return target;
2099 }
2100 
2102 {
2104 }
2105 
2107 {
2108  if (Show && GetMythDB()->GetBoolSetting("HideMouseCursor", false))
2109  return;
2110 
2111  // Set cursor call must come after Show() to work on some systems.
2112  setCursor(Show ? (Qt::ArrowCursor) : (Qt::BlankCursor));
2113  if (Show)
2114  m_priv->m_hideMouseTimer->start();
2115 }
2116 
2118 {
2119  ShowMouseCursor(false);
2120 }
2121 
2125 void MythMainWindow::DisableIdleTimer(bool DisableIdle)
2126 {
2127  m_priv->m_disableIdle = DisableIdle;
2128  if (m_priv->m_disableIdle)
2129  m_idleTimer.stop();
2130  else
2131  m_idleTimer.start();
2132 }
2133 
2138 {
2139  if (m_priv->m_disableIdle)
2140  return;
2141 
2142  if (m_idleTime == 0min || !m_idleTimer.isActive() || (m_priv->m_standby && m_priv->m_enteringStandby))
2143  return;
2144 
2145  if (m_priv->m_standby)
2146  ExitStandby(false);
2147 
2148  m_idleTimer.start();
2149 }
2150 
2155 {
2156  if (m_priv->m_disableIdle)
2157  return;
2158 
2159  // don't do anything if the idle timer is disabled
2160  if (m_idleTime == 0min)
2161  return;
2162 
2163  if (Pause)
2164  {
2165  LOG(VB_GENERAL, LOG_NOTICE, "Suspending idle timer");
2166  m_idleTimer.stop();
2167  }
2168  else
2169  {
2170  LOG(VB_GENERAL, LOG_NOTICE, "Resuming idle timer");
2171  m_idleTimer.start();
2172  }
2173 
2174  // ResetIdleTimer();
2175 }
2176 
2178 {
2179  if (m_priv->m_disableIdle)
2180  return;
2181 
2182  m_priv->m_enteringStandby = false;
2183 
2184  if (m_idleTime > 0min && !m_priv->m_standby)
2185  {
2186  LOG(VB_GENERAL, LOG_NOTICE,
2187  QString("Entering standby mode after %1 minutes of inactivity").arg(m_idleTime.count()));
2188  EnterStandby(false);
2189  if (gCoreContext->GetNumSetting("idleTimeoutSecs", 0) > 0)
2190  {
2191  m_priv->m_enteringStandby = true;
2192  JumpTo("Standby Mode");
2193  }
2194  }
2195 }
2196 
2198 {
2199  if (Manual && m_priv->m_enteringStandby)
2200  m_priv->m_enteringStandby = false;
2201 
2202  if (m_priv->m_standby)
2203  return;
2204 
2205  // We've manually entered standby mode and we want to pause the timer
2206  // to prevent it being Reset
2207  if (Manual)
2208  {
2209  PauseIdleTimer(true);
2210  LOG(VB_GENERAL, LOG_NOTICE, QString("Entering standby mode"));
2211  }
2212 
2213  m_priv->m_standby = true;
2215 
2216  QVariantMap state;
2217  state.insert("state", "standby");
2218  state.insert("menutheme", GetMythDB()->GetSetting("menutheme", "defaultmenu"));
2219  state.insert("currentlocation", GetMythUI()->GetCurrentLocation());
2221 
2222  // Cache WOL settings in case DB goes down
2223  QString masterserver = gCoreContext->GetSetting("MasterServerName");
2224  gCoreContext->GetSettingOnHost("BackendServerAddr", masterserver);
2226  gCoreContext->GetSetting("WOLbackendCommand", "");
2227 
2228  // While in standby do not attempt to wake the backend
2229  gCoreContext->SetWOLAllowed(false);
2230 }
2231 
2233 {
2235  return;
2236 
2237  if (Manual)
2238  PauseIdleTimer(false);
2239  else if (gCoreContext->GetNumSetting("idleTimeoutSecs", 0) > 0)
2240  JumpTo("Main Menu");
2241 
2242  if (!m_priv->m_standby)
2243  return;
2244 
2245  LOG(VB_GENERAL, LOG_NOTICE, "Leaving standby mode");
2246  m_priv->m_standby = false;
2247 
2248  // We may attempt to wake the backend
2249  gCoreContext->SetWOLAllowed(true);
2251 
2252  QVariantMap state;
2253  state.insert("state", "idle");
2254  state.insert("menutheme", GetMythDB()->GetSetting("menutheme", "defaultmenu"));
2255  state.insert("currentlocation", GetMythUI()->GetCurrentLocation());
2257 }
2258 
2260 {
2261  LOG(VB_GENERAL, LOG_NOTICE, QString("Application State Changed to %1").arg(State));
2262  switch (State)
2263  {
2264  case Qt::ApplicationState::ApplicationActive:
2265  PopDrawDisabled();
2266  break;
2267  case Qt::ApplicationState::ApplicationSuspended:
2268  PushDrawDisabled();
2269  break;
2270  default:
2271  break;
2272  }
2273 }
2274 /* 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:215
MythCoreContext::SetWOLAllowed
void SetWOLAllowed(bool allow)
Definition: mythcorecontext.cpp:633
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:812
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:127
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:26
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:317
mythrect.h
mythevent.h
MythMainWindow::m_idleTimer
QTimer m_idleTimer
Definition: mythmainwindow.h:164
ExternalKeycodeEvent::kEventType
static const Type kEventType
Definition: mythevent.h:113
MythGestureEvent::Click
@ Click
Definition: mythgesture.h:77
MythDate::toString
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:93
hardwareprofile.smolt.timeout
float timeout
Definition: smolt.py:102
ACTION_DOWN
static constexpr const char * ACTION_DOWN
Definition: mythuiactions.h:17
MythMainWindow::closeEvent
void closeEvent(QCloseEvent *Event) override
Definition: mythmainwindow.cpp:476
MythEvent::kMythUserMessage
static const Type kMythUserMessage
Definition: mythevent.h:80
MythInputDeviceHandler::MainWindowReady
void MainWindowReady(void)
Definition: mythinputdevicehandler.cpp:198
MythEvent::kMythEventMessage
static const Type kMythEventMessage
Definition: mythevent.h:79
MythMainWindow::Init
void Init(bool MayReInit=true)
Definition: mythmainwindow.cpp:641
MythNotificationCenter::ProcessQueue
void ProcessQueue(void)
ProcessQueue will be called by the GUI event handler and will process all queued MythNotifications an...
Definition: mythnotificationcenter.cpp:1354
MythMainWindow::OnApplicationStateChange
void OnApplicationStateChange(Qt::ApplicationState State)
Definition: mythmainwindow.cpp:2259
MythDisplay::SwitchToDesktop
void SwitchToDesktop()
Return the screen to the original desktop video mode.
Definition: mythdisplay.cpp:681
MythMainWindowPrivate::m_mediaDeviceForCallback
MythMediaDevice * m_mediaDeviceForCallback
Definition: mythmainwindowprivate.h:69
GESTURE_TIMEOUT
static constexpr std::chrono::milliseconds GESTURE_TIMEOUT
Definition: mythmainwindow.cpp:64
MythMainWindow::SignalDisableScreensaver
void SignalDisableScreensaver()
MythMainWindowPrivate::m_pendingUpdate
bool m_pendingUpdate
Definition: mythmainwindowprivate.h:84
mythdb.h
MythPainter::SupportsClipping
virtual bool SupportsClipping(void)=0
MythMainWindowPrivate::m_longPressKeyCode
int m_longPressKeyCode
Definition: mythmainwindowprivate.h:88
MythMainWindow::SaveScreenShot
static bool SaveScreenShot(const QImage &Image, QString Filename="")
Definition: mythmainwindow.cpp:536
MythCoreContext::AllowShutdown
void AllowShutdown(void)
Definition: mythcorecontext.cpp:614
ACTION_SCREENSHOT
static constexpr const char * ACTION_SCREENSHOT
Definition: mythuiactions.h:22
MythEvent::kPushDisableDrawingEventType
static const Type kPushDisableDrawingEventType
Definition: mythevent.h:84
MythGesture::Recording
bool Recording()
Determine if the stroke is being recorded.
Definition: mythgesture.cpp:142
MythUIScreenBounds::UpdateScreenSettings
void UpdateScreenSettings(MythDisplay *mDisplay)
Definition: mythuiscreenbounds.cpp:144
MythMainWindow::SignalWindowReady
void SignalWindowReady()
LONGPRESS_INTERVAL
static constexpr std::chrono::milliseconds LONGPRESS_INTERVAL
Definition: mythmainwindow.cpp:66
MythEvent::kEnableUDPListenerEventType
static const Type kEnableUDPListenerEventType
Definition: mythevent.h:90
MythGesture::Start
void Start()
Start recording.
Definition: mythgesture.cpp:151
MythMainWindowPrivate::m_gestureTimer
QTimer * m_gestureTimer
Definition: mythmainwindowprivate.h:75
MythEvent::kUnlockInputDevicesEventType
static const Type kUnlockInputDevicesEventType
Definition: mythevent.h:87
MythUIScreenBounds::m_wantFullScreen
bool m_wantFullScreen
Definition: mythuiscreenbounds.h:48
MythMainWindow::MythMainWindow
MythMainWindow(bool UseDB=true)
Definition: mythmainwindow.cpp:131
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:312
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:80
MythUIScreenBounds::m_qtFullScreen
bool m_qtFullScreen
Definition: mythuiscreenbounds.h:49
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
ACTION_0
static constexpr const char * ACTION_0
Definition: mythuiactions.h:4
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:204
MythScreenStack
Definition: mythscreenstack.h:16
MythMainWindow::RestoreScreensaver
static void RestoreScreensaver()
Definition: mythmainwindow.cpp:576
MythEvent::kDisableUDPListenerEventType
static const Type kDisableUDPListenerEventType
Definition: mythevent.h:89
MythMainWindow::ShowMouseCursor
void ShowMouseCursor(bool Show)
Definition: mythmainwindow.cpp:2106
ACTION_LEFT
static constexpr const char * ACTION_LEFT
Definition: mythuiactions.h:18
MythMainWindow::ReloadKeys
void ReloadKeys()
Definition: mythmainwindow.cpp:953
MythMainWindowPrivate::m_popwindows
bool m_popwindows
Definition: mythmainwindowprivate.h:57
MythNotification
Definition: mythnotification.h:29
MythMainWindow::LoadQtConfig
static void LoadQtConfig()
Definition: mythmainwindow.cpp:633
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:618
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:1356
MythScreenSaverControl::Reset
void Reset()
MythMainWindow::HandleTVAction
void HandleTVAction(const QString &Action)
Definition: mythmainwindow.cpp:1521
MythMediaEvent::kEventType
static const Type kEventType
Definition: mythmedia.h:193
MythMainWindow::Show
void Show()
Definition: mythmainwindow.cpp:961
MythMainWindowPrivate::m_mediaPluginMap
QMap< QString, MythMediaCallback > m_mediaPluginMap
Definition: mythmainwindowprivate.h:64
MythMainWindow::customEvent
void customEvent(QEvent *Event) override
Definition: mythmainwindow.cpp:1894
MythMainWindow::ResetIdleTimer
void ResetIdleTimer()
Reset the idle timeout timer.
Definition: mythmainwindow.cpp:2137
STANDBY_TIMEOUT
static constexpr std::chrono::minutes STANDBY_TIMEOUT
Definition: mythmainwindow.cpp:65
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
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:45
show
static void show(uint8_t *buf, int length)
Definition: ringbuffer.cpp:341
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:518
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:50
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:435
mythdirs.h
MythScreenSaverControl::Restore
void Restore()
MythMainWindow::GetRenderDevice
MythRender * GetRenderDevice()
Definition: mythmainwindow.cpp:291
MythMainWindowPrivate::m_hideMouseTimer
QTimer * m_hideMouseTimer
Definition: mythmainwindowprivate.h:76
MythMainWindow::GetPainter
MythPainter * GetPainter()
Definition: mythmainwindow.cpp:257
ACTION_SELECT
static constexpr const char * ACTION_SELECT
Definition: mythuiactions.h:15
MythGestureEvent::kEventType
static const Type kEventType
Definition: mythgesture.h:91
ACTION_9
static constexpr const char * ACTION_9
Definition: mythuiactions.h:13
MythMainWindow::PopScreenStack
void PopScreenStack()
Definition: mythmainwindow.cpp:303
mythmainwindowprivate.h
HasMythMainWindow
bool HasMythMainWindow(void)
Definition: mythmainwindow.cpp:109
MythMainWindow::SignalSetDrawEnabled
void SignalSetDrawEnabled(bool Enable)
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:15
MythCoreContext::ResetAudioLanguage
void ResetAudioLanguage(void)
Definition: mythcorecontext.cpp:1829
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
MythMainWindowPrivate::TranslateKeyNum
static int TranslateKeyNum(QKeyEvent *Event)
Definition: mythmainwindowprivate.cpp:8
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:296
MythMainWindow::SetEffectsEnabled
void SetEffectsEnabled(bool Enable)
Definition: mythmainwindow.cpp:1028
State
State
Definition: zmserver.h:68
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:2125
MythMainWindow::GetDisplay
MythDisplay * GetDisplay()
Definition: mythmainwindow.cpp:252
MythMainWindow::DisableScreensaver
static void DisableScreensaver()
Definition: mythmainwindow.cpp:582
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:105
MythMainWindow::KeyLongPressFilter
bool KeyLongPressFilter(QEvent **Event, QScopedPointer< QEvent > &NewEvent)
Definition: mythmainwindow.cpp:1546
MythGesture::Stop
void Stop(bool Timeout=false)
Stop recording.
Definition: mythgesture.cpp:163
mythdate.h
MythMainWindow::SetDrawEnabled
void SetDrawEnabled(bool Enable)
Definition: mythmainwindow.cpp:1004
mythrender_base.h
MythScreenSaverControl::Asleep
bool Asleep()
Definition: mythscreensaver.cpp:77
MythMainWindow::m_screensaver
MythScreenSaverControl * m_screensaver
Definition: mythmainwindow.h:163
MythMainWindowPrivate::m_exitMenuCallback
void(* m_exitMenuCallback)(void)
Definition: mythmainwindowprivate.h:67
mythdisplay.h
mythlogging.h
MythMainWindow::HideMouseTimeout
void HideMouseTimeout()
Definition: mythmainwindow.cpp:2117
ACTION_1
static constexpr const char * ACTION_1
Definition: mythuiactions.h:5
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:1111
s_mainWin
static MythMainWindow * s_mainWin
Definition: mythmainwindow.cpp:70
MythMainWindow::event
bool event(QEvent *Event) override
Definition: mythmainwindow.cpp:612
ACTION_TVPOWERON
static constexpr const char * ACTION_TVPOWERON
Definition: mythuiactions.h:25
MythMainWindow::destroyMainWindow
static void destroyMainWindow()
Definition: mythmainwindow.cpp:96
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:159
Event
Event details.
Definition: zmdefines.h:27
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:550
compat.h
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:225
MythMainWindow::HidePainterWindow
void HidePainterWindow()
Definition: mythmainwindow.cpp:281
MythMainWindow::ExitToMainMenu
void ExitToMainMenu()
Definition: mythmainwindow.cpp:1044
MythCoreContext::GetDurSetting
std::enable_if_t< std::chrono::__is_duration< T >::value, T > GetDurSetting(const QString &key, T defaultval=T::zero())
Definition: mythcorecontext.h:168
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:272
MythMainWindow::DestinationExists
bool DestinationExists(const QString &Destination) const
Definition: mythmainwindow.cpp:1470
DestroyMythMainWindow
void DestroyMythMainWindow(void)
Definition: mythmainwindow.cpp:114
MythNotificationCenter::DisplayedNotifications
int DisplayedNotifications(void) const
Returns number of notifications currently displayed.
Definition: mythnotificationcenter.cpp:1411
MythDisplay::SetWidget
void SetWidget(QWidget *MainWindow)
Set the QWidget and QWindow in use.
Definition: mythdisplay.cpp:246
MythCoreContext::GetDB
MythDB * GetDB(void)
Definition: mythcorecontext.cpp:1761
mythmedia.h
MythUIScreenBounds::m_screenRect
QRect m_screenRect
Definition: mythuiscreenbounds.h:44
MythUIScreenBounds::SetUIScreenRect
void SetUIScreenRect(QRect Rect)
Definition: mythuiscreenbounds.cpp:203
MythMainWindowPrivate::m_drawDisableLock
QMutex m_drawDisableLock
Definition: mythmainwindowprivate.h:77
MythMainWindow::RemoteScreenShot
void RemoteScreenShot(QString Filename, int Width, int Height)
Definition: mythmainwindow.cpp:529
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
MythMainWindow::Animate
void Animate()
Definition: mythmainwindow.cpp:337
JumpData::m_destination
QString m_destination
Definition: mythmainwindowprivate.h:39
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
MythNotificationCenterEvent::kEventType
static const Type kEventType
Definition: mythnotificationcenter.h:30
ACTION_8
static constexpr const char * ACTION_8
Definition: mythuiactions.h:12
MythMainWindow::GetPaintWindow
QWidget * GetPaintWindow()
Definition: mythmainwindow.cpp:267
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:605
MythEvent::kMythPostShowEventType
static const Type kMythPostShowEventType
Definition: mythevent.h:83
JumpData
Definition: mythmainwindowprivate.h:36
ACTION_TVPOWEROFF
static constexpr const char * ACTION_TVPOWEROFF
Definition: mythuiactions.h:24
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:137
ACTION_7
static constexpr const char * ACTION_7
Definition: mythuiactions.h:11
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
MythPainterWindow::GetRenderDevice
MythRender * GetRenderDevice()
Definition: mythpainterwindow.cpp:157
mythuistatetracker.h
MythMainWindow::GetStackAt
MythScreenStack * GetStackAt(int Position)
Definition: mythmainwindow.cpp:330
MythDisplay
Definition: mythdisplay.h:22
MythMainWindow::EnumerateDestinations
QStringList EnumerateDestinations() const
Definition: mythmainwindow.cpp:1475
MythMainWindow::m_refreshTimer
QTimer m_refreshTimer
Definition: mythmainwindow.h:158
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:916
mythgesture.h
A C++ ripoff of the stroke library for MythTV.
MythMainWindowPrivate::m_enteringStandby
bool m_enteringStandby
Definition: mythmainwindowprivate.h:81
ACTION_HANDLEMEDIA
static constexpr const char * ACTION_HANDLEMEDIA
Definition: mythuiactions.h:21
MythPainter::End
virtual void End()
Definition: mythpainter.h:55
MythMainWindow::PushDrawDisabled
uint PushDrawDisabled()
Definition: mythmainwindow.cpp:983
MythEvent::kPopDisableDrawingEventType
static const Type kPopDisableDrawingEventType
Definition: mythevent.h:85
MythMainWindow::m_priv
MythMainWindowPrivate * m_priv
Definition: mythmainwindow.h:155
ACTION_UP
static constexpr const char * ACTION_UP
Definition: mythuiactions.h:16
MythMainWindow::GetCurrentNotificationCenter
MythNotificationCenter * GetCurrentNotificationCenter()
Definition: mythmainwindow.cpp:262
MythMainWindow::m_idleTime
std::chrono::minutes m_idleTime
Definition: mythmainwindow.h:165
MythPainter::GetName
virtual QString GetName(void)=0
MythUDP::EnableUDPListener
static void EnableUDPListener(bool Enable=true)
Definition: mythudplistener.cpp:183
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:984
MythUIScreenBounds::InitScreenBounds
void InitScreenBounds()
Definition: mythuiscreenbounds.cpp:130
MythMainWindow::~MythMainWindow
~MythMainWindow() override
Definition: mythmainwindow.cpp:209
ACTION_4
static constexpr const char * ACTION_4
Definition: mythuiactions.h:8
MythMainWindow::paintEngine
QPaintEngine * paintEngine() const override
Definition: mythmainwindow.cpp:471
MythUIScreenBounds::m_wantWindow
bool m_wantWindow
Definition: mythuiscreenbounds.h:47
mythmiscutil.h
ACTION_3
static constexpr const char * ACTION_3
Definition: mythuiactions.h:7
MythScreenSaverControl::Disable
void Disable()
MythUIScreenBounds::WindowIsAlwaysFullscreen
static bool WindowIsAlwaysFullscreen()
Return true if the current platform only supports fullscreen windows.
Definition: mythuiscreenbounds.cpp:115
ACTION_GETSTATUS
static constexpr const char * ACTION_GETSTATUS
Definition: mythuiactions.h:27
MythMainWindow::GetTarget
QObject * GetTarget(QKeyEvent &Key)
Definition: mythmainwindow.cpp:2081
ACTION_RIGHT
static constexpr const char * ACTION_RIGHT
Definition: mythuiactions.h:19
mythcorecontext.h
MythMainWindow::EnterStandby
void EnterStandby(bool Manual=true)
Definition: mythmainwindow.cpp:2197
MythRender
Definition: mythrender_base.h:23
MythScreenType::inputMethodEvent
bool inputMethodEvent(QInputMethodEvent *event) override
Input Method event handler.
Definition: mythscreentype.cpp:395
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:19
MythPainter
Definition: mythpainter.h:34
MythDisplay::SwitchToGUI
bool SwitchToGUI(bool Wait=false)
Switches to the GUI resolution.
Definition: mythdisplay.cpp:774
MythMainWindow::InitKeys
void InitKeys()
Definition: mythmainwindow.cpp:792
MythMainWindow::m_display
MythDisplay * m_display
Definition: mythmainwindow.h:156
MythCoreContext::ResetLanguage
void ResetLanguage(void)
Definition: mythcorecontext.cpp:1795
myththemebase.h
MythMainWindow::PopDrawDisabled
uint PopDrawDisabled()
Definition: mythmainwindow.cpp:992
mythudplistener.h
Name
Definition: channelsettings.cpp:71
MythCoreContext::GetSettingOnHost
QString GetSettingOnHost(const QString &key, const QString &host, const QString &defaultval="")
Definition: mythcorecontext.cpp:930
MythMainWindow::IsScreensaverAsleep
static bool IsScreensaverAsleep()
Definition: mythmainwindow.cpp:594
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:888
MythMainWindow::m_repaintRegion
QRegion m_repaintRegion
Definition: mythmainwindow.h:157
MythMainWindowPrivate::m_allowInput
bool m_allowInput
Definition: mythmainwindowprivate.h:83
ACTION_5
static constexpr const char * ACTION_5
Definition: mythuiactions.h:9
MythMainWindow::m_deviceHandler
MythInputDeviceHandler * m_deviceHandler
Definition: mythmainwindow.h:162
GetNotificationCenter
MythNotificationCenter * GetNotificationCenter(void)
Definition: mythmainwindow.cpp:124
MythUIThemeCache::UpdateImageCache
void UpdateImageCache()
Definition: mythuithemecache.cpp:61
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:104
MythUIType::ContainsPoint
bool ContainsPoint(QPoint point) const
Check if the given point falls within this widgets area.
Definition: mythuitype.cpp:1412
build_compdb.action
action
Definition: build_compdb.py:9
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:778
MythMainWindow::IsExitingToMain
bool IsExitingToMain() const
Definition: mythmainwindow.cpp:1039
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:455
MythPainter::SetClipRect
virtual void SetClipRect(QRect clipRect)
Definition: mythpainter.cpp:46
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &Stackname)
Definition: mythmainwindow.cpp:322
MythEvent::kExitToMainMenuEventType
static const Type kExitToMainMenuEventType
Definition: mythevent.h:82
MythThemeBase::Reload
void Reload()
Definition: myththemebase.cpp:37
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:1318
MythPainterWindow::RenderIsShared
bool RenderIsShared()
Definition: mythpainterwindow.cpp:162
MythGestureEvent
A custom event that represents a mouse gesture.
Definition: mythgesture.h:39
MythMainWindow::m_painterWin
MythPainterWindow * m_painterWin
Definition: mythmainwindow.h:161
MythMainWindow::MoveResize
void MoveResize(QRect &Geometry)
Definition: mythmainwindow.cpp:972
MythDisplay::UsingVideoModes
virtual bool UsingVideoModes()
Definition: mythdisplay.h:30
MythCoreContext::BlockShutdown
void BlockShutdown(void)
Definition: mythcorecontext.cpp:600
ACTION_2
static constexpr const char * ACTION_2
Definition: mythuiactions.h:6
MythNotificationCenter
Definition: mythnotificationcenter.h:40
GetMythPainter
MythPainter * GetMythPainter(void)
Definition: mythmainwindow.cpp:119
s_mainLock
static QMutex s_mainLock
Definition: mythmainwindow.cpp:71
MythMainWindow::GrabWindow
static void GrabWindow(QImage &Image)
Definition: mythmainwindow.cpp:489
MythMainWindow::ResetScreensaver
static void ResetScreensaver()
Definition: mythmainwindow.cpp:588
MythMainWindow::AllowInput
void AllowInput(bool Allow)
Definition: mythmainwindow.cpp:1526
MythUIThemeCache::ClearThemeCacheDir
void ClearThemeCacheDir()
Definition: mythuithemecache.cpp:56
mythburn.usebookmark
bool usebookmark
Definition: mythburn.py:179
MythMainWindow::IdleTimeout
void IdleTimeout()
Definition: mythmainwindow.cpp:2177
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:564
build_compdb.filename
filename
Definition: build_compdb.py:21
MythMainWindow::RestartInputHandlers
void RestartInputHandlers()
Definition: mythmainwindow.cpp:2101
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:160
MythScreenType::IsInitialized
bool IsInitialized(void) const
Has Init() been called on this screen?
Definition: mythscreentype.cpp:357
MythCoreContext::dispatch
void dispatch(const MythEvent &event)
Definition: mythcorecontext.cpp:1727
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:566
MythPainter::Begin
virtual void Begin(QPaintDevice *)
Definition: mythpainter.h:54
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:2232
MythObservable::removeListener
void removeListener(QObject *listener)
Remove a listener to the observable.
Definition: mythobservable.cpp:55
ACTION_6
static constexpr const char * ACTION_6
Definition: mythuiactions.h:10
MythMainWindowPrivate::m_nc
MythNotificationCenter * m_nc
Definition: mythmainwindowprivate.h:79
MythMainWindow
Definition: mythmainwindow.h:28
MythMainWindow::drawScreen
void drawScreen(QPaintEvent *Event=nullptr)
Definition: mythmainwindow.cpp:375
MythCoreContext::SetGUIObject
void SetGUIObject(QObject *gui)
Definition: mythcorecontext.cpp:1741
mythscreentype.h
MythUIScreenBounds::GeometryIsOverridden
static bool GeometryIsOverridden()
Definition: mythuiscreenbounds.cpp:20
MythUIScreenBounds::m_uiScreenRect
QRect m_uiScreenRect
Definition: mythuiscreenbounds.h:43
MythMainWindow::PauseIdleTimer
void PauseIdleTimer(bool Pause)
Pause the idle timeout timer.
Definition: mythmainwindow.cpp:2154
uint
unsigned int uint
Definition: freesurround.h:24
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:902
MythUDP::StopUDPListener
static void StopUDPListener()
Definition: mythudplistener.cpp:223
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:837
MythInputDeviceHandler::IgnoreKeys
void IgnoreKeys(bool Ignore)
Definition: mythinputdevicehandler.cpp:186
MythScreenStack::GetTopScreen
virtual MythScreenType * GetTopScreen(void) const
Definition: mythscreenstack.cpp:182
MythNotificationCenter::Queue
bool Queue(const MythNotification &notification)
Queue a notification Queue() is thread-safe and can be called from anywhere.
Definition: mythnotificationcenter.cpp:1349
MythEvent::kLockInputDevicesEventType
static const Type kLockInputDevicesEventType
Definition: mythevent.h:86