MythTV  master
osd.h
Go to the documentation of this file.
1 #ifndef OSD_H
2 #define OSD_H
3 
4 // Qt headers
5 
6 #include <QCoreApplication>
7 #include <QHash>
8 
9 // MythTV headers
10 
11 #include "mythtvexp.h"
12 #include "programtypes.h"
13 #include "mythscreentype.h"
14 #include "mythtypes.h"
15 
16 // Screen names are prepended with alphanumerics to force the correct ordering
17 // when displayed. This is slightly complicated by the default windows
18 // (e.g. osd_window) whose names are hard coded into existing themes.
19 
20 // menu dialogs should always be on top
21 #define OSD_DLG_VIDEOEXIT "xx_OSD_VIDEO_EXIT"
22 #define OSD_DLG_MENU "xx_OSD_MENU"
23 #define OSD_DLG_SLEEP "xx_OSD_SLEEP"
24 #define OSD_DLG_IDLE "xx_OSD_IDLE"
25 #define OSD_DLG_INFO "xx_OSD_INFO"
26 #define OSD_DLG_EDITING "xx_OSD_EDITING"
27 #define OSD_DLG_ASKALLOW "xx_OSD_ASKALLOW"
28 #define OSD_DLG_EDITOR "xx_OSD_EDITOR"
29 #define OSD_DLG_CUTPOINT "xx_OSD_CUTPOINT"
30 #define OSD_DLG_DELETE "xx_OSD_DELETE"
31 #define OSD_DLG_NAVIGATE "xx_OSD_NAVIGATE"
32 #define OSD_DLG_CONFIRM "mythconfirmpopup"
33 // subtitles are always painted first
34 #define OSD_WIN_TELETEXT "aa_OSD_TELETEXT"
35 #define OSD_WIN_SUBTITLE "aa_OSD_SUBTITLES"
36 // MHEG and blu-ray overlay should cover subtitles
37 #define OSD_WIN_INTERACT "bb_OSD_INTERACTIVE"
38 #define OSD_WIN_BDOVERLAY "bb_OSD_BDOVERLAY"
39 
40 #define kOSDFadeTime 1000
41 
42 class MythPlayer;
43 class TeletextScreen;
44 class SubtitleScreen;
45 struct AVSubtitle;
46 class BDOverlay;
47 
49 {
57 };
58 
60 {
61  kOSDTimeout_Ignore = -1, // Don't update existing timeout
62  kOSDTimeout_None = 0, // Don't timeout
66 };
67 
68 class MTV_PUBLIC OSDHideEvent : public QEvent
69 {
70  public:
71  explicit OSDHideEvent(enum OSDFunctionalType osdFunctionalType)
72  : QEvent(kEventType), m_osdFunctionalType(osdFunctionalType) { }
73 
74  int GetFunctionalType() { return m_osdFunctionalType; }
75 
76  static Type kEventType;
77 
78  private:
80 };
81 
83 {
84  Q_OBJECT
85 
86  public:
87  ChannelEditor(QObject *retobject, const char * name);
88 
89  bool Create(void) override; // MythScreenType
90  bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
91 
92  void SetText(const InfoMap &map);
93  void GetText(InfoMap &map);
94 
95  protected:
100 
101  QObject *m_retObject;
102 
103  void sendResult(int result);
104 
105  public slots:
106  void Confirm();
107  void Probe();
108 };
109 
111 {
112  Q_OBJECT
113  public:
114  MythOSDWindow(MythScreenStack *parent, const QString &name,
115  bool themed)
116  : MythScreenType(parent, name, true), m_themed(themed)
117  {
118  }
119 
120  bool Create(void) override // MythScreenType
121  {
122  if (m_themed)
123  return XMLParseBase::LoadWindowFromXML("osd.xml", objectName(),
124  this);
125  return false;
126  }
127 
128  private:
129  bool m_themed;
130 };
131 
132 class OSD
133 {
135 
136  public:
137  OSD(MythPlayer *player, QObject *parent, MythPainter *painter);
138  ~OSD();
139 
140  bool Init(const QRect &rect, float font_aspect);
141  void SetPainter(MythPainter *painter);
142  QRect Bounds(void) const { return m_Rect; }
143  int GetFontStretch(void) const { return m_fontStretch; }
144  void OverrideUIScale(bool log = true);
145  void RevertUIScale(void);
146  bool Reinit(const QRect &rect, float font_aspect);
147  void DisableFade(void) { m_Effects = false; }
148  void SetFunctionalWindow(const QString &window,
149  enum OSDFunctionalType type);
150  void SetTimeouts(int _short, int _medium, int _long);
151 
152  bool IsVisible(void);
153  void HideAll(bool keepsubs = true, MythScreenType *except = nullptr,
154  bool dropnotification = false);
155 
156  MythScreenType *GetWindow(const QString &window);
157  void SetExpiry(const QString &window, enum OSDTimeout timeout,
158  int custom_timeout = 0);
159  void HideWindow(const QString &window);
160  bool HasWindow(const QString &window);
161  void ResetWindow(const QString &window);
162  void PositionWindow(MythScreenType *window);
163  void RemoveWindow(const QString &window);
164 
165  bool DrawDirect(MythPainter* painter, QSize size, bool repaint = false);
166  QRegion Draw(MythPainter* painter, QPaintDevice *device, QSize size,
167  QRegion &changed, int alignx = 0, int aligny = 0);
168 
169  void SetValues(const QString &window, const QHash<QString,int> &map,
171  void SetValues(const QString &window, const QHash<QString,float> &map,
173  void SetText(const QString &window, const InfoMap &map,
175  void SetRegions(const QString &window, frm_dir_map_t &map,
176  long long total);
177  void SetGraph(const QString &window, const QString &graph, int64_t timecode);
178  bool IsWindowVisible(const QString &window);
179 
180  bool DialogVisible(const QString& window = QString());
181  bool DialogHandleKeypress(QKeyEvent *e);
183  void DialogQuit(void);
184  void DialogShow(const QString &window, const QString &text = "",
185  int updatefor = 0);
186  void DialogSetText(const QString &text);
187  void DialogBack(const QString& text = "", const QVariant& data = 0, bool exit = false);
188  void DialogAddButton(const QString& text, QVariant data,
189  bool menu = false, bool current = false);
190  void DialogGetText(InfoMap &map);
191 
193  void EnableTeletext(bool enable, int page);
194  bool TeletextAction(const QString &action);
195  void TeletextReset(void);
196  void TeletextClear(void);
197 
199  void EnableSubtitles(int type, bool forced_only = false);
200  void DisableForcedSubtitles(void);
201  void ClearSubtitles(void);
202  void DisplayDVDButton(AVSubtitle* dvdButton, QRect &pos);
203 
204  void DisplayBDOverlay(BDOverlay *overlay);
205  MythPlayer *GetPlayer(void) { return m_parent; }
206 
207  private:
208  void TearDown(void);
209  void LoadWindows(void);
210 
211  void CheckExpiry(void);
212  void SendHideEvent(void);
213  void SetExpiry1(const QString &window, enum OSDTimeout timeout,
214  int custom_timeout);
215 
216  private:
218  QObject *m_ParentObject;
220  QRect m_Rect;
221  bool m_Effects;
225  QDateTime m_NextPulseUpdate;
226  bool m_Refresh;
227  bool m_Visible;
228  int m_Timeouts[4];
229 
236 
239 
240  QMap<QString, MythScreenType*> m_Children;
241  QHash<MythScreenType*, QDateTime> m_ExpireTimes;
242 };
243 
245 {
246  Q_OBJECT
247 
248  public:
249  OsdNavigation(QObject *retobject, const QString &name, OSD *osd);
250  bool Create(void) override; // MythScreenType
251  bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
252  void SetTextFromMap(const InfoMap &infoMap) override; // MythUIComposite
254  // Virtual
255  void ShowMenu(void) override; // MythScreenType
256 
257  protected:
258 
259  QObject *m_retObject;
265  char m_paused;
266  char m_muted;
270 
271  void sendResult(int result, const QString& action);
272 
273  public slots:
274  void GeneralAction(void);
275  void More(void);
276 };
277 
278 #endif
MythPlayer * GetPlayer(void)
Definition: osd.h:205
void DialogSetText(const QString &text)
Definition: osd.cpp:1273
void DialogShow(const QString &window, const QString &text="", int updatefor=0)
Definition: osd.cpp:1202
void sendResult(int result, const QString &action)
Definition: osd.cpp:1589
MythPainter * m_CurrentPainter
Definition: osd.h:219
QString m_PulsedDialogText
Definition: osd.h:224
unsigned int slots[4]
Definition: element.c:38
OSDFunctionalType
Definition: osd.h:48
TeletextScreen * InitTeletext(void)
Definition: osd.cpp:1305
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
int m_visibleGroup
Definition: osd.h:267
QRect m_SavedUIRect
Definition: osd.h:233
void SendHideEvent(void)
Definition: osd.cpp:1159
bool m_themed
Definition: osd.h:129
void DialogBack(const QString &text="", const QVariant &data=0, bool exit=false)
Definition: osd.cpp:1280
void SetText(const InfoMap &map)
Definition: osd.cpp:86
void TeletextReset(void)
Definition: osd.cpp:1371
bool HasWindow(const QString &window)
Definition: osd.cpp:1165
void SetTimeouts(int _short, int _medium, int _long)
Definition: osd.cpp:1047
void Probe()
Definition: osd.cpp:81
MythUITextEdit * m_channumEdit
Definition: osd.h:97
void TearDown(void)
Definition: osd.cpp:171
void RevertUIScale(void)
Definition: osd.cpp:244
void ClearSubtitles(void)
Definition: osd.cpp:1440
bool IsVisible(void)
Definition: osd.cpp:286
void DialogQuit(void)
Definition: osd.cpp:1192
MythOSDWindow(MythScreenStack *parent, const QString &name, bool themed)
Definition: osd.h:114
QObject * m_retObject
Definition: osd.h:259
QMap< QString, MythScreenType * > m_Children
Definition: osd.h:240
bool TeletextAction(const QString &action)
Definition: osd.cpp:1360
bool m_Refresh
Definition: osd.h:226
int getVisibleGroup()
Definition: osd.h:253
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:81
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: osd.cpp:106
QDateTime m_NextPulseUpdate
Definition: osd.h:225
enum OSDFunctionalType m_FunctionalType
Definition: osd.h:237
void GeneralAction(void)
Definition: osd.cpp:1599
void ShowMenu(void) override
Definition: osd.cpp:1584
void DialogAddButton(const QString &text, QVariant data, bool menu=false, bool current=false)
Definition: osd.cpp:1291
static MythThemedMenu * menu
void SetGraph(const QString &window, const QString &graph, int64_t timecode)
Definition: osd.cpp:659
void SetFunctionalWindow(const QString &window, enum OSDFunctionalType type)
Definition: osd.cpp:1127
bool m_UIScaleOverride
Definition: osd.h:230
void GetText(InfoMap &map)
Definition: osd.cpp:98
QRect m_Rect
Definition: osd.h:220
QObject * m_retObject
Definition: osd.h:101
OSDFunctionalType m_osdFunctionalType
Definition: osd.h:79
OSDTimeout
Definition: osd.h:59
bool Create(void) override
Definition: osd.h:120
void sendResult(int result)
Definition: osd.cpp:130
void EnableSubtitles(int type, bool forced_only=false)
Definition: osd.cpp:1424
bool DialogHandleGesture(MythGestureEvent *e)
Definition: osd.cpp:1185
bool m_Visible
Definition: osd.h:227
OSD(MythPlayer *player, QObject *parent, MythPainter *painter)
Definition: osd.cpp:154
SubtitleScreen * InitSubtitles(void)
Definition: osd.cpp:1391
MythUIButton * m_muteButton
Definition: osd.h:263
bool Create(void) override
Definition: osd.cpp:46
#define MTV_PUBLIC
Definition: mythtvexp.h:15
int m_savedFontStretch
Definition: osd.h:235
void SetPainter(MythPainter *painter)
Definition: osd.cpp:201
OSDHideEvent(enum OSDFunctionalType osdFunctionalType)
Definition: osd.h:71
void SetValues(const QString &window, const QHash< QString, int > &map, OSDTimeout timeout)
Definition: osd.cpp:357
void Confirm()
Definition: osd.cpp:76
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
void SetTextFromMap(const InfoMap &infoMap) override
Definition: osd.cpp:1636
MythUITextEdit * m_xmltvidEdit
Definition: osd.h:99
int m_FadeTime
Definition: osd.h:222
void DisableForcedSubtitles(void)
Definition: osd.cpp:1431
bool Reinit(const QRect &rect, float font_aspect)
Definition: osd.cpp:255
float m_SavedWMult
Definition: osd.h:231
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
void TeletextClear(void)
Definition: osd.cpp:1381
QRegion Draw(MythPainter *painter, QPaintDevice *device, QSize size, QRegion &changed, int alignx=0, int aligny=0)
Definition: osd.cpp:789
bool IsWindowVisible(const QString &window)
Definition: osd.cpp:1055
void More(void)
Definition: osd.cpp:1619
void DisableFade(void)
Definition: osd.h:147
MythUIButton * m_unMuteButton
Definition: osd.h:264
A text entry and edit widget.
bool DialogHandleKeypress(QKeyEvent *e)
Definition: osd.cpp:1178
MythUITextEdit * m_channameEdit
Definition: osd.h:98
bool DrawDirect(MythPainter *painter, QSize size, bool repaint=false)
Definition: osd.cpp:674
void DisplayBDOverlay(BDOverlay *overlay)
Definition: osd.cpp:1463
void CheckExpiry(void)
Definition: osd.cpp:971
void EnableTeletext(bool enable, int page)
Definition: osd.cpp:1342
void SetExpiry(const QString &window, enum OSDTimeout timeout, int custom_timeout=0)
Definition: osd.cpp:1013
def log(debug, txt)
Definition: utilities.py:5
QRect Bounds(void) const
Definition: osd.h:142
A custom event that represents a mouse gesture.
Definition: mythgesture.h:39
const char * name
Definition: ParseText.cpp:328
void RemoveWindow(const QString &window)
Definition: osd.cpp:1081
void HideAll(bool keepsubs=true, MythScreenType *except=nullptr, bool dropnotification=false)
Definition: osd.cpp:304
MythPlayer * m_parent
Definition: osd.h:217
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
MythScreenType * GetWindow(const QString &window)
Definition: osd.cpp:1092
MythScreenType * m_Dialog
Definition: osd.h:223
A single button widget.
Definition: mythuibutton.h:21
void OverrideUIScale(bool log=true)
Definition: osd.cpp:215
QString m_FunctionalWindow
Definition: osd.h:238
MythUITextEdit * m_callsignEdit
Definition: osd.h:96
void LoadWindows(void)
Definition: osd.cpp:329
ChannelEditor(QObject *retobject, const char *name)
Definition: osd.cpp:36
char m_paused
Definition: osd.h:265
float m_SavedHMult
Definition: osd.h:232
void DialogGetText(InfoMap &map)
Definition: osd.cpp:1298
QObject * m_ParentObject
Definition: osd.h:218
int GetFontStretch(void) const
Definition: osd.h:143
QHash< MythScreenType *, QDateTime > m_ExpireTimes
Definition: osd.h:241
static Type kEventType
Definition: osd.h:76
int m_Timeouts[4]
Definition: osd.h:228
void SetText(const QString &window, const InfoMap &map, OSDTimeout timeout)
Definition: osd.cpp:416
Q_DECLARE_TR_FUNCTIONS(OSD)
bool Create(void) override
Definition: osd.cpp:1490
void SetExpiry1(const QString &window, enum OSDTimeout timeout, int custom_timeout)
Definition: osd.cpp:1027
void HideWindow(const QString &window)
Definition: osd.cpp:1137
MythUIButton * m_playButton
Definition: osd.h:261
Definition: osd.h:132
void ResetWindow(const QString &window)
Definition: osd.cpp:1063
bool m_IsVolumeControl
Definition: osd.h:269
void PositionWindow(MythScreenType *window)
Definition: osd.cpp:1071
bool DialogVisible(const QString &window=QString())
Definition: osd.cpp:1170
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: osd.cpp:1545
int m_maxGroupNum
Definition: osd.h:268
Screen in which all other widgets are contained and rendered.
MythUIButton * m_pauseButton
Definition: osd.h:262
~OSD()
Definition: osd.cpp:166
OsdNavigation(QObject *retobject, const QString &name, OSD *osd)
Definition: osd.cpp:1473
int m_fontStretch
Definition: osd.h:234
OSD * m_osd
Definition: osd.h:260
void SetRegions(const QString &window, frm_dir_map_t &map, long long total)
Definition: osd.cpp:592
char m_muted
Definition: osd.h:266
bool m_Effects
Definition: osd.h:221
int GetFunctionalType()
Definition: osd.h:74
bool Init(const QRect &rect, float font_aspect)
Definition: osd.cpp:179
void DisplayDVDButton(AVSubtitle *dvdButton, QRect &pos)
Definition: osd.cpp:1450