Sayonara Player
GUI_ControlsBase.h
1 /* GUI_ControlsBase.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 GUI_CONTROLSBASE_H
22 #define GUI_CONTROLSBASE_H
23 
24 #include "Components/PlayManager/PlayState.h"
25 
26 #include "Gui/InfoDialog/InfoDialogContainer.h"
27 #include "Gui/Utils/Widgets/Widget.h"
28 #include "Gui/Utils/Icons.h"
29 
30 #include "Utils/MetaData/RadioMode.h"
31 #include "Utils/Pimpl.h"
32 
33 class QLabel;
34 class QSlider;
35 class QPushButton;
36 
37 namespace Gui
38 {
39  class CoverButton;
40  class SearchSlider;
41  class ProgressBar;
42  class RatingEditor;
43 }
44 
46  public Gui::Widget,
47  public InfoDialogContainer
48 {
49  Q_OBJECT
50  PIMPL(GUI_ControlsBase)
51 
52  public:
53  GUI_ControlsBase(QWidget* parent = nullptr);
54  virtual ~GUI_ControlsBase() override;
55  virtual void init();
56 
57  virtual QLabel* labSayonara() const = 0;
58  virtual QLabel* labTitle() const = 0;
59  virtual QLabel* labVersion() const = 0;
60  virtual QLabel* labAlbum() const = 0;
61  virtual QLabel* labArtist() const = 0;
62  virtual QLabel* labWrittenBy() const = 0;
63  virtual QLabel* labBitrate() const = 0;
64  virtual QLabel* labFilesize() const = 0;
65  virtual QLabel* labCopyright() const = 0;
66  virtual QLabel* labCurrentTime() const = 0;
67  virtual QLabel* labMaxTime() const = 0;
68  virtual Gui::RatingEditor* labRating() const;
69  virtual QWidget* widgetDetails() const = 0;
70 
71  virtual Gui::SearchSlider* sliProgress() const = 0;
72  virtual Gui::SearchSlider* sliVolume() const = 0;
73  virtual QPushButton* btnMute() const = 0;
74  virtual QPushButton* btnPlay() const = 0;
75  virtual QPushButton* btnRecord() const = 0;
76  virtual QPushButton* btnPrevious() const = 0;
77  virtual QPushButton* btnNext() const = 0;
78  virtual QPushButton* btnStop() const = 0;
79  virtual Gui::CoverButton* btnCover() const = 0;
80 
81  virtual QSize buttonSize() const final;
82  virtual bool isExternResizeAllowed() const = 0;
83 
84  private:
85  QIcon icon(Gui::Icons::IconName name);
86 
87  void played();
88  void paused();
89  void stopped();
90 
91  void setCoverLocation(const MetaData& md);
92  void setStandardCover();
93 
94  void setRadioMode(RadioMode radio);
95  void checkRecordButtonVisible();
96 
97  void setupVolumeButton(int percent);
98  void increaseVolume();
99  void decreaseVolume();
100 
101  void refreshCurrentPosition(int val);
102  void setTotalTimeLabel(MilliSeconds total_time);
103 
104  void setupShortcuts();
105  void setupConnections();
106 
107  public slots:
108  void changeVolumeByDelta(int val);
109 
110  private slots:
111  void playstateChanged(PlayState state);
112 
113  void recordChanged(bool b);
114 
115  void buffering(int progress);
116 
117  void currentPositionChanged(MilliSeconds pos_ms);
118  void progressMoved(int val);
119  void progressHovered(int val);
120 
121  void volumeChanged(int val);
122  void muteChanged(bool muted);
123 
124  void currentTrackChanged(const MetaData& md);
125  void metadataChanged();
126 
127  void refreshLabels(const MetaData& md);
128  void refreshCurrentTrack();
129 
130  // cover changed by engine
131  void coverChanged(const QByteArray& data, const QString& mimedata);
132  void coverClickRejected();
133 
134  void streamRecorderActiveChanged();
135 
136  protected:
137 
138  MD::Interpretation metadataInterpretation() const override;
139  MetaDataList infoDialogData() const override;
140 
141  void resizeEvent(QResizeEvent* e) override;
142  void showEvent(QShowEvent* e) override;
143  void contextMenuEvent(QContextMenuEvent* e) override;
144  void skinChanged() override;
145 };
146 
147 #endif // GUI_CONTROLSBASE_H
PlayState
PlayState
The PlayState enum.
Definition: PlayState.h:29
GUI_ControlsBase::metadataInterpretation
MD::Interpretation metadataInterpretation() const override
get the interpretation for the metadata. Maybe a list of metadata should be intrepeted as albums whil...
MetaDataList
The MetaDataList class.
Definition: MetaDataList.h:37
RadioMode
RadioMode
The RadioMode enum.
Definition: RadioMode.h:29
Gui::Widget
Widget with Settings connection. Also contains triggers for language_changed() and skin_changed() \nT...
Definition: Widget.h:39
Gui::RatingEditor
This class is used for the actual editing of a RatingLabel While the RatingLabel class is used in pai...
Definition: RatingLabel.h:97
Gui::Icons::IconName
IconName
The IconName enum.
Definition: Icons.h:58
GUI_ControlsBase::infoDialogData
MetaDataList infoDialogData() const override
get the metadata that should be used for the info dialog So for lists, the selected tracks are used h...
Gui::SearchSlider
A slider as it is used by the progress bar You can also set a different value by calling set_bufferin...
Definition: SearchSlider.h:41
Gui::CoverButton
The CoverButton class.
Definition: CoverButton.h:40
MetaData
The MetaData class.
Definition: MetaData.h:47
GUI_ControlsBase
Definition: GUI_ControlsBase.h:48
InfoDialogContainer
An interface used to abstract the usage of the info dialog. An implementing class has to return the i...
Definition: InfoDialogContainer.h:64