Sayonara Player
CoverButton.h
1 /* CoverButton.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (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 {
40  public QObject
41  {
42  Q_OBJECT
43  PIMPL(ByteArrayConverter)
44 
45  signals:
46  void sigFinished();
47 
48  public:
49  ByteArrayConverter(const QByteArray& data, const QString& mime);
51 
52  QPixmap pixmap() const;
53 
54  public slots:
55  void start();
56  };
57 
62  class CoverButton :
63  public Gui::WidgetTemplate<QPushButton>
64  {
65  Q_OBJECT
66  PIMPL(CoverButton)
67 
68  signals:
69  void sigCoverChanged();
70  void sigRejected();
71 
72  public:
73  explicit CoverButton(QWidget* parent=nullptr);
74  ~CoverButton() override;
75 
81  void setCoverLocation(const Cover::Location& cl);
82 
88  void setCoverData(const QByteArray& data, const QString& mimetype);
89 
97  void setSilent(bool silent);
98  bool isSilent() const;
99 
100  QPixmap pixmap() const;
101  int verticalPadding() const;
102 
103  void setAlternativeSearchEnabled(bool b);
104  bool isAlternativeSearchEnabled() const;
105 
106  public slots:
107  void trigger();
108 
109  private slots:
110  void alternativeCoverFetched(const Cover::Location& cl);
111  void coverLookupFinished(bool success);
112  void setCoverImage(const QString& path);
113  void setCoverImagePixmap(const QPixmap& pm);
114  void coversChanged();
115  void timerTimedOut();
116  void byteconverterFinished();
117 
118  private:
119  using QPushButton::setIcon;
120  using QPushButton::icon;
121 
122  protected:
123  void mouseMoveEvent(QMouseEvent* e) override;
124  void mouseReleaseEvent(QMouseEvent* event) override;
125  void paintEvent(QPaintEvent* event) override;
126  void resizeEvent(QResizeEvent* e) override;
127  };
128 }
129 
130 #endif
void setCoverData(const QByteArray &data, const QString &mimetype)
Sets the raw data parsed out of the audio file.
void setSilent(bool silent)
silent results that the cover is not stored productively. The AlternativeCoverFetcher will save the c...
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:38
The CoverButton class.
Definition: CoverButton.h:62
Definition: CoverButton.h:39
QIcon icon(const QString &iconName, IconTheme themeName)
fetch a icon from resources
void setCoverLocation(const Cover::Location &cl)
Set an appropriate cover location. Afterwards a search is triggered to find the cover.