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