MythTV  master
mythcaptionsoverlay.cpp
Go to the documentation of this file.
1 // MythTV other libs
3 
4 // MythTV
5 #include "Bluray/mythbdbuffer.h"
10 #include "mythcaptionsoverlay.h"
11 #include "mythplayerui.h"
12 
13 #define LOC QString("Captions: ")
14 
16  MythPlayerUI* Player, MythPainter* Painter)
17  : MythMediaOverlay(MainWindow, Tv, Player, Painter)
18 {
19 }
20 
22 {
24 }
25 
27 {
29 }
30 
31 void MythCaptionsOverlay::Draw(QRect Rect)
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  }
96  RevertUIScale();
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 
110 void 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 
129 bool 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  {
169  OverrideUIScale();
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  }
181  RevertUIScale();
182  }
183 
184  if (!sub)
185  LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create subtitle window");
186  return sub;
187 }
188 
189 void MythCaptionsOverlay::EnableSubtitles(int Type, bool ForcedOnly)
190 {
191  SubtitleScreen* sub = InitSubtitles();
192  if (sub)
193  sub->EnableSubtitles(Type, ForcedOnly);
194 }
195 
197 {
199  {
200  SubtitleScreen *sub = InitSubtitles();
201  if (sub)
202  sub->DisableForcedSubtitles();
203  }
204 }
205 
207 {
209  {
210  SubtitleScreen* sub = InitSubtitles();
211  if (sub)
212  sub->ClearAllSubtitles();
213  }
214 }
215 
216 void MythCaptionsOverlay::DisplayDVDButton(AVSubtitle* DVDButton, QRect &Pos)
217 {
218  if (DVDButton)
219  {
220  SubtitleScreen* sub = InitSubtitles();
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 }
MythCaptionsOverlay::TearDown
void TearDown() override
Definition: mythcaptionsoverlay.cpp:26
TeletextScreen::SetDisplaying
void SetDisplaying(bool display)
Definition: teletextscreen.cpp:239
MythMediaOverlay::RevertUIScale
void RevertUIScale()
Definition: mythmediaoverlay.cpp:154
MythCaptionsOverlay::~MythCaptionsOverlay
~MythCaptionsOverlay() override
Definition: mythcaptionsoverlay.cpp:21
OSD_WIN_BDOVERLAY
static constexpr const char * OSD_WIN_BDOVERLAY
Definition: mythcaptionsoverlay.h:10
MythCaptionsOverlay::EnableSubtitles
void EnableSubtitles(int Type, bool ForcedOnly=false)
Definition: mythcaptionsoverlay.cpp:189
OSD_WIN_TELETEXT
static constexpr const char * OSD_WIN_TELETEXT
Definition: mythcaptionsoverlay.h:7
mythplayerui.h
MythMediaOverlay::InitWindow
MythScreenType * InitWindow(const QString &Window, MythScreenType *Screen)
Definition: mythmediaoverlay.cpp:100
TeletextScreen::SetPage
void SetPage(int page, int subpage)
Definition: teletextscreen.cpp:233
teletextscreen.h
OSD_WIN_INTERACT
static constexpr const char * OSD_WIN_INTERACT
Definition: mythcaptionsoverlay.h:9
MythCaptionsOverlay::ClearSubtitles
void ClearSubtitles()
Definition: mythcaptionsoverlay.cpp:206
MythCaptionsOverlay::InitSubtitles
SubtitleScreen * InitSubtitles()
Definition: mythcaptionsoverlay.cpp:160
MythBDOverlay
Definition: mythbdoverlay.h:16
SubtitleScreen::Create
bool Create(void) override
Definition: subtitlescreen.cpp:1735
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythMediaOverlay::HideWindow
virtual void HideWindow(const QString &Window)
Definition: mythmediaoverlay.cpp:74
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
MythMediaOverlay::m_player
MythPlayerUI * m_player
Definition: mythmediaoverlay.h:52
MythCaptionsOverlay::DisplayBDOverlay
void DisplayBDOverlay(MythBDOverlay *Overlay)
Definition: mythcaptionsoverlay.cpp:229
Action
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:40
SubtitleScreen
Definition: subtitlescreen.h:176
MythCaptionsOverlay::EnableTeletext
void EnableTeletext(bool Enable, int Page)
Definition: mythcaptionsoverlay.cpp:110
MythPlayerUI
Definition: mythplayerui.h:12
MythMediaOverlay::HasWindow
bool HasWindow(const QString &Window)
Definition: mythmediaoverlay.cpp:87
MythMediaOverlay::m_painter
MythPainter * m_painter
Definition: mythmediaoverlay.h:53
MythMediaOverlay::m_fontStretch
int m_fontStretch
Definition: mythmediaoverlay.h:59
kDisplayDVDButton
@ kDisplayDVDButton
Definition: videoouttypes.h:19
mythlogging.h
subtitlescreen.h
SubtitleScreen::EnableSubtitles
void EnableSubtitles(int type, bool forced_only=false)
Definition: subtitlescreen.cpp:1428
MythCaptionsOverlay::TeletextAction
bool TeletextAction(const QString &Action, bool &Exit)
Definition: mythcaptionsoverlay.cpp:129
TeletextScreen::Reset
void Reset() override
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: teletextscreen.cpp:246
MythCaptionsOverlay::MythCaptionsOverlay
MythCaptionsOverlay(MythMainWindow *MainWindow, TV *Tv, MythPlayerUI *Player, MythPainter *Painter)
Definition: mythcaptionsoverlay.cpp:15
MythCaptionsOverlay::TeletextReset
void TeletextReset()
Definition: mythcaptionsoverlay.cpp:140
SubtitleScreen::DisplayDVDButton
void DisplayDVDButton(AVSubtitle *dvdButton, QRect &buttonPos)
Definition: subtitlescreen.cpp:1523
MythMediaOverlay::m_children
QMap< QString, MythScreenType * > m_children
Definition: mythmediaoverlay.h:61
SubtitleScreen::DisableForcedSubtitles
void DisableForcedSubtitles(void)
Definition: subtitlescreen.cpp:1486
interactivescreen.h
MythPainter::End
virtual void End()
Definition: mythpainter.h:55
TeletextScreen
Definition: teletextscreen.h:11
mythbdbuffer.h
InteractiveScreen
Definition: interactivescreen.h:9
MythCaptionsOverlay::TeletextClear
void TeletextClear()
Definition: mythcaptionsoverlay.cpp:150
MythMediaOverlay::GetWindow
virtual MythScreenType * GetWindow(const QString &Window)
Definition: mythmediaoverlay.cpp:92
MythMediaOverlay
Definition: mythmediaoverlay.h:30
mythbdoverlayscreen.h
MythCaptionsOverlay::InitTeletext
TeletextScreen * InitTeletext()
Definition: mythcaptionsoverlay.cpp:75
MythPainter
Definition: mythpainter.h:34
MythCaptionsOverlay::GetWindow
MythScreenType * GetWindow(const QString &Window) override
Definition: mythcaptionsoverlay.cpp:59
OSD_WIN_SUBTITLE
static constexpr const char * OSD_WIN_SUBTITLE
Definition: mythcaptionsoverlay.h:8
mythcaptionsoverlay.h
MythUIType::SetVisible
virtual void SetVisible(bool visible)
Definition: mythuitype.cpp:1105
LOC
#define LOC
Definition: mythcaptionsoverlay.cpp:13
MythBDOverlayScreen
Definition: mythbdoverlayscreen.h:10
MythCaptionsOverlay::Draw
void Draw(QRect Rect)
Definition: mythcaptionsoverlay.cpp:31
Player
Definition: zmliveplayer.h:34
MythMediaOverlay::TearDown
virtual void TearDown()
Definition: mythmediaoverlay.cpp:45
MythPainter::Begin
virtual void Begin(QPaintDevice *)
Definition: mythpainter.h:54
MythMediaOverlay::OverrideUIScale
void OverrideUIScale(bool Log=true)
Definition: mythmediaoverlay.cpp:121
MythMainWindow
Definition: mythmainwindow.h:28
TeletextScreen::Create
bool Create() override
Definition: teletextscreen.cpp:59
MythCaptionsOverlay::DisplayDVDButton
void DisplayDVDButton(AVSubtitle *DVDButton, QRect &Pos)
Definition: mythcaptionsoverlay.cpp:216
SubtitleScreen::ClearAllSubtitles
void ClearAllSubtitles(void)
Definition: subtitlescreen.cpp:1495
MythCaptionsOverlay::DisableForcedSubtitles
void DisableForcedSubtitles()
Definition: mythcaptionsoverlay.cpp:196
TV
Control TV playback.
Definition: tv_play.h:154