MythTV  master
mythmainwindow.h
Go to the documentation of this file.
1 #ifndef MYTHMAINWINDOW_H_
2 #define MYTHMAINWINDOW_H_
3 
4 // Qt
5 #include <QTimer>
6 
7 // MythTV
8 #include "mythscreenstack.h"
10 #include "mythuiactions.h"
11 #include "mythrect.h"
12 #include "mythuiscreenbounds.h"
13 
14 class QEvent;
15 class MythThemeBase;
16 class MythMediaDevice;
17 
18 #define REG_KEY(a, b, c, d) GetMythMainWindow()->RegisterKey(a, b, c, d)
19 #define GET_KEY(a, b) GetMythMainWindow()->GetKey(a, b)
20 #define REG_JUMP(a, b, c, d) GetMythMainWindow()->RegisterJump(a, b, c, d)
21 #define REG_JUMPLOC(a, b, c, d, e) GetMythMainWindow()->RegisterJump(a, b, c, d, true, e)
22 #define REG_JUMPEX(a, b, c, d, e) GetMythMainWindow()->RegisterJump(a, b, c, d, e)
23 #define REG_MEDIAPLAYER(a,b,c) GetMythMainWindow()->RegisterMediaPlugin(a, b, c)
24 
25 using MediaPlayCallback = int (*)(const QString &, const QString &, const QString &, const QString &, const QString &, int, int, const QString &, int, const QString &, const QString &, bool);
26 
28 class MythDisplay;
31 class MythPainterWindow;
32 class MythRender;
33 
35 {
36  Q_OBJECT
37 
40  friend class MythPainterWindowQt;
41 
42  public:
43  enum {drawRefresh = 70};
44 
45  void Init(bool mayReInit = true);
46  void ReinitDone(void);
47  void Show(void);
48  void MoveResize(QRect &Geometry);
49 
50  void AddScreenStack(MythScreenStack *stack, bool main = false);
51  void PopScreenStack();
52  int GetStackCount(void);
53  MythScreenStack *GetMainStack();
54  MythScreenStack *GetStack(const QString &stackname);
55  MythScreenStack *GetStackAt(int pos);
56 
57  bool TranslateKeyPress(const QString &context, QKeyEvent *e,
58  QStringList &actions, bool allowJumps = true);
59  bool keyLongPressFilter(QEvent **e,
60  QScopedPointer<QEvent> &sNewEvent);
61 
62  void ReloadKeys(void);
63  void ClearKey(const QString &context, const QString &action);
64  void ClearKeyContext(const QString &context);
65  void BindKey(const QString &context, const QString &action,
66  const QString &key);
67  void RegisterKey(const QString &context, const QString &action,
68  const QString &description, const QString &key);
69  static QString GetKey(const QString &context, const QString &action);
70  QObject *getTarget(QKeyEvent &key);
71  QString GetActionText(const QString &context, const QString &action) const;
72 
73  void ClearJump(const QString &destination);
74  void BindJump(const QString &destination, const QString &key);
75  void RegisterJump(const QString &destination, const QString &description,
76  const QString &key, void (*callback)(void),
77  bool exittomain = true, QString localAction = "");
78  void ClearAllJumps();
79 
80  void RegisterMediaPlugin(const QString &name, const QString &desc,
82 
83  bool HandleMedia(const QString& handler, const QString& mrl,
84  const QString& plot="", const QString& title="",
85  const QString& subtitle="", const QString& director="",
86  int season=0, int episode=0, const QString& inetref="",
87  int lenMins=120, const QString& year="1895",
88  const QString &id="", bool useBookmarks = false);
89  void HandleTVAction(const QString &Action);
90 
91  void JumpTo(const QString &destination, bool pop = true);
92  bool DestinationExists(const QString &destination) const;
93  QStringList EnumerateDestinations(void) const;
94 
95  bool IsExitingToMain(void) const;
96 
97  static MythMainWindow *getMainWindow(bool useDB = true);
98  static void destroyMainWindow();
99 
100  MythDisplay* GetDisplay();
101  MythPainter *GetPainter();
102  QWidget *GetPaintWindow();
104  MythNotificationCenter *GetCurrentNotificationCenter();
105  void ShowPainterWindow();
106  void HidePainterWindow();
107 
108  static void GrabWindow(QImage &image);
109  static bool SaveScreenShot(const QImage &image, QString filename = "");
110  static bool ScreenShot(int w = 0, int h = 0, QString filename = "");
111  static void RestoreScreensaver();
112  static void DisableScreensaver();
113  static void ResetScreensaver();
114  static bool IsScreensaverAsleep();
115  static bool IsTopScreenInitialized(void);
116  void RemoteScreenShot(QString filename, int x, int y);
117  void AllowInput(bool allow);
118  int GetDrawInterval() const;
119  void RestartInputHandlers(void);
120  uint PushDrawDisabled(void);
121  uint PopDrawDisabled(void);
122  void SetEffectsEnabled(bool enable);
123  void Draw(MythPainter *Painter = nullptr);
124 
125  void ResetIdleTimer();
126  void PauseIdleTimer(bool Pause);
127  void DisableIdleTimer(bool DisableIdle = true);
128  void EnterStandby(bool manual = true);
129  void ExitStandby(bool manual = true);
130 
131  QPaintEngine *paintEngine() const override; // QWidget
132 
133  public slots:
134  void mouseTimeout();
135  void HideMouseTimeout();
136  void IdleTimeout();
137 
138  protected slots:
139  void animate();
140  void doRemoteScreenShot(const QString& filename, int x, int y);
141  void SetDrawEnabled(bool enable);
142  void onApplicationStateChange(Qt::ApplicationState state);
143 
144  signals:
145  void signalRemoteScreenShot(QString filename, int x, int y);
146  void signalSetDrawEnabled(bool enable);
147  void signalWindowReady(void);
151 
152  protected:
153  explicit MythMainWindow(bool useDB = true);
154  ~MythMainWindow() override;
155 
156  static void LoadQtConfig();
157  void InitKeys(void);
158 
159  bool eventFilter(QObject *o, QEvent *e) override; // QWidget
160  void customEvent(QEvent *ce) override; // QWidget
161  void closeEvent(QCloseEvent *e) override; // QWidget
162  void drawScreen(QPaintEvent* Event = nullptr);
163  bool event(QEvent* e) override; // QWidget
164  void ExitToMainMenu();
165  void ShowMouseCursor(bool show);
166 
167  MythMainWindowPrivate *d {nullptr}; // NOLINT(readability-identifier-naming)
168 
169  private slots:
170  void DelayedAction(void);
171 
172  private:
173  MythDisplay* m_display { nullptr };
175 
176  MythThemeBase* m_themeBase { nullptr };
177  MythPainter* m_painter { nullptr };
178  MythPainter* m_oldPainter { nullptr };
179  MythPainterWindow* m_painterWin { nullptr };
180  MythPainterWindow* m_oldPainterWin { nullptr };
181  MythInputDeviceHandler* m_deviceHandler { nullptr };
182  MythScreenSaverControl *m_screensaver { nullptr };
183  QTimer m_idleTimer;
184  int m_idleTime { 0 };
185 };
186 
190 
192 
194 
195 #endif
mythrect.h
e
QDomElement e
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1420
bool
bool
Definition: pxsup2dast.c:30
bbciplayer.main
main
Definition: bbciplayer.py:263
MythMainWindow::m_idleTimer
QTimer m_idleTimer
Definition: mythmainwindow.h:183
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:25
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
GetMythPainter
MUI_PUBLIC MythPainter * GetMythPainter()
Definition: mythmainwindow.cpp:120
MythUIScreenBounds
Definition: mythuiscreenbounds.h:13
MythMainWindow::signalSetDrawEnabled
void signalSetDrawEnabled(bool enable)
ReloadKeys
static void ReloadKeys(void)
Definition: mythtv/programs/mythfrontend/main.cpp:1636
title
QString title
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:636
mythscreenstack.h
MythScreenStack
Definition: mythscreenstack.h:16
MythPainterWindow
Definition: mythpainterwindow.h:15
MythPainterWindowOpenGL
Definition: mythpainterwindowopengl.h:13
GetMythMainWindow
MUI_PUBLIC MythMainWindow * GetMythMainWindow()
Definition: mythmainwindow.cpp:105
GetNotificationCenter
MUI_PUBLIC MythNotificationCenter * GetNotificationCenter()
Definition: mythmainwindow.cpp:125
show
static void show(uint8_t *buf, int length)
Definition: ringbuffer.cpp:339
MythPainterWindowQt
Definition: mythpainterwindowqt.h:8
MythMainWindow::signalRestoreScreensaver
void signalRestoreScreensaver()
Action
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:41
mythuiscreenbounds.h
MythThemeBase
Definition: myththemebase.h:12
MythMainWindowPrivate
Definition: mythmainwindowprivate.h:50
MythInputDeviceHandler
A wrapper around sundry external input devices.
Definition: mythinputdevicehandler.h:19
Event
Event details.
Definition: zmdefines.h:27
MythScreenSaverControl
Controls all instances of the screensaver.
Definition: mythscreensaver.h:33
filename
QString filename
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:637
MythMainWindow::signalWindowReady
void signalWindowReady(void)
uint
unsigned int uint
Definition: compat.h:140
MythPainterWindow::GetRenderDevice
MythRender * GetRenderDevice()
Definition: mythpainterwindow.cpp:137
MythDisplay
Definition: mythdisplay.h:19
MythMainWindow::signalRemoteScreenShot
void signalRemoteScreenShot(QString filename, int x, int y)
MythMainWindow::signalDisableScreensaver
void signalDisableScreensaver()
InitKeys
static void InitKeys(void)
Definition: mythtv/programs/mythfrontend/main.cpp:1584
MythMainWindow::signalResetScreensaver
void signalResetScreensaver()
MythPainterWindowVulkan
Definition: mythpainterwindowvulkan.h:13
DestroyMythMainWindow
MUI_PUBLIC void DestroyMythMainWindow()
Definition: mythmainwindow.cpp:115
MythRender
Definition: mythrender_base.h:24
MythPainter
Definition: mythpainter.h:33
HasMythMainWindow
MUI_PUBLIC bool HasMythMainWindow()
Definition: mythmainwindow.cpp:110
MythMainWindow::m_repaintRegion
QRegion m_repaintRegion
Definition: mythmainwindow.h:174
build_compdb.action
action
Definition: build_compdb.py:9
mythuiactions.h
MythMediaDevice
Definition: mythmedia.h:49
d
static const iso6937table * d
Definition: iso6937tables.cpp:1025
MythNotificationCenter
Definition: mythnotificationcenter.h:34
mythnotificationcenter.h
MythMainWindow
Definition: mythmainwindow.h:35