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