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 typedef int (*MediaPlayCallback)(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(const QString& forcedpainter = QString(), bool mayReInit=true);
44  void ReinitDone(void);
45  void Show(void);
46 
47  void AddScreenStack(MythScreenStack *stack, bool main = false);
48  void PopScreenStack();
49  int GetStackCount(void);
50  MythScreenStack *GetMainStack();
51  MythScreenStack *GetStack(const QString &stackname);
52  MythScreenStack *GetStackAt(int pos);
53 
54  bool TranslateKeyPress(const QString &context, QKeyEvent *e,
55  QStringList &actions, bool allowJumps = true);
56  bool keyLongPressFilter(QEvent **e,
57  QScopedPointer<QEvent> &sNewEvent);
58 
59  void ReloadKeys(void);
60  void ClearKey(const QString &context, const QString &action);
61  void ClearKeyContext(const QString &context);
62  void BindKey(const QString &context, const QString &action,
63  const QString &key);
64  void RegisterKey(const QString &context, const QString &action,
65  const QString &description, const QString &key);
66  static QString GetKey(const QString &context, const QString &action);
67  QString GetActionText(const QString &context, const QString &action) const;
68 
69  void ClearJump(const QString &destination);
70  void BindJump(const QString &destination, const QString &key);
71  void RegisterJump(const QString &destination, const QString &description,
72  const QString &key, void (*callback)(void),
73  bool exittomain = true, QString localAction = "");
74  void ClearAllJumps();
75 
76  void RegisterMediaPlugin(const QString &name, const QString &desc,
78 
79  bool HandleMedia(const QString& handler, const QString& mrl,
80  const QString& plot="", const QString& title="",
81  const QString& subtitle="", const QString& director="",
82  int season=0, int episode=0, const QString& inetref="",
83  int lenMins=120, const QString& year="1895",
84  const QString &id="", bool useBookmarks = false);
85  void HandleTVPower(bool poweron);
86 
87  void JumpTo(const QString &destination, bool pop = true);
88  bool DestinationExists(const QString &destination) const;
89  QStringList EnumerateDestinations(void) const;
90 
91  bool IsExitingToMain(void) const;
92 
93  static MythMainWindow *getMainWindow(const bool useDB = true);
94  static void destroyMainWindow();
95 
96  MythPainter *GetCurrentPainter();
97  QWidget *GetPaintWindow();
98  MythRender *GetRenderDevice();
99  MythNotificationCenter *GetCurrentNotificationCenter();
100  void ShowPainterWindow();
101  void HidePainterWindow();
102  void ResizePainterWindow(const QSize &size);
103 
104  static void GrabWindow(QImage &image);
105  static bool SaveScreenShot(const QImage &image, QString filename = "");
106  static bool ScreenShot(int w = 0, int h = 0, QString filename = "");
107  void RemoteScreenShot(QString filename, int x, int y);
108 
109  void AllowInput(bool allow);
110 
111  QRect GetUIScreenRect();
112  void SetUIScreenRect(QRect &rect);
113 
114  int GetDrawInterval() const;
115  int NormalizeFontSize(int pointSize);
116  MythRect NormRect(const MythRect &rect);
117  QPoint NormPoint(const QPoint &point);
118  QSize NormSize(const QSize &size);
119  int NormX(const int x);
120  int NormY(const int y);
121  void SetScalingFactors(float wmult, float hmult);
122 
123  void StartLIRC(void);
124 
125  /* compatibility functions, to go away once everything's mythui */
126  void attach(QWidget *child);
127  void detach(QWidget *child);
128 
129  QWidget *currentWidget(void);
130 
131  uint PushDrawDisabled(void);
132  uint PopDrawDisabled(void);
133  void SetEffectsEnabled(bool enable);
134  void draw(MythPainter *painter = nullptr);
135 
136  void ResetIdleTimer(void);
137  void PauseIdleTimer(bool pause);
138  void DisableIdleTimer(bool disableIdle = true);
139  void EnterStandby(bool manual = true);
140  void ExitStandby(bool manual = true);
141 
142  QPaintEngine *paintEngine() const override; // QWidget
143 
144  public slots:
145  void mouseTimeout();
146  void HideMouseTimeout();
147  void IdleTimeout();
148 
149  protected slots:
150  void animate();
151  void doRemoteScreenShot(const QString& filename, int x, int y);
152  void SetDrawEnabled(bool enable);
153  void onApplicationStateChange(Qt::ApplicationState state);
154 
155  signals:
156  void signalRemoteScreenShot(QString filename, int x, int y);
157  void signalSetDrawEnabled(bool enable);
158 
159  protected:
160  explicit MythMainWindow(const bool useDB = true);
161  virtual ~MythMainWindow();
162 
163  void InitKeys(void);
164 
165  bool eventFilter(QObject *o, QEvent *e) override; // QWidget
166  void customEvent(QEvent *ce) override; // QWidget
167  void closeEvent(QCloseEvent *e) override; // QWidget
168 
169  void drawScreen();
170 
171  bool event(QEvent* e) override; // QWidget
172 
173  void ExitToMainMenu();
174 
175  QObject *getTarget(QKeyEvent &key);
176 
177  void LockInputDevices(bool locked);
178 
179  void ShowMouseCursor(bool show);
180 
182 
183  private slots:
184  void DelayedAction(void);
185 };
186 
190 
192 
194 
195 #endif
unsigned int slots[4]
Definition: element.c:38
int(* MediaPlayCallback)(const QString &, const QString &, const QString &, const QString &, const QString &, int, int, const QString &, int, const QString &, const QString &, bool)
MUI_PUBLIC MythPainter * GetMythPainter()
bool
Definition: pxsup2dast.c:30
unsigned int uint
Definition: compat.h:140
static void ReloadKeys(void)
static void show(uint8_t *buf, int length)
Definition: ringbuffer.c:316
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
const char * name
Definition: ParseText.cpp:328
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()