Sayonara Player
GUI_ControlsBase.h
1 /* GUI_ControlsBase.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 #ifndef GUI_CONTROLSBASE_H
24 #define GUI_CONTROLSBASE_H
25 
26 #include "GUI/Utils/Shortcuts/ShortcutWidget.h"
27 #include "GUI/Utils/Widgets/Widget.h"
28 #include "GUI/InfoDialog/InfoDialogContainer.h"
29 #include "GUI/Utils/Icons.h"
30 
31 #include "Components/PlayManager/PlayState.h"
32 
33 #include "Utils/Pimpl.h"
34 #include "Utils/MetaData/RadioMode.h"
35 
36 class QLabel;
37 class QSlider;
38 class QPushButton;
39 class CoverButton;
40 class SearchSlider;
41 class RatingLabel;
42 
43 namespace Gui
44 {
45  class ProgressBar;
46 }
47 
49  public Gui::Widget,
50  public ShortcutWidget,
51  public InfoDialogContainer
52 {
53  Q_OBJECT
54  PIMPL(GUI_ControlsBase)
55 
56 public:
57  GUI_ControlsBase(QWidget* parent=nullptr);
58  virtual ~GUI_ControlsBase();
59  virtual void init();
60 
61  virtual QLabel* lab_sayonara() const=0;
62  virtual QLabel* lab_title() const=0;
63  virtual QLabel* lab_version() const=0;
64  virtual QLabel* lab_album() const=0;
65  virtual QLabel* lab_artist() const=0;
66  virtual QLabel* lab_writtenby() const=0;
67  virtual QLabel* lab_bitrate() const=0;
68  virtual QLabel* lab_filesize() const=0;
69  virtual QLabel* lab_copyright() const=0;
70  virtual QLabel* lab_current_time() const=0;
71  virtual QLabel* lab_max_time() const=0;
72  virtual RatingLabel* lab_rating() const;
73  virtual QWidget* widget_details() const=0;
74 
75  virtual SearchSlider* sli_progress() const=0;
76  virtual SearchSlider* sli_volume() const=0;
77  virtual Gui::ProgressBar* sli_buffer() const=0;
78  virtual QPushButton* btn_mute() const=0;
79  virtual QPushButton* btn_play() const=0;
80  virtual QPushButton* btn_rec() const=0;
81  virtual QPushButton* btn_bwd() const=0;
82  virtual QPushButton* btn_fwd() const=0;
83  virtual QPushButton* btn_stop() const=0;
84  virtual CoverButton* btn_cover() const=0;
85 
86  virtual void toggle_buffer_mode(bool buffering)=0;
87  virtual bool is_resizable() const=0;
88 
89 
90 private:
91  QIcon icon(Gui::Icons::IconName name);
92 
93  void played();
94  void paused();
95  void stopped();
96 
97  void check_record_button_visible();
98 
99  void set_cover_location(const MetaData &md);
100  void set_standard_cover();
101  void set_radio_mode(RadioMode radio);
102 
103  void setup_volume_button(int percent);
104  void increase_volume();
105  void decrease_volume();
106 
107  void set_cur_pos_label(int val);
108  void set_total_time_label(MilliSeconds total_time);
109  void set_info_labels(const MetaData &md);
110  void refresh_info_labels();
111 
112  void setup_shortcuts();
113  void setup_connections();
114 
115 
116 protected:
117  void resizeEvent(QResizeEvent* e) override;
118  void showEvent(QShowEvent* e) override;
119  void contextMenuEvent(QContextMenuEvent* e) override;
120  void skin_changed() override;
121 
122 public:
123  void file_info_changed();
124  void sr_active_changed();
125 
126 public slots:
127  void change_volume_by_tick(int val);
128 
129 private slots:
130  void playstate_changed(PlayState state);
131 
132  void rec_changed(bool b);
133 
134  void buffering(int progress);
135 
136  void cur_pos_changed(MilliSeconds pos_ms);
137  void progress_moved(int val);
138  void progress_hovered(int val);
139  void volume_changed(int val);
140 
141  void mute_changed(bool muted);
142 
143  void track_changed(const MetaData& md);
144  void id3_tags_changed(const MetaDataList &v_md_old, const MetaDataList &v_md_new);
145  void md_changed(const MetaData &md);
146  void dur_changed(const MetaData &md);
147  void br_changed(const MetaData &md);
148 
149  // cover changed by engine
150  void force_cover(const QImage &img);
151 
152 
153  // InfoDialogContainer interface
154 protected:
155  MD::Interpretation metadata_interpretation() const override;
156  MetaDataList info_dialog_data() const override;
157 };
158 
159 #endif // GUI_CONTROLSBASE_H
Definition: SearchSlider.h:30
Definition: GUI_ControlsBase.h:48
The ProgressBar class.
Definition: ProgressBar.h:36
An interface used to abstract the usage of the info dialog. An implementing class has to return the i...
Definition: InfoDialogContainer.h:36
Definition: GUI_ControlsBase.h:43
PlayState
The PlayState enum.
Definition: PlayState.h:28
The MetaData class.
Definition: MetaData.h:48
RadioMode
The RadioMode enum.
Definition: RadioMode.h:30
The MetaDataList class.
Definition: MetaDataList.h:38
The CoverButton class.
Definition: CoverButton.h:42
Widget with Settings connection. Also contains triggers for language_changed() and skin_changed() wi...
Definition: Widget.h:38
The RatingLabel class.
Definition: RatingLabel.h:34
Interface that should be implemented when using configurable shortcuts.
Definition: ShortcutWidget.h:32