14 #include <QWaitCondition>
15 #include <QApplication>
21 #include <QKeySequence>
22 #include <QInputMethodEvent>
58 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
68 #define LOC QString("MythMainWindow: ")
143 setObjectName(
"mainwindow");
160 installEventFilter(
this);
176 setUpdatesEnabled(
true);
179 Qt::BlockingQueuedConnection);
181 Qt::BlockingQueuedConnection);
325 if (widget->objectName() == Stackname)
332 if (Position >= 0 && Position < m_priv->m_stackList.size())
351 QVector<MythScreenType *> drawList;
352 (*it)->GetDrawOrder(drawList);
354 for (
auto *screen : std::as_const(drawList))
358 if (screen->NeedsRedraw())
360 QRegion topDirty = screen->GetDirtyArea();
361 screen->ResetNeedsRedraw();
372 widget->ScheduleInitIfNeeded();
399 QVector<MythScreenType *> redrawList;
400 (*it)->GetDrawOrder(redrawList);
402 for (
const auto *screen : std::as_const(redrawList))
404 if (screen->NeedsRedraw())
406 for (
const QRect& wrect: screen->GetDirtyArea())
408 bool foundThisRect =
false;
414 if (drect.contains(wrect))
416 foundThisRect =
true;
449 if (rect.width() == 0 || rect.height() == 0)
459 QVector<MythScreenType *> redrawList;
460 (*it)->GetDrawOrder(redrawList);
461 for (
auto *screen : std::as_const(redrawList))
462 screen->Draw(Painter, 0, 0, 255, rect);
473 return testAttribute(Qt::WA_PaintOnScreen) ? nullptr : QWidget::paintEngine();
478 if (
Event->spontaneous())
480 auto * key =
new QKeyEvent(QEvent::KeyPress,
m_priv->
m_escapekey, Qt::NoModifier);
481 QCoreApplication::postEvent(
this, key);
486 QWidget::closeEvent(
Event);
492 auto * active = QApplication::activeWindow();
495 winid = active->winId();
507 if (
auto * screen = display->GetCurrentScreen(); screen)
509 QPixmap image = screen->grabWindow(winid);
510 Image = image.toImage();
522 args << QString::number(Width);
523 args << QString::number(Height);
526 QCoreApplication::sendEvent(
this, &me);
538 if (Filename.isEmpty())
540 QString fpath =
GetMythDB()->GetSetting(
"ScreenShotPath",
"/tmp");
541 Filename = QString(
"%1/myth-screenshot-%2.png")
545 QString extension = Filename.section(
'.', -1, -1);
546 if (extension ==
"jpg")
551 LOG(VB_GENERAL, LOG_INFO, QString(
"Saving screenshot to %1 (%2x%3)")
552 .arg(Filename).arg(Image.width()).arg(Image.height()));
554 if (Image.save(Filename, extension.toLatin1(), 100))
556 LOG(VB_GENERAL, LOG_INFO,
"MythMainWindow::screenShot succeeded");
560 LOG(VB_GENERAL, LOG_INFO,
"MythMainWindow::screenShot Failed!");
571 Height = img.height();
572 img = img.scaled(Width, Height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
614 if (!updatesEnabled() && (
Event->type() == QEvent::UpdateRequest))
617 if (
Event->type() == QEvent::Show && !
Event->spontaneous())
627 if ((
Event->type() == QEvent::WindowActivate) || (
Event->type() == QEvent::WindowDeactivate))
630 return QWidget::event(
Event);
638 QApplication::setStyle(
"Windows");
651 Qt::WindowFlags flags = Qt::Window;
659 setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
663 LOG(VB_GENERAL, LOG_INFO,
"Using Frameless Window");
664 flags |= Qt::FramelessWindowHint;
669 flags |= Qt::MSWindowsOwnDC;
677 if (fullscreen && !inwindow)
679 LOG(VB_GENERAL, LOG_INFO,
"Using Full Screen Window");
684 setWindowState(Qt::WindowFullScreen);
690 setWindowState(Qt::WindowNoState);
694 flags |= Qt::WindowStaysOnTopHint;
696 setWindowFlags(flags);
712 if (!
GetMythDB()->GetBoolSetting(
"HideMouseCursor",
false))
713 setMouseTracking(
true);
721 LOG(VB_GENERAL, LOG_INFO,
"Destroying painter and painter window");
726 if (!warningmsg.isEmpty())
728 LOG(VB_GENERAL, LOG_WARNING, warningmsg);
733 LOG(VB_GENERAL, LOG_ERR,
"MythMainWindow failed to create a painter window.");
739 setAttribute(Qt::WA_NoSystemBackground);
740 setAutoFillBackground(
false);
742 setAttribute(Qt::WA_InputMethodEnabled);
750 static const QLatin1String EARLY_SHOW_PLATFORM_NAME_CHECK {
"android" };
752 static const QLatin1String EARLY_SHOW_PLATFORM_NAME_CHECK {
"egl" };
754 if (QGuiApplication::platformName().contains(EARLY_SHOW_PLATFORM_NAME_CHECK))
755 QCoreApplication::processEvents();
757 if (!
GetMythDB()->GetBoolSetting(
"HideMouseCursor",
false))
771 if (!warningmsg.isEmpty())
784 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
785 QtAndroid::hideSplashScreen();
787 QNativeInterface::QAndroidApplication::hideSplashScreen();
797 "Down Arrow"),
"Down");
799 "Left Arrow"),
"Left");
801 "Right Arrow"),
"Right");
802 RegisterKey(
"Global",
"NEXT", QT_TRANSLATE_NOOP(
"MythControls",
803 "Move to next widget"),
"Tab");
804 RegisterKey(
"Global",
"PREVIOUS", QT_TRANSLATE_NOOP(
"MythControls",
805 "Move to preview widget"),
"Backtab");
807 "Select"),
"Return,Enter,Space");
808 RegisterKey(
"Global",
"BACKSPACE", QT_TRANSLATE_NOOP(
"MythControls",
809 "Backspace"),
"Backspace");
810 RegisterKey(
"Global",
"ESCAPE", QT_TRANSLATE_NOOP(
"MythControls",
811 "Escape"),
"Esc,Back");
812 RegisterKey(
"Global",
"MENU", QT_TRANSLATE_NOOP(
"MythControls",
813 "Pop-up menu"),
"M,Meta+Enter,Ctrl+M,Menu");
814 RegisterKey(
"Global",
"INFO", QT_TRANSLATE_NOOP(
"MythControls",
815 "More information"),
"I,Ctrl+I,Home Page");
816 RegisterKey(
"Global",
"DELETE", QT_TRANSLATE_NOOP(
"MythControls",
817 "Delete"),
"D,Ctrl+E");
818 RegisterKey(
"Global",
"EDIT", QT_TRANSLATE_NOOP(
"MythControls",
821 "Save screenshot"),
"");
823 "Play a media resource"),
"");
825 RegisterKey(
"Global",
"PAGEUP", QT_TRANSLATE_NOOP(
"MythControls",
827 RegisterKey(
"Global",
"PAGEDOWN", QT_TRANSLATE_NOOP(
"MythControls",
828 "Page Down"),
"PgDown");
829 RegisterKey(
"Global",
"PAGETOP", QT_TRANSLATE_NOOP(
"MythControls",
830 "Page to top of list"),
"");
831 RegisterKey(
"Global",
"PAGEMIDDLE", QT_TRANSLATE_NOOP(
"MythControls",
832 "Page to middle of list"),
"");
833 RegisterKey(
"Global",
"PAGEBOTTOM", QT_TRANSLATE_NOOP(
"MythControls",
834 "Page to bottom of list"),
"");
836 RegisterKey(
"Global",
"PREVVIEW", QT_TRANSLATE_NOOP(
"MythControls",
837 "Previous View"),
"Home,Media Previous");
838 RegisterKey(
"Global",
"NEXTVIEW", QT_TRANSLATE_NOOP(
"MythControls",
839 "Next View"),
"End,Media Next");
841 RegisterKey(
"Global",
"HELP", QT_TRANSLATE_NOOP(
"MythControls",
843 RegisterKey(
"Global",
"EJECT", QT_TRANSLATE_NOOP(
"MythControls"
844 ,
"Eject Removable Media"),
"");
846 RegisterKey(
"Global",
"CUT", QT_TRANSLATE_NOOP(
"MythControls",
847 "Cut text from textedit"),
"Ctrl+X");
848 RegisterKey(
"Global",
"COPY", QT_TRANSLATE_NOOP(
"MythControls"
849 ,
"Copy text from textedit"),
"Ctrl+C");
850 RegisterKey(
"Global",
"PASTE", QT_TRANSLATE_NOOP(
"MythControls",
851 "Paste text into textedit"),
"Ctrl+V");
852 RegisterKey(
"Global",
"NEWLINE", QT_TRANSLATE_NOOP(
"MythControls",
853 "Insert newline into textedit"),
"Ctrl+Return");
854 RegisterKey(
"Global",
"UNDO", QT_TRANSLATE_NOOP(
"MythControls",
856 RegisterKey(
"Global",
"REDO", QT_TRANSLATE_NOOP(
"MythControls",
858 RegisterKey(
"Global",
"SEARCH", QT_TRANSLATE_NOOP(
"MythControls",
859 "Show incremental search dialog"),
"Ctrl+S,Search");
873 "Turn the display on"),
"");
875 "Turn the display off"),
"");
877 RegisterKey(
"Global",
"SYSEVENT01", QT_TRANSLATE_NOOP(
"MythControls",
878 "Trigger System Key Event #1"),
"");
879 RegisterKey(
"Global",
"SYSEVENT02", QT_TRANSLATE_NOOP(
"MythControls",
880 "Trigger System Key Event #2"),
"");
881 RegisterKey(
"Global",
"SYSEVENT03", QT_TRANSLATE_NOOP(
"MythControls",
882 "Trigger System Key Event #3"),
"");
883 RegisterKey(
"Global",
"SYSEVENT04", QT_TRANSLATE_NOOP(
"MythControls",
884 "Trigger System Key Event #4"),
"");
885 RegisterKey(
"Global",
"SYSEVENT05", QT_TRANSLATE_NOOP(
"MythControls",
886 "Trigger System Key Event #5"),
"");
887 RegisterKey(
"Global",
"SYSEVENT06", QT_TRANSLATE_NOOP(
"MythControls",
888 "Trigger System Key Event #6"),
"");
889 RegisterKey(
"Global",
"SYSEVENT07", QT_TRANSLATE_NOOP(
"MythControls",
890 "Trigger System Key Event #7"),
"");
891 RegisterKey(
"Global",
"SYSEVENT08", QT_TRANSLATE_NOOP(
"MythControls",
892 "Trigger System Key Event #8"),
"");
893 RegisterKey(
"Global",
"SYSEVENT09", QT_TRANSLATE_NOOP(
"MythControls",
894 "Trigger System Key Event #9"),
"");
895 RegisterKey(
"Global",
"SYSEVENT10", QT_TRANSLATE_NOOP(
"MythControls",
896 "Trigger System Key Event #10"),
"");
899 RegisterKey(
"Browser",
"ZOOMIN", QT_TRANSLATE_NOOP(
"MythControls",
900 "Zoom in on browser window"),
".,>,Ctrl+F,Media Fast Forward");
901 RegisterKey(
"Browser",
"ZOOMOUT", QT_TRANSLATE_NOOP(
"MythControls",
902 "Zoom out on browser window"),
",,<,Ctrl+B,Media Rewind");
903 RegisterKey(
"Browser",
"TOGGLEINPUT", QT_TRANSLATE_NOOP(
"MythControls",
904 "Toggle where keyboard input goes to"),
"F1");
906 RegisterKey(
"Browser",
"MOUSEUP", QT_TRANSLATE_NOOP(
"MythControls",
907 "Move mouse pointer up"),
"2");
908 RegisterKey(
"Browser",
"MOUSEDOWN", QT_TRANSLATE_NOOP(
"MythControls",
909 "Move mouse pointer down"),
"8");
910 RegisterKey(
"Browser",
"MOUSELEFT", QT_TRANSLATE_NOOP(
"MythControls",
911 "Move mouse pointer left"),
"4");
912 RegisterKey(
"Browser",
"MOUSERIGHT", QT_TRANSLATE_NOOP(
"MythControls",
913 "Move mouse pointer right"),
"6");
914 RegisterKey(
"Browser",
"MOUSELEFTBUTTON", QT_TRANSLATE_NOOP(
"MythControls",
915 "Mouse Left button click"),
"5");
917 RegisterKey(
"Browser",
"PAGEDOWN", QT_TRANSLATE_NOOP(
"MythControls",
918 "Scroll down half a page"),
"9");
919 RegisterKey(
"Browser",
"PAGEUP", QT_TRANSLATE_NOOP(
"MythControls",
920 "Scroll up half a page"),
"3");
921 RegisterKey(
"Browser",
"PAGELEFT", QT_TRANSLATE_NOOP(
"MythControls",
922 "Scroll left half a page"),
"7");
923 RegisterKey(
"Browser",
"PAGERIGHT", QT_TRANSLATE_NOOP(
"MythControls",
924 "Scroll right half a page"),
"1");
926 RegisterKey(
"Browser",
"NEXTLINK", QT_TRANSLATE_NOOP(
"MythControls",
927 "Move selection to next link"),
"Z");
928 RegisterKey(
"Browser",
"PREVIOUSLINK", QT_TRANSLATE_NOOP(
"MythControls",
929 "Move selection to previous link"),
"Q");
930 RegisterKey(
"Browser",
"FOLLOWLINK", QT_TRANSLATE_NOOP(
"MythControls",
931 "Follow selected link"),
"Return,Space,Enter");
932 RegisterKey(
"Browser",
"HISTORYBACK", QT_TRANSLATE_NOOP(
"MythControls",
933 "Go back to previous page"),
"R,Backspace");
934 RegisterKey(
"Browser",
"HISTORYFORWARD", QT_TRANSLATE_NOOP(
"MythControls",
935 "Go forward to previous page"),
"F");
937 RegisterKey(
"Main Menu",
"EXITPROMPT", QT_TRANSLATE_NOOP(
"MythControls",
938 "Display System Exit Prompt"),
"Esc,Back");
939 RegisterKey(
"Main Menu",
"EXIT", QT_TRANSLATE_NOOP(
"MythControls",
941 RegisterKey(
"Main Menu",
"STANDBYMODE",QT_TRANSLATE_NOOP(
"MythControls",
942 "Enter Standby Mode"),
"");
943 RegisterKey(
"Long Press",
"LONGPRESS1",QT_TRANSLATE_NOOP(
"MythControls",
944 "Up to 16 Keys that allow Long Press"),
"");
945 RegisterKey(
"Long Press",
"LONGPRESS2",QT_TRANSLATE_NOOP(
"MythControls",
946 "Up to 16 Keys that allow Long Press"),
"");
947 RegisterKey(
"Long Press",
"LONGPRESS3",QT_TRANSLATE_NOOP(
"MythControls",
948 "Up to 16 Keys that allow Long Press"),
"");
949 RegisterKey(
"Long Press",
"LONGPRESS4",QT_TRANSLATE_NOOP(
"MythControls",
950 "Up to 16 Keys that allow Long Press"),
"");
974 setFixedSize(Geometry.size());
975 setGeometry(Geometry);
979 m_painterWin->setGeometry(0, 0, Geometry.width(), Geometry.height());
1012 setUpdatesEnabled(Enable);
1017 QApplication::postEvent(
this,
new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority);
1033 widget->EnableEffects();
1035 widget->DisableEffects();
1054 if (screen && screen->objectName() != QString(
"mainmenu"))
1058 if (screen->objectName() == QString(
"video playback window"))
1060 auto *me =
new MythEvent(
"EXIT_TO_MENU");
1061 QCoreApplication::postEvent(screen, me);
1067 QCoreApplication::postEvent(
this, key);
1073 QCoreApplication::postEvent(
1096 callback(mediadevice);
1112 QStringList& Actions,
bool AllowJumps)
1119 !
Event->text().isEmpty() &&
1120 Event->modifiers() == Qt::NoModifier)
1146 QStringList localActions;
1150 keycontext && (keycontext->GetMapping(keynum, localActions)))
1169 QCoreApplication::postEvent(
1175 keycontext->GetMapping(keynum, Actions);
1177 if (Context !=
"Global")
1181 keycontextG->GetMapping(keynum, Actions);
1190 if (keycontext ==
nullptr)
1193 QMutableMapIterator<int, QStringList> it(keycontext->m_actionMap);
1194 while (it.hasNext())
1197 QStringList list = it.value();
1207 if (keycontext !=
nullptr)
1208 keycontext->m_actionMap.clear();
1214 if (keycontext ==
nullptr)
1217 if (keycontext ==
nullptr)
1222 QKeySequence keyseq(Key);
1223 for (
unsigned int i = 0; i < static_cast<uint>(keyseq.count()); i++)
1225 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
1226 int keynum = keyseq[i];
1228 int keynum = keyseq[i].toCombined();
1231 QStringList dummyaction(
"");
1232 if (keycontext->GetMapping(keynum, dummyaction))
1234 LOG(VB_GENERAL, LOG_WARNING, QString(
"Key %1 is bound to multiple actions in context %2.")
1235 .arg(Key, Context));
1238 keycontext->AddMapping(keynum,
Action);
1240 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Binding: %1 to action: %2 (%3)")
1241 .arg(Key).arg(
Action).arg(Context));
1244 if (
Action ==
"ESCAPE" && Context ==
"Global" && i == 0)
1250 const QString& Description,
const QString& Key)
1252 QString keybind = Key;
1258 query.
prepare(
"SELECT keylist, description FROM keybindings WHERE "
1259 "context = :CONTEXT AND action = :ACTION AND "
1260 "hostname = :HOSTNAME ;");
1267 keybind = query.
value(0).toString();
1268 QString db_description = query.
value(1).toString();
1271 if (db_description != Description)
1273 LOG(VB_GENERAL, LOG_NOTICE,
1274 "Updating keybinding description...");
1276 "UPDATE keybindings "
1277 "SET description = :DESCRIPTION "
1278 "WHERE context = :CONTEXT AND "
1279 " action = :ACTION AND "
1280 " hostname = :HOSTNAME");
1282 query.
bindValue(
":DESCRIPTION", Description);
1295 const QString& inskey = keybind;
1297 query.
prepare(
"INSERT INTO keybindings (context, action, "
1298 "description, keylist, hostname) VALUES "
1299 "( :CONTEXT, :ACTION, :DESCRIPTION, :KEYLIST, "
1303 query.
bindValue(
":DESCRIPTION", Description);
1324 query.
prepare(
"SELECT keylist "
1326 "WHERE context = :CONTEXT AND "
1327 " action = :ACTION AND "
1328 " hostname = :HOSTNAME");
1336 return query.
value(0).toString();
1340 const QString&
Action)
const
1345 if (entry.contains(
Action))
1346 return entry.value(
Action);
1356 LOG(VB_GENERAL, LOG_ERR,
"Cannot clear ficticious jump point" + Destination);
1361 while (it.hasNext())
1376 LOG(VB_GENERAL, LOG_ERR,
"Cannot bind to ficticious jump point" + Destination);
1380 QKeySequence keyseq(Key);
1382 for (
unsigned int i = 0; i < static_cast<uint>(keyseq.count()); i++)
1384 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
1385 int keynum = keyseq[i];
1387 int keynum = keyseq[i].toCombined();
1393 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Binding: %1 to JumpPoint: %2")
1394 .arg(keybind).arg(destination));
1401 LOG(VB_GENERAL, LOG_WARNING, QString(
"Key %1 is already bound to a jump point.")
1407 LOG(VB_GENERAL, LOG_DEBUG,
1408 QString(
"JumpPoint: %2 exists, no keybinding") .arg(destination));
1413 const QString& Key,
void (*Callback)(
void),
1414 bool Exittomain, QString LocalAction)
1416 QString keybind = Key;
1421 query.
prepare(
"SELECT keylist FROM jumppoints WHERE destination = :DEST and hostname = :HOST ;");
1426 keybind = query.
value(0).toString();
1430 const QString& inskey = keybind;
1432 query.
prepare(
"INSERT INTO jumppoints (destination, description, "
1433 "keylist, hostname) VALUES ( :DEST, :DESC, :KEYLIST, "
1444 JumpData jd = { Callback, Destination, Description, Exittomain, std::move(LocalAction) };
1452 QList<QString>::Iterator it;
1453 for (it = destinations.begin(); it != destinations.end(); ++it)
1464 QCoreApplication::postEvent(
1485 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Registering %1 as a media playback plugin.")
1491 LOG(VB_GENERAL, LOG_NOTICE, QString(
"%1 is already registered as a media playback plugin.")
1497 const QString& Plot,
const QString& Title,
1498 const QString& Subtitle,
1499 const QString& Director,
int Season,
1500 int Episode,
const QString& Inetref,
1501 std::chrono::minutes LenMins,
const QString& Year,
1502 const QString& Id,
bool UseBookmarks)
1504 QString lhandler(Handler);
1505 if (lhandler.isEmpty())
1506 lhandler =
"Internal";
1512 Director, Season, Episode,
1513 Inetref, LenMins, Year, Id,
1540 QCoreApplication::postEvent(
this,
event);
1548 auto * keyevent =
dynamic_cast<QKeyEvent*
>(*Event);
1551 int keycode = keyevent->key();
1556 QEvent *newevent =
nullptr;
1557 switch ((*Event)->type())
1559 case QEvent::KeyPress:
1572 newevent =
new QKeyEvent(QEvent::KeyPress, keycode,
1573 keyevent->modifiers() | Qt::MetaModifier, keyevent->nativeScanCode(),
1574 keyevent->nativeVirtualKey(), keyevent->nativeModifiers(),
1575 keyevent->text(),
false,1);
1577 NewEvent.reset(newevent);
1588 QStringList actions;
1595 LOG(VB_GUI, LOG_ERR, QString(
"TranslateKeyPress Long Press Invalid Response"));
1598 if (!actions.empty() && actions[0].startsWith(
"LONGPRESS"))
1607 case QEvent::KeyRelease:
1611 if (keyevent->isAutoRepeat())
1616 Qt::KeyboardModifiers modifier = Qt::NoModifier;
1620 modifier = Qt::MetaModifier;
1622 newevent =
new QKeyEvent(QEvent::KeyPress, keycode,
1623 keyevent->modifiers() | modifier, keyevent->nativeScanCode(),
1624 keyevent->nativeVirtualKey(), keyevent->nativeModifiers(),
1625 keyevent->text(),
false,1);
1627 NewEvent.reset(newevent);
1650 QScopedPointer<QEvent> newevent(
nullptr);
1654 switch (
Event->type())
1656 case QEvent::KeyPress:
1659 auto *
event =
dynamic_cast<QKeyEvent*
>(
Event);
1664 event =
static_cast<QKeyEvent*
>(
Event);
1671 switch (
event->nativeScanCode())
1674 keycode = Qt::Key_MediaPause;
1682 auto * key =
new QKeyEvent(QEvent::KeyPress, keycode,
event->modifiers());
1683 if (
auto * target =
GetTarget(*key); target)
1684 QCoreApplication::postEvent(target, key);
1686 QCoreApplication::postEvent(
this, key);
1692 QVector<MythScreenStack *>::const_reverse_iterator it;
1695 if (
auto * top = (*it)->GetTopScreen(); top)
1697 if (top->keyPressEvent(
event))
1701 if ((*it)->objectName() ==
"popup stack")
1707 case QEvent::InputMethod:
1710 auto *ie =
dynamic_cast<QInputMethodEvent*
>(
Event);
1712 return MythUIScreenBounds::eventFilter(Watched,
Event);
1713 QWidget *widget = QApplication::focusWidget();
1717 if (widget->isEnabled())
1718 QCoreApplication::instance()->notify(widget, ie);
1721 QVector<MythScreenStack *>::const_reverse_iterator it;
1731 if ((*it)->objectName() ==
"popup stack")
1736 case QEvent::MouseButtonPress:
1743 auto * mouseEvent =
dynamic_cast<QMouseEvent*
>(
Event);
1745 return MythUIScreenBounds::eventFilter(Watched,
Event);
1753 case QEvent::MouseButtonRelease:
1764 QPoint point { -1, -1 };
1765 auto * mouseevent =
dynamic_cast<QMouseEvent*
>(
Event);
1768 point = mouseevent->pos();
1776 return MythUIScreenBounds::eventFilter(Watched,
Event);
1778 QVector<MythScreenStack *>::const_reverse_iterator it;
1781 auto * screen = (*it)->GetTopScreen();
1782 if (!screen || !screen->ContainsPoint(point))
1785 if (screen->gestureEvent(gesture))
1794 if ((*it)->objectName() ==
"popup stack")
1801 bool handled =
false;
1805 QCoreApplication::postEvent(
this, gesture);
1809 QVector<MythScreenStack *>::const_reverse_iterator it;
1828 if ((*it)->objectName() ==
"popup stack")
1835 QCoreApplication::postEvent(
this, gesture);
1842 case QEvent::MouseMove:
1851 auto * mouseevent =
dynamic_cast<QMouseEvent*
>(
Event);
1853 return MythUIScreenBounds::eventFilter(Watched,
Event);
1863 auto * wheel =
dynamic_cast<QWheelEvent*
>(
Event);
1864 if (wheel ==
nullptr)
1865 return MythUIScreenBounds::eventFilter(Watched,
Event);
1866 int delta = wheel->angleDelta().y();
1870 auto *key =
new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);
1871 if (
auto * target =
GetTarget(*key); target)
1872 QCoreApplication::postEvent(target, key);
1874 QCoreApplication::postEvent(
this, key);
1879 auto * key =
new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);
1880 if (
auto * target =
GetTarget(*key); !target)
1881 QCoreApplication::postEvent(target, key);
1883 QCoreApplication::postEvent(
this, key);
1891 return MythUIScreenBounds::eventFilter(Watched,
Event);
1899 if (gesture ==
nullptr)
1902 if (
auto * screen = toplevel->GetTopScreen(); screen)
1903 screen->gestureEvent(gesture);
1904 LOG(VB_GUI, LOG_DEBUG, QString(
"Gesture: %1 (Button: %2)")
1905 .arg(gesture->GetName(), gesture->GetButtonName()));
1914 if (
event ==
nullptr)
1916 auto * key =
new QKeyEvent(QEvent::KeyPress,
event->getKeycode(), Qt::NoModifier);
1917 if (
auto * target =
GetTarget(*key); target)
1918 QCoreApplication::sendEvent(target, key);
1920 QCoreApplication::sendEvent(
this, key);
1943 QVector<MythScreenType*> screenList;
1944 widget->GetScreenList(screenList);
1945 for (
auto * screen : std::as_const(screenList))
1947 screen->mediaEvent(me);
1953 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Media Event: %1 - %2")
1954 .arg(device->getDevicePath()).arg(device->getStatus()));
1986 if (
event ==
nullptr)
1989 QString message =
event->
Message();
1992 if (
event->ExtraDataCount() == 1)
1994 else if (
event->ExtraDataCount() >= 11)
1997 if (
event->ExtraDataCount() >= 12)
2002 event->ExtraData(5).toInt(),
event->ExtraData(6).toInt(),
2003 event->ExtraData(7), std::chrono::minutes(
event->ExtraData(8).toInt()),
2009 LOG(VB_GENERAL, LOG_ERR,
"Failed to handle media");
2017 if (
event->ExtraDataCount() >= 2)
2019 width =
event->ExtraData(0).toInt();
2020 height =
event->ExtraData(1).toInt();
2021 if (
event->ExtraDataCount() == 3)
2029 state.insert(
"state",
"idle");
2030 state.insert(
"menutheme",
GetMythDB()->GetSetting(
"menutheme",
"defaultmenu"));
2031 state.insert(
"currentlocation",
GetMythUI()->GetCurrentLocation());
2034 else if (message ==
"CLEAR_SETTINGS_CACHE")
2048 LOG(VB_GENERAL, LOG_INFO, QString(
"Updating the frontend idle time to: %1 mins").arg(
m_idleTime.count()));
2052 LOG(VB_GENERAL, LOG_INFO,
"Frontend idle timeout is disabled");
2055 else if (message ==
"NOTIFICATION")
2072 if (
const QString& message =
event->Message(); !message.isEmpty())
2083 auto * target = QWidget::keyboardGrabber();
2086 if (
auto * widget = QApplication::focusWidget(); widget && widget->isEnabled())
2092 target = widget->topLevelWidget();
2108 if (
Show &&
GetMythDB()->GetBoolSetting(
"HideMouseCursor",
false))
2112 setCursor(
Show ? (Qt::ArrowCursor) : (Qt::BlankCursor));
2165 LOG(VB_GENERAL, LOG_NOTICE,
"Suspending idle timer");
2170 LOG(VB_GENERAL, LOG_NOTICE,
"Resuming idle timer");
2186 LOG(VB_GENERAL, LOG_NOTICE,
2187 QString(
"Entering standby mode after %1 minutes of inactivity").arg(
m_idleTime.count()));
2210 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Entering standby mode"));
2217 state.insert(
"state",
"standby");
2218 state.insert(
"menutheme",
GetMythDB()->GetSetting(
"menutheme",
"defaultmenu"));
2219 state.insert(
"currentlocation",
GetMythUI()->GetCurrentLocation());
2245 LOG(VB_GENERAL, LOG_NOTICE,
"Leaving standby mode");
2253 state.insert(
"state",
"idle");
2254 state.insert(
"menutheme",
GetMythDB()->GetSetting(
"menutheme",
"defaultmenu"));
2255 state.insert(
"currentlocation",
GetMythUI()->GetCurrentLocation());
2261 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Application State Changed to %1").arg(
State));
2264 case Qt::ApplicationState::ApplicationActive:
2267 case Qt::ApplicationState::ApplicationSuspended: