MythTV  master
importmusic.h
Go to the documentation of this file.
1 #ifndef IMPORTMUSIC_H_
2 #define IMPORTMUSIC_H_
3 
4 #include <iostream>
5 #include <vector>
6 using namespace std;
7 
8 #include <QStringList>
9 
10 #include <mythscreentype.h>
11 #include <mthread.h>
12 
13 class MusicMetadata;
14 class ImportMusicDialog;
15 
16 class MythUIText;
17 class MythUITextEdit;
18 class MythUIImage;
19 class MythUIButton;
20 class MythUIButtonList;
21 class MythUICheckBox;
22 class MythDialogBox;
23 
24 struct TrackInfo
25 {
27  bool isNewTune;
29 };
30 
32 {
33  public:
34  explicit FileScannerThread(ImportMusicDialog *parent);
35  void run() override; // MThread
36 
37  private:
38  ImportMusicDialog *m_parent {nullptr};
39 };
40 
41 class FileCopyThread: public MThread
42 {
43  public:
44  FileCopyThread(const QString &src, const QString &dst)
45  : MThread("FileCopy"), m_srcFile(src), m_dstFile(dst) {}
46  void run() override; // MThread
47 
48  bool GetResult(void) { return m_result; }
49 
50  private:
51  QString m_srcFile;
52  QString m_dstFile;
53  bool m_result {false};
54 };
55 
57 {
58 
59  Q_OBJECT
60 
61  public:
62  explicit ImportMusicDialog(MythScreenStack *parent);
64 
65  bool Create(void) override; // MythScreenType
66  bool keyPressEvent(QKeyEvent *) override; // MythScreenType
67  void customEvent(QEvent *) override; // MythUIType
68 
69  bool somethingWasImported() { return m_somethingWasImported; }
70  void doScan(void);
71  void doFileCopy(const QString &src, const QString &dst);
72 
73  public slots:
74  void addAllNewPressed(void);
75  void playPressed(void);
76  void addPressed(void);
77  void nextNewPressed(void);
78  void locationPressed(void);
79  void coverArtPressed(void);
80 
81  void nextPressed(void);
82  void prevPressed(void);
83  void showEditMetadataDialog(void);
84  void startScan(void);
85  void doExit(bool ok);
86 
87  // popup menu
88  void ShowMenu(void) override; // MythScreenType
89  void saveDefaults(void);
90  void setCompilation(void);
91  void setCompilationArtist(void);
92  void setArtist(void);
93  void setAlbum(void);
94  void setYear(void);
95  void setTrack(void);
96  void setGenre(void);
97  void setRating(void);
98  void setTitleWordCaps(void);
99  void setTitleInitialCap(void);
100  void metadataChanged(void);
101  void chooseBackend(void);
102  void setSaveHost(const QString& host);
103 
104  signals:
105  void importFinished(void);
106 
107  private:
108  void fillWidgets();
109  void scanDirectory(QString &directory, vector<TrackInfo*> *tracks);
110  void showImportCoverArtDialog();
111  static bool copyFile(const QString &src, const QString &dst);
112 
114  bool m_somethingWasImported {false};
115  vector<TrackInfo*> *m_tracks {nullptr};
116  QStringList m_sourceFiles;
117  int m_currentTrack {0};
118  MusicMetadata *m_playingMetaData {nullptr};
119 
120  // GUI stuff
121  MythUITextEdit *m_locationEdit {nullptr};
122  MythUIButton *m_locationButton {nullptr};
123  MythUIButton *m_scanButton {nullptr};
124  MythUIButton *m_coverartButton {nullptr};
125 
126  MythUIText *m_filenameText {nullptr};
127  MythUIText *m_compartistText {nullptr};
128  MythUIText *m_artistText {nullptr};
129  MythUIText *m_albumText {nullptr};
130  MythUIText *m_titleText {nullptr};
131  MythUIText *m_genreText {nullptr};
132  MythUIText *m_yearText {nullptr};
133  MythUIText *m_trackText {nullptr};
134 
135  MythUIButton *m_nextButton {nullptr};
136  MythUIButton *m_prevButton {nullptr};
137 
138  MythUIText *m_currentText {nullptr};
139  MythUIText *m_statusText {nullptr};
140 
141  MythUIButton *m_playButton {nullptr};
142  MythUIButton *m_addButton {nullptr};
143  MythUIButton *m_addallnewButton {nullptr};
144  MythUIButton *m_nextnewButton {nullptr};
145 
146  MythUICheckBox *m_compilationCheck {nullptr};
147 
148  // default metadata values
149  bool m_defaultCompilation {false};
152  QString m_defaultAlbum;
153  QString m_defaultGenre;
154  int m_defaultYear {0};
155  int m_defaultRating {0};
156  bool m_haveDefaults {false};
157 };
158 
160 
162 {
163 
164  Q_OBJECT
165 
166  public:
167 
168  ImportCoverArtDialog(MythScreenStack *parent, const QString &sourceDir,
169  MusicMetadata *metadata, const QString &storageDir)
170  : MythScreenType(parent, "import_coverart"), m_sourceDir(sourceDir),
171  m_musicStorageDir(storageDir), m_metadata(metadata) {}
172  ~ImportCoverArtDialog() = default;
173 
174  bool Create(void) override; // MythScreenType
175  bool keyPressEvent(QKeyEvent *) override; // MythScreenType
176 
177  public slots:
178  void copyPressed(void);
179  void prevPressed(void);
180  void nextPressed(void);
181  void selectorChanged(void);
182 
183  private:
184  void scanDirectory(void);
185  void updateStatus(void);
186  void updateTypeSelector(void);
187 
188  QStringList m_filelist;
189  QString m_sourceDir;
191  MusicMetadata *m_metadata {nullptr};
192  int m_currentFile {0};
193  QString m_saveFilename;
194 
195  //
196  // GUI stuff
197  //
198  MythUIText *m_filenameText {nullptr};
199  MythUIText *m_currentText {nullptr};
200  MythUIText *m_statusText {nullptr};
201  MythUIText *m_destinationText {nullptr};
202 
203  MythUIImage *m_coverartImage {nullptr};
204  MythUIButtonList *m_typeList {nullptr};
205 
206  MythUIButton *m_nextButton {nullptr};
207  MythUIButton *m_prevButton {nullptr};
208  MythUIButton *m_copyButton {nullptr};
209  MythUIButton *m_exitButton {nullptr};
210 };
211 
212 #endif
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
unsigned int slots[4]
Definition: element.c:38
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
Basic menu dialog, message and a list of options.
QString m_defaultAlbum
Definition: importmusic.h:152
bool isNewTune
Definition: importmusic.h:27
QString m_dstFile
Definition: importmusic.h:52
QStringList m_sourceFiles
Definition: importmusic.h:116
A text entry and edit widget.
QString m_defaultGenre
Definition: importmusic.h:153
bool GetResult(void)
Definition: importmusic.h:48
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
QString m_musicStorageDir
Definition: importmusic.h:113
A single button widget.
Definition: mythuibutton.h:21
bool metadataHasChanged
Definition: importmusic.h:28
QString m_defaultArtist
Definition: importmusic.h:151
bool somethingWasImported()
Definition: importmusic.h:69
QStringList m_filelist
Definition: importmusic.h:188
QString m_srcFile
Definition: importmusic.h:51
ImportCoverArtDialog(MythScreenStack *parent, const QString &sourceDir, MusicMetadata *metadata, const QString &storageDir)
Definition: importmusic.h:168
QString m_defaultCompArtist
Definition: importmusic.h:150
MusicMetadata * metadata
Definition: importmusic.h:26
Screen in which all other widgets are contained and rendered.
FileCopyThread(const QString &src, const QString &dst)
Definition: importmusic.h:44