| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // MythTV | ||
| #include "mythmainwindowprivate.h" | ||
|
|
||
| // Make keynum in QKeyEvent be equivalent to what's in QKeySequence | ||
| int MythMainWindowPrivate::TranslateKeyNum(QKeyEvent* Event) | ||
| { | ||
| int keynum = Event->key(); | ||
|
|
||
| if ((keynum != Qt::Key_Shift ) && (keynum !=Qt::Key_Control ) && | ||
| (keynum != Qt::Key_Meta ) && (keynum !=Qt::Key_Alt ) && | ||
| (keynum != Qt::Key_Super_L) && (keynum !=Qt::Key_Super_R ) && | ||
| (keynum != Qt::Key_Hyper_L) && (keynum !=Qt::Key_Hyper_R ) && | ||
| (keynum != Qt::Key_AltGr ) && (keynum !=Qt::Key_CapsLock ) && | ||
| (keynum != Qt::Key_NumLock) && (keynum !=Qt::Key_ScrollLock )) | ||
| { | ||
| Qt::KeyboardModifiers modifiers; | ||
| // if modifiers have been pressed, rebuild keynum | ||
| if ((modifiers = Event->modifiers()) != Qt::NoModifier) | ||
| { | ||
| int modnum = Qt::NoModifier; | ||
| if (((modifiers & Qt::ShiftModifier) != 0U) && | ||
| (keynum > 0x7f) && | ||
| (keynum != Qt::Key_Backtab)) | ||
| modnum |= Qt::SHIFT; | ||
| if ((modifiers & Qt::ControlModifier) != 0U) | ||
| modnum |= Qt::CTRL; | ||
| if ((modifiers & Qt::MetaModifier) != 0U) | ||
| modnum |= Qt::META; | ||
| if ((modifiers & Qt::AltModifier) != 0U) | ||
| modnum |= Qt::ALT; | ||
| modnum &= ~Qt::UNICODE_ACCEL; | ||
| return (keynum | modnum); | ||
| } | ||
| } | ||
|
|
||
| return keynum; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| #ifndef MYTHMAINWINDOWPRIVATE_H | ||
| #define MYTHMAINWINDOWPRIVATE_H | ||
|
|
||
| // Qt | ||
| #include <QRect> | ||
| #include <QKeyEvent> | ||
|
|
||
| // MythTV | ||
| #include "mythconfig.h" | ||
| #include "mythdisplay.h" | ||
| #include "mythmainwindow.h" | ||
| #include "mythgesture.h" | ||
|
|
||
| #ifdef USING_LIBCEC | ||
| #include "devices/mythcecadapter.h" | ||
| #endif | ||
| #ifdef USING_APPLEREMOTE | ||
| #include "AppleRemoteListener.h" | ||
| #endif | ||
|
|
||
| class MythPainter; | ||
| class MythPainterWindow; | ||
| class MythScreenStack; | ||
| class MythSignalingTimer; | ||
| class MythThemeBase; | ||
| class MythUDPListener; | ||
| class JoystickMenuThread; | ||
| class LIRC; | ||
| class MythMediaDevice; | ||
|
|
||
| class KeyContext | ||
| { | ||
| public: | ||
| void AddMapping(int key, const QString& action) | ||
| { | ||
| m_actionMap[key].append(action); | ||
| } | ||
|
|
||
| bool GetMapping(int key, QStringList &actions) | ||
| { | ||
| if (m_actionMap.count(key) > 0) | ||
| { | ||
| actions += m_actionMap[key]; | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| QMap<int, QStringList> m_actionMap; | ||
| }; | ||
|
|
||
| // Adding member initializers caused compilation to fail with an error | ||
| // that it cannot convert a brace-enclosed initializer list to JumpData. | ||
| // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) | ||
| struct JumpData | ||
| { | ||
| void (*m_callback)(void); | ||
| QString m_destination; | ||
| QString m_description; | ||
| bool m_exittomain; | ||
| QString m_localAction; | ||
| }; | ||
|
|
||
| // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) | ||
| struct MPData { | ||
| QString m_description; | ||
| MediaPlayCallback m_playFn; | ||
| }; | ||
|
|
||
| class MythMainWindowPrivate | ||
| { | ||
| friend class MythMainWindow; | ||
| friend class MythPainterWindowOpenGL; | ||
| friend class MythPainterWindowQt; | ||
|
|
||
| protected: | ||
| MythMainWindowPrivate() = default; | ||
|
|
||
| static int TranslateKeyNum(QKeyEvent *Event); | ||
|
|
||
| float m_wmult { 1.0F }; | ||
| float m_hmult { 1.0F }; | ||
| QRect m_screenRect; | ||
| QRect m_uiScreenRect; | ||
| bool m_doesFillScreen { false }; | ||
| bool m_ignoreLircKeys { false }; | ||
| bool m_ignoreJoystickKeys { false }; | ||
| LIRC *m_lircThread { nullptr }; | ||
| #ifdef USE_JOYSTICK_MENU | ||
| JoystickMenuThread *m_joystickThread { nullptr }; | ||
| #endif | ||
| #ifdef USING_APPLEREMOTE | ||
| AppleRemoteListener *m_appleRemoteListener { nullptr }; | ||
| AppleRemote *m_appleRemote { nullptr }; | ||
| #endif | ||
|
|
||
| #ifdef USING_LIBCEC | ||
| MythCECAdapter m_cecAdapter { }; | ||
| #endif | ||
|
|
||
| bool m_exitingtomain { false }; | ||
| bool m_popwindows { false }; | ||
| /// To allow or prevent database access | ||
| bool m_useDB { true }; | ||
|
|
||
| QHash<QString, KeyContext *> m_keyContexts; | ||
| QMap<int, JumpData*> m_jumpMap; | ||
| QMap<QString, JumpData> m_destinationMap; | ||
| QMap<QString, MPData> m_mediaPluginMap; | ||
| QHash<QString, QHash<QString, QString> > m_actionText; | ||
|
|
||
| void (*m_exitMenuCallback)(void) { nullptr }; | ||
| void (*m_exitMenuMediaDeviceCallback)(MythMediaDevice* mediadevice) { nullptr }; | ||
| MythMediaDevice * m_mediaDeviceForCallback { nullptr }; | ||
|
|
||
| int m_escapekey { 0 }; | ||
| QObject *m_sysEventHandler { nullptr }; | ||
| int m_drawInterval { 1000 / MythMainWindow::drawRefresh }; | ||
| MythSignalingTimer *m_drawTimer { nullptr }; | ||
| QVector<MythScreenStack *> m_stackList; | ||
| MythScreenStack *m_mainStack { nullptr }; | ||
| MythDisplay *m_display { MythDisplay::AcquireRelease() }; | ||
| MythPainter *m_painter { nullptr }; | ||
| QRegion m_repaintRegion; | ||
| MythGesture m_gesture; | ||
| QTimer *m_gestureTimer { nullptr }; | ||
| QTimer *m_hideMouseTimer { nullptr }; | ||
| MythPainterWindow *m_paintwin { nullptr }; | ||
| QWidget *m_oldpaintwin { nullptr }; | ||
| MythPainter *m_oldpainter { nullptr }; | ||
| QMutex m_drawDisableLock; | ||
| uint m_drawDisabledDepth { 0 }; | ||
| bool m_drawEnabled { true }; | ||
| MythThemeBase *m_themeBase { nullptr }; | ||
| MythUDPListener *m_udpListener { nullptr }; | ||
| MythNotificationCenter *m_nc { nullptr }; | ||
| QTimer *m_idleTimer { nullptr }; | ||
| int m_idleTime { 0 }; | ||
| bool m_standby { false }; | ||
| bool m_enteringStandby { false }; | ||
| bool m_disableIdle { false }; | ||
| bool m_allowInput { true }; | ||
| bool m_pendingUpdate { false }; | ||
| // window aspect | ||
| bool m_firstinit { true }; | ||
| bool m_bSavedPOS { false }; | ||
| // Support for long press | ||
| int m_longPressKeyCode { 0 }; | ||
| ulong m_longPressTime { 0 }; | ||
| }; | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // MythTV | ||
| #include "mythmainwindow.h" | ||
| #include "mythpainterwindow.h" | ||
|
|
||
| MythPainterWindow::MythPainterWindow(MythMainWindow *MainWin) | ||
| : QWidget(MainWin) | ||
| { | ||
| } | ||
|
|
||
| MythRender* MythPainterWindow::GetRenderDevice(void) | ||
| { | ||
| return m_render; | ||
| } | ||
|
|
||
| bool MythPainterWindow::RenderIsShared(void) | ||
| { | ||
| return m_render && m_render->IsShared(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #ifndef MYTHPAINTERWINDOW_H | ||
| #define MYTHPAINTERWINDOW_H | ||
|
|
||
| // Qt | ||
| #include <QWidget> | ||
|
|
||
| // MythTV | ||
| #include "mythrender_base.h" | ||
|
|
||
| class MythMainWindow; | ||
|
|
||
| class MythPainterWindow : public QWidget | ||
| { | ||
| public: | ||
| MythPainterWindow(MythMainWindow *MainWin); | ||
| MythRender* GetRenderDevice(void); | ||
| bool RenderIsShared (void); | ||
|
|
||
| protected: | ||
| MythRender* m_render { nullptr }; | ||
| }; | ||
|
|
||
| #endif // MYTHPAINTERWINDOW_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // MythTV | ||
| #include "mythmainwindowprivate.h" | ||
| #include "mythpainterwindowqt.h" | ||
|
|
||
| MythPainterWindowQt::MythPainterWindowQt(MythMainWindow *MainWin, | ||
| MythMainWindowPrivate *MainWinPriv) | ||
| : MythPainterWindow(MainWin), | ||
| m_parent(MainWin), | ||
| d(MainWinPriv) | ||
| { | ||
| setAttribute(Qt::WA_NoSystemBackground); | ||
| } | ||
|
|
||
| void MythPainterWindowQt::paintEvent(QPaintEvent *Event) | ||
| { | ||
| d->m_repaintRegion = d->m_repaintRegion.united(Event->region()); | ||
| m_parent->drawScreen(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #ifndef MYTHPAINTERWINDOWQT_H | ||
| #define MYTHPAINTERWINDOWQT_H | ||
|
|
||
| // MythTV | ||
| #include "mythpainterwindow.h" | ||
|
|
||
| class MythMainWindowPrivate; | ||
|
|
||
| class MythPainterWindowQt : public MythPainterWindow | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| MythPainterWindowQt(MythMainWindow *MainWin, MythMainWindowPrivate *MainWinPriv); | ||
|
|
||
| void paintEvent(QPaintEvent *Event) override; | ||
|
|
||
| MythMainWindow *m_parent; | ||
| MythMainWindowPrivate *d; | ||
| }; | ||
| #endif // MYTHPAINTERWINDOWQT_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,6 @@ | |
| #include <QPainter> | ||
|
|
||
| // MythTV | ||
| #include "mythrenderopengl.h" | ||
| #include "mythpainteropengl.h" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // MythTV | ||
| #include "mythmainwindow.h" | ||
| #include "mythmainwindowprivate.h" | ||
| #include "opengl/mythpainterwindowopengl.h" | ||
|
|
||
| #define LOC QString("GLPaintWin: ") | ||
|
|
||
| MythPainterWindowOpenGL::MythPainterWindowOpenGL(MythMainWindow *MainWin, | ||
| MythMainWindowPrivate *MainWinPriv) | ||
| : MythPainterWindow(MainWin), | ||
| m_parent(MainWin), | ||
| d(MainWinPriv) | ||
| { | ||
| setAttribute(Qt::WA_NoSystemBackground); | ||
| setAttribute(Qt::WA_NativeWindow); | ||
| setAttribute(Qt::WA_DontCreateNativeAncestors); | ||
| winId(); | ||
| #ifdef Q_OS_MACOS | ||
| // must be visible before OpenGL initialisation on OSX | ||
| setVisible(true); | ||
| #endif | ||
| MythRenderOpenGL *render = MythRenderOpenGL::Create(this); | ||
| if (render) | ||
| { | ||
| m_render = render; | ||
| if (render->Init() && render->IsRecommendedRenderer()) | ||
| m_valid = true; | ||
| } | ||
| else | ||
| { | ||
| LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create MythRenderOpenGL"); | ||
| } | ||
| } | ||
|
|
||
| QPaintEngine *MythPainterWindowOpenGL::paintEngine(void) const | ||
| { | ||
| return testAttribute(Qt::WA_PaintOnScreen) ? nullptr : m_parent->paintEngine(); | ||
| } | ||
|
|
||
| MythPainterWindowOpenGL::~MythPainterWindowOpenGL() | ||
| { | ||
| if (m_render) | ||
| m_render->DecrRef(); | ||
| } | ||
|
|
||
| bool MythPainterWindowOpenGL::IsValid(void) const | ||
| { | ||
| return m_valid; | ||
| } | ||
|
|
||
| void MythPainterWindowOpenGL::paintEvent(QPaintEvent *pe) | ||
| { | ||
| d->m_repaintRegion = d->m_repaintRegion.united(pe->region()); | ||
| m_parent->drawScreen(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #ifndef MYTHPAINTERWINDOWOPENGL_H | ||
| #define MYTHPAINTERWINDOWOPENGL_H | ||
|
|
||
| // MythTV | ||
| #include "mythpainterwindow.h" | ||
| #include "mythrenderopengl.h" | ||
|
|
||
| class MythMainWindow; | ||
| class MythMainWindowPrivate; | ||
|
|
||
| class MythPainterWindowOpenGL : public MythPainterWindow | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| MythPainterWindowOpenGL(MythMainWindow *MainWin, MythMainWindowPrivate *MainWinPriv); | ||
| ~MythPainterWindowOpenGL() override; | ||
|
|
||
| bool IsValid (void) const; | ||
| QPaintEngine* paintEngine(void) const override; | ||
| void paintEvent (QPaintEvent *e) override; | ||
|
|
||
| MythMainWindow *m_parent { nullptr }; | ||
| MythMainWindowPrivate *d { nullptr }; | ||
| bool m_valid { false }; | ||
| }; | ||
|
|
||
| #endif |