Sayonara Player
CoverLookup.h
1 /* CoverLookup.h */
2 
3 /* Copyright (C) 2011-2017 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 /*
23  * CoverLookup.h
24  *
25  * Created on: Apr 4, 2011
26  * Author: Lucio Carreras
27  */
28 
29 #ifndef COVERLOOKUP_H_
30 #define COVERLOOKUP_H_
31 
32 #include "AbstractCoverLookup.h"
33 #include "Utils/Pimpl.h"
34 
35 #include <QPixmap>
36 #include <QList>
37 
38 namespace Cover
39 {
40  class Location;
41 
46  class Lookup :
47  public LookupBase
48  {
49  Q_OBJECT
50  PIMPL(Lookup)
51 
52 
53  public:
54 
55  Lookup(QObject* parent=nullptr, int n_covers=1);
56  Lookup(QObject* parent, int n_covers, const Location& cl);
57  ~Lookup() override;
58 
67  bool fetch_cover(const Location& cl, bool also_www=true);
68 
69 
75  void stop() override;
76 
81  bool is_thread_running() const;
82 
87  void set_user_data(void* data);
88 
93  void* user_data();
94 
99  QList<QPixmap> pixmaps() const;
100 
107 
108 
109  private:
110 
111  bool fetch_from_database();
112  bool fetch_from_audio_source();
113  bool fetch_from_file_system();
114  bool fetch_from_www();
115 
116 
121  bool start_new_thread(const Location& cl);
122 
123  bool add_new_cover(const QPixmap& pm, const QString& hash);
124  bool add_new_cover(const QPixmap& pm);
125 
126  void emit_finished(bool success);
127 
128  public slots:
129  void start();
130 
131  private slots:
136  void cover_found(int idx);
137 
141  void thread_finished(bool);
142 
143  void extractor_finished();
144  };
145 
146  class Extractor : public QObject
147  {
148  Q_OBJECT
149  PIMPL(Extractor)
150 
151  signals:
152  void sig_finished();
153 
154  public:
155  Extractor(const QString& filepath, QObject* parent);
156  ~Extractor();
157 
158  QPixmap pixmap();
159 
160  public slots:
161  void start();
162  };
163 
168  using LookupPtr=std::shared_ptr<Lookup>;
169 
170 }
171 #endif /* COVERLOOKUP_H_ */
QList< QPixmap > take_pixmaps()
Get all pixmaps that where fetched and remove them from Cover::Lookup.
bool is_thread_running() const
indicates if the Cover::FetchThread is running
The CoverLookup class.
Definition: CoverLookup.h:46
void set_user_data(void *data)
Set some custom data you can retrieve later.
std::shared_ptr< Lookup > LookupPtr
CoverLookupPtr.
Definition: CoverLookup.h:168
QList< QPixmap > pixmaps() const
Get a copy of all pixmaps that where fetched.
The CoverLookupInterface class.
Definition: AbstractCoverLookup.h:35
bool fetch_cover(const Location &cl, bool also_www=true)
fetches cover for a CoverLocation.
The CoverLocation class.
Definition: CoverLocation.h:37
void stop() override
Stop the Cover::FetchThread if running and retrieve the sig_finished signal If no Cover::FetchThread ...
Definition: CoverLookup.h:146
void * user_data()
Fetch your custom data again.
Definition: SomaFMStation.h:33
Definition: org_mpris_media_player2_adaptor.h:20