MythTV
master
mythplugins
mythmusic
mythmusic
miniplayer.cpp
Go to the documentation of this file.
1
2
// C++
3
#include <chrono>
4
5
// Qt
6
#include <QTimer>
7
8
// MythTV
9
#include <
libmythbase/lcddevice.h
>
10
#include <
libmythbase/mythlogging.h
>
11
#include <
libmythui/mythmainwindow.h
>
12
13
// mythmusic
14
#include "
decoder.h
"
15
#include "
miniplayer.h
"
16
#include "
musicplayer.h
"
17
18
19
MiniPlayer::MiniPlayer
(
MythScreenStack
*parent)
20
:
MusicCommon
(parent, nullptr,
"music_miniplayer"
),
21
m_displayTimer(new QTimer(this))
22
{
23
m_currentView
=
MV_MINIPLAYER
;
24
m_displayTimer
->setSingleShot(
true
);
25
connect(
m_displayTimer
, &
QTimer::timeout
,
this
, &
MiniPlayer::timerTimeout
);
26
}
27
28
MiniPlayer::~MiniPlayer
(
void
)
29
{
30
gPlayer
->
removeListener
(
this
);
31
32
// Timers are deleted by Qt
33
m_displayTimer
->disconnect();
34
m_displayTimer
=
nullptr
;
35
36
if
(
LCD
*lcd =
LCD::Get
())
37
lcd->switchToTime ();
38
}
39
40
void
MiniPlayer::timerTimeout
(
void
)
41
{
42
Close
();
43
}
44
45
bool
MiniPlayer::Create
(
void
)
46
{
47
// Load the theme for this screen
48
bool
err =
LoadWindowFromXML
(
"music-ui.xml"
,
"miniplayer"
,
this
);
49
50
if
(!err)
51
return
false
;
52
53
// find common widgets available on any view
54
err =
CreateCommon
();
55
56
if
(err)
57
{
58
LOG
(VB_GENERAL, LOG_ERR,
"Cannot load screen 'miniplayer'"
);
59
return
false
;
60
}
61
62
m_displayTimer
->start(10s);
63
64
BuildFocusList
();
65
66
return
true
;
67
}
68
69
bool
MiniPlayer::keyPressEvent
(QKeyEvent *event)
70
{
71
// restart the display timer on any keypress if it is active
72
if
(
m_displayTimer
&&
m_displayTimer
->isActive())
73
m_displayTimer
->start();
74
75
if
(
GetFocusWidget
() &&
GetFocusWidget
()->
keyPressEvent
(event))
76
return
true
;
77
78
QStringList actions;
79
bool
handled =
GetMythMainWindow
()->
TranslateKeyPress
(
"Music"
, event, actions);
80
81
for
(
int
i = 0; i < actions.size() && !handled; i++)
82
{
83
const
QString&
action
= actions[i];
84
handled =
true
;
85
86
if
(
action
==
"SELECT"
)
87
{
88
if
(
m_displayTimer
)
89
m_displayTimer
->stop();
90
}
91
else
if
(
action
==
"ESCAPE"
)
92
{
93
Close
();
94
}
95
else
if
(
action
==
"MENU"
)
96
{
97
gPlayer
->
autoShowPlayer
(!
gPlayer
->
getAutoShowPlayer
());
98
//showAutoMode();
99
}
100
else
101
{
102
handled =
false
;
103
}
104
}
105
106
if
(!handled &&
MusicCommon::keyPressEvent
(event))
107
handled =
true
;
108
109
return
handled;
110
}
MusicCommon::m_currentView
MusicView m_currentView
Definition:
musiccommon.h:141
gPlayer
MusicPlayer * gPlayer
Definition:
musicplayer.cpp:38
hardwareprofile.smolt.timeout
float timeout
Definition:
smolt.py:101
MiniPlayer::MiniPlayer
MiniPlayer(MythScreenStack *parent)
Definition:
miniplayer.cpp:19
MusicPlayer::getAutoShowPlayer
bool getAutoShowPlayer(void) const
Definition:
musicplayer.h:116
MusicCommon::CreateCommon
bool CreateCommon(void)
Definition:
musiccommon.cpp:78
MythScreenType::Close
virtual void Close()
Definition:
mythscreentype.cpp:384
MusicCommon::keyPressEvent
bool keyPressEvent(QKeyEvent *e) override
Key event handler.
Definition:
musiccommon.cpp:587
MiniPlayer::timerTimeout
void timerTimeout(void)
Definition:
miniplayer.cpp:40
MiniPlayer::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition:
miniplayer.cpp:69
MythScreenStack
Definition:
mythscreenstack.h:16
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition:
mythlogging.h:39
MusicPlayer::removeListener
void removeListener(QObject *listener)
Definition:
musicplayer.cpp:162
LCD::Get
static LCD * Get(void)
Definition:
lcddevice.cpp:69
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition:
mythscreentype.cpp:111
mythlogging.h
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
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition:
mythscreentype.cpp:204
MiniPlayer::Create
bool Create(void) override
Definition:
miniplayer.cpp:45
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition:
xmlparsebase.cpp:701
MiniPlayer::~MiniPlayer
~MiniPlayer() override
Definition:
miniplayer.cpp:28
miniplayer.h
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition:
mythmainwindow.cpp:104
build_compdb.action
action
Definition:
build_compdb.py:9
MusicPlayer::autoShowPlayer
void autoShowPlayer(bool autoShow)
This will allow/disallow the mini player showing on track changes.
Definition:
musicplayer.h:115
lcddevice.h
MV_MINIPLAYER
@ MV_MINIPLAYER
Definition:
musiccommon.h:43
mythmainwindow.h
LCD
Definition:
lcddevice.h:169
MusicCommon
Definition:
musiccommon.h:49
decoder.h
MiniPlayer::m_displayTimer
QTimer * m_displayTimer
Definition:
miniplayer.h:27
musicplayer.h
Generated on Wed Feb 26 2025 03:17:51 for MythTV by
1.8.17