MythTV  master
mythmainwindow.h
Go to the documentation of this file.
1 #ifndef MYTHMAINWINDOW_H_
2 #define MYTHMAINWINDOW_H_
3 
4 // Qt
5 #include <QWidget>
6 
7 // MythTV
8 #include "mythscreenstack.h"
10 #include "mythuiactions.h"
11 #include "mythrect.h"
12 
13 class QEvent;
14 
15 class MythMediaDevice;
16 
17 #define REG_KEY(a, b, c, d) GetMythMainWindow()->RegisterKey(a, b, c, d)
18 #define GET_KEY(a, b) GetMythMainWindow()->GetKey(a, b)
19 #define REG_JUMP(a, b, c, d) GetMythMainWindow()->RegisterJump(a, b, c, d)
20 #define REG_JUMPLOC(a, b, c, d, e) GetMythMainWindow()->RegisterJump(a, b, c, d, true, e)
21 #define REG_JUMPEX(a, b, c, d, e) GetMythMainWindow()->RegisterJump(a, b, c, d, e)
22 #define REG_MEDIAPLAYER(a,b,c) GetMythMainWindow()->RegisterMediaPlugin(a, b, c)
23 
24 using MediaPlayCallback = int (*)(const QString &, const QString &, const QString &, const QString &, const QString &, int, int, const QString &, int, const QString &, const QString &, bool);
25 
26 class MythDisplay;
29 class MythPainterWindow;
30 class MythRender;
31 
32 class MUI_PUBLIC MythMainWindow : public QWidget
33 {
34  Q_OBJECT
37  friend class MythPainterWindowQt;
38 
39  public:
40  enum {drawRefresh = 70};
41 
42  void Init(bool mayReInit = true);
43  void ReinitDone(void);
44  void Show(void);
45  void MoveResize(QRect &Geometry);
46  static bool WindowIsAlwaysFullscreen(void);
47 
48  void AddScreenStack(MythScreenStack *stack, bool main = false);
49  void PopScreenStack();
50  int GetStackCount(void);
51  MythScreenStack *GetMainStack();
52  MythScreenStack *GetStack(const QString &stackname);
53  MythScreenStack *GetStackAt(int pos);
54 
55  bool TranslateKeyPress(const QString &context, QKeyEvent *e,
56  QStringList &actions, bool allowJumps = true);
57  bool keyLongPressFilter(QEvent **e,
58  QScopedPointer<QEvent> &sNewEvent);
59 
60  void ReloadKeys(void);
61  void ClearKey(const QString &context, const QString &action);
62  void ClearKeyContext(const QString &context);
63  void BindKey(const QString &context, const QString &action,
64  const QString &key);
65  void RegisterKey(const QString &context, const QString &action,
66  const QString &description, const QString &key);
67  static QString GetKey(const QString &context, const QString &action);
68  QObject *getTarget(QKeyEvent &key);
69  QString GetActionText(const QString &context, const QString &action) const;
70 
71  void ClearJump(const QString &destination);
72  void BindJump(const QString &destination, const QString &key);
73  void RegisterJump(const QString &destination, const QString &description,
74  const QString &key, void (*callback)(void),
75  bool exittomain = true, QString localAction = "");
76  void ClearAllJumps();
77 
78  void RegisterMediaPlugin(const QString &name, const QString &desc,
80 
81  bool HandleMedia(const QString& handler, const QString& mrl,
82  const QString& plot="", const QString& title="",
83  const QString& subtitle="", const QString& director="",
84  int season=0, int episode=0, const QString& inetref="",
85  int lenMins=120, const QString& year="1895",
86  const QString &id="", bool useBookmarks = false);
87  void HandleTVAction(const QString &Action);
88 
89  void JumpTo(const QString &destination, bool pop = true);
90  bool DestinationExists(const QString &destination) const;
91  QStringList EnumerateDestinations(void) const;
92 
93  bool IsExitingToMain(void) const;
94 
95  static MythMainWindow *getMainWindow(bool useDB = true);
96  static void destroyMainWindow();
97 
98  MythPainter *GetCurrentPainter();
99  QWidget *GetPaintWindow();
101  MythNotificationCenter *GetCurrentNotificationCenter();
102  void ShowPainterWindow();
103  void HidePainterWindow();
104 
105  static void GrabWindow(QImage &image);
106  static bool SaveScreenShot(const QImage &image, QString filename = "");
107  static bool ScreenShot(int w = 0, int h = 0, QString filename = "");
108  void RemoteScreenShot(QString filename, int x, int y);
109 
110  void AllowInput(bool allow);
111 
112  QRect GetUIScreenRect();
113  void SetUIScreenRect(QRect &rect);
114 
115  int GetDrawInterval() const;
116  int NormalizeFontSize(int pointSize);
117  MythRect NormRect(const MythRect &rect);
118  QPoint NormPoint(const QPoint &point);
119  QSize NormSize(const QSize &size);
120  int NormX(int x);
121  int NormY(int y);
122  void SetScalingFactors(float wmult, float hmult);
123  void RestartInputHandlers(void);
124  uint PushDrawDisabled(void);
125  uint PopDrawDisabled(void);
126  void SetEffectsEnabled(bool enable);
127  void Draw(MythPainter *Painter = nullptr);
128 
129  void ResetIdleTimer(void);
130  void PauseIdleTimer(bool pause);
131  void DisableIdleTimer(bool disableIdle = true);
132  void EnterStandby(bool manual = true);
133  void ExitStandby(bool manual = true);
134 
135  QPaintEngine *paintEngine() const override; // QWidget
136 
137  public slots:
138  void mouseTimeout();
139  void HideMouseTimeout();
140  void IdleTimeout();
141 
142  protected slots:
143  void animate();
144  void doRemoteScreenShot(const QString& filename, int x, int y);
145  void SetDrawEnabled(bool enable);
146  void onApplicationStateChange(Qt::ApplicationState state);
147 
148  signals:
149  void signalRemoteScreenShot(QString filename, int x, int y);
150  void signalSetDrawEnabled(bool enable);
151  void signalWindowReady(void);
152 
153  protected:
154  explicit MythMainWindow(bool useDB = true);
155  ~MythMainWindow() override;
156 
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  MythPainter* m_painter { nullptr };
176  MythPainter* m_oldPainter { nullptr };
177  MythPainterWindow* m_painterWin { nullptr };
178  MythPainterWindow* m_oldPainterWin { nullptr };
179  MythInputDeviceHandler* m_deviceHandler { nullptr };
180 };
181 
185 
187 
189 
190 #endif
mythrect.h
e
QDomElement e
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1417
bool
bool
Definition: pxsup2dast.c:30
bbciplayer.main
main
Definition: bbciplayer.py:263
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
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
GetMythPainter
MUI_PUBLIC MythPainter * GetMythPainter()
Definition: mythmainwindow.cpp:122
MythMainWindow::signalSetDrawEnabled
void signalSetDrawEnabled(bool enable)
ReloadKeys
static void ReloadKeys(void)
Definition: mythtv/programs/mythfrontend/main.cpp:1645
title
QString title
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:633
mythscreenstack.h
d
static const uint16_t * d
Definition: iso6937tables.cpp:1025
MythScreenStack
Definition: mythscreenstack.h:16
MythPainterWindow
Definition: mythpainterwindow.h:14
MythPainterWindowOpenGL
Definition: mythpainterwindowopengl.h:11
GetMythMainWindow
MUI_PUBLIC MythMainWindow * GetMythMainWindow()
Definition: mythmainwindow.cpp:107
slots
unsigned int slots[4]
Definition: element.cpp:38
GetNotificationCenter
MUI_PUBLIC MythNotificationCenter * GetNotificationCenter()
Definition: mythmainwindow.cpp:127
show
static void show(uint8_t *buf, int length)
Definition: ringbuffer.cpp:319
MythPainterWindowQt
Definition: mythpainterwindowqt.h:8
MythRect
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Definition: mythrect.h:18
Action
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:41
MythMainWindowPrivate
Definition: mythmainwindowprivate.h:51
MythInputDeviceHandler
A wrapper around sundry external input devices.
Definition: mythinputdevicehandler.h:19
Event
Event details.
Definition: zmdefines.h:27
filename
QString filename
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:634
MythMainWindow::signalWindowReady
void signalWindowReady(void)
uint
unsigned int uint
Definition: compat.h:140
MythPainterWindow::GetRenderDevice
MythRender * GetRenderDevice(void)
Definition: mythpainterwindow.cpp:72
MythDisplay
Definition: mythdisplay.h:19
MythMainWindow::signalRemoteScreenShot
void signalRemoteScreenShot(QString filename, int x, int y)
InitKeys
static void InitKeys(void)
Definition: mythtv/programs/mythfrontend/main.cpp:1593
MythPainterWindowVulkan
Definition: mythpainterwindowvulkan.h:11
DestroyMythMainWindow
MUI_PUBLIC void DestroyMythMainWindow()
Definition: mythmainwindow.cpp:117
MythRender
Definition: mythrender_base.h:23
MythPainter
Definition: mythpainter.h:33
HasMythMainWindow
MUI_PUBLIC bool HasMythMainWindow()
Definition: mythmainwindow.cpp:112
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
MythNotificationCenter
Definition: mythnotificationcenter.h:34
mythnotificationcenter.h
MythMainWindow
Definition: mythmainwindow.h:33