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
10 #include "libmythui/mythrect.h"
14 
15 class QEvent;
16 class MythThemeBase;
17 class MythMediaDevice;
18 
19 using MediaPlayCallback = int (*)(const QString& , const QString& , const QString& , const QString& , const QString& , int, int, const QString& , std::chrono::minutes, const QString& , const QString& , bool);
20 
22 class MythDisplay;
25 class MythPainterWindow;
26 class MythRender;
27 
29 {
30  Q_OBJECT
31 
34  friend class MythPainterWindowQt;
35 
36  public:
37  void Init(bool MayReInit = true);
38  void Show();
39  void MoveResize(QRect& Geometry);
40 
41  void AddScreenStack(MythScreenStack* Stack, bool Main = false);
42  void PopScreenStack();
43  int GetStackCount();
44  MythScreenStack* GetMainStack();
45  MythScreenStack* GetStack(const QString& Stackname);
46  MythScreenStack* GetStackAt(int Position);
47 
48  bool TranslateKeyPress(const QString& Context, QKeyEvent* Event,
49  QStringList& Actions, bool AllowJumps = true);
50  bool KeyLongPressFilter(QEvent** Event, QScopedPointer<QEvent>& NewEvent);
51 
52  void ReloadKeys();
53  void ClearKey(const QString& Context, const QString& Action);
54  void ClearKeyContext(const QString& Context);
55  void BindKey(const QString& Context, const QString& Action, const QString& Key);
56  void RegisterKey(const QString& Context, const QString& Action,
57  const QString& Description, const QString& Key);
58  static QString GetKey(const QString& Context, const QString& Action);
59  QObject* GetTarget(QKeyEvent& Key);
60  QString GetActionText(const QString& Context, const QString& Action) const;
61 
62  void ClearJump(const QString& Destination);
63  void BindJump(const QString& Destination, const QString& Key);
64  void RegisterJump(const QString& Destination, const QString& Description,
65  const QString& Key, void (*Callback)(void),
66  bool Exittomain = true, QString LocalAction = "");
67  void ClearAllJumps();
68  void RegisterMediaPlugin(const QString& Name, const QString& Desc,
69  MediaPlayCallback Func);
70  bool HandleMedia(const QString& Handler, const QString& Mrl,
71  const QString& Plot="", const QString& Title="",
72  const QString& Subtitle="", const QString& Director="",
73  int Season=0, int Episode=0, const QString& Inetref="",
74  std::chrono::minutes LenMins=2h, const QString& Year="1895",
75  const QString& Id="", bool UseBookmarks = false);
76  void HandleTVAction(const QString& Action);
77 
78  void JumpTo(const QString& Destination, bool Pop = true);
79  bool DestinationExists(const QString& Destination) const;
80  QStringList EnumerateDestinations() const;
81 
82  bool IsExitingToMain() const;
83 
84  static MythMainWindow *getMainWindow(bool UseDB = true);
85  static void destroyMainWindow();
86 
87  MythDisplay* GetDisplay();
88  MythPainter* GetPainter();
89  QWidget* GetPaintWindow();
91  MythNotificationCenter* GetCurrentNotificationCenter();
92  void ShowPainterWindow();
93  void HidePainterWindow();
94  static void GrabWindow(QImage& Image);
95  static bool SaveScreenShot(const QImage& Image, QString Filename = "");
96  static bool ScreenShot(int Width = 0, int Height = 0, QString Filename = "");
97  static void RestoreScreensaver();
98  static void DisableScreensaver();
99  static void ResetScreensaver();
100  static bool IsScreensaverAsleep();
101  static bool IsTopScreenInitialized();
102  void RemoteScreenShot(QString Filename, int Width, int Height);
103  void AllowInput(bool Allow);
104  void RestartInputHandlers();
105  uint PushDrawDisabled();
106  uint PopDrawDisabled();
107  void SetEffectsEnabled(bool Enable);
108  void Draw(MythPainter* Painter = nullptr);
109  void ResetIdleTimer();
110  void PauseIdleTimer(bool Pause);
111  void DisableIdleTimer(bool DisableIdle = true);
112  void EnterStandby(bool Manual = true);
113  void ExitStandby(bool Manual = true);
114 
115  QPaintEngine* paintEngine() const override;
116 
117  public slots:
118  void MouseTimeout();
119  void HideMouseTimeout();
120  void IdleTimeout();
121 
122  protected slots:
123  void Animate();
124  void DoRemoteScreenShot(const QString& Filename, int Width, int Height);
125  void SetDrawEnabled(bool Enable);
126  void OnApplicationStateChange(Qt::ApplicationState State);
127 
128  signals:
129  void SignalRemoteScreenShot(QString Filename, int Width, int Height);
130  void SignalSetDrawEnabled(bool Enable);
131  void SignalWindowReady();
132  void SignalRestoreScreensaver();
133  void SignalDisableScreensaver();
134  void SignalResetScreensaver();
135 
136  protected:
137  explicit MythMainWindow(bool UseDB = true);
138  ~MythMainWindow() override;
139 
140  static void LoadQtConfig();
141  void InitKeys();
142 
143  bool eventFilter(QObject* Watched, QEvent* Event) override;
144  void customEvent(QEvent* Event) override;
145  void closeEvent(QCloseEvent* Event) override;
146  void drawScreen(QPaintEvent* Event = nullptr);
147  bool event(QEvent* Event) override;
148  void ExitToMainMenu();
149  void ShowMouseCursor(bool Show);
150 
151  private slots:
152  void DelayedAction();
153 
154  private:
155  MythMainWindowPrivate* m_priv { nullptr };
156  MythDisplay* m_display { nullptr };
159  MythThemeBase* m_themeBase { nullptr };
160  MythPainter* m_painter { nullptr };
161  MythPainterWindow* m_painterWin { nullptr };
162  MythInputDeviceHandler* m_deviceHandler { nullptr };
163  MythScreenSaverControl* m_screensaver { nullptr };
164  QTimer m_idleTimer;
165  std::chrono::minutes m_idleTime { 0min };
166 };
167 
173 
174 static inline void
175 REG_KEY(const QString& Context, const QString& Action,
176  const QString& Description, const QString& Key)
177 {
178  GetMythMainWindow()->RegisterKey(Context, Action, Description, Key);
179 }
180 
181 static inline QString
182 GET_KEY(const QString& Context, const QString& Action)
183 {
184  return MythMainWindow::GetKey(Context, Action);
185 }
186 
187 static inline void
188 REG_JUMP(const QString& Destination, const QString& Description,
189  const QString& Key, void (*Callback)(void))
190 {
191  GetMythMainWindow()->RegisterJump(Destination, Description, Key, Callback);
192 }
193 
194 static inline void
195 REG_JUMPLOC(const QString& Destination, const QString& Description,
196  const QString& Key, void (*Callback)(void), const QString& LocalAction)
197 {
198  GetMythMainWindow()->RegisterJump(Destination, Description, Key, Callback, true, LocalAction);
199 }
200 
201 static inline void
202 REG_JUMPEX(const QString& Destination, const QString& Description,
203  const QString& Key, void (*Callback)(void), bool ExitToMain)
204 {
205  GetMythMainWindow()->RegisterJump(Destination, Description, Key, Callback, ExitToMain);
206 }
207 
208 static inline void
209 REG_MEDIAPLAYER(const QString& Name, const QString& Desc, MediaPlayCallback Func)
210 {
212 }
213 
214 #endif
mythrect.h
bool
bool
Definition: pxsup2dast.c:30
MythMainWindow::m_idleTimer
QTimer m_idleTimer
Definition: mythmainwindow.h:164
REG_KEY
static void REG_KEY(const QString &Context, const QString &Action, const QString &Description, const QString &Key)
Definition: mythmainwindow.h:175
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
GetMythPainter
MUI_PUBLIC MythPainter * GetMythPainter()
Definition: mythmainwindow.cpp:119
MythUIScreenBounds
Definition: mythuiscreenbounds.h:12
ReloadKeys
static void ReloadKeys(void)
Definition: mythfrontend.cpp:1680
mythscreenstack.h
MythScreenStack
Definition: mythscreenstack.h:16
MythPainterWindow
Definition: mythpainterwindow.h:34
MythPainterWindowOpenGL
Definition: mythpainterwindowopengl.h:12
GetMythMainWindow
MUI_PUBLIC MythMainWindow * GetMythMainWindow()
Definition: mythmainwindow.cpp:104
GetNotificationCenter
MUI_PUBLIC MythNotificationCenter * GetNotificationCenter()
Definition: mythmainwindow.cpp:124
MythMainWindow::RegisterKey
void RegisterKey(const QString &Context, const QString &Action, const QString &Description, const QString &Key)
Definition: mythmainwindow.cpp:1250
MythMainWindow::RegisterMediaPlugin
void RegisterMediaPlugin(const QString &Name, const QString &Desc, MediaPlayCallback Func)
Definition: mythmainwindow.cpp:1481
MythPainterWindowQt
Definition: mythpainterwindowqt.h:7
Action
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:40
mythuiscreenbounds.h
MythMainWindow::GetKey
static QString GetKey(const QString &Context, const QString &Action)
Definition: mythmainwindow.cpp:1319
MythThemeBase
Definition: myththemebase.h:11
MythMainWindowPrivate
Definition: mythmainwindowprivate.h:47
MythInputDeviceHandler
A wrapper around sundry external input devices.
Definition: mythinputdevicehandler.h:18
Event
Event details.
Definition: zmdefines.h:26
State
State
Definition: zmserver.h:68
MythScreenSaverControl
Controls all instances of the screensaver.
Definition: mythscreensaver.h:33
MythMainWindow::RegisterJump
void RegisterJump(const QString &Destination, const QString &Description, const QString &Key, void(*Callback)(void), bool Exittomain=true, QString LocalAction="")
Definition: mythmainwindow.cpp:1413
uint
unsigned int uint
Definition: compat.h:81
MythPainterWindow::GetRenderDevice
MythRender * GetRenderDevice()
Definition: mythpainterwindow.cpp:157
MythDisplay
Definition: mythdisplay.h:22
MythMainWindow::m_refreshTimer
QTimer m_refreshTimer
Definition: mythmainwindow.h:158
GET_KEY
static QString GET_KEY(const QString &Context, const QString &Action)
Definition: mythmainwindow.h:182
MythPainterWindowVulkan
Definition: mythpainterwindowvulkan.h:12
DestroyMythMainWindow
MUI_PUBLIC void DestroyMythMainWindow()
Definition: mythmainwindow.cpp:114
MythRender
Definition: mythrender_base.h:23
MediaPlayCallback
int(*)(const QString &, const QString &, const QString &, const QString &, const QString &, int, int, const QString &, std::chrono::minutes, const QString &, const QString &, bool) MediaPlayCallback
Definition: mythmainwindow.h:19
MythPainter
Definition: mythpainter.h:34
Name
Definition: channelsettings.cpp:71
HasMythMainWindow
MUI_PUBLIC bool HasMythMainWindow()
Definition: mythmainwindow.cpp:109
MythMainWindow::m_repaintRegion
QRegion m_repaintRegion
Definition: mythmainwindow.h:157
REG_JUMP
static void REG_JUMP(const QString &Destination, const QString &Description, const QString &Key, void(*Callback)(void))
Definition: mythmainwindow.h:188
mythchrono.h
REG_MEDIAPLAYER
static void REG_MEDIAPLAYER(const QString &Name, const QString &Desc, MediaPlayCallback Func)
Definition: mythmainwindow.h:209
REG_JUMPEX
static void REG_JUMPEX(const QString &Destination, const QString &Description, const QString &Key, void(*Callback)(void), bool ExitToMain)
Definition: mythmainwindow.h:202
mythuiactions.h
MythMediaDevice
Definition: mythmedia.h:48
MythNotificationCenter
Definition: mythnotificationcenter.h:40
mythnotificationcenter.h
REG_JUMPLOC
static void REG_JUMPLOC(const QString &Destination, const QString &Description, const QString &Key, void(*Callback)(void), const QString &LocalAction)
Definition: mythmainwindow.h:195
MythMainWindow
Definition: mythmainwindow.h:28
InitKeys
static void InitKeys(void)
Definition: mythfrontend.cpp:1628