MythTV  master
musiccommon.h
Go to the documentation of this file.
1 #ifndef MUSICCOMMON_H_
2 #define MUSICCOMMON_H_
3 
4 // qt
5 #include <QKeyEvent>
6 #include <QObject>
7 
8 // mythtv
13 
14 // mythmusic
15 #include "musicplayer.h"
16 #include "playlist.h"
17 
18 class Output;
19 class Decoder;
20 class QTimer;
21 class MythUIProgressBar;
22 class MythUIImage;
23 class MythUIText;
24 class MythUIStateType;
25 class MythUIButton;
26 class MythUIVideo;
27 class MythUIButton;
28 class MythUICheckBox;
29 class MythMenu;
30 
32 {
44 };
45 
47 
49 {
50  Q_OBJECT
51 
52  protected:
53 
54  MusicCommon(MythScreenStack *parent, MythScreenType *parentScreen,
55  const QString &name);
56  ~MusicCommon(void) override;
57 
58  bool CreateCommon(void);
59 
60  void switchView(MusicView view);
61 
62  void customEvent(QEvent *event) override; // MythUIType
63  bool keyPressEvent(QKeyEvent *e) override; // MythScreenType
64 
65  void ShowMenu(void) override; // MythScreenType
66 
67  protected slots:
68  void viewExited(void);
69 
70  static void play(void);
71  void stop(void);
72  static void pause(void);
73  void previous(void);
74  void next(void);
75  void seekforward(void);
76  void seekback(void);
77  void seek(std::chrono::seconds pos);
78  void stopAll(void);
79  static void changeRating(bool increase);
80 
81  void searchButtonList(void);
82  MythMenu* createMainMenu(void);
83  MythMenu* createSubMenu(void);
84  MythMenu* createPlaylistMenu(void);
85  MythMenu* createPlayerMenu(void);
86  MythMenu* createQuickPlaylistsMenu(void);
87  MythMenu* createRepeatMenu(void);
88  MythMenu* createShuffleMenu(void);
89  MythMenu* createVisualizerMenu(void);
90  MythMenu* createPlaylistOptionsMenu(void);
91 
92  void playlistItemClicked(MythUIButtonListItem *item);
93  static void playlistItemVisible(MythUIButtonListItem *item);
94 
95  void fromCD(void);
96  void allTracks(void);
97  void byArtist(void);
98  void byAlbum(void);
99  void byGenre(void);
100  void byYear(void);
101  void byTitle(void);
102  void doUpdatePlaylist(void);
103 
104  protected:
105  void showExitMenu(void);
106  void showPlaylistOptionsMenu(bool addMainMenu = false);
107 
108  protected:
109  void init(bool startPlayback = true);
110  static QString getTimeString(std::chrono::seconds exTime, std::chrono::seconds maxTime);
111  void updateProgressBar(void);
112  static void setTrackOnLCD(MusicMetadata *mdata);
113  static void editTrackInfo(MusicMetadata *mdata);
114  void updateTrackInfo(MusicMetadata *mdata);
115  static void showTrackInfo(MusicMetadata *mdata);
116  void updateUIPlaylist(void);
117  void updatePlaylistStats(void);
118  void updateUIPlayedList(void); // for streaming
119  void updateRepeatMode(void);
120  void updateShuffleMode(bool updateUIList = false);
121 
122  void changeVolume(bool up) const;
123  static void changeSpeed(bool up);
124  void toggleMute(void) const;
125  static void toggleUpmix(void);
126  static void showVolume(void);
127  void updateVolume(void);
128  static void showSpeed(bool show);
129 
130  void startVisualizer(void);
131  void stopVisualizer(void);
132  void cycleVisualizer(void);
133  void switchVisualizer(const QString &visual);
134  void switchVisualizer(int visual);
135 
136  static void playFirstTrack();
137  bool restorePosition(int trackID);
138 
139  MythScreenType *m_parentScreen {nullptr};
140  MusicView m_currentView {};
141 
142  // visualiser stuff
143  MainVisual *m_mainvisual {nullptr};
144  bool m_fullscreenBlank {false};
145  bool m_cycleVisualizer {false};
146  bool m_randomVisualizer {false};
147 
148  QStringList m_visualModes;
149  unsigned int m_currentVisual {0};
150 
151  bool m_moveTrackMode {false};
152  bool m_movingTrack {false};
153 
154  bool m_controlVolume {true};
155 
156  int m_currentTrack {0};
157  std::chrono::seconds m_currentTime {0s};
158  std::chrono::seconds m_maxTime {0s};
159 
160  uint m_playlistTrackCount {0};
161  std::chrono::seconds m_playlistPlayedTime {0s};
162  std::chrono::seconds m_playlistMaxTime {0s};
163 
164  // for quick playlists
165  PlaylistOptions m_playlistOptions {PL_REPLACE, PL_CURRENT};
166  QString m_whereClause;
167 
168  // for adding tracks from playlist editor
169  QList<int> m_songList;
170 
171  // UI widgets
172  MythUIText *m_timeText {nullptr};
173  MythUIText *m_infoText {nullptr};
174  MythUIText *m_visualText {nullptr};
175  MythUIText *m_noTracksText {nullptr};
176 
177  MythUIStateType *m_shuffleState {nullptr};
178  MythUIStateType *m_repeatState {nullptr};
179 
180  MythUIStateType *m_movingTracksState {nullptr};
181 
182  MythUIStateType *m_ratingState {nullptr};
183 
184  MythUIProgressBar *m_trackProgress {nullptr};
185  MythUIText *m_trackProgressText {nullptr};
186  MythUIText *m_trackSpeedText {nullptr};
187  MythUIStateType *m_trackState {nullptr};
188 
189  MythUIStateType *m_muteState {nullptr};
190  MythUIText *m_volumeText {nullptr};
191 
192  MythUIProgressBar *m_playlistProgress {nullptr};
193 
194  MythUIButton *m_prevButton {nullptr};
195  MythUIButton *m_rewButton {nullptr};
196  MythUIButton *m_pauseButton {nullptr};
197  MythUIButton *m_playButton {nullptr};
198  MythUIButton *m_stopButton {nullptr};
199  MythUIButton *m_ffButton {nullptr};
200  MythUIButton *m_nextButton {nullptr};
201 
202  MythUIImage *m_coverartImage {nullptr};
203 
204  MythUIButtonList *m_currentPlaylist {nullptr};
205  MythUIButtonList *m_playedTracksList {nullptr};
206 
207  MythUIVideo *m_visualizerVideo {nullptr};
208 };
209 
211 {
212  Q_OBJECT
213  public:
214  MythMusicVolumeDialog(MythScreenStack *parent, const char *name)
215  : MythScreenType(parent, name, false) {}
216  ~MythMusicVolumeDialog(void) override;
217 
218  bool Create(void) override; // MythScreenType
219  bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
220 
221  protected:
222  void increaseVolume(void);
223  void decreaseVolume(void);
224  void toggleMute(void);
225 
226  void updateDisplay(void);
227 
228  QTimer *m_displayTimer {nullptr};
229  MythUIText *m_messageText {nullptr};
230  MythUIText *m_volText {nullptr};
231  MythUIStateType *m_muteState {nullptr};
232  MythUIProgressBar *m_volProgress {nullptr};
233 };
234 
236 {
237  Q_OBJECT
238  public:
239  TrackInfoDialog(MythScreenStack *parent, MusicMetadata *mdata, const char *name)
240  : MythScreenType(parent, name, false),
241  m_metadata(mdata) {}
242  ~TrackInfoDialog(void) override = default;
243 
244  bool Create(void) override; // MythScreenType
245  bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
246 
247  protected:
248  MusicMetadata *m_metadata {nullptr};
249 };
250 
251 #endif
PL_REPLACE
@ PL_REPLACE
Definition: playlist.h:24
MV_MINIPLAYER
@ MV_MINIPLAYER
Definition: musiccommon.h:43
MythMusicVolumeDialog
Definition: musiccommon.h:210
MythUIImage
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
MusicCommon::m_whereClause
QString m_whereClause
Definition: musiccommon.h:166
false
VERBOSE_PREAMBLE false
Definition: verbosedefs.h:89
MV_PLAYLISTEDITORTREE
@ MV_PLAYLISTEDITORTREE
Definition: musiccommon.h:35
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(MusicView)
MusicCommon::m_songList
QList< int > m_songList
Definition: musiccommon.h:169
TrackInfoDialog
Definition: musiccommon.h:235
MythScreenStack
Definition: mythscreenstack.h:16
MythScreenType::Create
virtual bool Create(void)
Definition: mythscreentype.cpp:266
MythUIType::customEvent
void customEvent(QEvent *event) override
Definition: mythuitype.cpp:1006
MV_PLAYLIST
@ MV_PLAYLIST
Definition: musiccommon.h:33
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
show
static void show(uint8_t *buf, int length)
Definition: ringbuffer.cpp:339
MusicMetadata
Definition: musicmetadata.h:80
startPlayback
static void startPlayback(void)
Definition: mythfrontend.cpp:575
MV_RADIO
@ MV_RADIO
Definition: musiccommon.h:42
MusicCommon::m_visualModes
QStringList m_visualModes
Definition: musiccommon.h:148
MythUIButtonListItem
Definition: mythuibuttonlist.h:41
mythpluginexport.h
Decoder
Definition: decoder.h:70
MythUIProgressBar
Progress bar widget.
Definition: mythuiprogressbar.h:12
MV_VISUALIZER
@ MV_VISUALIZER
Definition: musiccommon.h:37
PlaylistOptions
Definition: playlist.h:37
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
MV_PLAYLISTEDITORGALLERY
@ MV_PLAYLISTEDITORGALLERY
Definition: musiccommon.h:36
MV_ARTISTINFO
@ MV_ARTISTINFO
Definition: musiccommon.h:39
MV_LYRICS
@ MV_LYRICS
Definition: musiccommon.h:34
uint
unsigned int uint
Definition: compat.h:81
MythUICheckBox
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
Definition: mythuicheckbox.h:15
MythMusicVolumeDialog::MythMusicVolumeDialog
MythMusicVolumeDialog(MythScreenStack *parent, const char *name)
Definition: musiccommon.h:214
MainVisual
Definition: mainvisual.h:34
MythMenu
Definition: mythdialogbox.h:99
MythUIText
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:404
MV_ALBUMINFO
@ MV_ALBUMINFO
Definition: musiccommon.h:40
TrackInfoDialog::TrackInfoDialog
TrackInfoDialog(MythScreenStack *parent, MusicMetadata *mdata, const char *name)
Definition: musiccommon.h:239
MythUIVideo
Video widget, displays raw image data.
Definition: mythuivideo.h:14
audiooutput.h
MPLUGIN_PUBLIC
#define MPLUGIN_PUBLIC
Definition: mythpluginexport.h:9
MusicView
MusicView
Definition: musiccommon.h:31
MV_TRACKINFO
@ MV_TRACKINFO
Definition: musiccommon.h:41
MythScreenType::ShowMenu
virtual void ShowMenu(void)
Definition: mythscreentype.cpp:393
MV_SEARCH
@ MV_SEARCH
Definition: musiccommon.h:38
playlist.h
PL_CURRENT
@ PL_CURRENT
Definition: playlist.h:34
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:191
musicmetadata.h
MythUIStateType
This widget is used for grouping other widgets for display when a particular named state is called....
Definition: mythuistatetype.h:22
mythscreentype.h
MusicCommon
Definition: musiccommon.h:48
musicplayer.h