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 "mythchrono.h"
9 #include "mythscreenstack.h"
10 #include "mythnotificationcenter.h"
11 #include "mythuiactions.h"
12 #include "mythrect.h"
13 #include "mythuiscreenbounds.h"
14 
15 class QEvent;
16 class MythThemeBase;
17 class MythMediaDevice;
18 
19 #define REG_KEY(a, b, c, d) GetMythMainWindow()->RegisterKey(a, b, c, d)
20 #define GET_KEY(a, b) GetMythMainWindow()->GetKey(a, b)
21 #define REG_JUMP(a, b, c, d) GetMythMainWindow()->RegisterJump(a, b, c, d)
22 #define REG_JUMPLOC(a, b, c, d, e) GetMythMainWindow()->RegisterJump(a, b, c, d, true, e)
23 #define REG_JUMPEX(a, b, c, d, e) GetMythMainWindow()->RegisterJump(a, b, c, d, e)
24 #define REG_MEDIAPLAYER(a,b,c) GetMythMainWindow()->RegisterMediaPlugin(a, b, c)
25 
26 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);
27 
29 class MythDisplay;
32 class MythPainterWindow;
33 class MythRender;
34 
36 {
37  Q_OBJECT
38 
41  friend class MythPainterWindowQt;
42 
43  public:
44  void Init(bool MayReInit = true);
45  void Show();
46  void MoveResize(QRect& Geometry);
47 
48  void AddScreenStack(MythScreenStack* Stack, bool Main = false);
49  void PopScreenStack();
50  int GetStackCount();
51  MythScreenStack* GetMainStack();
52  MythScreenStack* GetStack(const QString& Stackname);
53  MythScreenStack* GetStackAt(int Position);
54 
55  bool TranslateKeyPress(const QString& Context, QKeyEvent* Event,
56  QStringList& Actions, bool AllowJumps = true);
57  bool KeyLongPressFilter(QEvent** Event, QScopedPointer<QEvent>& NewEvent);
58 
59  void ReloadKeys();
60  void ClearKey(const QString& Context, const QString& Action);
61  void ClearKeyContext(const QString& Context);
62  void BindKey(const QString& Context, const QString& Action, const QString& Key);
63  void RegisterKey(const QString& Context, const QString& Action,
64  const QString& Description, const QString& Key);
65  static QString GetKey(const QString& Context, const QString& Action);
66  QObject* GetTarget(QKeyEvent& Key);
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  void RegisterMediaPlugin(const QString& Name, const QString& Desc,
76  MediaPlayCallback Func);
77  bool HandleMedia(const QString& Handler, const QString& Mrl,
78  const QString& Plot="", const QString& Title="",
79  const QString& Subtitle="", const QString& Director="",
80  int Season=0, int Episode=0, const QString& Inetref="",
81  std::chrono::minutes LenMins=2h, const QString& Year="1895",
82  const QString& Id="", bool UseBookmarks = false);
83  void HandleTVAction(const QString& Action);
84 
85  void JumpTo(const QString& Destination, bool Pop = true);
86  bool DestinationExists(const QString& Destination) const;
87  QStringList EnumerateDestinations() const;
88 
89  bool IsExitingToMain() const;
90 
91  static MythMainWindow *getMainWindow(bool UseDB = true);
92  static void destroyMainWindow();
93 
94  MythDisplay* GetDisplay();
95  MythPainter* GetPainter();
96  QWidget* GetPaintWindow();
98  MythNotificationCenter* GetCurrentNotificationCenter();
99  void ShowPainterWindow();
100  void HidePainterWindow();
101  static void GrabWindow(QImage& Image);
102  static bool SaveScreenShot(const QImage& Image, QString Filename = "");
103  static bool ScreenShot(int Width = 0, int Height = 0, QString Filename = "");
104  static void RestoreScreensaver();
105  static void DisableScreensaver();
106  static void ResetScreensaver();
107  static bool IsScreensaverAsleep();
108  static bool IsTopScreenInitialized();
109  void RemoteScreenShot(QString Filename, int Width, int Height);
110  void AllowInput(bool Allow);
111  void RestartInputHandlers();
112  uint PushDrawDisabled();
113  uint PopDrawDisabled();
114  void SetEffectsEnabled(bool Enable);
115  void Draw(MythPainter* Painter = nullptr);
116  void ResetIdleTimer();
117  void PauseIdleTimer(bool Pause);
118  void DisableIdleTimer(bool DisableIdle = true);
119  void EnterStandby(bool Manual = true);
120  void ExitStandby(bool Manual = true);
121 
122  QPaintEngine* paintEngine() const override;
123 
124  public slots:
125  void MouseTimeout();
126  void HideMouseTimeout();
127  void IdleTimeout();
128 
129  protected slots:
130  void Animate();
131  void DoRemoteScreenShot(const QString& Filename, int Width, int Height);
132  void SetDrawEnabled(bool Enable);
133  void OnApplicationStateChange(Qt::ApplicationState State);
134 
135  signals:
136  void SignalRemoteScreenShot(QString Filename, int Width, int Height);
137  void SignalSetDrawEnabled(bool Enable);
138  void SignalWindowReady();
139  void SignalRestoreScreensaver();
140  void SignalDisableScreensaver();
141  void SignalResetScreensaver();
142 
143  protected:
144  explicit MythMainWindow(bool UseDB = true);
145  ~MythMainWindow() override;
146 
147  static void LoadQtConfig();
148  void InitKeys();
149 
150  bool eventFilter(QObject* Watched, QEvent* Event) override;
151  void customEvent(QEvent* Event) override;
152  void closeEvent(QCloseEvent* Event) override;
153  void drawScreen(QPaintEvent* Event = nullptr);
154  bool event(QEvent* Event) override;
155  void ExitToMainMenu();
156  void ShowMouseCursor(bool Show);
157 
158  private slots:
159  void DelayedAction();
160 
161  private:
162  MythMainWindowPrivate* m_priv { nullptr };
163  MythDisplay* m_display { nullptr };
166  MythThemeBase* m_themeBase { nullptr };
167  MythPainter* m_painter { nullptr };
168  MythPainterWindow* m_painterWin { nullptr };
169  MythInputDeviceHandler* m_deviceHandler { nullptr };
170  MythScreenSaverControl* m_screensaver { nullptr };
171  QTimer m_idleTimer;
172  std::chrono::minutes m_idleTime { 0min };
173 };
174 
180 
181 #endif
mythrect.h
bool
bool
Definition: pxsup2dast.c:30
MythMainWindow::m_idleTimer
QTimer m_idleTimer
Definition: mythmainwindow.h:171
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
GetMythPainter
MUI_PUBLIC MythPainter * GetMythPainter()
Definition: mythmainwindow.cpp:116
MythUIScreenBounds
Definition: mythuiscreenbounds.h:12
ReloadKeys
static void ReloadKeys(void)
Definition: mythtv/programs/mythfrontend/main.cpp:1626
mythscreenstack.h
MythScreenStack
Definition: mythscreenstack.h:16
MythPainterWindow
Definition: mythpainterwindow.h:38
MythPainterWindowOpenGL
Definition: mythpainterwindowopengl.h:12
GetMythMainWindow
MUI_PUBLIC MythMainWindow * GetMythMainWindow()
Definition: mythmainwindow.cpp:101
GetNotificationCenter
MUI_PUBLIC MythNotificationCenter * GetNotificationCenter()
Definition: mythmainwindow.cpp:121
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
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
uint
unsigned int uint
Definition: compat.h:144
MythPainterWindow::GetRenderDevice
MythRender * GetRenderDevice()
Definition: mythpainterwindow.cpp:160
MythDisplay
Definition: mythdisplay.h:22
MythMainWindow::m_refreshTimer
QTimer m_refreshTimer
Definition: mythmainwindow.h:165
InitKeys
static void InitKeys(void)
Definition: mythtv/programs/mythfrontend/main.cpp:1574
MythPainterWindowVulkan
Definition: mythpainterwindowvulkan.h:12
DestroyMythMainWindow
MUI_PUBLIC void DestroyMythMainWindow()
Definition: mythmainwindow.cpp:111
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:26
MythPainter
Definition: mythpainter.h:32
Name
Definition: channelsettings.cpp:46
HasMythMainWindow
MUI_PUBLIC bool HasMythMainWindow()
Definition: mythmainwindow.cpp:106
MythMainWindow::m_repaintRegion
QRegion m_repaintRegion
Definition: mythmainwindow.h:164
mythchrono.h
mythuiactions.h
MythMediaDevice
Definition: mythmedia.h:48
MythNotificationCenter
Definition: mythnotificationcenter.h:40
mythnotificationcenter.h
MythMainWindow
Definition: mythmainwindow.h:35