MythTV
master
mythtv
libs
libmythtv
overlays
mythnavigationoverlay.cpp
Go to the documentation of this file.
1
// MythTV
2
#include "
libmythui/mythdialogbox.h
"
3
#include "
libmythui/mythmainwindow.h
"
4
#include "
libmythui/mythuibutton.h
"
5
#include "
libmythui/mythuigroup.h
"
6
#include "
mythplayerui.h
"
7
#include "
overlays/mythnavigationoverlay.h
"
8
#include "
tv_play.h
"
9
10
MythNavigationOverlay::MythNavigationOverlay
(
MythMainWindow
*MainWindow,
TV
* Tv,
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
20
bool
MythNavigationOverlay::Create
()
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)
29
connect(more, &
MythUIButton::Clicked
,
this
, &
MythNavigationOverlay::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
36
connect(
m_player
, &
MythPlayerUI::PauseChanged
,
this
, &
MythNavigationOverlay::PauseChanged
);
37
connect(
m_player
, &
MythPlayerUI::AudioStateChanged
,
this
, &
MythNavigationOverlay::AudioStateChanged
);
38
39
// Default constructor uses kMuteOff. Set initial mute button state accordingly
40
// and then request latest state.
41
if
(
m_muteButton
)
42
m_muteButton
->
Show
();
43
if
(
m_unMuteButton
)
44
m_unMuteButton
->
Hide
();
45
m_player
->
RefreshAudioState
();
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)
70
connect(button, &
MythUIButton::Clicked
,
this
, &
MythNavigationOverlay::GeneralAction
);
71
}
72
}
73
}
74
75
BuildFocusList
();
76
77
return
true
;
78
}
79
80
bool
MythNavigationOverlay::keyPressEvent
(QKeyEvent*
Event
)
81
{
82
bool
extendtimeout =
true
;
83
bool
handled =
false
;
84
85
MythUIType
*
current
=
GetFocusWidget
();
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)
110
m_parentOverlay
->
SetExpiry
(
OSD_DLG_NAVIGATE
,
kOSDTimeout_Long
);
111
112
return
handled;
113
}
114
115
void
MythNavigationOverlay::ShowMenu
()
116
{
117
SendResult
(100,
"MENU"
);
118
}
119
120
void
MythNavigationOverlay::SendResult
(
int
Result,
const
QString&
Action
)
121
{
122
auto
* dce =
new
DialogCompletionEvent
(
""
, Result,
""
,
Action
);
123
QCoreApplication::postEvent(
m_tv
, dce);
124
}
125
126
void
MythNavigationOverlay::PauseChanged
(
bool
Paused)
127
{
128
if
(!(
m_playButton
&&
m_pauseButton
))
129
return
;
130
131
if
(
m_paused
== Paused)
132
return
;
133
134
m_paused
= Paused;
135
MythUIType
*
current
=
GetFocusWidget
();
136
m_playButton
->
SetVisible
(
m_paused
);
137
m_pauseButton
->
SetVisible
(!
m_paused
);
138
139
if
(
current
&& (
current
==
m_playButton
||
current
==
m_pauseButton
))
140
{
141
current
->LoseFocus();
142
SetFocusWidget
(
m_paused
?
m_playButton
:
m_pauseButton
);
143
}
144
}
145
146
void
MythNavigationOverlay::AudioStateChanged
(
const
MythAudioState
& AudioState)
147
{
148
if
(!(
m_muteButton
&&
m_unMuteButton
))
149
return
;
150
151
if
(!(AudioState.
m_volumeControl
&& AudioState.
m_hasAudioOut
))
152
{
153
m_muteButton
->
Hide
();
154
m_unMuteButton
->
Hide
();
155
}
156
else
if
(
m_audioState
.
m_muteState
!= AudioState.
m_muteState
)
157
{
158
bool
muted = AudioState.
m_muteState
==
kMuteAll
;
159
MythUIType
*
current
=
GetFocusWidget
();
160
m_muteButton
->
SetVisible
(!muted);
161
m_unMuteButton
->
SetVisible
(muted);
162
163
if
(
current
&& (
current
==
m_muteButton
||
current
==
m_unMuteButton
))
164
{
165
current
->LoseFocus();
166
SetFocusWidget
(muted ?
m_unMuteButton
:
m_muteButton
);
167
}
168
}
169
170
m_audioState
= AudioState;
171
}
172
173
void
MythNavigationOverlay::GeneralAction
()
174
{
175
MythUIType
*
current
=
GetFocusWidget
();
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.
193
void
MythNavigationOverlay::More
()
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
204
if
(++
m_visibleGroup
>
m_maxGroupNum
)
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
}
MythUIButton::Clicked
void Clicked()
MythNavigationOverlay::m_player
MythPlayerUI * m_player
Definition:
mythnavigationoverlay.h:34
MythNavigationOverlay::Create
bool Create() override
Definition:
mythnavigationoverlay.cpp:20
mythplayerui.h
MythNavigationOverlay::m_mainWindow
MythMainWindow * m_mainWindow
Definition:
mythnavigationoverlay.h:32
MythNavigationOverlay::m_visibleGroup
int m_visibleGroup
Definition:
mythnavigationoverlay.h:42
MythAudioState::m_muteState
MuteState m_muteState
Definition:
mythplayerstate.h:56
MythNavigationOverlay::m_pauseButton
MythUIButton * m_pauseButton
Definition:
mythnavigationoverlay.h:37
MythPlayer::IsPaused
bool IsPaused(void) const
Definition:
mythplayer.h:152
mythdialogbox.h
MythUIGroup
Create a group of widgets.
Definition:
mythuigroup.h:11
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition:
mythscreentype.h:45
MythNavigationOverlay::m_maxGroupNum
int m_maxGroupNum
Definition:
mythnavigationoverlay.h:43
MythUIType::GetAllChildren
QList< MythUIType * > * GetAllChildren(void)
Return a list of all child widgets.
Definition:
mythuitype.cpp:202
MythNavigationOverlay::m_parentOverlay
OSD * m_parentOverlay
Definition:
mythnavigationoverlay.h:35
MythNavigationOverlay::m_tv
TV * m_tv
Definition:
mythnavigationoverlay.h:33
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition:
mythdate.cpp:15
Action
An action (for this plugin) consists of a description, and a set of key sequences.
Definition:
action.h:40
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition:
mythscreentype.cpp:110
MythNavigationOverlay::GeneralAction
void GeneralAction()
Definition:
mythnavigationoverlay.cpp:173
MythNavigationOverlay::m_muteButton
MythUIButton * m_muteButton
Definition:
mythnavigationoverlay.h:38
MythPlayer::PauseChanged
void PauseChanged(bool Paused)
MythNavigationOverlay::AudioStateChanged
void AudioStateChanged(const MythAudioState &AudioState)
Definition:
mythnavigationoverlay.cpp:146
MythPlayerUI
Definition:
mythplayerui.h:12
MythUIType::Show
void Show(void)
Definition:
mythuitype.cpp:1144
MythNavigationOverlay::More
void More()
Definition:
mythnavigationoverlay.cpp:193
MythMainWindow::TranslateKeyPress
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
Definition:
mythmainwindow.cpp:1111
MythPlayerAudioUI::AudioStateChanged
void AudioStateChanged(MythAudioState State)
Event
Event details.
Definition:
zmdefines.h:27
MythScreenType::SetFocusWidget
bool SetFocusWidget(MythUIType *widget=nullptr)
Definition:
mythscreentype.cpp:115
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition:
mythscreentype.cpp:203
MythUIButton
A single button widget.
Definition:
mythuibutton.h:21
OSD_DLG_NAVIGATE
static constexpr const char * OSD_DLG_NAVIGATE
Definition:
osd.h:26
MythNavigationOverlay::m_unMuteButton
MythUIButton * m_unMuteButton
Definition:
mythnavigationoverlay.h:39
MythNavigationOverlay::m_audioState
MythAudioState m_audioState
Definition:
mythnavigationoverlay.h:41
kOSDTimeout_Long
@ kOSDTimeout_Long
Definition:
osd.h:61
UIUtilDisp::Assign
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition:
mythuiutils.h:27
MythUIType::Hide
void Hide(void)
Definition:
mythuitype.cpp:1139
mythuigroup.h
MythUIType
The base class on which all widgets and screens are based.
Definition:
mythuitype.h:85
MythNavigationOverlay::PauseChanged
void PauseChanged(bool Paused)
Definition:
mythnavigationoverlay.cpp:126
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition:
mythscreentype.cpp:401
MythNavigationOverlay::MythNavigationOverlay
MythNavigationOverlay(MythMainWindow *MainWindow, TV *Tv, MythPlayerUI *Player, const QString &Name, OSD *Osd)
Definition:
mythnavigationoverlay.cpp:10
MythNavigationOverlay::SendResult
void SendResult(int Result, const QString &Action)
Definition:
mythnavigationoverlay.cpp:120
MythNavigationOverlay::m_paused
bool m_paused
Definition:
mythnavigationoverlay.h:40
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition:
xmlparsebase.cpp:701
Name
Definition:
channelsettings.cpp:71
DialogCompletionEvent
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition:
mythdialogbox.h:41
MythUIType::SetVisible
virtual void SetVisible(bool visible)
Definition:
mythuitype.cpp:1105
MythPlayerAudioUI::RefreshAudioState
void RefreshAudioState()
Definition:
mythplayeraudioui.cpp:69
build_compdb.action
action
Definition:
build_compdb.py:9
MythAudioState
A simple wrapper around audio state used to signal changes in the current state.
Definition:
mythplayerstate.h:47
mythuibutton.h
MythNavigationOverlay::m_playButton
MythUIButton * m_playButton
Definition:
mythnavigationoverlay.h:36
mythnavigationoverlay.h
Player
Definition:
zmliveplayer.h:34
kMuteAll
@ kMuteAll
Definition:
volumebase.h:12
MythAudioState::m_volumeControl
bool m_volumeControl
Definition:
mythplayerstate.h:54
mythmainwindow.h
OSD::SetExpiry
void SetExpiry(const QString &Window, enum OSDTimeout Timeout, std::chrono::milliseconds CustomTimeout=0ms)
Definition:
osd.cpp:589
OSD
Definition:
osd.h:93
MythNavigationOverlay::keyPressEvent
bool keyPressEvent(QKeyEvent *Event) override
Key event handler.
Definition:
mythnavigationoverlay.cpp:80
MythMainWindow
Definition:
mythmainwindow.h:28
MythAudioState::m_hasAudioOut
bool m_hasAudioOut
Definition:
mythplayerstate.h:53
MythNavigationOverlay::ShowMenu
void ShowMenu() override
Definition:
mythnavigationoverlay.cpp:115
tv_play.h
TV
Control TV playback.
Definition:
tv_play.h:154
Generated on Sun Jan 5 2025 03:16:21 for MythTV by
1.8.17