MythTV  master
osd.h
Go to the documentation of this file.
1 #ifndef OSD_H
2 #define OSD_H
3 
4 // Qt
5 #include <QCoreApplication>
6 #include <QHash>
7 
8 // MythTV
9 #include "mythtvexp.h"
10 #include "programtypes.h"
11 #include "mythscreentype.h"
12 #include "mythtypes.h"
13 
14 // Screen names are prepended with alphanumerics to force the correct ordering
15 // when displayed. This is slightly complicated by the default windows
16 // (e.g. osd_window) whose names are hard coded into existing themes.
17 
18 // menu dialogs should always be on top
19 #define OSD_DLG_VIDEOEXIT "xx_OSD_VIDEO_EXIT"
20 #define OSD_DLG_MENU "xx_OSD_MENU"
21 #define OSD_DLG_SLEEP "xx_OSD_SLEEP"
22 #define OSD_DLG_IDLE "xx_OSD_IDLE"
23 #define OSD_DLG_INFO "xx_OSD_INFO"
24 #define OSD_DLG_EDITING "xx_OSD_EDITING"
25 #define OSD_DLG_ASKALLOW "xx_OSD_ASKALLOW"
26 #define OSD_DLG_EDITOR "xx_OSD_EDITOR"
27 #define OSD_DLG_CUTPOINT "xx_OSD_CUTPOINT"
28 #define OSD_DLG_DELETE "xx_OSD_DELETE"
29 #define OSD_DLG_NAVIGATE "xx_OSD_NAVIGATE"
30 #define OSD_DLG_CONFIRM "mythconfirmpopup"
31 // subtitles are always painted first
32 #define OSD_WIN_TELETEXT "aa_OSD_TELETEXT"
33 #define OSD_WIN_SUBTITLE "aa_OSD_SUBTITLES"
34 // MHEG and blu-ray overlay should cover subtitles
35 #define OSD_WIN_INTERACT "bb_OSD_INTERACTIVE"
36 #define OSD_WIN_BDOVERLAY "bb_OSD_BDOVERLAY"
37 
38 #define kOSDFadeTime 1000
39 
40 class MythPlayer;
41 class TeletextScreen;
42 class SubtitleScreen;
43 struct AVSubtitle;
44 class MythBDOverlay;
45 
47 {
55 };
56 
58 {
59  kOSDTimeout_Ignore = -1, // Don't update existing timeout
60  kOSDTimeout_None = 0, // Don't timeout
64 };
65 
66 class MTV_PUBLIC OSDHideEvent : public QEvent
67 {
68  public:
69  explicit OSDHideEvent(enum OSDFunctionalType OsdFunctionalType)
70  : QEvent(kEventType),
71  m_osdFunctionalType(OsdFunctionalType) { }
72 
73  int GetFunctionalType() { return m_osdFunctionalType; }
74 
75  static Type kEventType;
76 
77  private:
79 };
80 
82 {
83  Q_OBJECT
84 
85  public:
86  ChannelEditor(QObject *RetObject, const char * Name)
87  : MythScreenType((MythScreenType*)nullptr, Name),
88  m_retObject(RetObject) {}
89 
90  bool Create(void) override;
91  bool keyPressEvent(QKeyEvent *Event) override;
92  void SetText(const InfoMap &Map);
93  void GetText(InfoMap &Map);
94 
95  public slots:
96  void Confirm();
97  void Probe();
98 
99  protected:
100  void SendResult(int result);
101 
106  QObject *m_retObject { nullptr };
107 };
108 
110 {
111  Q_OBJECT
112 
113  public:
114  MythOSDWindow(MythScreenStack *Parent, const QString &Name, bool Themed)
115  : MythScreenType(Parent, Name, true),
116  m_themed(Themed)
117  {
118  }
119 
120  bool Create(void) override
121  {
122  if (m_themed)
123  return XMLParseBase::LoadWindowFromXML("osd.xml", objectName(), this);
124  return false;
125  }
126 
127  private:
128  bool m_themed { false };
129 };
130 
131 class OSD
132 {
133  Q_DECLARE_TR_FUNCTIONS(OSD)
134 
135  public:
136  OSD(MythPlayer *Player, QObject *Parent, MythPainter *Painter)
137  : m_parent(Player), m_parentObject(Parent), m_currentPainter(Painter) {}
138  ~OSD();
139 
140  bool Init(const QRect &Rect, float FontAspect);
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 FontAspect);
147  void SetFunctionalWindow(const QString &Window, enum OSDFunctionalType Type);
148  void SetTimeouts(int Short, int Medium, int Long);
149  bool IsVisible(void);
150  void HideAll(bool KeepSubs = true, MythScreenType *Except = nullptr, bool DropNotification = false);
151  MythScreenType *GetWindow(const QString &Window);
152  void SetExpiry(const QString &Window, enum OSDTimeout Timeout, int CustomTimeout = 0);
153  void HideWindow(const QString &Window);
154  bool HasWindow(const QString &Window);
155  void ResetWindow(const QString &Window);
156  void PositionWindow(MythScreenType *Window);
157  void RemoveWindow(const QString &Window);
158  bool Draw(MythPainter* Painter, QSize Size, bool Repaint = false);
159 
160  void SetValues(const QString &Window, const QHash<QString,int> &Map, OSDTimeout Timeout);
161  void SetValues(const QString &Window, const QHash<QString,float> &Map, OSDTimeout Timeout);
162  void SetText(const QString &Window, const InfoMap &Map, OSDTimeout Timeout);
163  void SetRegions(const QString &Window, frm_dir_map_t &Map, long long Total);
164  void SetGraph(const QString &Window, const QString &Graph, int64_t Timecode);
165  bool IsWindowVisible(const QString &Window);
166 
167  bool DialogVisible(const QString& Window = QString());
168  bool DialogHandleKeypress(QKeyEvent *Event);
170  void DialogQuit(void);
171  void DialogShow(const QString &Window, const QString &Text = "", int UpdateFor = 0);
172  void DialogSetText(const QString &Text);
173  void DialogBack(const QString& Text = "", const QVariant& Data = 0, bool Exit = false);
174  void DialogAddButton(const QString& Text, QVariant Data, bool Menu = false, bool Current = false);
175  void DialogGetText(InfoMap &Map);
176 
178  void EnableTeletext(bool Enable, int Page);
179  bool TeletextAction(const QString &Action);
180  void TeletextReset(void);
181  void TeletextClear(void);
182 
184  void EnableSubtitles(int Type, bool ForcedOnly = false);
185  void DisableForcedSubtitles(void);
186  void ClearSubtitles(void);
187  void DisplayDVDButton(AVSubtitle* DVDButton, QRect &Pos);
188 
189  void DisplayBDOverlay(MythBDOverlay *Overlay);
190  MythPlayer *GetPlayer(void) { return m_parent; }
191 
192  private:
193  void TearDown(void);
194  void LoadWindows(void);
195 
196  void CheckExpiry(void);
197  void SendHideEvent(void);
198  void SetExpiryPriv(const QString &Window, enum OSDTimeout Timeout, int CustomTimeout);
199 
200  private:
201  MythPlayer *m_parent { nullptr };
202  QObject *m_parentObject { nullptr };
204  QRect m_rect { };
206  MythScreenType *m_dialog { nullptr };
207  QString m_pulsedDialogText { };
208  QDateTime m_nextPulseUpdate { };
209  bool m_refresh { false };
210  bool m_visible { false };
211  std::array<int,4> m_timeouts { -1,3000,5000,13000 };
212  bool m_uiScaleOverride { false };
213  float m_savedWMult { 1.0F };
214  float m_savedHMult { 1.0F };
215  QRect m_savedUIRect { };
216  int m_fontStretch { 100 };
217  int m_savedFontStretch { 100 };
218  enum OSDFunctionalType m_functionalType { kOSDFunctionalType_Default };
219  QString m_functionalWindow { };
220  QMap<QString, MythScreenType*> m_children { };
221  QHash<MythScreenType*, QDateTime> m_expireTimes { };
222 };
223 
225 {
226  Q_OBJECT
227 
228  public:
229  OsdNavigation(QObject *RetObject, const QString &Name, OSD *Osd)
230  : MythScreenType((MythScreenType*)nullptr, Name),
231  m_retObject(RetObject), m_osd(Osd) {}
232  bool Create(void) override;
233  bool keyPressEvent(QKeyEvent *Event) override;
234  void SetTextFromMap(const InfoMap &Map) override;
235  void ShowMenu(void) override;
236 
237  int getVisibleGroup() const { return m_visibleGroup; }
238 
239  public slots:
240  void GeneralAction(void);
241  void More(void);
242 
243  protected:
244  void SendResult(int Result, const QString& Action);
245 
246  QObject *m_retObject { nullptr };
247  OSD *m_osd { nullptr };
252  char m_paused { 'X' };
253  char m_muted { 'X' };
254  int m_visibleGroup { 0 };
255  int m_maxGroupNum { -1 };
256  bool m_isVolumeControl { true };
257 };
258 
259 #endif
OSD::DialogAddButton
void DialogAddButton(const QString &Text, QVariant Data, bool Menu=false, bool Current=false)
Definition: osd.cpp:1052
OsdNavigation::More
void More(void)
Definition: osd.cpp:1362
OsdNavigation::m_muted
char m_muted
Definition: osd.h:253
OSD::m_expireTimes
QHash< MythScreenType *, QDateTime > m_expireTimes
Definition: osd.h:221
OSD::DialogGetText
void DialogGetText(InfoMap &Map)
Definition: osd.cpp:1059
OSD::SendHideEvent
void SendHideEvent(void)
Definition: osd.cpp:921
OSD::DialogVisible
bool DialogVisible(const QString &Window=QString())
Definition: osd.cpp:932
OSD::m_rect
QRect m_rect
Definition: osd.h:204
OSD::RevertUIScale
void RevertUIScale(void)
Definition: osd.cpp:216
OsdNavigation::m_playButton
MythUIButton * m_playButton
Definition: osd.h:248
OSD::m_visible
bool m_visible
Definition: osd.h:210
OSD::Draw
bool Draw(MythPainter *Painter, QSize Size, bool Repaint=false)
Definition: osd.cpp:623
OSD::TeletextAction
bool TeletextAction(const QString &Action)
Definition: osd.cpp:1121
OSD::IsWindowVisible
bool IsWindowVisible(const QString &Window)
Definition: osd.cpp:817
OSD::SetTimeouts
void SetTimeouts(int Short, int Medium, int Long)
Definition: osd.cpp:809
OSD::m_savedFontStretch
int m_savedFontStretch
Definition: osd.h:217
OSD::m_savedHMult
float m_savedHMult
Definition: osd.h:214
OSD::DisplayDVDButton
void DisplayDVDButton(AVSubtitle *DVDButton, QRect &Pos)
Definition: osd.cpp:1211
OSD::DialogHandleGesture
bool DialogHandleGesture(MythGestureEvent *Event)
Definition: osd.cpp:946
OSD::Reinit
bool Reinit(const QRect &Rect, float FontAspect)
Definition: osd.cpp:227
OsdNavigation::GeneralAction
void GeneralAction(void)
Definition: osd.cpp:1342
OSD::SetGraph
void SetGraph(const QString &Window, const QString &Graph, int64_t Timecode)
Definition: osd.cpp:608
mythtvexp.h
ChannelEditor::m_callsignEdit
MythUITextEdit * m_callsignEdit
Definition: osd.h:102
OSDHideEvent::m_osdFunctionalType
OSDFunctionalType m_osdFunctionalType
Definition: osd.h:78
OSD::ResetWindow
void ResetWindow(const QString &Window)
Definition: osd.cpp:825
MythScreenStack
Definition: mythscreenstack.h:15
frm_dir_map_t
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:82
ChannelEditor::keyPressEvent
bool keyPressEvent(QKeyEvent *Event) override
Key event handler.
Definition: osd.cpp:95
OsdNavigation::m_unMuteButton
MythUIButton * m_unMuteButton
Definition: osd.h:251
MythBDOverlay
Definition: mythbdoverlay.h:18
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:32
slots
unsigned int slots[4]
Definition: element.cpp:38
ChannelEditor::m_retObject
QObject * m_retObject
Definition: osd.h:106
OSD::TearDown
void TearDown(void)
Definition: osd.cpp:147
OSD::OverrideUIScale
void OverrideUIScale(bool Log=true)
Definition: osd.cpp:191
OSD::HideAll
void HideAll(bool KeepSubs=true, MythScreenType *Except=nullptr, bool DropNotification=false)
Definition: osd.cpp:267
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:44
OSD::SetText
void SetText(const QString &Window, const InfoMap &Map, OSDTimeout Timeout)
Definition: osd.cpp:377
OSD::m_functionalWindow
QString m_functionalWindow
Definition: osd.h:219
OSDHideEvent::kEventType
static Type kEventType
Definition: osd.h:75
kOSDTimeout_None
@ kOSDTimeout_None
Definition: osd.h:60
MythPlayer
Definition: mythplayer.h:164
OSD::DialogSetText
void DialogSetText(const QString &Text)
Definition: osd.cpp:1034
OSD::m_savedUIRect
QRect m_savedUIRect
Definition: osd.h:215
OSD::SetRegions
void SetRegions(const QString &Window, frm_dir_map_t &Map, long long Total)
Definition: osd.cpp:542
OSD::m_parent
MythPlayer * m_parent
Definition: osd.h:201
ChannelEditor::Probe
void Probe()
Definition: osd.cpp:70
OSD::LoadWindows
void LoadWindows(void)
Definition: osd.cpp:292
OsdNavigation::getVisibleGroup
int getVisibleGroup() const
Definition: osd.h:237
OSD::ClearSubtitles
void ClearSubtitles(void)
Definition: osd.cpp:1201
OSD::RemoveWindow
void RemoveWindow(const QString &Window)
Definition: osd.cpp:843
true
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
OsdNavigation::m_retObject
QObject * m_retObject
Definition: osd.h:246
kOSDFunctionalType_TimeStretchAdjust
@ kOSDFunctionalType_TimeStretchAdjust
Definition: osd.h:51
Action
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:40
OSD::m_parentObject
QObject * m_parentObject
Definition: osd.h:202
programtypes.h
OSD::DialogShow
void DialogShow(const QString &Window, const QString &Text="", int UpdateFor=0)
Definition: osd.cpp:963
OSD::SetExpiryPriv
void SetExpiryPriv(const QString &Window, enum OSDTimeout Timeout, int CustomTimeout)
Definition: osd.cpp:790
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
OsdNavigation::ShowMenu
void ShowMenu(void) override
Definition: osd.cpp:1328
SubtitleScreen
Definition: subtitlescreen.h:172
OSD::m_uiScaleOverride
bool m_uiScaleOverride
Definition: osd.h:212
OSD::HideWindow
void HideWindow(const QString &Window)
Definition: osd.cpp:899
OSD::GetWindow
MythScreenType * GetWindow(const QString &Window)
Definition: osd.cpp:854
kOSDFadeTime
#define kOSDFadeTime
Definition: osd.h:38
OSD::m_fadeTime
int m_fadeTime
Definition: osd.h:205
OSD::EnableTeletext
void EnableTeletext(bool Enable, int Page)
Definition: osd.cpp:1103
ChannelEditor::m_xmltvidEdit
MythUITextEdit * m_xmltvidEdit
Definition: osd.h:105
OSDTimeout
OSDTimeout
Definition: osd.h:57
OSD::TeletextClear
void TeletextClear(void)
Definition: osd.cpp:1142
kOSDFunctionalType_Default
@ kOSDFunctionalType_Default
Definition: osd.h:48
OSD::SetPainter
void SetPainter(MythPainter *Painter)
Definition: osd.cpp:177
Event
Event details.
Definition: zmdefines.h:26
kOSDFunctionalType_SmartForward
@ kOSDFunctionalType_SmartForward
Definition: osd.h:50
kOSDFunctionalType_SubtitleDelayAdjust
@ kOSDFunctionalType_SubtitleDelayAdjust
Definition: osd.h:54
OSD::m_refresh
bool m_refresh
Definition: osd.h:209
OSD::DisplayBDOverlay
void DisplayBDOverlay(MythBDOverlay *Overlay)
Definition: osd.cpp:1224
ChannelEditor
Definition: osd.h:81
MythOSDWindow
Definition: osd.h:109
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
mythtypes.h
kOSDTimeout_Short
@ kOSDTimeout_Short
Definition: osd.h:61
OSDHideEvent::GetFunctionalType
int GetFunctionalType()
Definition: osd.h:73
kOSDTimeout_Long
@ kOSDTimeout_Long
Definition: osd.h:63
OSD::EnableSubtitles
void EnableSubtitles(int Type, bool ForcedOnly=false)
Definition: osd.cpp:1185
OSD::SetFunctionalWindow
void SetFunctionalWindow(const QString &Window, enum OSDFunctionalType Type)
Definition: osd.cpp:889
OSDHideEvent::OSDHideEvent
OSDHideEvent(enum OSDFunctionalType OsdFunctionalType)
Definition: osd.h:69
kOSDTimeout_Ignore
@ kOSDTimeout_Ignore
Definition: osd.h:59
MythOSDWindow::m_themed
bool m_themed
Definition: osd.h:128
OSD::GetFontStretch
int GetFontStretch(void) const
Definition: osd.h:143
OSD::m_children
QMap< QString, MythScreenType * > m_children
Definition: osd.h:220
ChannelEditor::Confirm
void Confirm()
Definition: osd.cpp:65
OSD::InitTeletext
TeletextScreen * InitTeletext(void)
Definition: osd.cpp:1066
OSD::DisableForcedSubtitles
void DisableForcedSubtitles(void)
Definition: osd.cpp:1192
OSD::HasWindow
bool HasWindow(const QString &Window)
Definition: osd.cpp:927
kOSDFunctionalType_SubtitleZoomAdjust
@ kOSDFunctionalType_SubtitleZoomAdjust
Definition: osd.h:53
OsdNavigation::m_visibleGroup
int m_visibleGroup
Definition: osd.h:254
OsdNavigation::m_osd
OSD * m_osd
Definition: osd.h:247
OSD::m_currentPainter
MythPainter * m_currentPainter
Definition: osd.h:203
TeletextScreen
Definition: teletextscreen.h:10
OsdNavigation::m_paused
char m_paused
Definition: osd.h:252
OSD::m_pulsedDialogText
QString m_pulsedDialogText
Definition: osd.h:207
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
OSD::SetExpiry
void SetExpiry(const QString &Window, enum OSDTimeout Timeout, int CustomTimeout=0)
Definition: osd.cpp:776
MythOSDWindow::Create
bool Create(void) override
Definition: osd.h:120
kOSDFunctionalType_AudioSyncAdjust
@ kOSDFunctionalType_AudioSyncAdjust
Definition: osd.h:52
ChannelEditor::m_channumEdit
MythUITextEdit * m_channumEdit
Definition: osd.h:103
OSD::DialogQuit
void DialogQuit(void)
Definition: osd.cpp:953
OSD::GetPlayer
MythPlayer * GetPlayer(void)
Definition: osd.h:190
OsdNavigation::SendResult
void SendResult(int Result, const QString &Action)
Definition: osd.cpp:1333
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:692
OSD::~OSD
~OSD()
Definition: osd.cpp:142
MythPainter
Definition: mythpainter.h:32
OsdNavigation::m_isVolumeControl
bool m_isVolumeControl
Definition: osd.h:256
OSD::m_timeouts
std::array< int, 4 > m_timeouts
Definition: osd.h:211
Name
Definition: channelsettings.cpp:46
OSD::InitSubtitles
SubtitleScreen * InitSubtitles(void)
Definition: osd.cpp:1152
kOSDFunctionalType_PictureAdjust
@ kOSDFunctionalType_PictureAdjust
Definition: osd.h:49
OsdNavigation::keyPressEvent
bool keyPressEvent(QKeyEvent *Event) override
Key event handler.
Definition: osd.cpp:1289
ChannelEditor::Create
bool Create(void) override
Definition: osd.cpp:35
OSD::m_dialog
MythScreenType * m_dialog
Definition: osd.h:206
OSD::m_savedWMult
float m_savedWMult
Definition: osd.h:213
OsdNavigation::m_maxGroupNum
int m_maxGroupNum
Definition: osd.h:255
OSD::CheckExpiry
void CheckExpiry(void)
Definition: osd.cpp:735
OSD::PositionWindow
void PositionWindow(MythScreenType *Window)
Definition: osd.cpp:833
OSD::DialogBack
void DialogBack(const QString &Text="", const QVariant &Data=0, bool Exit=false)
Definition: osd.cpp:1041
MythOSDWindow::MythOSDWindow
MythOSDWindow(MythScreenStack *Parent, const QString &Name, bool Themed)
Definition: osd.h:114
ChannelEditor::SendResult
void SendResult(int result)
Definition: osd.cpp:119
OSD::SetValues
void SetValues(const QString &Window, const QHash< QString, int > &Map, OSDTimeout Timeout)
Definition: osd.cpp:319
OSD::IsVisible
bool IsVisible(void)
Definition: osd.cpp:249
OSD::Bounds
QRect Bounds(void) const
Definition: osd.h:142
OSD::m_fontStretch
int m_fontStretch
Definition: osd.h:216
OSD::DialogHandleKeypress
bool DialogHandleKeypress(QKeyEvent *Event)
Definition: osd.cpp:939
OSDFunctionalType
OSDFunctionalType
Definition: osd.h:46
OSD::Init
bool Init(const QRect &Rect, float FontAspect)
Definition: osd.cpp:155
ChannelEditor::GetText
void GetText(InfoMap &Map)
Definition: osd.cpp:87
ChannelEditor::m_channameEdit
MythUITextEdit * m_channameEdit
Definition: osd.h:104
MythGestureEvent
A custom event that represents a mouse gesture.
Definition: mythgesture.h:39
OsdNavigation
Definition: osd.h:224
Player
Definition: zmliveplayer.h:35
OSD::m_nextPulseUpdate
QDateTime m_nextPulseUpdate
Definition: osd.h:208
OsdNavigation::Create
bool Create(void) override
Definition: osd.cpp:1234
OSDHideEvent
Definition: osd.h:66
OsdNavigation::SetTextFromMap
void SetTextFromMap(const InfoMap &Map) override
Definition: osd.cpp:1379
OsdNavigation::m_muteButton
MythUIButton * m_muteButton
Definition: osd.h:250
kOSDTimeout_Med
@ kOSDTimeout_Med
Definition: osd.h:62
OSD::OSD
OSD(MythPlayer *Player, QObject *Parent, MythPainter *Painter)
Definition: osd.h:136
ChannelEditor::SetText
void SetText(const InfoMap &Map)
Definition: osd.cpp:75
OSD
Definition: osd.h:131
OsdNavigation::OsdNavigation
OsdNavigation(QObject *RetObject, const QString &Name, OSD *Osd)
Definition: osd.h:229
ChannelEditor::ChannelEditor
ChannelEditor(QObject *RetObject, const char *Name)
Definition: osd.h:86
mythscreentype.h
OSD::TeletextReset
void TeletextReset(void)
Definition: osd.cpp:1132
OsdNavigation::m_pauseButton
MythUIButton * m_pauseButton
Definition: osd.h:249