MythTV  master
cdrip.h
Go to the documentation of this file.
1 #ifndef CDRIP_H_
2 #define CDRIP_H_
3 
4 // qt
5 #include <QEvent>
6 #include <QVector>
7 #include <QCoreApplication>
8 
9 // mythtv
10 #include <musicmetadata.h>
11 #include <mythscreentype.h>
12 #include <mthread.h>
13 
14 
15 class MythUIText;
16 class MythUITextEdit;
17 class MythUIImage;
18 class MythUIButton;
19 class MythUIButtonList;
20 class MythUICheckBox;
21 
22 class CdDecoder;
23 class Encoder;
24 class Ripper;
25 
26 class CDScannerThread: public MThread
27 {
28  public:
29  explicit CDScannerThread(Ripper *ripper)
30  : MThread("CDScanner"), m_parent(ripper) {}
31  void run() override; // MThread
32 
33  private:
34  Ripper *m_parent {nullptr};
35 };
36 
37 class CDEjectorThread: public MThread
38 {
39  public:
40  explicit CDEjectorThread(Ripper *ripper)
41  : MThread("CDEjector"), m_parent(ripper) {}
42  void run() override; // MThread
43 
44  private:
45  Ripper *m_parent {nullptr};
46 };
47 
48 typedef struct
49 {
51  bool active;
52  int length;
53  bool isNew;
54 } RipTrack;
55 
57 
58 class RipStatus;
59 
60 class CDRipperThread: public MThread
61 {
63 
64  public:
65  CDRipperThread(RipStatus *parent, QString device,
66  QVector<RipTrack*> *tracks, int quality);
68 
69  void cancel(void);
70 
71  private:
72  void run(void) override; // MThread
73  int ripTrack(QString &cddevice, Encoder *encoder, int tracknum);
74 
75  bool isCancelled(void);
76 
77  RipStatus *m_parent {nullptr};
78  bool m_quit {false};
79  QString m_CDdevice;
80  int m_quality;
81  QVector<RipTrack*> *m_tracks {nullptr};
82 
83  long int m_totalSectors {0};
84  long int m_totalSectorsDone {0};
85 
86  int m_lastTrackPct {0};
88 
90 
91 };
92 
93 class Ripper : public MythScreenType
94 {
95  Q_OBJECT
96  public:
97  Ripper(MythScreenStack *parent, QString device);
98  ~Ripper(void);
99 
100  bool Create(void) override; // MythScreenType
101  bool keyPressEvent(QKeyEvent *) override; // MythScreenType
102  void customEvent(QEvent *) override; // MythUIType
103 
104  bool somethingWasRipped();
105  void scanCD(void);
106  void ejectCD(void);
107 
108  void ShowMenu(void) override; // MythScreenType
109 
110  protected slots:
111  void startRipper(void);
112  void startScanCD(void);
113  void startEjectCD(void);
114  void artistChanged(void);
115  void albumChanged(void);
116  void genreChanged(void);
117  void yearChanged(void);
118  void compilationChanged(bool state);
119  void switchTitlesAndArtists();
120  void searchArtist(void);
121  void searchAlbum(void);
122  void searchGenre(void);
123  void setArtist(const QString& artist);
124  void setAlbum(const QString& album);
125  void setGenre(const QString& genre);
126  void RipComplete(bool result);
129  void EjectFinished(void);
130  void ScanFinished(void);
131  void metadataChanged(void);
132  void showEditMetadataDialog(void);
133  void chooseBackend(void);
134  void setSaveHost(const QString& host);
135 
136  signals:
137  void ripFinished(void);
138 
139  private:
140  bool deleteExistingTrack(RipTrack *track);
141  void deleteAllExistingTracks(void);
142  void updateTrackList(void);
143  void updateTrackLengths(void);
144  void toggleTrackActive(RipTrack *);
145  void ShowConflictMenu(RipTrack *);
146 
148 
149  CdDecoder *m_decoder {nullptr};
150 
155 
157 
160 
167 
168  QVector<RipTrack*> *m_tracks {nullptr};
169 
171  QStringList m_searchList;
172  bool m_somethingwasripped {false};
173  bool m_mediaMonitorActive {false};
174 
175  QString m_CDdevice;
176 
179 };
180 
181 
182 class RipStatusEvent : public QEvent
183 {
184  public:
185  RipStatusEvent(Type type, int val) :
186  QEvent(type), m_text(""), m_value(val) {}
187  RipStatusEvent(Type type, const QString &val) :
188  QEvent(type), m_text(val) {}
189  ~RipStatusEvent() = default;
190 
191  QString m_text;
192  int m_value {-1};
193 
194  static Type kTrackTextEvent;
195  static Type kOverallTextEvent;
196  static Type kStatusTextEvent;
197  static Type kTrackProgressEvent;
198  static Type kTrackPercentEvent;
199  static Type kTrackStartEvent;
201  static Type kOverallPercentEvent;
202  static Type kOverallStartEvent;
203  static Type kCopyStartEvent;
204  static Type kCopyEndEvent;
205  static Type kFinishedEvent;
206  static Type kEncoderErrorEvent;
207 };
208 
209 class RipStatus : public MythScreenType
210 {
211  Q_OBJECT
212  public:
213  RipStatus(MythScreenStack *parent, const QString &device,
214  QVector<RipTrack*> *tracks, int quality)
215  : MythScreenType(parent, "ripstatus"), m_tracks(tracks),
216  m_quality(quality), m_CDdevice(device) {}
217  ~RipStatus(void);
218 
219  bool Create(void) override; // MythScreenType
220  bool keyPressEvent(QKeyEvent *) override; // MythScreenType
221 
222  signals:
223  void Result(bool);
224 
225  protected slots:
226  void startRip(void);
227 
228  private:
229  void customEvent(QEvent *event) override; // MythUIType
230 
231  QVector<RipTrack*> *m_tracks {nullptr};
233  QString m_CDdevice;
234 
242 
244 };
245 
246 #endif
MythUITextEdit * m_genreEdit
Definition: cdrip.h:153
MythUITextEdit * m_artistEdit
Definition: cdrip.h:151
void startEjectCD(void)
Definition: cdrip.cpp:1140
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
void searchAlbum(void)
Definition: cdrip.cpp:1270
void updateTrackLengths(void)
Definition: cdrip.cpp:1420
void switchTitlesAndArtists()
Definition: cdrip.cpp:1071
MythUITextEdit * m_albumEdit
Definition: cdrip.h:152
unsigned int slots[4]
Definition: element.c:38
QString m_musicStorageDir
Definition: cdrip.h:89
QString m_CDdevice
Definition: cdrip.h:175
int m_quality
Definition: cdrip.h:232
MythUIButton * m_switchTitleArtist
Definition: cdrip.h:161
void customEvent(QEvent *) override
Definition: cdrip.cpp:1441
MythUIText * m_trackPctText
Definition: cdrip.h:239
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
void deleteAllExistingTracks(void)
Definition: cdrip.cpp:843
MythUIButton * m_searchGenreButton
Definition: cdrip.h:166
void customEvent(QEvent *event) override
Definition: cdrip.cpp:1542
MusicMetadata * metadata
Definition: cdrip.h:50
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: cdrip.cpp:102
MythUIProgressBar * m_trackProgress
Definition: cdrip.h:241
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
CDRipperThread * m_ripperThread
Definition: cdrip.h:243
static Type kTrackProgressEvent
Definition: cdrip.h:197
RipStatus * m_parent
Definition: cdrip.h:77
Ripper * m_parent
Definition: cdrip.h:34
void scanCD(void)
Definition: cdrip.cpp:827
static Type kTrackStartEvent
Definition: cdrip.h:199
RipStatusEvent(Type type, int val)
Definition: cdrip.h:185
bool isNew
Definition: cdrip.h:53
void ShowMenu(void) override
Definition: cdrip.cpp:661
bool m_quit
Definition: cdrip.h:78
Q_DECLARE_METATYPE(GrabberScript *)
MythUIButton * m_scanButton
Definition: cdrip.h:162
MythUICheckBox * m_compilationCheck
Definition: cdrip.h:156
bool keyPressEvent(QKeyEvent *) override
Key event handler.
Definition: cdrip.cpp:1509
void ShowConflictMenu(RipTrack *)
Definition: cdrip.cpp:1395
void ripFinished(void)
CDScannerThread(Ripper *ripper)
Definition: cdrip.h:29
void setGenre(const QString &genre)
Definition: cdrip.cpp:1318
QString m_year
Definition: cdrip.h:170
void showEditMetadataDialog(void)
Definition: cdrip.cpp:683
void toggleTrackActive(MythUIButtonListItem *)
Definition: cdrip.cpp:1366
RipStatus(MythScreenStack *parent, const QString &device, QVector< RipTrack * > *tracks, int quality)
Definition: cdrip.h:213
void startRipper(void)
Definition: cdrip.cpp:1098
MythUIButton * m_searchAlbumButton
Definition: cdrip.h:165
Ripper(MythScreenStack *parent, QString device)
Definition: cdrip.cpp:519
void updateTrackList(void)
Definition: cdrip.cpp:1189
MythUITextEdit * m_yearEdit
Definition: cdrip.h:154
void ScanFinished(void)
Definition: cdrip.cpp:751
void EjectFinished(void)
Definition: cdrip.cpp:1155
int m_lastOverallPct
Definition: cdrip.h:87
static Type kCopyStartEvent
Definition: cdrip.h:203
~RipStatus(void)
Definition: cdrip.cpp:1481
int ripTrack(QString &cddevice, Encoder *encoder, int tracknum)
Definition: cdrip.cpp:398
static Type kTrackPercentEvent
Definition: cdrip.h:198
void startRip(void)
Definition: cdrip.cpp:1636
A text entry and edit widget.
QString m_albumName
Definition: cdrip.h:170
int m_lastTrackPct
Definition: cdrip.h:86
void setAlbum(const QString &album)
Definition: cdrip.cpp:1289
CDEjectorThread * m_ejectThread
Definition: cdrip.h:177
void RipComplete(bool result)
Definition: cdrip.cpp:1122
void artistChanged(void)
Definition: cdrip.cpp:945
bool m_mediaMonitorActive
Definition: cdrip.h:173
void searchArtist(void)
Definition: cdrip.cpp:1246
QString m_artistName
Definition: cdrip.h:170
CDScannerThread * m_scanThread
Definition: cdrip.h:178
void metadataChanged(void)
Definition: cdrip.cpp:1351
MythUIButton * m_searchArtistButton
Definition: cdrip.h:164
Ripper * m_parent
Definition: cdrip.h:45
bool keyPressEvent(QKeyEvent *) override
Key event handler.
Definition: cdrip.cpp:634
bool Create(void) override
Definition: cdrip.cpp:1488
~RipStatusEvent()=default
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: cdrip.cpp:111
bool somethingWasRipped()
Definition: cdrip.cpp:940
QString m_CDdevice
Definition: cdrip.h:79
void chooseBackend(void)
Definition: cdrip.cpp:688
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
bool isCancelled(void)
Definition: cdrip.cpp:197
void ejectCD(void)
Definition: cdrip.cpp:1163
MythUIText * m_trackText
Definition: cdrip.h:236
MythUIButtonList * m_trackList
Definition: cdrip.h:158
static Type kOverallProgressEvent
Definition: cdrip.h:200
void albumChanged(void)
Definition: cdrip.cpp:974
CDEjectorThread(Ripper *ripper)
Definition: cdrip.h:40
bool active
Definition: cdrip.h:51
QVector< RipTrack * > * m_tracks
Definition: cdrip.h:168
A single button widget.
Definition: mythuibutton.h:21
long int m_totalSectors
Definition: cdrip.h:83
QString m_text
Definition: cdrip.h:191
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: cdrip.cpp:202
static Type kTrackTextEvent
Definition: cdrip.h:194
void genreChanged(void)
Definition: cdrip.cpp:991
void searchGenre(void)
Definition: cdrip.cpp:1294
void cancel(void)
Definition: cdrip.cpp:192
void setArtist(const QString &artist)
Definition: cdrip.cpp:1265
static Type kFinishedEvent
Definition: cdrip.h:205
bool m_somethingwasripped
Definition: cdrip.h:172
Q_DECLARE_TR_FUNCTIONS(CDRipperThread)
QString m_musicStorageDir
Definition: cdrip.h:147
Definition: cdrip.h:48
int m_quality
Definition: cdrip.h:80
static Type kOverallPercentEvent
Definition: cdrip.h:201
QString m_genreName
Definition: cdrip.h:170
MythUIProgressBar * m_overallProgress
Definition: cdrip.h:240
MythUIText * m_overallPctText
Definition: cdrip.h:238
MythUIButton * m_ripButton
Definition: cdrip.h:163
Definition: cdrip.h:93
MythUIText * m_overallText
Definition: cdrip.h:235
~Ripper(void)
Definition: cdrip.cpp:550
CdDecoder * m_decoder
Definition: cdrip.h:149
RipStatusEvent(Type type, const QString &val)
Definition: cdrip.h:187
static Type kStatusTextEvent
Definition: cdrip.h:196
QVector< RipTrack * > * m_tracks
Definition: cdrip.h:81
QVector< RipTrack * > * m_tracks
Definition: cdrip.h:231
void setSaveHost(const QString &host)
Definition: cdrip.cpp:729
void compilationChanged(bool state)
Definition: cdrip.cpp:1025
static Type kOverallTextEvent
Definition: cdrip.h:195
Screen in which all other widgets are contained and rendered.
Progress bar widget.
static Type kOverallStartEvent
Definition: cdrip.h:202
MythUIText * m_statusText
Definition: cdrip.h:237
long int m_totalSectorsDone
Definition: cdrip.h:84
bool deleteExistingTrack(RipTrack *track)
Definition: cdrip.cpp:860
static Type kEncoderErrorEvent
Definition: cdrip.h:206
void Result(bool)
QStringList m_searchList
Definition: cdrip.h:171
void startScanCD(void)
Definition: cdrip.cpp:738
int m_value
Definition: cdrip.h:192
QString m_CDdevice
Definition: cdrip.h:233
int length
Definition: cdrip.h:52
bool Create(void) override
Definition: cdrip.cpp:572
CDRipperThread(RipStatus *parent, QString device, QVector< RipTrack * > *tracks, int quality)
Definition: cdrip.cpp:168
static Type kCopyEndEvent
Definition: cdrip.h:204
MythUIButtonList * m_qualityList
Definition: cdrip.h:159
void yearChanged(void)
Definition: cdrip.cpp:1008