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 ReinitDone();
46  void Show();
47  void MoveResize(QRect& Geometry);
48 
49  void AddScreenStack(MythScreenStack* Stack, bool Main = false);
50  void PopScreenStack();
51  int GetStackCount();
52  MythScreenStack* GetMainStack();
53  MythScreenStack* GetStack(const QString& Stackname);
54  MythScreenStack* GetStackAt(int Position);
55 
56  bool TranslateKeyPress(const QString& Context, QKeyEvent* Event,
57  QStringList& Actions, bool AllowJumps = true);
58  bool KeyLongPressFilter(QEvent** Event, QScopedPointer<QEvent>& NewEvent);
59 
60  void ReloadKeys();
61  void ClearKey(const QString& Context, const QString& Action);
62  void ClearKeyContext(const QString& Context);
63  void BindKey(const QString& Context, const QString& Action, 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  QObject* GetTarget(QKeyEvent& Key);
68  QString GetActionText(const QString& Context, const QString& Action) const;
69 
70  void ClearJump(const QString& Destination);
71  void BindJump(const QString& Destination, const QString& Key);
72  void RegisterJump(const QString& Destination, const QString& Description,
73  const QString& Key, void (*Callback)(void),
74  bool Exittomain = true, QString LocalAction = "");
75  void ClearAllJumps();
76  void RegisterMediaPlugin(const QString& Name, const QString& Desc,
77  MediaPlayCallback Func);
78  bool HandleMedia(const QString& Handler, const QString& Mrl,
79  const QString& Plot="", const QString& Title="",
80  const QString& Subtitle="", const QString& Director="",
81  int Season=0, int Episode=0, const QString& Inetref="",
82  std::chrono::minutes LenMins=2h, const QString& Year="1895",
83  const QString& Id="", bool UseBookmarks = false);
84  void HandleTVAction(const QString& Action);
85 
86  void JumpTo(const QString& Destination, bool Pop = true);
87  bool DestinationExists(const QString& Destination) const;
88  QStringList EnumerateDestinations() const;
89 
90  bool IsExitingToMain() const;
91 
92  static MythMainWindow *getMainWindow(bool UseDB = true);
93  static void destroyMainWindow();
94 
95  MythDisplay* GetDisplay();
96  MythPainter* GetPainter();
97  QWidget* GetPaintWindow();
99  MythNotificationCenter* GetCurrentNotificationCenter();
100  void ShowPainterWindow();
101  void HidePainterWindow();
102  static void GrabWindow(QImage& Image);
103  static bool SaveScreenShot(const QImage& Image, QString Filename = "");
104  static bool ScreenShot(int Width = 0, int Height = 0, QString Filename = "");
105  static void RestoreScreensaver();
106  static void DisableScreensaver();
107  static void ResetScreensaver();
108  static bool IsScreensaverAsleep();
109  static bool IsTopScreenInitialized();
110  void RemoteScreenShot(QString Filename, int Width, int Height);
111  void AllowInput(bool Allow);
112  void RestartInputHandlers();
113  uint PushDrawDisabled();
114  uint PopDrawDisabled();
115  void SetEffectsEnabled(bool Enable);
116  void Draw(MythPainter* Painter = nullptr);
117  void ResetIdleTimer();
118  void PauseIdleTimer(bool Pause);
119  void DisableIdleTimer(bool DisableIdle = true);
120  void EnterStandby(bool Manual = true);
121  void ExitStandby(bool Manual = true);
122 
123  QPaintEngine* paintEngine() const override;
124 
125  public slots:
126  void MouseTimeout();
127  void HideMouseTimeout();
128  void IdleTimeout();
129 
130  protected slots:
131  void Animate();
132  void DoRemoteScreenShot(const QString& Filename, int Width, int Height);
133  void SetDrawEnabled(bool Enable);
134  void OnApplicationStateChange(Qt::ApplicationState State);
135 
136  signals:
137  void SignalRemoteScreenShot(QString Filename, int Width, int Height);
138  void SignalSetDrawEnabled(bool Enable);
139  void SignalWindowReady();
140  void SignalRestoreScreensaver();
141  void SignalDisableScreensaver();
142  void SignalResetScreensaver();
143 
144  protected:
145  explicit MythMainWindow(bool UseDB = true);
146  ~MythMainWindow() override;
147 
148  static void LoadQtConfig();
149  void InitKeys();
150 
151  bool eventFilter(QObject* Watched, QEvent* Event) override;
152  void customEvent(QEvent* Event) override;
153  void closeEvent(QCloseEvent* Event) override;
154  void drawScreen(QPaintEvent* Event = nullptr);
155  bool event(QEvent* Event) override;
156  void ExitToMainMenu();
157  void ShowMouseCursor(bool Show);
158 
159  private slots:
160  void DelayedAction();
161 
162  private:
163  MythMainWindowPrivate* m_priv { nullptr };
164  MythDisplay* m_display { nullptr };
167  MythThemeBase* m_themeBase { nullptr };
168  MythPainter* m_painter { nullptr };
169  MythPainter* m_oldPainter { nullptr };
170  MythPainterWindow* m_painterWin { nullptr };
171  MythPainterWindow* m_oldPainterWin { nullptr };
172  MythInputDeviceHandler* m_deviceHandler { nullptr };
173  MythScreenSaverControl* m_screensaver { nullptr };
174  QTimer m_idleTimer;
175  std::chrono::minutes m_idleTime { 0min };
176 };
177 
183 
184 #endif
mythrect.h
bool
bool
Definition: pxsup2dast.c:30
MythMainWindow::m_idleTimer
QTimer m_idleTimer
Definition: mythmainwindow.h:174
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: mythtv/programs/mythfrontend/main.cpp:1630
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:104
GetNotificationCenter
MUI_PUBLIC MythNotificationCenter * GetNotificationCenter()
Definition: mythmainwindow.cpp:124
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:140
MythPainterWindow::GetRenderDevice
MythRender * GetRenderDevice()
Definition: mythpainterwindow.cpp:160
MythDisplay
Definition: mythdisplay.h:21
MythMainWindow::m_refreshTimer
QTimer m_refreshTimer
Definition: mythmainwindow.h:166
InitKeys
static void InitKeys(void)
Definition: mythtv/programs/mythfrontend/main.cpp:1578
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:26
MythPainter
Definition: mythpainter.h:32
Name
Definition: channelsettings.cpp:46
HasMythMainWindow
MUI_PUBLIC bool HasMythMainWindow()
Definition: mythmainwindow.cpp:109
MythMainWindow::m_repaintRegion
QRegion m_repaintRegion
Definition: mythmainwindow.h:165
mythchrono.h
mythuiactions.h
MythMediaDevice
Definition: mythmedia.h:48
MythNotificationCenter
Definition: mythnotificationcenter.h:33
mythnotificationcenter.h
MythMainWindow
Definition: mythmainwindow.h:35