MythTV master
mythcaptionsoverlay.cpp
Go to the documentation of this file.
1// MythTV other libs
3
4// MythTV
10#include "mythcaptionsoverlay.h"
11#include "mythplayerui.h"
12
13#define LOC QString("Captions: ")
14
17 : MythMediaOverlay(MainWindow, Tv, Player, Painter)
18{
19}
20
22{
24}
25
27{
29}
30
32{
33 bool visible = false;
34 for (auto * screen : std::as_const(m_children))
35 {
36 if (screen->IsVisible())
37 {
38 visible = true;
39 screen->Pulse();
40 }
41 }
42
43 if (visible)
44 {
45 m_painter->Begin(nullptr);
46 for (auto * screen : std::as_const(m_children))
47 {
48 if (screen->IsVisible())
49 {
50 screen->Draw(m_painter, 0, 0, 255, Rect);
51 screen->SetAlpha(255);
52 screen->ResetNeedsRedraw();
53 }
54 }
55 m_painter->End();
56 }
57}
58
60{
61 if (m_children.contains(Window))
62 return m_children.value(Window);
63
64 MythScreenType* newwindow = nullptr;
65 if (Window == OSD_WIN_INTERACT)
66 newwindow = new InteractiveScreen(m_player, m_painter, Window);
67 else if (Window == OSD_WIN_BDOVERLAY)
68 newwindow = new MythBDOverlayScreen(m_player, m_painter, Window);
69 else
70 return MythMediaOverlay::GetWindow(Window);
71
72 return InitWindow(Window, newwindow);
73}
74
76{
77 TeletextScreen* teletext = nullptr;
78 if (m_children.contains(OSD_WIN_TELETEXT))
79 {
80 teletext = qobject_cast<TeletextScreen*>(m_children.value(OSD_WIN_TELETEXT));
81 }
82 else
83 {
86 if (teletext->Create())
87 {
88 m_children.insert(OSD_WIN_TELETEXT, teletext);
89 LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Created window %1").arg(OSD_WIN_TELETEXT));
90 }
91 else
92 {
93 delete teletext;
94 teletext = nullptr;
95 }
97 }
98
99 if (!teletext)
100 {
101 LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create Teletext window");
102 return nullptr;
103 }
104
106 teletext->SetDisplaying(false);
107 return teletext;
108}
109
110void MythCaptionsOverlay::EnableTeletext(bool Enable, int Page)
111{
113 if (tt)
114 {
115 tt->SetVisible(Enable);
116 tt->SetDisplaying(Enable);
117 if (Enable)
118 {
119 tt->SetPage(Page, -1);
120 LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Enabled teletext page %1").arg(Page));
121 }
122 else
123 {
124 LOG(VB_PLAYBACK, LOG_INFO, LOC + "Disabled teletext");
125 }
126 }
127}
128
129bool MythCaptionsOverlay::TeletextAction(const QString &Action, bool& Exit)
130{
132 {
133 auto* tt = qobject_cast<TeletextScreen*>(m_children.value(OSD_WIN_TELETEXT));
134 if (tt)
135 return tt->KeyPress(Action, Exit);
136 }
137 return false;
138}
139
141{
143 {
145 if (tt)
146 tt->Reset();
147 }
148}
149
151{
153 {
154 auto* tt = qobject_cast<TeletextScreen*>(m_children.value(OSD_WIN_TELETEXT));
155 if (tt)
156 tt->ClearScreen();
157 }
158}
159
161{
162 SubtitleScreen *sub = nullptr;
163 if (m_children.contains(OSD_WIN_SUBTITLE))
164 {
165 sub = qobject_cast<SubtitleScreen*>(m_children.value(OSD_WIN_SUBTITLE));
166 }
167 else
168 {
171 if (sub->Create())
172 {
173 m_children.insert(OSD_WIN_SUBTITLE, sub);
174 LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Created window %1").arg(OSD_WIN_SUBTITLE));
175 }
176 else
177 {
178 delete sub;
179 sub = nullptr;
180 }
182 }
183
184 if (!sub)
185 LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create subtitle window");
186 return sub;
187}
188
189void MythCaptionsOverlay::EnableSubtitles(int Type, bool ForcedOnly)
190{
192 if (sub)
193 sub->EnableSubtitles(Type, ForcedOnly);
194}
195
197{
199 {
201 if (sub)
203 }
204}
205
207{
209 {
211 if (sub)
212 sub->ClearAllSubtitles();
213 }
214}
215
216void MythCaptionsOverlay::DisplayDVDButton(AVSubtitle* DVDButton, QRect &Pos)
217{
218 if (DVDButton)
219 {
221 if (sub)
222 {
224 sub->DisplayDVDButton(DVDButton, Pos);
225 }
226 }
227}
228
230{
231 if (Overlay)
232 {
233 auto * bd = qobject_cast<MythBDOverlayScreen*>(GetWindow(OSD_WIN_BDOVERLAY));
234 if (bd)
235 bd->DisplayBDOverlay(Overlay);
236 }
237}
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:41
void EnableSubtitles(int Type, bool ForcedOnly=false)
void EnableTeletext(bool Enable, int Page)
void DisplayBDOverlay(MythBDOverlay *Overlay)
TeletextScreen * InitTeletext()
MythScreenType * GetWindow(const QString &Window) override
bool TeletextAction(const QString &Action, bool &Exit)
MythCaptionsOverlay(MythMainWindow *MainWindow, TV *Tv, MythPlayerUI *Player, MythPainter *Painter)
SubtitleScreen * InitSubtitles()
void DisplayDVDButton(AVSubtitle *DVDButton, QRect &Pos)
MythPlayerUI * m_player
virtual void TearDown()
MythPainter * m_painter
QMap< QString, MythScreenType * > m_children
virtual MythScreenType * GetWindow(const QString &Window)
void OverrideUIScale(bool Log=true)
MythScreenType * InitWindow(const QString &Window, MythScreenType *Screen)
virtual void HideWindow(const QString &Window)
bool HasWindow(const QString &Window)
virtual void Begin(QPaintDevice *)
Definition: mythpainter.h:54
virtual void End()
Definition: mythpainter.h:55
Screen in which all other widgets are contained and rendered.
virtual void SetVisible(bool visible)
void ClearAllSubtitles(void)
void DisableForcedSubtitles(void)
bool Create(void) override
void DisplayDVDButton(AVSubtitle *dvdButton, QRect &buttonPos)
void EnableSubtitles(int type, bool forced_only=false)
Control TV playback.
Definition: tv_play.h:156
void SetPage(int page, int subpage)
bool Create() override
void SetDisplaying(bool display)
void Reset() override
Reset the widget to it's original state, should not reset changes made by the theme.
#define LOC
static constexpr const char * OSD_WIN_SUBTITLE
static constexpr const char * OSD_WIN_TELETEXT
static constexpr const char * OSD_WIN_INTERACT
static constexpr const char * OSD_WIN_BDOVERLAY
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
@ kDisplayDVDButton
Definition: videoouttypes.h:19