Sayonara Player
CoverButton.h
1 /* CoverButton.h */
2 
3 /* Copyright (C) 2011-2019 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 #ifndef COVER_BUTTON_H
22 #define COVER_BUTTON_H
23 
24 #include "Utils/Pimpl.h"
25 #include "Gui/Utils/Widgets/WidgetTemplate.h"
26 
27 #include <QPushButton>
28 
29 class QPixmap;
30 class QResizeEvent;
31 
32 namespace Cover
33 {
34  class Location;
35 }
36 
37 namespace Gui
38 {
39 
41  public QObject
42  {
43  Q_OBJECT
44  PIMPL(ByteArrayConverter)
45 
46  signals:
47  void sig_finished();
48 
49  public:
50  ByteArrayConverter(const QByteArray& data, const QString& mime);
52 
53  QPixmap pixmap() const;
54 
55  public slots:
56  void start();
57  };
58 
63  class CoverButton :
64  public Gui::WidgetTemplate<QPushButton>
65  {
66  Q_OBJECT
67  PIMPL(CoverButton)
68 
69  signals:
70  void sig_cover_changed();
71  void sig_rejected();
72 
73  public:
74  explicit CoverButton(QWidget* parent=nullptr);
75  virtual ~CoverButton();
76 
82  void set_cover_location(const Cover::Location& cl);
83 
89  void set_cover_data(const QByteArray& data, const QString& mimetype);
90 
91 
99  void set_silent(bool silent);
100  bool is_silent() const;
101 
102  QPixmap pixmap() const;
103 
104  private:
105  using QPushButton::setIcon;
106  using QPushButton::icon;
107 
108 
109  protected:
110  void mouseMoveEvent(QMouseEvent* e) override;
111  void mouseReleaseEvent(QMouseEvent* event) override;
112  void paintEvent(QPaintEvent* event) override;
113  void resizeEvent(QResizeEvent* e) override;
114 
115  private slots:
116  void alternative_cover_fetched(const Cover::Location& cl);
117  void cover_lookup_finished(bool success);
118  void set_cover_image(const QString& path);
119  void set_cover_image_pixmap(const QPixmap& pm);
120  void covers_changed();
121  void timer_timed_out();
122  void byteconverter_finished();
123 
124  public slots:
125  void trigger();
126  };
127 }
128 
129 #endif
void set_cover_location(const Cover::Location &cl)
Set an appropriate cover location. Afterwards a search is triggered to find the cover.
void set_cover_data(const QByteArray &data, const QString &mimetype)
Sets the raw data parsed out of the audio file.
Definition: AbstractLibrary.h:36
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings...
Definition: WidgetTemplate.h:84
The CoverLocation class.
Definition: CoverLocation.h:42
The CoverButton class.
Definition: CoverButton.h:63
Definition: CoverButton.h:40
QIcon icon(const QString &icon_name, IconTheme theme_name)
fetch a icon from resources
void set_silent(bool silent)
silent results that the cover is not stored productively. The AlternativeCoverFetcher will save the c...
Definition: AbstractCoverLookup.h:30