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