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 <utility>
6 #include <vector>
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:
39 };
40 
41 class FileCopyThread: public MThread
42 {
43  public:
44  FileCopyThread(QString src, QString dst)
45  : MThread("FileCopy"), m_srcFile(std::move(src)),
46  m_dstFile(std::move(dst)) {}
47  void run() override; // MThread
48 
49  bool GetResult(void) const { return m_result; }
50 
51  private:
52  QString m_srcFile;
53  QString m_dstFile;
54  bool m_result {false};
55 };
56 
58 {
59 
60  Q_OBJECT
61 
62  public:
63  explicit ImportMusicDialog(MythScreenStack *parent);
64  ~ImportMusicDialog() override;
65 
66  bool Create(void) override; // MythScreenType
67  bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
68  void customEvent(QEvent *event) override; // MythUIType
69 
71  void doScan(void);
72  void doFileCopy(const QString &src, const QString &dst);
73 
74  public slots:
75  void addAllNewPressed(void);
76  void playPressed(void);
77  void addPressed(void);
78  void nextNewPressed(void);
79  void locationPressed(void);
80  void coverArtPressed(void);
81 
82  void nextPressed(void);
83  void prevPressed(void);
84  void showEditMetadataDialog(void);
85  void startScan(void);
86  void doExit(bool ok);
87 
88  // popup menu
89  void ShowMenu(void) override; // MythScreenType
90  void saveDefaults(void);
91  void setCompilation(void);
92  void setCompilationArtist(void);
93  void setArtist(void);
94  void setAlbum(void);
95  void setYear(void);
96  void setTrack(void);
97  void setGenre(void);
98  void setRating(void);
99  void setTitleWordCaps(void);
100  void setTitleInitialCap(void);
101  void metadataChanged(void);
102  void chooseBackend(void) const;
103  void setSaveHost(const QString& host);
104 
105  signals:
106  void importFinished(void);
107 
108  private:
109  void fillWidgets();
110  void scanDirectory(QString &directory, std::vector<TrackInfo*> *tracks);
112  static bool copyFile(const QString &src, const QString &dst);
113 
116  std::vector<TrackInfo*> *m_tracks {nullptr};
117  QStringList m_sourceFiles;
118  int m_currentTrack {0};
120 
121  // GUI stuff
126 
133  MythUIText *m_yearText {nullptr};
135 
138 
141 
146 
148 
149  // default metadata values
150  bool m_defaultCompilation {false};
153  QString m_defaultAlbum;
154  QString m_defaultGenre;
155  int m_defaultYear {0};
157  bool m_haveDefaults {false};
158 };
159 
161 
163 {
164 
165  Q_OBJECT
166 
167  public:
168 
169  ImportCoverArtDialog(MythScreenStack *parent, QString sourceDir,
170  MusicMetadata *metadata, QString storageDir)
171  : MythScreenType(parent, "import_coverart"),
172  m_sourceDir(std::move(sourceDir)),
173  m_musicStorageDir(std::move(storageDir)),
174  m_metadata(metadata) {}
175  ~ImportCoverArtDialog() override = default;
176 
177  bool Create(void) override; // MythScreenType
178  bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
179 
180  public slots:
181  void copyPressed(void);
182  void prevPressed(void);
183  void nextPressed(void);
184  void selectorChanged(void);
185 
186  private:
187  void scanDirectory(void);
188  void updateStatus(void);
189  void updateTypeSelector(void);
190 
191  QStringList m_filelist;
192  QString m_sourceDir;
195  int m_currentFile {0};
196  QString m_saveFilename;
197 
198  //
199  // GUI stuff
200  //
205 
208 
213 };
214 
215 #endif
ImportMusicDialog::nextPressed
void nextPressed(void)
Definition: importmusic.cpp:336
ImportCoverArtDialog::m_prevButton
MythUIButton * m_prevButton
Definition: importmusic.h:210
ImportMusicDialog::m_currentTrack
int m_currentTrack
Definition: importmusic.h:118
ImportMusicDialog::m_albumText
MythUIText * m_albumText
Definition: importmusic.h:130
ImportCoverArtDialog::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: importmusic.cpp:880
ImportMusicDialog::m_defaultAlbum
QString m_defaultAlbum
Definition: importmusic.h:153
ImportMusicDialog::setTitleWordCaps
void setTitleWordCaps(void)
Definition: importmusic.cpp:832
MythUIImage
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:98
ImportMusicDialog::setArtist
void setArtist(void)
Definition: importmusic.cpp:755
ImportMusicDialog::m_somethingWasImported
bool m_somethingWasImported
Definition: importmusic.h:115
ImportMusicDialog::m_defaultYear
int m_defaultYear
Definition: importmusic.h:155
ImportMusicDialog::playPressed
void playPressed(void)
Definition: importmusic.cpp:317
ImportMusicDialog::importFinished
void importFinished(void)
ImportMusicDialog::nextNewPressed
void nextNewPressed(void)
Definition: importmusic.cpp:442
ImportCoverArtDialog::Create
bool Create(void) override
Definition: importmusic.cpp:911
TrackInfo::metadataHasChanged
bool metadataHasChanged
Definition: importmusic.h:28
ImportMusicDialog::setCompilationArtist
void setCompilationArtist(void)
Definition: importmusic.cpp:744
ImportMusicDialog::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: importmusic.cpp:134
ImportMusicDialog::m_scanButton
MythUIButton * m_scanButton
Definition: importmusic.h:124
ImportMusicDialog::addPressed
void addPressed(void)
Definition: importmusic.cpp:345
FileScannerThread
Definition: importmusic.h:32
ImportMusicDialog::m_genreText
MythUIText * m_genreText
Definition: importmusic.h:132
FileCopyThread::m_srcFile
QString m_srcFile
Definition: importmusic.h:52
ImportMusicDialog::m_statusText
MythUIText * m_statusText
Definition: importmusic.h:140
ImportMusicDialog::somethingWasImported
bool somethingWasImported() const
Definition: importmusic.h:70
MythScreenStack
Definition: mythscreenstack.h:16
ImportCoverArtDialog::m_currentFile
int m_currentFile
Definition: importmusic.h:195
ImportCoverArtDialog::prevPressed
void prevPressed(void)
Definition: importmusic.cpp:1002
ImportMusicDialog::m_compilationCheck
MythUICheckBox * m_compilationCheck
Definition: importmusic.h:147
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:33
ImportMusicDialog::m_sourceFiles
QStringList m_sourceFiles
Definition: importmusic.h:117
ImportCoverArtDialog::m_filenameText
MythUIText * m_filenameText
Definition: importmusic.h:201
ImportMusicDialog::coverArtPressed
void coverArtPressed(void)
Definition: importmusic.cpp:312
ImportMusicDialog::m_defaultCompilation
bool m_defaultCompilation
Definition: importmusic.h:150
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
ImportMusicDialog::m_tracks
std::vector< TrackInfo * > * m_tracks
Definition: importmusic.h:116
ImportMusicDialog::startScan
void startScan(void)
Definition: importmusic.cpp:501
ImportMusicDialog::locationPressed
void locationPressed(void)
Definition: importmusic.cpp:297
ImportCoverArtDialog::updateTypeSelector
void updateTypeSelector(void)
Definition: importmusic.cpp:1118
MusicMetadata
Definition: musicmetadata.h:81
ImportMusicDialog::Create
bool Create(void) override
Definition: importmusic.cpp:238
ImportMusicDialog::m_defaultRating
int m_defaultRating
Definition: importmusic.h:156
ImportMusicDialog::ShowMenu
void ShowMenu(void) override
Definition: importmusic.cpp:624
ImportCoverArtDialog::m_copyButton
MythUIButton * m_copyButton
Definition: importmusic.h:211
ImportCoverArtDialog::m_currentText
MythUIText * m_currentText
Definition: importmusic.h:202
ImportCoverArtDialog::~ImportCoverArtDialog
~ImportCoverArtDialog() override=default
ImportMusicDialog::m_addButton
MythUIButton * m_addButton
Definition: importmusic.h:143
ImportMusicDialog::setRating
void setRating(void)
Definition: importmusic.cpp:813
ImportMusicDialog::setTitleInitialCap
void setTitleInitialCap(void)
Definition: importmusic.cpp:822
ImportMusicDialog::m_titleText
MythUIText * m_titleText
Definition: importmusic.h:131
ImportMusicDialog::metadataChanged
void metadataChanged(void)
Definition: importmusic.cpp:615
TrackInfo::isNewTune
bool isNewTune
Definition: importmusic.h:27
ImportCoverArtDialog::m_metadata
MusicMetadata * m_metadata
Definition: importmusic.h:194
ImportCoverArtDialog::nextPressed
void nextPressed(void)
Definition: importmusic.cpp:1012
ImportCoverArtDialog::m_musicStorageDir
QString m_musicStorageDir
Definition: importmusic.h:193
ImportMusicDialog::setTrack
void setTrack(void)
Definition: importmusic.cpp:794
ImportMusicDialog::m_playingMetaData
MusicMetadata * m_playingMetaData
Definition: importmusic.h:119
ImportMusicDialog::m_prevButton
MythUIButton * m_prevButton
Definition: importmusic.h:137
ImportMusicDialog::~ImportMusicDialog
~ImportMusicDialog() override
Definition: importmusic.cpp:68
FileCopyThread
Definition: importmusic.h:42
MythDialogBox
Basic menu dialog, message and a list of options.
Definition: mythdialogbox.h:167
ImportMusicDialog::m_nextButton
MythUIButton * m_nextButton
Definition: importmusic.h:136
ImportMusicDialog::showEditMetadataDialog
void showEditMetadataDialog(void)
Definition: importmusic.cpp:591
ImportMusicDialog::doScan
void doScan(void)
Definition: importmusic.cpp:540
ImportMusicDialog::m_artistText
MythUIText * m_artistText
Definition: importmusic.h:129
ImportMusicDialog::m_compartistText
MythUIText * m_compartistText
Definition: importmusic.h:128
ImportCoverArtDialog::ImportCoverArtDialog
ImportCoverArtDialog(MythScreenStack *parent, QString sourceDir, MusicMetadata *metadata, QString storageDir)
Definition: importmusic.h:169
ImportMusicDialog::m_nextnewButton
MythUIButton * m_nextnewButton
Definition: importmusic.h:145
MythUIButton
A single button widget.
Definition: mythuibutton.h:22
ImportCoverArtDialog::m_filelist
QStringList m_filelist
Definition: importmusic.h:191
ImportCoverArtDialog::m_exitButton
MythUIButton * m_exitButton
Definition: importmusic.h:212
ImportCoverArtDialog::selectorChanged
void selectorChanged(void)
Definition: importmusic.cpp:970
ImportMusicDialog::setYear
void setYear(void)
Definition: importmusic.cpp:783
ImportMusicDialog::ImportMusicDialog
ImportMusicDialog(MythScreenStack *parent)
Definition: importmusic.cpp:58
ImportMusicDialog::saveDefaults
void saveDefaults(void)
Definition: importmusic.cpp:709
TrackInfo
Definition: importmusic.h:25
ImportMusicDialog::m_filenameText
MythUIText * m_filenameText
Definition: importmusic.h:127
ImportMusicDialog::scanDirectory
void scanDirectory(QString &directory, std::vector< TrackInfo * > *tracks)
Definition: importmusic.cpp:548
FileCopyThread::FileCopyThread
FileCopyThread(QString src, QString dst)
Definition: importmusic.h:44
ImportMusicDialog::doExit
void doExit(bool ok)
Definition: importmusic.cpp:291
MythUICheckBox
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
Definition: mythuicheckbox.h:16
FileCopyThread::m_dstFile
QString m_dstFile
Definition: importmusic.h:53
FileCopyThread::m_result
bool m_result
Definition: importmusic.h:54
ImportCoverArtDialog::updateStatus
void updateStatus(void)
Definition: importmusic.cpp:1052
ImportMusicDialog::chooseBackend
void chooseBackend(void) const
Definition: importmusic.cpp:658
ImportMusicDialog::fillWidgets
void fillWidgets()
Definition: importmusic.cpp:85
ImportMusicDialog::m_locationEdit
MythUITextEdit * m_locationEdit
Definition: importmusic.h:122
ImportMusicDialog::m_locationButton
MythUIButton * m_locationButton
Definition: importmusic.h:123
ImportCoverArtDialog::copyPressed
void copyPressed(void)
Definition: importmusic.cpp:975
ImportMusicDialog::m_musicStorageDir
QString m_musicStorageDir
Definition: importmusic.h:114
ImportMusicDialog
Definition: importmusic.h:58
ImportCoverArtDialog::m_typeList
MythUIButtonList * m_typeList
Definition: importmusic.h:207
MythUIText
All purpose text widget, displays a text string.
Definition: mythuitext.h:29
ImportCoverArtDialog
Definition: importmusic.h:163
ImportMusicDialog::m_addallnewButton
MythUIButton * m_addallnewButton
Definition: importmusic.h:144
ImportCoverArtDialog::scanDirectory
void scanDirectory(void)
Definition: importmusic.cpp:1022
ImportMusicDialog::m_playButton
MythUIButton * m_playButton
Definition: importmusic.h:142
FileCopyThread::GetResult
bool GetResult(void) const
Definition: importmusic.h:49
ImportMusicDialog::m_defaultCompArtist
QString m_defaultCompArtist
Definition: importmusic.h:151
ImportMusicDialog::doFileCopy
void doFileCopy(const QString &src, const QString &dst)
FileScannerThread::m_parent
ImportMusicDialog * m_parent
Definition: importmusic.h:38
FileCopyThread::run
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: importmusic.cpp:48
ImportMusicDialog::m_haveDefaults
bool m_haveDefaults
Definition: importmusic.h:157
ImportMusicDialog::m_defaultArtist
QString m_defaultArtist
Definition: importmusic.h:152
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
mthread.h
ImportCoverArtDialog::m_coverartImage
MythUIImage * m_coverartImage
Definition: importmusic.h:206
ImportMusicDialog::setAlbum
void setAlbum(void)
Definition: importmusic.cpp:769
ImportMusicDialog::copyFile
static bool copyFile(const QString &src, const QString &dst)
Definition: importmusic.cpp:460
ImportCoverArtDialog::m_destinationText
MythUIText * m_destinationText
Definition: importmusic.h:204
ImportMusicDialog::m_coverartButton
MythUIButton * m_coverartButton
Definition: importmusic.h:125
ImportMusicDialog::m_currentText
MythUIText * m_currentText
Definition: importmusic.h:139
ImportCoverArtDialog::m_statusText
MythUIText * m_statusText
Definition: importmusic.h:203
ImportMusicDialog::m_yearText
MythUIText * m_yearText
Definition: importmusic.h:133
ImportCoverArtDialog::m_saveFilename
QString m_saveFilename
Definition: importmusic.h:196
ImportMusicDialog::m_trackText
MythUIText * m_trackText
Definition: importmusic.h:134
ImportMusicDialog::setSaveHost
void setSaveHost(const QString &host)
Definition: importmusic.cpp:699
ImportMusicDialog::showImportCoverArtDialog
void showImportCoverArtDialog()
Definition: importmusic.cpp:846
TrackInfo::metadata
MusicMetadata * metadata
Definition: importmusic.h:26
ImportMusicDialog::setCompilation
void setCompilation(void)
Definition: importmusic.cpp:723
ImportMusicDialog::m_defaultGenre
QString m_defaultGenre
Definition: importmusic.h:154
ImportMusicDialog::prevPressed
void prevPressed(void)
Definition: importmusic.cpp:327
ImportCoverArtDialog::m_nextButton
MythUIButton * m_nextButton
Definition: importmusic.h:209
ImportCoverArtDialog::m_sourceDir
QString m_sourceDir
Definition: importmusic.h:192
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:152
ImportMusicDialog::setGenre
void setGenre(void)
Definition: importmusic.cpp:802
ImportMusicDialog::customEvent
void customEvent(QEvent *event) override
Definition: importmusic.cpp:866
mythscreentype.h
FileScannerThread::run
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: importmusic.cpp:39
FileScannerThread::FileScannerThread
FileScannerThread(ImportMusicDialog *parent)
Definition: importmusic.cpp:34
ImportMusicDialog::addAllNewPressed
void addAllNewPressed(void)
Definition: importmusic.cpp:413