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) const;
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() const;
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);
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);
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::EjectFinished
void EjectFinished(void)
Ripper::m_artistEdit
MythUITextEdit * m_artistEdit
Definition: cdrip.h:153
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(GrabberScript *)
Ripper::m_genreName
QString m_genreName
Definition: cdrip.h:174
RipTrack::metadata
MusicMetadata * metadata
Definition: cdrip.h:52
Ripper::m_somethingwasripped
bool m_somethingwasripped
Definition: cdrip.h:177
RipStatusEvent::kTrackPercentEvent
static Type kTrackPercentEvent
Definition: cdrip.h:203
CDEjectorThread::m_parent
Ripper * m_parent
Definition: cdrip.h:47
Ripper::m_cdDevice
QString m_cdDevice
Definition: cdrip.h:180
CDRipperThread::run
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:203
MythUIImage
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:98
slots
std::array< unsigned int, 4 > slots
Definition: element.cpp:38
CDEjectorThread::run
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:112
Ripper::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: cdrip.cpp:639
Ripper::m_qualityList
MythUIButtonList * m_qualityList
Definition: cdrip.h:161
CDEjectorThread
Definition: cdrip.h:40
Ripper::m_year
QString m_year
Definition: cdrip.h:175
Ripper::m_tracks
QVector< RipTrack * > * m_tracks
Definition: cdrip.h:170
RipStatus::Create
bool Create(void) override
Ripper::m_searchGenreButton
MythUIButton * m_searchGenreButton
Definition: cdrip.h:168
CDRipperThread::isCancelled
bool isCancelled(void) const
Definition: cdrip.cpp:198
Ripper::setGenre
void setGenre(const QString &genre)
Ripper::m_searchArtistButton
MythUIButton * m_searchArtistButton
Definition: cdrip.h:166
Ripper::deleteExistingTrack
bool deleteExistingTrack(RipTrack *track)
Definition: cdrip.cpp:863
CDScannerThread::m_parent
Ripper * m_parent
Definition: cdrip.h:36
RipStatusEvent::kCopyEndEvent
static Type kCopyEndEvent
Definition: cdrip.h:209
RipStatus::m_trackText
MythUIText * m_trackText
Definition: cdrip.h:241
CDRipperThread::m_lastOverallPct
int m_lastOverallPct
Definition: cdrip.h:89
RipStatusEvent::kOverallTextEvent
static Type kOverallTextEvent
Definition: cdrip.h:200
Ripper::ejectCD
void ejectCD(void)
Ripper::yearChanged
void yearChanged(void)
Ripper::toggleTrackActive
void toggleTrackActive(MythUIButtonListItem *item)
RipStatus
Definition: cdrip.h:215
CDRipperThread::m_cdDevice
QString m_cdDevice
Definition: cdrip.h:81
Ripper::scanCD
void scanCD(void)
Definition: cdrip.cpp:831
MythScreenStack
Definition: mythscreenstack.h:16
RipStatus::m_trackProgress
MythUIProgressBar * m_trackProgress
Definition: cdrip.h:246
Ripper::deleteAllExistingTracks
void deleteAllExistingTracks(void)
Definition: cdrip.cpp:847
Ripper::compilationChanged
void compilationChanged(bool state)
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:33
RipStatus::m_ripperThread
CDRipperThread * m_ripperThread
Definition: cdrip.h:248
Encoder
Definition: mythplugins/mythmusic/mythmusic/encoder.h:14
Ripper::m_decoder
CdDecoder * m_decoder
Definition: cdrip.h:151
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
RipStatus::m_trackPctText
MythUIText * m_trackPctText
Definition: cdrip.h:244
Ripper::m_scanButton
MythUIButton * m_scanButton
Definition: cdrip.h:164
MusicMetadata
Definition: musicmetadata.h:81
CDRipperThread::m_musicStorageDir
QString m_musicStorageDir
Definition: cdrip.h:91
RipStatus::RipStatus
RipStatus(MythScreenStack *parent, QString device, QVector< RipTrack * > *tracks, int quality)
Definition: cdrip.h:218
CDRipperThread::CDRipperThread
CDRipperThread(RipStatus *parent, QString device, QVector< RipTrack * > *tracks, int quality)
Definition: cdrip.cpp:169
RipStatus::m_overallText
MythUIText * m_overallText
Definition: cdrip.h:240
Ripper::m_trackList
MythUIButtonList * m_trackList
Definition: cdrip.h:160
RipStatusEvent::kCopyStartEvent
static Type kCopyStartEvent
Definition: cdrip.h:208
Ripper::ripFinished
void ripFinished(void)
RipStatus::~RipStatus
~RipStatus(void) override
RipTrack::length
int length
Definition: cdrip.h:54
RipStatus::startRip
void startRip(void)
Ripper::m_mediaMonitorActive
bool m_mediaMonitorActive
Definition: cdrip.h:178
Ripper::showEditMetadataDialog
void showEditMetadataDialog(MythUIButtonListItem *item)
Ripper::m_searchList
QStringList m_searchList
Definition: cdrip.h:176
MythUIButtonListItem
Definition: mythuibuttonlist.h:28
RipStatusEvent::kTrackTextEvent
static Type kTrackTextEvent
Definition: cdrip.h:199
RipStatusEvent::RipStatusEvent
RipStatusEvent(Type type, int val)
Definition: cdrip.h:190
CDRipperThread::m_totalSectors
long int m_totalSectors
Definition: cdrip.h:85
CdDecoder
Definition: cddecoder.h:27
Ripper::genreChanged
void genreChanged(void)
Ripper::startScanCD
void startScanCD(void)
Definition: cdrip.cpp:743
RipStatus::Result
void Result(bool)
Ripper::m_searchAlbumButton
MythUIButton * m_searchAlbumButton
Definition: cdrip.h:167
MythUIProgressBar
Progress bar widget.
Definition: mythuiprogressbar.h:13
CDRipperThread::m_tracks
QVector< RipTrack * > * m_tracks
Definition: cdrip.h:83
CDRipperThread::m_totalSectorsDone
long int m_totalSectorsDone
Definition: cdrip.h:86
RipStatus::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Ripper::m_scanThread
CDScannerThread * m_scanThread
Definition: cdrip.h:183
CDRipperThread::m_parent
RipStatus * m_parent
Definition: cdrip.h:79
CDScannerThread::run
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:103
RipStatusEvent::kEncoderErrorEvent
static Type kEncoderErrorEvent
Definition: cdrip.h:211
CDRipperThread::m_quit
bool m_quit
Definition: cdrip.h:80
Ripper::chooseBackend
void chooseBackend(void)
Definition: cdrip.cpp:693
MythUIButton
A single button widget.
Definition: mythuibutton.h:22
Ripper::Ripper
Ripper(MythScreenStack *parent, QString device)
Definition: cdrip.cpp:524
Ripper::albumChanged
void albumChanged(void)
Ripper::setArtist
void setArtist(const QString &artist)
RipStatusEvent::RipStatusEvent
RipStatusEvent(Type type, QString val)
Definition: cdrip.h:192
Ripper::m_artistName
QString m_artistName
Definition: cdrip.h:173
RipStatusEvent::kTrackStartEvent
static Type kTrackStartEvent
Definition: cdrip.h:204
RipTrack::active
bool active
Definition: cdrip.h:53
Ripper::searchGenre
void searchGenre(void)
Ripper
Definition: cdrip.h:96
Ripper::ShowMenu
void ShowMenu(void) override
Definition: cdrip.cpp:666
RipStatusEvent
Definition: cdrip.h:188
MythUICheckBox
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
Definition: mythuicheckbox.h:16
Ripper::updateTrackLengths
void updateTrackLengths(void)
CDRipperThread::m_lastTrackPct
int m_lastTrackPct
Definition: cdrip.h:88
Ripper::m_musicStorageDir
QString m_musicStorageDir
Definition: cdrip.h:149
CDRipperThread::~CDRipperThread
~CDRipperThread() override
Definition: cdrip.cpp:187
Ripper::m_switchTitleArtist
MythUIButton * m_switchTitleArtist
Definition: cdrip.h:163
RipStatus::customEvent
void customEvent(QEvent *event) override
Ripper::updateTrackList
void updateTrackList(void)
RipStatus::m_overallPctText
MythUIText * m_overallPctText
Definition: cdrip.h:243
CDScannerThread
Definition: cdrip.h:29
RipStatusEvent::kFinishedEvent
static Type kFinishedEvent
Definition: cdrip.h:210
RipStatusEvent::kOverallProgressEvent
static Type kOverallProgressEvent
Definition: cdrip.h:205
Ripper::Create
bool Create(void) override
Definition: cdrip.cpp:577
RipStatusEvent::kTrackProgressEvent
static Type kTrackProgressEvent
Definition: cdrip.h:202
RipStatusEvent::m_text
QString m_text
Definition: cdrip.h:196
Ripper::RipComplete
void RipComplete(bool result)
MythUIText
All purpose text widget, displays a text string.
Definition: mythuitext.h:29
Ripper::customEvent
void customEvent(QEvent *event) override
Ripper::startEjectCD
void startEjectCD(void)
RipStatus::m_cdDevice
QString m_cdDevice
Definition: cdrip.h:238
RipStatus::m_overallProgress
MythUIProgressBar * m_overallProgress
Definition: cdrip.h:245
Ripper::searchAlbum
void searchAlbum(void)
RipStatus::m_statusText
MythUIText * m_statusText
Definition: cdrip.h:242
Ripper::m_genreEdit
MythUITextEdit * m_genreEdit
Definition: cdrip.h:155
Ripper::showEditMetadataDialog
void showEditMetadataDialog(void)
Definition: cdrip.cpp:688
CDScannerThread::CDScannerThread
CDScannerThread(Ripper *ripper)
Definition: cdrip.h:31
Ripper::m_yearEdit
MythUITextEdit * m_yearEdit
Definition: cdrip.h:156
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
RipStatus::m_tracks
QVector< RipTrack * > * m_tracks
Definition: cdrip.h:236
mthread.h
Ripper::ShowConflictMenu
void ShowConflictMenu(RipTrack *track)
RipStatusEvent::kStatusTextEvent
static Type kStatusTextEvent
Definition: cdrip.h:201
CDRipperThread::m_quality
int m_quality
Definition: cdrip.h:82
CDRipperThread::cancel
void cancel(void)
Definition: cdrip.cpp:193
Ripper::setSaveHost
void setSaveHost(const QString &host)
Definition: cdrip.cpp:734
Ripper::startRipper
void startRipper(void)
Ripper::m_albumEdit
MythUITextEdit * m_albumEdit
Definition: cdrip.h:154
Ripper::switchTitlesAndArtists
void switchTitlesAndArtists()
Ripper::searchArtist
void searchArtist(void)
RipStatusEvent::~RipStatusEvent
~RipStatusEvent() override=default
CDRipperThread::Q_DECLARE_TR_FUNCTIONS
Q_DECLARE_TR_FUNCTIONS(CDRipperThread)
CDRipperThread::ripTrack
int ripTrack(QString &cddevice, Encoder *encoder, int tracknum)
Definition: cdrip.cpp:399
Ripper::artistChanged
void artistChanged(void)
CDEjectorThread::CDEjectorThread
CDEjectorThread(Ripper *ripper)
Definition: cdrip.h:42
Ripper::setAlbum
void setAlbum(const QString &album)
Ripper::m_ejectThread
CDEjectorThread * m_ejectThread
Definition: cdrip.h:182
Ripper::m_ripButton
MythUIButton * m_ripButton
Definition: cdrip.h:165
RipStatusEvent::m_value
int m_value
Definition: cdrip.h:197
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:144
CDRipperThread
Definition: cdrip.h:63
RipTrack
Definition: cdrip.h:51
Ripper::metadataChanged
void metadataChanged(void)
RipTrack::isNew
bool isNew
Definition: cdrip.h:55
RipStatus::m_quality
int m_quality
Definition: cdrip.h:237
musicmetadata.h
RipStatusEvent::kOverallStartEvent
static Type kOverallStartEvent
Definition: cdrip.h:207
Ripper::~Ripper
~Ripper(void) override
Definition: cdrip.cpp:555
Ripper::ScanFinished
void ScanFinished(void)
Definition: cdrip.cpp:756
mythscreentype.h
RipStatusEvent::kOverallPercentEvent
static Type kOverallPercentEvent
Definition: cdrip.h:206
Ripper::somethingWasRipped
bool somethingWasRipped() const
Ripper::toggleTrackActive
void toggleTrackActive(RipTrack *track)
Ripper::m_albumName
QString m_albumName
Definition: cdrip.h:172
Ripper::m_compilationCheck
MythUICheckBox * m_compilationCheck
Definition: cdrip.h:158