|
MythTV
0.26-pre
|
00001 // mythtv 00002 #include <mythcontext.h> 00003 #include <lcddevice.h> 00004 00005 // mythmusic 00006 #include "miniplayer.h" 00007 #include "musicplayer.h" 00008 #include "decoder.h" 00009 00010 MiniPlayer::MiniPlayer(MythScreenStack *parent) 00011 : MusicCommon(parent, "music_miniplayer") 00012 { 00013 m_displayTimer = new QTimer(this); 00014 m_displayTimer->setSingleShot(true); 00015 connect(m_displayTimer, SIGNAL(timeout()), this, SLOT(timerTimeout())); 00016 } 00017 00018 MiniPlayer::~MiniPlayer(void) 00019 { 00020 gPlayer->removeListener(this); 00021 00022 // Timers are deleted by Qt 00023 m_displayTimer->disconnect(); 00024 m_displayTimer = NULL; 00025 00026 if (LCD *lcd = LCD::Get()) 00027 lcd->switchToTime (); 00028 } 00029 00030 void MiniPlayer::timerTimeout(void) 00031 { 00032 Close(); 00033 } 00034 00035 bool MiniPlayer::Create(void) 00036 { 00037 bool err = false; 00038 00039 // Load the theme for this screen 00040 err = LoadWindowFromXML("music-ui.xml", "miniplayer", this); 00041 00042 if (!err) 00043 return false; 00044 00045 // find common widgets available on any view 00046 err = CreateCommon(); 00047 00048 if (err) 00049 { 00050 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'miniplayer'"); 00051 return false; 00052 } 00053 00054 m_displayTimer->start(10000); 00055 00056 BuildFocusList(); 00057 00058 return true; 00059 } 00060 00061 bool MiniPlayer::keyPressEvent(QKeyEvent *event) 00062 { 00063 // restart the display timer on any keypress if it is active 00064 if (m_displayTimer && m_displayTimer->isActive()) 00065 m_displayTimer->start(); 00066 00067 if (GetFocusWidget() && GetFocusWidget()->keyPressEvent(event)) 00068 return true; 00069 00070 bool handled = false; 00071 QStringList actions; 00072 handled = GetMythMainWindow()->TranslateKeyPress("Music", event, actions); 00073 00074 for (int i = 0; i < actions.size() && !handled; i++) 00075 { 00076 QString action = actions[i]; 00077 handled = true; 00078 00079 if (action == "SELECT") 00080 { 00081 if (m_displayTimer) 00082 m_displayTimer->stop(); 00083 } 00084 else if (action == "ESCAPE") 00085 { 00086 Close(); 00087 } 00088 else if (action == "MENU") 00089 { 00090 gPlayer->autoShowPlayer(!gPlayer->getAutoShowPlayer()); 00091 //showAutoMode(); 00092 } 00093 else 00094 handled = false; 00095 } 00096 00097 if (!handled && MusicCommon::keyPressEvent(event)) 00098 handled = true; 00099 00100 if (!handled && MythScreenType::keyPressEvent(event)) 00101 handled = true; 00102 00103 return handled; 00104 }
1.7.6.1