1 /*
2  * Strawberry Music Player
3  * This file was part of Clementine.
4  * Copyright 2010, David Sansome <me@davidsansome.com>
5  *
6  * Strawberry is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Strawberry is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Strawberry.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef ALBUMCOVEREXPORTER_H
22 #define ALBUMCOVEREXPORTER_H
23 
24 #include "config.h"
25 
26 #include <QObject>
27 #include <QQueue>
28 #include <QString>
29 
30 #include "albumcoverexport.h"
31 
32 class QThreadPool;
33 class Song;
34 class CoverExportRunnable;
35 
36 class AlbumCoverExporter : public QObject {
37   Q_OBJECT
38 
39  public:
40   explicit AlbumCoverExporter(QObject *parent = nullptr);
41 
42   static const int kMaxConcurrentRequests;
43 
44   void SetDialogResult(const AlbumCoverExport::DialogResult &dialog_result);
45   void AddExportRequest(const Song &song);
46   void StartExporting();
47   void Cancel();
48 
request_count()49   int request_count() { return requests_.size(); }
50 
51  signals:
52   void AlbumCoversExportUpdate(int exported, int skipped, int all);
53 
54  private slots:
55   void CoverExported();
56   void CoverSkipped();
57 
58  private:
59   void AddJobsToPool();
60   AlbumCoverExport::DialogResult dialog_result_;
61 
62   QQueue<CoverExportRunnable*> requests_;
63   QThreadPool *thread_pool_;
64 
65   int exported_;
66   int skipped_;
67   int all_;
68 };
69 
70 #endif  // ALBUMCOVEREXPORTER_H
71 
72