15#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
16#include <QtSystemDetection>
17#include <QtVersionChecks>
19#include <QWaitCondition>
20#include <QApplication>
26#include <QKeySequence>
27#include <QInputMethodEvent>
63#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
73#define LOC QString("MythMainWindow: ")
148 setObjectName(
"mainwindow");
165 installEventFilter(
this);
181 setUpdatesEnabled(
true);
184 Qt::BlockingQueuedConnection);
186 Qt::BlockingQueuedConnection);
330 if (widget->objectName() == Stackname)
337 if (Position >= 0 && Position < m_priv->m_stackList.size())
356 QVector<MythScreenType *> drawList;
357 (*it)->GetDrawOrder(drawList);
359 for (
auto *screen : std::as_const(drawList))
363 if (screen->NeedsRedraw())
365 QRegion topDirty = screen->GetDirtyArea();
366 screen->ResetNeedsRedraw();
377 widget->ScheduleInitIfNeeded();
404 QVector<MythScreenType *> redrawList;
405 (*it)->GetDrawOrder(redrawList);
407 for (
const auto *screen : std::as_const(redrawList))
409 if (screen->NeedsRedraw())
411 for (
const QRect& wrect: screen->GetDirtyArea())
413 bool foundThisRect =
false;
419 if (drect.contains(wrect))
421 foundThisRect =
true;
454 if (rect.width() == 0 || rect.height() == 0)
464 QVector<MythScreenType *> redrawList;
465 (*it)->GetDrawOrder(redrawList);
466 for (
auto *screen : std::as_const(redrawList))
467 screen->Draw(Painter, 0, 0, 255, rect);
478 return testAttribute(Qt::WA_PaintOnScreen) ? nullptr : QWidget::paintEngine();
483 if (
Event->spontaneous())
485 auto * key =
new QKeyEvent(QEvent::KeyPress,
m_priv->
m_escapekey, Qt::NoModifier);
486 QCoreApplication::postEvent(
this, key);
491 QWidget::closeEvent(
Event);
497 auto * active = QApplication::activeWindow();
500 winid = active->winId();
512 if (
auto * screen = display->GetCurrentScreen(); screen)
514 QPixmap image = screen->grabWindow(winid);
515 Image = image.toImage();
527 args << QString::number(Width);
528 args << QString::number(Height);
531 QCoreApplication::sendEvent(
this, &me);
543 if (Filename.isEmpty())
545 QString fpath =
GetMythDB()->GetSetting(
"ScreenShotPath",
"/tmp");
546 Filename = QString(
"%1/myth-screenshot-%2.png")
550 QString extension = Filename.section(
'.', -1, -1);
551 if (extension ==
"jpg")
556 LOG(VB_GENERAL, LOG_INFO, QString(
"Saving screenshot to %1 (%2x%3)")
557 .arg(Filename).arg(Image.width()).arg(Image.height()));
559 if (Image.save(Filename, extension.toLatin1().constData(), 100))
561 LOG(VB_GENERAL, LOG_INFO,
"MythMainWindow::screenShot succeeded");
565 LOG(VB_GENERAL, LOG_INFO,
"MythMainWindow::screenShot Failed!");
576 Height = img.height();
577 img = img.scaled(Width, Height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
619 if (!updatesEnabled() && (
Event->type() == QEvent::UpdateRequest))
622 if (
Event->type() == QEvent::Show && !
Event->spontaneous())
632 if ((
Event->type() == QEvent::WindowActivate) || (
Event->type() == QEvent::WindowDeactivate))
635 return QWidget::event(
Event);
643 QApplication::setStyle(
"Windows");
656 Qt::WindowFlags flags = Qt::Window;
664 setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
668 LOG(VB_GENERAL, LOG_INFO,
"Using Frameless Window");
669 flags |= Qt::FramelessWindowHint;
674 flags |= Qt::MSWindowsOwnDC;
682 if (fullscreen && !inwindow)
684 LOG(VB_GENERAL, LOG_INFO,
"Using Full Screen Window");
689 setWindowState(Qt::WindowFullScreen);
695 setWindowState(Qt::WindowNoState);
699 flags |= Qt::WindowStaysOnTopHint;
701 setWindowFlags(flags);
717 if (!
GetMythDB()->GetBoolSetting(
"HideMouseCursor",
false))
718 setMouseTracking(
true);
726 LOG(VB_GENERAL, LOG_INFO,
"Destroying painter and painter window");
731 if (!warningmsg.isEmpty())
733 LOG(VB_GENERAL, LOG_WARNING, warningmsg);
738 LOG(VB_GENERAL, LOG_ERR,
"MythMainWindow failed to create a painter window.");
744 setAttribute(Qt::WA_NoSystemBackground);
745 setAutoFillBackground(
false);
747 setAttribute(Qt::WA_InputMethodEnabled);
755 static const QLatin1String EARLY_SHOW_PLATFORM_NAME_CHECK {
"android" };
757 static const QLatin1String EARLY_SHOW_PLATFORM_NAME_CHECK {
"egl" };
759 if (QGuiApplication::platformName().contains(EARLY_SHOW_PLATFORM_NAME_CHECK))
760 QCoreApplication::processEvents();
762 if (!
GetMythDB()->GetBoolSetting(
"HideMouseCursor",
false))
776 if (!warningmsg.isEmpty())
789#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
790 QtAndroid::hideSplashScreen();
792 QNativeInterface::QAndroidApplication::hideSplashScreen();
802 "Down Arrow"),
"Down");
804 "Left Arrow"),
"Left");
806 "Right Arrow"),
"Right");
807 RegisterKey(
"Global",
"NEXT", QT_TRANSLATE_NOOP(
"MythControls",
808 "Move to next widget"),
"Tab");
809 RegisterKey(
"Global",
"PREVIOUS", QT_TRANSLATE_NOOP(
"MythControls",
810 "Move to preview widget"),
"Backtab");
812 "Select"),
"Return,Enter,Space");
813 RegisterKey(
"Global",
"BACKSPACE", QT_TRANSLATE_NOOP(
"MythControls",
814 "Backspace"),
"Backspace");
815 RegisterKey(
"Global",
"ESCAPE", QT_TRANSLATE_NOOP(
"MythControls",
816 "Escape"),
"Esc,Back");
817 RegisterKey(
"Global",
"MENU", QT_TRANSLATE_NOOP(
"MythControls",
818 "Pop-up menu"),
"M,Meta+Enter,Ctrl+M,Menu");
819 RegisterKey(
"Global",
"INFO", QT_TRANSLATE_NOOP(
"MythControls",
820 "More information"),
"I,Ctrl+I,Home Page");
821 RegisterKey(
"Global",
"DELETE", QT_TRANSLATE_NOOP(
"MythControls",
822 "Delete"),
"D,Ctrl+E");
823 RegisterKey(
"Global",
"EDIT", QT_TRANSLATE_NOOP(
"MythControls",
826 "Save screenshot"),
"");
828 "Play a media resource"),
"");
830 RegisterKey(
"Global",
"PAGEUP", QT_TRANSLATE_NOOP(
"MythControls",
832 RegisterKey(
"Global",
"PAGEDOWN", QT_TRANSLATE_NOOP(
"MythControls",
833 "Page Down"),
"PgDown");
834 RegisterKey(
"Global",
"PAGETOP", QT_TRANSLATE_NOOP(
"MythControls",
835 "Page to top of list"),
"");
836 RegisterKey(
"Global",
"PAGEMIDDLE", QT_TRANSLATE_NOOP(
"MythControls",
837 "Page to middle of list"),
"");
838 RegisterKey(
"Global",
"PAGEBOTTOM", QT_TRANSLATE_NOOP(
"MythControls",
839 "Page to bottom of list"),
"");
841 RegisterKey(
"Global",
"PREVVIEW", QT_TRANSLATE_NOOP(
"MythControls",
842 "Previous View"),
"Home,Media Previous");
843 RegisterKey(
"Global",
"NEXTVIEW", QT_TRANSLATE_NOOP(
"MythControls",
844 "Next View"),
"End,Media Next");
846 RegisterKey(
"Global",
"HELP", QT_TRANSLATE_NOOP(
"MythControls",
848 RegisterKey(
"Global",
"EJECT", QT_TRANSLATE_NOOP(
"MythControls"
849 ,
"Eject Removable Media"),
"");
851 RegisterKey(
"Global",
"CUT", QT_TRANSLATE_NOOP(
"MythControls",
852 "Cut text from textedit"),
"Ctrl+X");
853 RegisterKey(
"Global",
"COPY", QT_TRANSLATE_NOOP(
"MythControls"
854 ,
"Copy text from textedit"),
"Ctrl+C");
855 RegisterKey(
"Global",
"PASTE", QT_TRANSLATE_NOOP(
"MythControls",
856 "Paste text into textedit"),
"Ctrl+V");
857 RegisterKey(
"Global",
"NEWLINE", QT_TRANSLATE_NOOP(
"MythControls",
858 "Insert newline into textedit"),
"Ctrl+Return");
859 RegisterKey(
"Global",
"UNDO", QT_TRANSLATE_NOOP(
"MythControls",
861 RegisterKey(
"Global",
"REDO", QT_TRANSLATE_NOOP(
"MythControls",
863 RegisterKey(
"Global",
"SEARCH", QT_TRANSLATE_NOOP(
"MythControls",
864 "Show incremental search dialog"),
"Ctrl+S,Search");
878 "Turn the display on"),
"");
880 "Turn the display off"),
"");
882 RegisterKey(
"Global",
"SYSEVENT01", QT_TRANSLATE_NOOP(
"MythControls",
883 "Trigger System Key Event #1"),
"");
884 RegisterKey(
"Global",
"SYSEVENT02", QT_TRANSLATE_NOOP(
"MythControls",
885 "Trigger System Key Event #2"),
"");
886 RegisterKey(
"Global",
"SYSEVENT03", QT_TRANSLATE_NOOP(
"MythControls",
887 "Trigger System Key Event #3"),
"");
888 RegisterKey(
"Global",
"SYSEVENT04", QT_TRANSLATE_NOOP(
"MythControls",
889 "Trigger System Key Event #4"),
"");
890 RegisterKey(
"Global",
"SYSEVENT05", QT_TRANSLATE_NOOP(
"MythControls",
891 "Trigger System Key Event #5"),
"");
892 RegisterKey(
"Global",
"SYSEVENT06", QT_TRANSLATE_NOOP(
"MythControls",
893 "Trigger System Key Event #6"),
"");
894 RegisterKey(
"Global",
"SYSEVENT07", QT_TRANSLATE_NOOP(
"MythControls",
895 "Trigger System Key Event #7"),
"");
896 RegisterKey(
"Global",
"SYSEVENT08", QT_TRANSLATE_NOOP(
"MythControls",
897 "Trigger System Key Event #8"),
"");
898 RegisterKey(
"Global",
"SYSEVENT09", QT_TRANSLATE_NOOP(
"MythControls",
899 "Trigger System Key Event #9"),
"");
900 RegisterKey(
"Global",
"SYSEVENT10", QT_TRANSLATE_NOOP(
"MythControls",
901 "Trigger System Key Event #10"),
"");
904 RegisterKey(
"Browser",
"ZOOMIN", QT_TRANSLATE_NOOP(
"MythControls",
905 "Zoom in on browser window"),
".,>,Ctrl+F,Media Fast Forward");
906 RegisterKey(
"Browser",
"ZOOMOUT", QT_TRANSLATE_NOOP(
"MythControls",
907 "Zoom out on browser window"),
",,<,Ctrl+B,Media Rewind");
908 RegisterKey(
"Browser",
"TOGGLEINPUT", QT_TRANSLATE_NOOP(
"MythControls",
909 "Toggle where keyboard input goes to"),
"F1");
910 RegisterKey(
"Browser",
"RELOAD" , QT_TRANSLATE_NOOP(
"MythControls",
911 "Reload the current webpage"),
"F2");
912 RegisterKey(
"Browser",
"FULLRELOAD", QT_TRANSLATE_NOOP(
"MythControls",
913 "Reload the current webpage bypassing the cache"),
"F3");
915 RegisterKey(
"Browser",
"MOUSEUP", QT_TRANSLATE_NOOP(
"MythControls",
916 "Move mouse pointer up"),
"2");
917 RegisterKey(
"Browser",
"MOUSEDOWN", QT_TRANSLATE_NOOP(
"MythControls",
918 "Move mouse pointer down"),
"8");
919 RegisterKey(
"Browser",
"MOUSELEFT", QT_TRANSLATE_NOOP(
"MythControls",
920 "Move mouse pointer left"),
"4");
921 RegisterKey(
"Browser",
"MOUSERIGHT", QT_TRANSLATE_NOOP(
"MythControls",
922 "Move mouse pointer right"),
"6");
923 RegisterKey(
"Browser",
"MOUSELEFTBUTTON", QT_TRANSLATE_NOOP(
"MythControls",
924 "Mouse Left button click"),
"5");
926 RegisterKey(
"Browser",
"PAGEDOWN", QT_TRANSLATE_NOOP(
"MythControls",
927 "Scroll down half a page"),
"9");
928 RegisterKey(
"Browser",
"PAGEUP", QT_TRANSLATE_NOOP(
"MythControls",
929 "Scroll up half a page"),
"3");
930 RegisterKey(
"Browser",
"PAGELEFT", QT_TRANSLATE_NOOP(
"MythControls",
931 "Scroll left half a page"),
"7");
932 RegisterKey(
"Browser",
"PAGERIGHT", QT_TRANSLATE_NOOP(
"MythControls",
933 "Scroll right half a page"),
"1");
935 RegisterKey(
"Browser",
"NEXTLINK", QT_TRANSLATE_NOOP(
"MythControls",
936 "Move selection to next link"),
"Z");
937 RegisterKey(
"Browser",
"PREVIOUSLINK", QT_TRANSLATE_NOOP(
"MythControls",
938 "Move selection to previous link"),
"Q");
939 RegisterKey(
"Browser",
"FOLLOWLINK", QT_TRANSLATE_NOOP(
"MythControls",
940 "Follow selected link"),
"Return,Space,Enter");
941 RegisterKey(
"Browser",
"HISTORYBACK", QT_TRANSLATE_NOOP(
"MythControls",
942 "Go back to previous page"),
"R,Backspace");
943 RegisterKey(
"Browser",
"HISTORYFORWARD", QT_TRANSLATE_NOOP(
"MythControls",
944 "Go forward to previous page"),
"F");
946 RegisterKey(
"Main Menu",
"EXITPROMPT", QT_TRANSLATE_NOOP(
"MythControls",
947 "Display System Exit Prompt"),
"Esc,Back");
948 RegisterKey(
"Main Menu",
"EXIT", QT_TRANSLATE_NOOP(
"MythControls",
950 RegisterKey(
"Main Menu",
"STANDBYMODE",QT_TRANSLATE_NOOP(
"MythControls",
951 "Enter Standby Mode"),
"");
952 RegisterKey(
"Long Press",
"LONGPRESS1",QT_TRANSLATE_NOOP(
"MythControls",
953 "Up to 16 Keys that allow Long Press"),
"");
954 RegisterKey(
"Long Press",
"LONGPRESS2",QT_TRANSLATE_NOOP(
"MythControls",
955 "Up to 16 Keys that allow Long Press"),
"");
956 RegisterKey(
"Long Press",
"LONGPRESS3",QT_TRANSLATE_NOOP(
"MythControls",
957 "Up to 16 Keys that allow Long Press"),
"");
958 RegisterKey(
"Long Press",
"LONGPRESS4",QT_TRANSLATE_NOOP(
"MythControls",
959 "Up to 16 Keys that allow Long Press"),
"");
983 setFixedSize(Geometry.size());
984 setGeometry(Geometry);
988 m_painterWin->setGeometry(0, 0, Geometry.width(), Geometry.height());
1021 setUpdatesEnabled(Enable);
1026 QApplication::postEvent(
this,
new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority);
1042 widget->EnableEffects();
1044 widget->DisableEffects();
1063 if (screen && screen->objectName() != QString(
"mainmenu"))
1067 if (screen->objectName() == QString(
"video playback window"))
1069 auto *me =
new MythEvent(
"EXIT_TO_MENU");
1070 QCoreApplication::postEvent(screen, me);
1076 QCoreApplication::postEvent(
this, key);
1082 QCoreApplication::postEvent(
1105 callback(mediadevice);
1121 QStringList& Actions,
bool AllowJumps)
1128 !
Event->text().isEmpty() &&
1129 Event->modifiers() == Qt::NoModifier)
1155 QStringList localActions;
1159 keycontext && (keycontext->GetMapping(keynum, localActions)))
1178 QCoreApplication::postEvent(
1184 keycontext->GetMapping(keynum, Actions);
1186 if (Context !=
"Global")
1190 keycontextG->GetMapping(keynum, Actions);
1199 if (keycontext ==
nullptr)
1202 for (
auto it = keycontext->m_actionMap.begin();
1203 it != keycontext->m_actionMap.end();
1206 QStringList list = it.value();
1209 it = keycontext->m_actionMap.erase(it);
1218 if (keycontext !=
nullptr)
1219 keycontext->m_actionMap.clear();
1225 if (keycontext ==
nullptr)
1228 if (keycontext ==
nullptr)
1233 QKeySequence keyseq(Key);
1234 for (
unsigned int i = 0; i < static_cast<uint>(keyseq.count()); i++)
1236#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
1237 int keynum = keyseq[i];
1239 int keynum = keyseq[i].toCombined();
1242 QStringList dummyaction(
"");
1243 if (keycontext->GetMapping(keynum, dummyaction))
1245 LOG(VB_GENERAL, LOG_WARNING, QString(
"Key %1 is bound to multiple actions in context %2.")
1246 .arg(Key, Context));
1249 keycontext->AddMapping(keynum,
Action);
1251 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Binding: %1 to action: %2 (%3)")
1252 .arg(Key).arg(
Action).arg(Context));
1255 if (
Action ==
"ESCAPE" && Context ==
"Global" && i == 0)
1261 const QString& Description,
const QString& Key)
1263 QString keybind = Key;
1269 query.
prepare(
"SELECT keylist, description FROM keybindings WHERE "
1270 "context = :CONTEXT AND action = :ACTION AND "
1271 "hostname = :HOSTNAME ;");
1278 keybind = query.
value(0).toString();
1279 QString db_description = query.
value(1).toString();
1282 if (db_description != Description)
1284 LOG(VB_GENERAL, LOG_NOTICE,
1285 "Updating keybinding description...");
1287 "UPDATE keybindings "
1288 "SET description = :DESCRIPTION "
1289 "WHERE context = :CONTEXT AND "
1290 " action = :ACTION AND "
1291 " hostname = :HOSTNAME");
1293 query.
bindValue(
":DESCRIPTION", Description);
1306 const QString& inskey = keybind;
1308 query.
prepare(
"INSERT INTO keybindings (context, action, "
1309 "description, keylist, hostname) VALUES "
1310 "( :CONTEXT, :ACTION, :DESCRIPTION, :KEYLIST, "
1314 query.
bindValue(
":DESCRIPTION", Description);
1335 query.
prepare(
"SELECT keylist "
1337 "WHERE context = :CONTEXT AND "
1338 " action = :ACTION AND "
1339 " hostname = :HOSTNAME");
1347 return query.
value(0).toString();
1351 const QString&
Action)
const
1356 if (entry.contains(
Action))
1357 return entry.value(
Action);
1367 LOG(VB_GENERAL, LOG_ERR,
"Cannot clear ficticious jump point" + Destination);
1389 LOG(VB_GENERAL, LOG_ERR,
"Cannot bind to ficticious jump point" + Destination);
1393 QKeySequence keyseq(Key);
1395 for (
unsigned int i = 0; i < static_cast<uint>(keyseq.count()); i++)
1397#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
1398 int keynum = keyseq[i];
1400 int keynum = keyseq[i].toCombined();
1406 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Binding: %1 to JumpPoint: %2")
1407 .arg(keybind).arg(destination));
1414 LOG(VB_GENERAL, LOG_WARNING, QString(
"Key %1 is already bound to a jump point.")
1420 LOG(VB_GENERAL, LOG_DEBUG,
1421 QString(
"JumpPoint: %2 exists, no keybinding") .arg(destination));
1426 const QString& Key,
void (*Callback)(
void),
1427 bool Exittomain, QString LocalAction)
1429 QString keybind = Key;
1434 query.
prepare(
"SELECT keylist FROM jumppoints WHERE destination = :DEST and hostname = :HOST ;");
1439 keybind = query.
value(0).toString();
1443 const QString& inskey = keybind;
1445 query.
prepare(
"INSERT INTO jumppoints (destination, description, "
1446 "keylist, hostname) VALUES ( :DEST, :DESC, :KEYLIST, "
1457 JumpData jd = { Callback, Destination, Description, Exittomain, std::move(LocalAction) };
1465 QList<QString>::Iterator it;
1466 for (it = destinations.begin(); it != destinations.end(); ++it)
1477 QCoreApplication::postEvent(
1498 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Registering %1 as a media playback plugin.")
1504 LOG(VB_GENERAL, LOG_NOTICE, QString(
"%1 is already registered as a media playback plugin.")
1510 const QString& Plot,
const QString& Title,
1511 const QString& Subtitle,
1512 const QString& Director,
int Season,
1513 int Episode,
const QString& Inetref,
1514 std::chrono::minutes LenMins,
const QString& Year,
1515 const QString& Id,
bool UseBookmarks)
1517 QString lhandler(Handler);
1518 if (lhandler.isEmpty())
1519 lhandler =
"Internal";
1525 Director, Season, Episode,
1526 Inetref, LenMins, Year, Id,
1553 QCoreApplication::postEvent(
this,
event);
1561 auto * keyevent =
dynamic_cast<QKeyEvent*
>(*Event);
1564 int keycode = keyevent->key();
1569 QEvent *newevent =
nullptr;
1570 switch ((*Event)->type())
1572 case QEvent::KeyPress:
1585 newevent =
new QKeyEvent(QEvent::KeyPress, keycode,
1586 keyevent->modifiers() | Qt::MetaModifier, keyevent->nativeScanCode(),
1587 keyevent->nativeVirtualKey(), keyevent->nativeModifiers(),
1588 keyevent->text(),
false,1);
1590 NewEvent.reset(newevent);
1601 QStringList actions;
1608 LOG(VB_GUI, LOG_ERR, QString(
"TranslateKeyPress Long Press Invalid Response"));
1611 if (!actions.empty() && actions[0].startsWith(
"LONGPRESS"))
1620 case QEvent::KeyRelease:
1624 if (keyevent->isAutoRepeat())
1629 Qt::KeyboardModifiers modifier = Qt::NoModifier;
1633 modifier = Qt::MetaModifier;
1635 newevent =
new QKeyEvent(QEvent::KeyPress, keycode,
1636 keyevent->modifiers() | modifier, keyevent->nativeScanCode(),
1637 keyevent->nativeVirtualKey(), keyevent->nativeModifiers(),
1638 keyevent->text(),
false,1);
1640 NewEvent.reset(newevent);
1663 QScopedPointer<QEvent> newevent(
nullptr);
1667 switch (
Event->type())
1669 case QEvent::KeyPress:
1672 auto *
event =
dynamic_cast<QKeyEvent*
>(
Event);
1677 event =
static_cast<QKeyEvent*
>(
Event);
1684 switch (
event->nativeScanCode())
1687 keycode = Qt::Key_MediaPause;
1695 auto * key =
new QKeyEvent(QEvent::KeyPress, keycode,
event->modifiers());
1696 if (
auto * target =
GetTarget(*key); target)
1697 QCoreApplication::postEvent(target, key);
1699 QCoreApplication::postEvent(
this, key);
1705 QVector<MythScreenStack *>::const_reverse_iterator it;
1708 if (
auto * top = (*it)->GetTopScreen(); top)
1710 if (top->keyPressEvent(
event))
1714 if ((*it)->objectName() ==
"popup stack")
1720 case QEvent::InputMethod:
1723 auto *ie =
dynamic_cast<QInputMethodEvent*
>(
Event);
1725 return MythUIScreenBounds::eventFilter(Watched,
Event);
1726 QWidget *widget = QApplication::focusWidget();
1730 if (widget->isEnabled())
1731 QCoreApplication::instance()->notify(widget, ie);
1734 QVector<MythScreenStack *>::const_reverse_iterator it;
1744 if ((*it)->objectName() ==
"popup stack")
1749 case QEvent::MouseButtonPress:
1756 auto * mouseEvent =
dynamic_cast<QMouseEvent*
>(
Event);
1758 return MythUIScreenBounds::eventFilter(Watched,
Event);
1766 case QEvent::MouseButtonRelease:
1777 QPoint point { -1, -1 };
1778 auto * mouseevent =
dynamic_cast<QMouseEvent*
>(
Event);
1781 point = mouseevent->pos();
1789 return MythUIScreenBounds::eventFilter(Watched,
Event);
1791 QVector<MythScreenStack *>::const_reverse_iterator it;
1794 auto * screen = (*it)->GetTopScreen();
1795 if (!screen || !screen->ContainsPoint(point))
1798 if (screen->gestureEvent(gesture))
1807 if ((*it)->objectName() ==
"popup stack")
1814 bool handled =
false;
1818 QCoreApplication::postEvent(
this, gesture);
1822 QVector<MythScreenStack *>::const_reverse_iterator it;
1841 if ((*it)->objectName() ==
"popup stack")
1848 QCoreApplication::postEvent(
this, gesture);
1855 case QEvent::MouseMove:
1864 auto * mouseevent =
dynamic_cast<QMouseEvent*
>(
Event);
1866 return MythUIScreenBounds::eventFilter(Watched,
Event);
1876 auto * wheel =
dynamic_cast<QWheelEvent*
>(
Event);
1877 if (wheel ==
nullptr)
1878 return MythUIScreenBounds::eventFilter(Watched,
Event);
1879 int delta = wheel->angleDelta().y();
1883 auto *key =
new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);
1884 if (
auto * target =
GetTarget(*key); target)
1885 QCoreApplication::postEvent(target, key);
1887 QCoreApplication::postEvent(
this, key);
1892 auto * key =
new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);
1893 if (
auto * target =
GetTarget(*key); !target)
1894 QCoreApplication::postEvent(target, key);
1896 QCoreApplication::postEvent(
this, key);
1904 return MythUIScreenBounds::eventFilter(Watched,
Event);
1912 if (gesture ==
nullptr)
1915 if (
auto * screen = toplevel->GetTopScreen(); screen)
1916 screen->gestureEvent(gesture);
1917 LOG(VB_GUI, LOG_DEBUG, QString(
"Gesture: %1 (Button: %2)")
1918 .arg(gesture->GetName(), gesture->GetButtonName()));
1927 if (
event ==
nullptr)
1929 auto * key =
new QKeyEvent(QEvent::KeyPress,
event->getKeycode(), Qt::NoModifier);
1930 if (
auto * target =
GetTarget(*key); target)
1931 QCoreApplication::sendEvent(target, key);
1933 QCoreApplication::sendEvent(
this, key);
1956 QVector<MythScreenType*> screenList;
1957 widget->GetScreenList(screenList);
1958 for (
auto * screen : std::as_const(screenList))
1960 screen->mediaEvent(me);
1966 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Media Event: %1 - %2")
1967 .arg(device->getDevicePath()).arg(device->getStatus()));
1999 if (
event ==
nullptr)
2002 QString message =
event->
Message();
2005 if (
event->ExtraDataCount() == 1)
2007 else if (
event->ExtraDataCount() >= 11)
2010 if (
event->ExtraDataCount() >= 12)
2015 event->ExtraData(5).toInt(),
event->ExtraData(6).toInt(),
2016 event->ExtraData(7), std::chrono::minutes(
event->ExtraData(8).toInt()),
2022 LOG(VB_GENERAL, LOG_ERR,
"Failed to handle media");
2030 if (
event->ExtraDataCount() >= 2)
2032 width =
event->ExtraData(0).toInt();
2033 height =
event->ExtraData(1).toInt();
2034 if (
event->ExtraDataCount() == 3)
2042 state.insert(
"state",
"idle");
2043 state.insert(
"menutheme",
GetMythDB()->GetSetting(
"menutheme",
"defaultmenu"));
2044 state.insert(
"currentlocation",
GetMythUI()->GetCurrentLocation());
2047 else if (message ==
"CLEAR_SETTINGS_CACHE")
2061 LOG(VB_GENERAL, LOG_INFO, QString(
"Updating the frontend idle time to: %1 mins").arg(
m_idleTime.count()));
2065 LOG(VB_GENERAL, LOG_INFO,
"Frontend idle timeout is disabled");
2068 else if (message ==
"NOTIFICATION")
2085 if (
const QString& message =
event->Message(); !message.isEmpty())
2096 auto * target = QWidget::keyboardGrabber();
2099 if (
auto * widget = QApplication::focusWidget(); widget && widget->isEnabled())
2105 target = widget->topLevelWidget();
2121 if (
Show &&
GetMythDB()->GetBoolSetting(
"HideMouseCursor",
false))
2125 setCursor(
Show ? (Qt::ArrowCursor) : (Qt::BlankCursor));
2178 LOG(VB_GENERAL, LOG_NOTICE,
"Suspending idle timer");
2183 LOG(VB_GENERAL, LOG_NOTICE,
"Resuming idle timer");
2199 LOG(VB_GENERAL, LOG_NOTICE,
2200 QString(
"Entering standby mode after %1 minutes of inactivity").arg(
m_idleTime.count()));
2223 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Entering standby mode"));
2230 state.insert(
"state",
"standby");
2231 state.insert(
"menutheme",
GetMythDB()->GetSetting(
"menutheme",
"defaultmenu"));
2232 state.insert(
"currentlocation",
GetMythUI()->GetCurrentLocation());
2258 LOG(VB_GENERAL, LOG_NOTICE,
"Leaving standby mode");
2266 state.insert(
"state",
"idle");
2267 state.insert(
"menutheme",
GetMythDB()->GetSetting(
"menutheme",
"defaultmenu"));
2268 state.insert(
"currentlocation",
GetMythUI()->GetCurrentLocation());
2274 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Application State Changed to %1").arg(
State));
2277 case Qt::ApplicationState::ApplicationActive:
2280 case Qt::ApplicationState::ApplicationSuspended:
An action (for this plugin) consists of a description, and a set of key sequences.
static const Type kEventType
QSqlQuery wrapper that fetches a DB connection from the connection pool.
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
QVariant value(int i) const
bool isActive(void) const
bool isConnected(void) const
Only updated once during object creation.
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
void ResetAudioLanguage(void)
void SetWOLAllowed(bool allow)
QString GetSetting(const QString &key, const QString &defaultval="")
static int GetMasterServerPort(void)
Returns the Master Backend control port If no master server port has been defined in the database,...
QString GetSettingOnHost(const QString &key, const QString &host, const QString &defaultval="")
void dispatch(const MythEvent &event)
void SetGUIObject(QObject *gui)
int GetNumSetting(const QString &key, int defaultval=0)
std::enable_if_t< std::chrono::__is_duration< T >::value, T > GetDurSetting(const QString &key, T defaultval=T::zero())
static void DBError(const QString &where, const MSqlQuery &query)
void SwitchToDesktop()
Return the screen to the original desktop video mode.
bool SwitchToGUI(bool Wait=false)
Switches to the GUI resolution.
virtual bool UsingVideoModes()
void SetWidget(QWidget *MainWindow)
Set the QWidget and QWindow in use.
This class is used as a container for messages.
static const Type kExitToMainMenuEventType
static const Type kPushDisableDrawingEventType
static const Type kDisableUDPListenerEventType
const QString & Message() const
static const Type kUnlockInputDevicesEventType
static const Type kPopDisableDrawingEventType
static const Type kEnableUDPListenerEventType
static const Type kMythPostShowEventType
static const Type kMythEventMessage
static const Type kMythUserMessage
static const Type kLockInputDevicesEventType
A custom event that represents a mouse gesture.
void SetPosition(QPoint Position)
static const Type kEventType
bool Record(QPoint Point, Qt::MouseButton Button)
Record a point.
MythGestureEvent * GetGesture() const
Complete the gesture event of the last completed stroke.
bool Recording()
Determine if the stroke is being recorded.
void Start()
Start recording.
void Stop(bool Timeout=false)
Stop recording.
QTimer * m_hideMouseTimer
void(* m_exitMenuCallback)(void)
QVector< MythScreenStack * > m_stackList
QMap< int, JumpData * > m_jumpMap
std::chrono::milliseconds m_longPressTime
QHash< QString, QHash< QString, QString > > m_actionText
QMap< QString, JumpData > m_destinationMap
MythNotificationCenter * m_nc
QHash< QString, KeyContext * > m_keyContexts
bool m_useDB
To allow or prevent database access.
static int TranslateKeyNum(QKeyEvent *Event)
QMap< QString, MythMediaCallback > m_mediaPluginMap
void(* m_exitMenuMediaDeviceCallback)(MythMediaDevice *mediadevice)
MythMediaDevice * m_mediaDeviceForCallback
MythScreenStack * m_mainStack
void customEvent(QEvent *Event) override
QWidget * GetPaintWindow()
void ClearKeyContext(const QString &Context)
static void DisableScreensaver()
void ShowMouseCursor(bool Show)
MythScreenStack * GetStackAt(int Position)
static void LoadQtConfig()
void ExitStandby(bool Manual=true)
void RemoteScreenShot(QString Filename, int Width, int Height)
MythNotificationCenter * GetCurrentNotificationCenter()
void SetDrawEnabled(bool Enable)
static void ResetScreensaver()
void OnApplicationStateChange(Qt::ApplicationState State)
void SignalRemoteScreenShot(QString Filename, int Width, int Height)
std::chrono::minutes m_idleTime
QString GetActionText(const QString &Context, const QString &Action) const
void PauseIdleTimer(bool Pause)
Pause the idle timeout timer.
MythDisplay * GetDisplay()
void HandleTVAction(const QString &Action)
MythScreenStack * GetMainStack()
static bool ScreenShot(int Width=0, int Height=0, QString Filename="")
void RestartInputHandlers()
void SignalDisableScreensaver()
void drawScreen(QPaintEvent *Event=nullptr)
MythRender * GetRenderDevice()
~MythMainWindow() override
MythScreenSaverControl * m_screensaver
void JumpTo(const QString &Destination, bool Pop=true)
void BindJump(const QString &Destination, const QString &Key)
bool event(QEvent *Event) override
void SignalResetScreensaver()
bool eventFilter(QObject *Watched, QEvent *Event) override
MythPainter * GetPainter()
static MythMainWindow * getMainWindow(bool UseDB=true)
Return the existing main window, or create one.
void SignalRestoreScreensaver()
static bool IsScreensaverAsleep()
void RegisterMediaPlugin(const QString &Name, const QString &Desc, MediaPlayCallback Func)
void ClearKey(const QString &Context, const QString &Action)
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
MythMainWindow(bool UseDB=true)
void RegisterJump(const QString &Destination, const QString &Description, const QString &Key, void(*Callback)(void), bool Exittomain=true, QString LocalAction="")
static bool IsTopScreenInitialized()
bool IsExitingToMain() const
void SignalSetDrawEnabled(bool Enable)
static bool SaveScreenShot(const QImage &Image, QString Filename="")
void MoveResize(QRect &Geometry)
MythThemeBase * m_themeBase
void DoRemoteScreenShot(const QString &Filename, int Width, int Height)
void AddScreenStack(MythScreenStack *Stack, bool Main=false)
MythMainWindowPrivate * m_priv
static void GrabWindow(QImage &Image)
static void destroyMainWindow()
MythScreenStack * GetStack(const QString &Stackname)
void ResetIdleTimer()
Reset the idle timeout timer.
void EnterStandby(bool Manual=true)
static QString GetKey(const QString &Context, const QString &Action)
bool KeyLongPressFilter(QEvent **Event, QScopedPointer< QEvent > &NewEvent)
MythPainterWindow * m_painterWin
bool DestinationExists(const QString &Destination) const
void ClearJump(const QString &Destination)
void RegisterKey(const QString &Context, const QString &Action, const QString &Description, const QString &Key)
QStringList EnumerateDestinations() const
bool HandleMedia(const QString &Handler, const QString &Mrl, const QString &Plot="", const QString &Title="", const QString &Subtitle="", const QString &Director="", int Season=0, int Episode=0, const QString &Inetref="", std::chrono::minutes LenMins=2h, const QString &Year="1895", const QString &Id="", bool UseBookmarks=false)
static void RestoreScreensaver()
QPaintEngine * paintEngine() const override
void Draw(MythPainter *Painter=nullptr)
void closeEvent(QCloseEvent *Event) override
void SetEffectsEnabled(bool Enable)
void BindKey(const QString &Context, const QString &Action, const QString &Key)
void DisableIdleTimer(bool DisableIdle=true)
Disable the idle timeout timer.
void Init(bool MayReInit=true)
MythInputDeviceHandler * m_deviceHandler
QObject * GetTarget(QKeyEvent &Key)
void AllowInput(bool Allow)
static const Type kEventType
void ProcessQueue(void)
ProcessQueue will be called by the GUI event handler and will process all queued MythNotifications an...
static MythNotificationCenter * GetInstance(void)
returns the MythNotificationCenter singleton
int DisplayedNotifications(void) const
Returns number of notifications currently displayed.
bool Queue(const MythNotification ¬ification)
Queue a notification Queue() is thread-safe and can be called from anywhere.
void addListener(QObject *listener)
Add a listener to the observable.
void removeListener(QObject *listener)
Remove a listener to the observable.
static void DestroyPainters(MythPainterWindow *&PaintWin, MythPainter *&Painter)
static QString CreatePainters(MythMainWindow *MainWin, MythPainterWindow *&PaintWin, MythPainter *&Paint)
MythRender * GetRenderDevice()
virtual bool SupportsClipping(void)=0
virtual void SetClipRect(QRect clipRect)
virtual QString GetName(void)=0
virtual void Begin(QPaintDevice *)
Controls all instances of the screensaver.
virtual MythScreenType * GetTopScreen(void) const
Screen in which all other widgets are contained and rendered.
bool gestureEvent(MythGestureEvent *event) override
Mouse click/movement handler, receives mouse gesture events from the QCoreApplication event loop.
bool inputMethodEvent(QInputMethodEvent *event) override
Input Method event handler.
bool IsInitialized(void) const
Has Init() been called on this screen?
static void EnableUDPListener(bool Enable=true)
static void StopUDPListener()
static bool WindowIsAlwaysFullscreen()
Return true if the current platform only supports fullscreen windows.
void UpdateScreenSettings(MythDisplay *mDisplay)
static bool GeometryIsOverridden()
void SetUIScreenRect(QRect Rect)
static void SetState(const QVariantMap &NewState)
void ClearThemeCacheDir()
bool ContainsPoint(QPoint point) const
Check if the given point falls within this widgets area.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
A C++ ripoff of the stroke library for MythTV.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
static constexpr std::chrono::minutes STANDBY_TIMEOUT
MythNotificationCenter * GetNotificationCenter(void)
bool HasMythMainWindow(void)
static constexpr std::chrono::milliseconds LONGPRESS_INTERVAL
MythPainter * GetMythPainter(void)
MythMainWindow * GetMythMainWindow(void)
static MythMainWindow * s_mainWin
void DestroyMythMainWindow(void)
static constexpr std::chrono::milliseconds GESTURE_TIMEOUT
int(*)(const QString &, const QString &, const QString &, const QString &, const QString &, int, int, const QString &, std::chrono::minutes, const QString &, const QString &, bool) MediaPlayCallback
static constexpr const char * ACTION_7
static constexpr const char * ACTION_5
static constexpr const char * ACTION_0
static constexpr const char * ACTION_SCREENSHOT
static constexpr const char * ACTION_LEFT
static constexpr const char * ACTION_DOWN
static constexpr const char * ACTION_3
static constexpr const char * ACTION_1
static constexpr const char * ACTION_TVPOWERON
static constexpr const char * ACTION_HANDLEMEDIA
static constexpr const char * ACTION_TVPOWEROFF
static constexpr const char * ACTION_4
static constexpr const char * ACTION_RIGHT
static constexpr const char * ACTION_SELECT
static constexpr const char * ACTION_UP
static constexpr const char * ACTION_GETSTATUS
static constexpr const char * ACTION_6
static constexpr const char * ACTION_8
static constexpr const char * ACTION_2
static constexpr const char * ACTION_9
MythUIHelper * GetMythUI()
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
@ kScreenShotFilename
"yyyy-MM-ddThh-mm-ss.zzz"
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
static void show(uint8_t *buf, int length)