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 
108 public slots:
109  void changeVolumeByDelta(int val);
110 
111 private slots:
112  void playstateChanged(PlayState state);
113 
114  void recordChanged(bool b);
115 
116  void buffering(int progress);
117 
118  void currentPositionChanged(MilliSeconds pos_ms);
119  void progressMoved(int val);
120  void progressHovered(int val);
121 
122  void volumeChanged(int val);
123  void muteChanged(bool muted);
124 
125  void currentTrackChanged(const MetaData& md);
126  void metadataChanged();
127 
128  void refreshLabels(const MetaData& md);
129  void refreshCurrentTrack();
130 
131  // cover changed by engine
132  void coverChanged(const QByteArray& data, const QString& mimedata);
133  void coverClickRejected();
134 
135  void streamRecorderActiveChanged();
136 
137 protected:
138 
139  MD::Interpretation metadataInterpretation() const override;
140  MetaDataList infoDialogData() const override;
141 
142  void resizeEvent(QResizeEvent* e) override;
143  void showEvent(QShowEvent* e) override;
144  void contextMenuEvent(QContextMenuEvent* e) override;
145  void skinChanged() override;
146 };
147 
148 #endif // GUI_CONTROLSBASE_H
PlayState
PlayState
The PlayState enum.
Definition: PlayState.h:28
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:35
RadioMode
RadioMode
The RadioMode enum.
Definition: RadioMode.h:28
Gui::Widget
Widget with Settings connection. Also contains triggers for language_changed() and skin_changed() \nT...
Definition: Widget.h:37
Gui::RatingEditor
This class is used for the actual editing of a RatingLabel While the RatingLabel class is used in pai...
Definition: RatingLabel.h:96
Gui::Icons::IconName
IconName
The IconName enum.
Definition: Icons.h:57
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:39
Gui::CoverButton
The CoverButton class.
Definition: CoverButton.h:38
MetaData
The MetaData class.
Definition: MetaData.h:45
GUI_ControlsBase
Definition: GUI_ControlsBase.h:45
InfoDialogContainer
An interface used to abstract the usage of the info dialog. An implementing class has to return the i...
Definition: InfoDialogContainer.h:61