MythTV master
miniplayer.cpp
Go to the documentation of this file.
1
2// C++
3#include <chrono>
4
5// Qt
6#include <QTimer>
7
8// MythTV
12
13// mythmusic
14#include "decoder.h"
15#include "miniplayer.h"
16#include "musicplayer.h"
17
18
20 : MusicCommon(parent, nullptr, "music_miniplayer"),
21 m_displayTimer(new QTimer(this))
22{
24 m_displayTimer->setSingleShot(true);
26}
27
29{
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
41{
42 Close();
43}
44
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
65
66 return true;
67}
68
69bool 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
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 {
89 m_displayTimer->stop();
90 }
91 else if (action == "ESCAPE")
92 {
93 Close();
94 }
95 else if (action == "MENU")
96 {
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}
Definition: lcddevice.h:170
static LCD * Get(void)
Definition: lcddevice.cpp:69
bool Create(void) override
Definition: miniplayer.cpp:45
~MiniPlayer() override
Definition: miniplayer.cpp:28
void timerTimeout(void)
Definition: miniplayer.cpp:40
QTimer * m_displayTimer
Definition: miniplayer.h:27
MiniPlayer(MythScreenStack *parent)
Definition: miniplayer.cpp:19
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: miniplayer.cpp:69
MusicView m_currentView
Definition: musiccommon.h:141
bool CreateCommon(void)
Definition: musiccommon.cpp:78
bool keyPressEvent(QKeyEvent *e) override
Key event handler.
void removeListener(QObject *listener)
void autoShowPlayer(bool autoShow)
This will allow/disallow the mini player showing on track changes.
Definition: musicplayer.h:115
bool getAutoShowPlayer(void) const
Definition: musicplayer.h:116
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
virtual void Close()
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
@ MV_MINIPLAYER
Definition: musiccommon.h:43
MusicPlayer * gPlayer
Definition: musicplayer.cpp:38
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythMainWindow * GetMythMainWindow(void)