MythTV master
mythnavigationoverlay.cpp
Go to the documentation of this file.
1// MythTV
6#include "mythplayerui.h"
8#include "tv_play.h"
9
11 MythPlayerUI *Player, const QString& Name, OSD* Osd)
12 : MythScreenType(static_cast<MythScreenType*>(nullptr), Name),
13 m_mainWindow(MainWindow),
14 m_tv(Tv),
15 m_player(Player),
16 m_parentOverlay(Osd)
17{
18}
19
21{
22 // Setup screen
23 if (!XMLParseBase::LoadWindowFromXML("osd.xml", "osd_navigation", this))
24 return false;
25
26 MythUIButton* more = nullptr;
27 UIUtilW::Assign(this, more, "more");
28 if (more)
30 UIUtilW::Assign(this, m_pauseButton, "PAUSE");
31 UIUtilW::Assign(this, m_playButton, "PLAY");
32 UIUtilW::Assign(this, m_muteButton, "MUTE");
33 UIUtilW::Assign(this, m_unMuteButton, "unmute");
34
35 // Listen for player state changes
38
39 // Default constructor uses kMuteOff. Set initial mute button state accordingly
40 // and then request latest state.
41 if (m_muteButton)
46
47 // TODO convert to video state when ready
48 bool paused = m_player->IsPaused();
49 m_paused = !paused;
50 PauseChanged(paused);
51
52 // Find number of groups and make sure only corrrect one is visible
53 MythUIGroup *group = nullptr;
54 for (int i = 0; i < 100 ; i++)
55 {
56 UIUtilW::Assign(this, group, QString("grp%1").arg(i));
57 if (!group)
58 break;
59
60 m_maxGroupNum = i;
61 if (i != m_visibleGroup)
62 group->SetVisible(false);
63 QList<MythUIType *> * children = group->GetAllChildren();
64 for (auto * child : std::as_const(*children))
65 {
66 if (child != more)
67 {
68 auto * button = dynamic_cast<MythUIButton*>(child);
69 if (button)
71 }
72 }
73 }
74
76
77 return true;
78}
79
81{
82 bool extendtimeout = true;
83 bool handled = false;
84
86 if (current && current->keyPressEvent(Event))
87 handled = true;
88
89 if (!handled)
90 {
91 QStringList actions;
92 handled = m_mainWindow->TranslateKeyPress("qt", Event, actions);
93
94 for (int i = 0; i < actions.size() && !handled; i++)
95 {
96 const QString& action = actions[i];
97 if (action == "ESCAPE" )
98 {
99 SendResult(-1, action);
100 handled = true;
101 extendtimeout = false;
102 }
103 }
104 }
105
106 if (!handled && MythScreenType::keyPressEvent(Event))
107 handled = true;
108
109 if (extendtimeout)
111
112 return handled;
113}
114
116{
117 SendResult(100, "MENU");
118}
119
120void MythNavigationOverlay::SendResult(int Result, const QString& Action)
121{
122 auto * dce = new DialogCompletionEvent("", Result, "", Action);
123 QCoreApplication::postEvent(m_tv, dce);
124}
125
127{
128 if (!(m_playButton && m_pauseButton))
129 return;
130
131 if (m_paused == Paused)
132 return;
133
134 m_paused = Paused;
138
140 {
141 current->LoseFocus();
143 }
144}
145
147{
149 return;
150
151 if (!(AudioState.m_volumeControl && AudioState.m_hasAudioOut))
152 {
155 }
156 else if (m_audioState.m_muteState != AudioState.m_muteState)
157 {
158 bool muted = AudioState.m_muteState == kMuteAll;
160 m_muteButton->SetVisible(!muted);
162
164 {
165 current->LoseFocus();
167 }
168 }
169
170 m_audioState = AudioState;
171}
172
174{
176 if (current)
177 {
178 QString name = current->objectName();
179 int result = 100;
180 int hashPos = name.indexOf('#');
181 if (hashPos > -1)
182 name.truncate(hashPos);
183 if (name == "INFO")
184 result = 0;
185 if (name == "unmute")
186 name = "MUTE";
187 SendResult(result, name);
188 }
189}
190
191// Switch to next group of icons. They have to be
192// named grp0, grp1, etc with no gaps in numbers.
194{
195 if (m_maxGroupNum <= 0)
196 return;
197
198 MythUIGroup* group = nullptr;
199 UIUtilW::Assign(this, group, QString("grp%1").arg(m_visibleGroup));
200 if (group != nullptr)
201 group->SetVisible(false);
202
203 // wrap around after last group displayed
205 m_visibleGroup = 0;
206
207 UIUtilW::Assign(this, group, QString("grp%1").arg(m_visibleGroup));
208 if (group != nullptr)
209 group->SetVisible(true);
210}
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:41
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:41
Event details.
Definition: zmdefines.h:28
A simple wrapper around audio state used to signal changes in the current state.
MuteState m_muteState
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
MythMainWindow * m_mainWindow
void SendResult(int Result, const QString &Action)
bool keyPressEvent(QKeyEvent *Event) override
Key event handler.
MythNavigationOverlay(MythMainWindow *MainWindow, TV *Tv, MythPlayerUI *Player, const QString &Name, OSD *Osd)
void AudioStateChanged(const MythAudioState &AudioState)
void AudioStateChanged(MythAudioState State)
bool IsPaused(void) const
Definition: mythplayer.h:151
void PauseChanged(bool Paused)
Screen in which all other widgets are contained and rendered.
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool SetFocusWidget(MythUIType *widget=nullptr)
A single button widget.
Definition: mythuibutton.h:22
void Clicked()
Create a group of widgets.
Definition: mythuigroup.h:12
The base class on which all widgets and screens are based.
Definition: mythuitype.h:86
QList< MythUIType * > * GetAllChildren(void)
Return a list of all child widgets.
Definition: mythuitype.cpp:202
virtual void SetVisible(bool visible)
void Hide(void)
void Show(void)
Definition: osd.h:94
void SetExpiry(const QString &Window, enum OSDTimeout Timeout, std::chrono::milliseconds CustomTimeout=0ms)
Definition: osd.cpp:590
Control TV playback.
Definition: tv_play.h:156
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:15
@ kOSDTimeout_Long
Definition: osd.h:61
static constexpr const char * OSD_DLG_NAVIGATE
Definition: osd.h:26
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
@ kMuteAll
Definition: volumebase.h:12