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