MythTV  0.27pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
miniplayer.cpp
Go to the documentation of this file.
1 // mythtv
2 #include <mythcontext.h>
3 #include <lcddevice.h>
4 
5 // mythmusic
6 #include "miniplayer.h"
7 #include "musicplayer.h"
8 #include "decoder.h"
9 
11  : MusicCommon(parent, "music_miniplayer")
12 {
14  m_displayTimer = new QTimer(this);
15  m_displayTimer->setSingleShot(true);
16  connect(m_displayTimer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
17 }
18 
20 {
21  gPlayer->removeListener(this);
22 
23  // Timers are deleted by Qt
24  m_displayTimer->disconnect();
25  m_displayTimer = NULL;
26 
27  if (LCD *lcd = LCD::Get())
28  lcd->switchToTime ();
29 }
30 
32 {
33  Close();
34 }
35 
37 {
38  bool err = false;
39 
40  // Load the theme for this screen
41  err = LoadWindowFromXML("music-ui.xml", "miniplayer", this);
42 
43  if (!err)
44  return false;
45 
46  // find common widgets available on any view
47  err = CreateCommon();
48 
49  if (err)
50  {
51  LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'miniplayer'");
52  return false;
53  }
54 
55  m_displayTimer->start(10000);
56 
58 
59  return true;
60 }
61 
62 bool MiniPlayer::keyPressEvent(QKeyEvent *event)
63 {
64  // restart the display timer on any keypress if it is active
65  if (m_displayTimer && m_displayTimer->isActive())
66  m_displayTimer->start();
67 
68  if (GetFocusWidget() && GetFocusWidget()->keyPressEvent(event))
69  return true;
70 
71  bool handled = false;
72  QStringList actions;
73  handled = GetMythMainWindow()->TranslateKeyPress("Music", event, actions);
74 
75  for (int i = 0; i < actions.size() && !handled; i++)
76  {
77  QString action = actions[i];
78  handled = true;
79 
80  if (action == "SELECT")
81  {
82  if (m_displayTimer)
83  m_displayTimer->stop();
84  }
85  else if (action == "ESCAPE")
86  {
87  Close();
88  }
89  else if (action == "MENU")
90  {
92  //showAutoMode();
93  }
94  else
95  handled = false;
96  }
97 
98  if (!handled && MusicCommon::keyPressEvent(event))
99  handled = true;
100 
101  if (!handled && MythScreenType::keyPressEvent(event))
102  handled = true;
103 
104  return handled;
105 }