MythTV  master
cdrip.h
Go to the documentation of this file.
1 #ifndef CDRIP_H_
2 #define CDRIP_H_
3 
4 #include <utility>
5 
6 // qt
7 #include <QCoreApplication>
8 #include <QEvent>
9 #include <QVector>
10 
11 // mythtv
12 #include <musicmetadata.h>
13 #include <mythscreentype.h>
14 #include <mthread.h>
15 
16 
17 class MythUIText;
18 class MythUITextEdit;
19 class MythUIImage;
20 class MythUIButton;
21 class MythUIButtonList;
22 class MythUICheckBox;
23 
24 class CdDecoder;
25 class Encoder;
26 class Ripper;
27 
28 class CDScannerThread: public MThread
29 {
30  public:
31  explicit CDScannerThread(Ripper *ripper)
32  : MThread("CDScanner"), m_parent(ripper) {}
33  void run() override; // MThread
34 
35  private:
36  Ripper *m_parent {nullptr};
37 };
38 
39 class CDEjectorThread: public MThread
40 {
41  public:
42  explicit CDEjectorThread(Ripper *ripper)
43  : MThread("CDEjector"), m_parent(ripper) {}
44  void run() override; // MThread
45 
46  private:
47  Ripper *m_parent {nullptr};
48 };
49 
50 struct RipTrack
51 {
53  bool active;
54  int length;
55  bool isNew;
56 };
57 
59 
60 class RipStatus;
61 
62 class CDRipperThread: public MThread
63 {
65 
66  public:
67  CDRipperThread(RipStatus *parent, QString device,
68  QVector<RipTrack*> *tracks, int quality);
69  ~CDRipperThread() override;
70 
71  void cancel(void);
72 
73  private:
74  void run(void) override; // MThread
75  int ripTrack(QString &cddevice, Encoder *encoder, int tracknum);
76 
77  bool isCancelled(void);
78 
79  RipStatus *m_parent {nullptr};
80  bool m_quit {false};
81  QString m_cdDevice;
82  int m_quality;
83  QVector<RipTrack*> *m_tracks {nullptr};
84 
85  long int m_totalSectors {0};
86  long int m_totalSectorsDone {0};
87 
88  int m_lastTrackPct {0};
90 
92 
93 };
94 
95 class Ripper : public MythScreenType
96 {
97  Q_OBJECT
98  public:
99  Ripper(MythScreenStack *parent, QString device);
100  ~Ripper(void) override;
101 
102  bool Create(void) override; // MythScreenType
103  bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
104  void customEvent(QEvent *event) override; // MythUIType
105 
106  bool somethingWasRipped();
107  void scanCD(void);
108  void ejectCD(void);
109 
110  void ShowMenu(void) override; // MythScreenType
111 
112  protected slots:
113  void startRipper(void);
114  void startScanCD(void);
115  void startEjectCD(void);
116  void artistChanged(void);
117  void albumChanged(void);
118  void genreChanged(void);
119  void yearChanged(void);
120  void compilationChanged(bool state);
121  void switchTitlesAndArtists();
122  void searchArtist(void);
123  void searchAlbum(void);
124  void searchGenre(void);
125  void setArtist(const QString& artist);
126  void setAlbum(const QString& album);
127  void setGenre(const QString& genre);
128  void RipComplete(bool result);
131  void EjectFinished(void);
132  void ScanFinished(void);
133  void metadataChanged(void);
134  void showEditMetadataDialog(void);
135  void chooseBackend(void);
136  void setSaveHost(const QString& host);
137 
138  signals:
139  void ripFinished(void);
140 
141  private:
142  bool deleteExistingTrack(RipTrack *track);
143  void deleteAllExistingTracks(void);
144  void updateTrackList(void);
145  void updateTrackLengths(void);
146  void toggleTrackActive(RipTrack *track);
147  void ShowConflictMenu(RipTrack *track);
148 
150 
151  CdDecoder *m_decoder {nullptr};
152 
157 
159 
162 
169 
170  QVector<RipTrack*> *m_tracks {nullptr};
171 
172  QString m_albumName;
173  QString m_artistName;
174  QString m_genreName;
175  QString m_year;
176  QStringList m_searchList;
177  bool m_somethingwasripped {false};
178  bool m_mediaMonitorActive {false};
179 
180  QString m_cdDevice;
181 
184 };
185 
186 
187 class RipStatusEvent : public QEvent
188 {
189  public:
190  RipStatusEvent(Type type, int val) :
191  QEvent(type), m_text(""), m_value(val) {}
192  RipStatusEvent(Type type, QString val) :
193  QEvent(type), m_text(std::move(val)) {}
194  ~RipStatusEvent() override = default;
195 
196  QString m_text;
197  int m_value {-1};
198 
199  static Type kTrackTextEvent;
200  static Type kOverallTextEvent;
201  static Type kStatusTextEvent;
202  static Type kTrackProgressEvent;
203  static Type kTrackPercentEvent;
204  static Type kTrackStartEvent;
206  static Type kOverallPercentEvent;
207  static Type kOverallStartEvent;
208  static Type kCopyStartEvent;
209  static Type kCopyEndEvent;
210  static Type kFinishedEvent;
211  static Type kEncoderErrorEvent;
212 };
213 
214 class RipStatus : public MythScreenType
215 {
216  Q_OBJECT
217  public:
218  RipStatus(MythScreenStack *parent, QString device,
219  QVector<RipTrack*> *tracks, int quality)
220  : MythScreenType(parent, "ripstatus"), m_tracks(tracks),
221  m_quality(quality), m_cdDevice(std::move(device)) {}
222  ~RipStatus(void) override;
223 
224  bool Create(void) override; // MythScreenType
225  bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
226 
227  signals:
228  void Result(bool);
229 
230  protected slots:
231  void startRip(void);
232 
233  private:
234  void customEvent(QEvent *event) override; // MythUIType
235 
236  QVector<RipTrack*> *m_tracks {nullptr};
238  QString m_cdDevice;
239 
247 
249 };
250 
251 #endif
~Ripper(void) override
Definition: cdrip.cpp:554
MythUITextEdit * m_genreEdit
Definition: cdrip.h:155
MythUITextEdit * m_artistEdit
Definition: cdrip.h:153
void startEjectCD(void)
Definition: cdrip.cpp:1138
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: cdrip.cpp:1504
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
void searchAlbum(void)
Definition: cdrip.cpp:1266
void updateTrackLengths(void)
Definition: cdrip.cpp:1415
void switchTitlesAndArtists()
Definition: cdrip.cpp:1072
MythUITextEdit * m_albumEdit
Definition: cdrip.h:154
unsigned int slots[4]
Definition: element.c:38
QString m_musicStorageDir
Definition: cdrip.h:91
int m_quality
Definition: cdrip.h:237
MythUIButton * m_switchTitleArtist
Definition: cdrip.h:163
void toggleTrackActive(MythUIButtonListItem *item)
Definition: cdrip.cpp:1362
MythUIText * m_trackPctText
Definition: cdrip.h:244
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
void deleteAllExistingTracks(void)
Definition: cdrip.cpp:846
MythUIButton * m_searchGenreButton
Definition: cdrip.h:168
void customEvent(QEvent *event) override
Definition: cdrip.cpp:1537
MusicMetadata * metadata
Definition: cdrip.h:52
QString m_cdDevice
Definition: cdrip.h:238
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
~RipStatusEvent() override=default
QString m_cdDevice
Definition: cdrip.h:180
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:246
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
CDRipperThread * m_ripperThread
Definition: cdrip.h:248
static Type kTrackProgressEvent
Definition: cdrip.h:202
RipStatus * m_parent
Definition: cdrip.h:79
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: cdrip.cpp:638
Ripper * m_parent
Definition: cdrip.h:36
~CDRipperThread() override
Definition: cdrip.cpp:186
void scanCD(void)
Definition: cdrip.cpp:830
static Type kTrackStartEvent
Definition: cdrip.h:204
RipStatusEvent(Type type, int val)
Definition: cdrip.h:190
bool isNew
Definition: cdrip.h:55
void ShowMenu(void) override
Definition: cdrip.cpp:665
bool m_quit
Definition: cdrip.h:80
Q_DECLARE_METATYPE(GrabberScript *)
MythUIButton * m_scanButton
Definition: cdrip.h:164
MythUICheckBox * m_compilationCheck
Definition: cdrip.h:158
void ripFinished(void)
CDScannerThread(Ripper *ripper)
Definition: cdrip.h:31
void setGenre(const QString &genre)
Definition: cdrip.cpp:1314
QString m_year
Definition: cdrip.h:175
void showEditMetadataDialog(void)
Definition: cdrip.cpp:687
void startRipper(void)
Definition: cdrip.cpp:1097
MythUIButton * m_searchAlbumButton
Definition: cdrip.h:167
Ripper(MythScreenStack *parent, QString device)
Definition: cdrip.cpp:523
void updateTrackList(void)
Definition: cdrip.cpp:1187
MythUITextEdit * m_yearEdit
Definition: cdrip.h:156
void ScanFinished(void)
Definition: cdrip.cpp:755
void EjectFinished(void)
Definition: cdrip.cpp:1153
int m_lastOverallPct
Definition: cdrip.h:89
static Type kCopyStartEvent
Definition: cdrip.h:208
int ripTrack(QString &cddevice, Encoder *encoder, int tracknum)
Definition: cdrip.cpp:398
static Type kTrackPercentEvent
Definition: cdrip.h:203
void startRip(void)
Definition: cdrip.cpp:1631
A text entry and edit widget.
QString m_albumName
Definition: cdrip.h:172
int m_lastTrackPct
Definition: cdrip.h:88
void setAlbum(const QString &album)
Definition: cdrip.cpp:1285
CDEjectorThread * m_ejectThread
Definition: cdrip.h:182
void RipComplete(bool result)
Definition: cdrip.cpp:1120
void artistChanged(void)
Definition: cdrip.cpp:947
bool m_mediaMonitorActive
Definition: cdrip.h:178
void searchArtist(void)
Definition: cdrip.cpp:1242
QString m_artistName
Definition: cdrip.h:173
CDScannerThread * m_scanThread
Definition: cdrip.h:183
void metadataChanged(void)
Definition: cdrip.cpp:1347
MythUIButton * m_searchArtistButton
Definition: cdrip.h:166
Ripper * m_parent
Definition: cdrip.h:47
bool Create(void) override
Definition: cdrip.cpp:1483
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:942
QString m_cdDevice
Definition: cdrip.h:81
void chooseBackend(void)
Definition: cdrip.cpp:692
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:1161
MythUIText * m_trackText
Definition: cdrip.h:241
MythUIButtonList * m_trackList
Definition: cdrip.h:160
static Type kOverallProgressEvent
Definition: cdrip.h:205
void albumChanged(void)
Definition: cdrip.cpp:976
CDEjectorThread(Ripper *ripper)
Definition: cdrip.h:42
bool active
Definition: cdrip.h:53
QVector< RipTrack * > * m_tracks
Definition: cdrip.h:170
A single button widget.
Definition: mythuibutton.h:21
long int m_totalSectors
Definition: cdrip.h:85
QString m_text
Definition: cdrip.h:196
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:199
void genreChanged(void)
Definition: cdrip.cpp:993
void searchGenre(void)
Definition: cdrip.cpp:1290
void cancel(void)
Definition: cdrip.cpp:192
void setArtist(const QString &artist)
Definition: cdrip.cpp:1261
static Type kFinishedEvent
Definition: cdrip.h:210
bool m_somethingwasripped
Definition: cdrip.h:177
Q_DECLARE_TR_FUNCTIONS(CDRipperThread)
QString m_musicStorageDir
Definition: cdrip.h:149
Definition: cdrip.h:50
int m_quality
Definition: cdrip.h:82
static Type kOverallPercentEvent
Definition: cdrip.h:206
QString m_genreName
Definition: cdrip.h:174
RipStatusEvent(Type type, QString val)
Definition: cdrip.h:192
MythUIProgressBar * m_overallProgress
Definition: cdrip.h:245
MythUIText * m_overallPctText
Definition: cdrip.h:243
MythUIButton * m_ripButton
Definition: cdrip.h:165
Definition: cdrip.h:95
MythUIText * m_overallText
Definition: cdrip.h:240
void ShowConflictMenu(RipTrack *track)
Definition: cdrip.cpp:1391
CdDecoder * m_decoder
Definition: cdrip.h:151
static Type kStatusTextEvent
Definition: cdrip.h:201
QVector< RipTrack * > * m_tracks
Definition: cdrip.h:83
QVector< RipTrack * > * m_tracks
Definition: cdrip.h:236
RipStatus(MythScreenStack *parent, QString device, QVector< RipTrack * > *tracks, int quality)
Definition: cdrip.h:218
~RipStatus(void) override
Definition: cdrip.cpp:1476
void setSaveHost(const QString &host)
Definition: cdrip.cpp:733
void compilationChanged(bool state)
Definition: cdrip.cpp:1027
static Type kOverallTextEvent
Definition: cdrip.h:200
Screen in which all other widgets are contained and rendered.
Progress bar widget.
static Type kOverallStartEvent
Definition: cdrip.h:207
MythUIText * m_statusText
Definition: cdrip.h:242
long int m_totalSectorsDone
Definition: cdrip.h:86
bool deleteExistingTrack(RipTrack *track)
Definition: cdrip.cpp:862
static Type kEncoderErrorEvent
Definition: cdrip.h:211
void Result(bool)
QStringList m_searchList
Definition: cdrip.h:176
void startScanCD(void)
Definition: cdrip.cpp:742
int m_value
Definition: cdrip.h:197
int length
Definition: cdrip.h:54
bool Create(void) override
Definition: cdrip.cpp:576
CDRipperThread(RipStatus *parent, QString device, QVector< RipTrack * > *tracks, int quality)
Definition: cdrip.cpp:168
static Type kCopyEndEvent
Definition: cdrip.h:209
void customEvent(QEvent *event) override
Definition: cdrip.cpp:1435
MythUIButtonList * m_qualityList
Definition: cdrip.h:161
void yearChanged(void)
Definition: cdrip.cpp:1010