MythTV  master
mythmainwindow.h
Go to the documentation of this file.
1 #ifndef MYTHMAINWINDOW_H_
2 #define MYTHMAINWINDOW_H_
3 
4 #include <QWidget>
5 
6 #include "mythscreenstack.h"
8 #include "mythuiactions.h"
9 #include "mythrect.h"
10 
11 class QEvent;
12 
13 class MythMediaDevice;
14 
15 #define REG_KEY(a, b, c, d) GetMythMainWindow()->RegisterKey(a, b, c, d)
16 #define GET_KEY(a, b) GetMythMainWindow()->GetKey(a, b)
17 #define REG_JUMP(a, b, c, d) GetMythMainWindow()->RegisterJump(a, b, c, d)
18 #define REG_JUMPLOC(a, b, c, d, e) GetMythMainWindow()->RegisterJump(a, b, c, d, true, e)
19 #define REG_JUMPEX(a, b, c, d, e) GetMythMainWindow()->RegisterJump(a, b, c, d, e)
20 #define REG_MEDIAPLAYER(a,b,c) GetMythMainWindow()->RegisterMediaPlugin(a, b, c)
21 
22 using MediaPlayCallback = int (*)(const QString &, const QString &, const QString &, const QString &, const QString &, int, int, const QString &, int, const QString &, const QString &, bool);
23 
25 
28 class MythPainterWindowVDPAU;
30 class MythRender;
31 
32 class MUI_PUBLIC MythMainWindow : public QWidget
33 {
34  Q_OBJECT
35  friend class MythPainterWindowGL;
36  friend class MythPainterWindowQt;
37  friend class MythPainterWindowVDPAU;
38  friend class MythPainterWindowD3D9;
39 
40  public:
41  enum {drawRefresh = 70};
42 
43  void Init(bool mayReInit = true);
44  void ReinitDone(void);
45  void Show(void);
46  void MoveResize(QRect &Geometry);
47  static bool WindowIsAlwaysFullscreen(void);
48 
49  void AddScreenStack(MythScreenStack *stack, bool main = false);
50  void PopScreenStack();
51  int GetStackCount(void);
52  MythScreenStack *GetMainStack();
53  MythScreenStack *GetStack(const QString &stackname);
54  MythScreenStack *GetStackAt(int pos);
55 
56  bool TranslateKeyPress(const QString &context, QKeyEvent *e,
57  QStringList &actions, bool allowJumps = true);
58  bool keyLongPressFilter(QEvent **e,
59  QScopedPointer<QEvent> &sNewEvent);
60 
61  void ReloadKeys(void);
62  void ClearKey(const QString &context, const QString &action);
63  void ClearKeyContext(const QString &context);
64  void BindKey(const QString &context, const QString &action,
65  const QString &key);
66  void RegisterKey(const QString &context, const QString &action,
67  const QString &description, const QString &key);
68  static QString GetKey(const QString &context, const QString &action);
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 HandleTVPower(bool poweron);
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();
100  MythRender *GetRenderDevice();
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 StartLIRC(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 
152  protected:
153  explicit MythMainWindow(bool useDB = true);
154  ~MythMainWindow() override;
155 
156  void InitKeys(void);
157 
158  bool eventFilter(QObject *o, QEvent *e) override; // QWidget
159  void customEvent(QEvent *ce) override; // QWidget
160  void closeEvent(QCloseEvent *e) override; // QWidget
161 
162  void drawScreen();
163 
164  bool event(QEvent* e) override; // QWidget
165 
166  void ExitToMainMenu();
167 
168  QObject *getTarget(QKeyEvent &key);
169 
170  void LockInputDevices(bool locked);
171 
172  void ShowMouseCursor(bool show);
173 
174  MythMainWindowPrivate *d {nullptr}; // NOLINT(readability-identifier-naming)
175 
176  private slots:
177  void DelayedAction(void);
178 };
179 
183 
185 
187 
188 #endif
unsigned int slots[4]
Definition: element.c:38
MUI_PUBLIC MythPainter * GetMythPainter()
bool
Definition: pxsup2dast.c:30
static void ReloadKeys(void)
static void show(uint8_t *buf, int length)
Definition: ringbuffer.c:318
static const uint16_t * d
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Definition: mythrect.h:17
unsigned int uint
Definition: compat.h:140
static void InitKeys(void)
MUI_PUBLIC MythMainWindow * GetMythMainWindow()
MUI_PUBLIC MythNotificationCenter * GetNotificationCenter()
#define MUI_PUBLIC
Definition: mythuiexp.h:9
MUI_PUBLIC bool HasMythMainWindow()
MUI_PUBLIC void DestroyMythMainWindow()
int(*)(const QString &, const QString &, const QString &, const QString &, const QString &, int, int, const QString &, int, const QString &, const QString &, bool) MediaPlayCallback