Sayonara Player
GUI_AbstractStream.h
1 /* GUI_AbstractStream.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 #ifndef GUI_ABSTRACT_STREAM_H_
22 #define GUI_ABSTRACT_STREAM_H_
23 
24 #include "Interfaces/PlayerPlugin/PlayerPlugin.h"
25 #include "Helper/Pimpl.h"
26 
27 class QComboBox;
28 class QPushButton;
29 class QLineEdit;
30 class QLabel;
31 class MenuToolButton;
33 
36 {
37  Q_OBJECT
38 
39 public:
40  explicit GUI_AbstractStream(AbstractStreamHandler* stream_handler, QWidget* parent=nullptr);
41  virtual ~GUI_AbstractStream();
42 
43 protected:
44  virtual void language_changed() override;
45  virtual void play(QString url, QString station_name);
46 
47  virtual QString get_title_fallback_name() const=0;
48  void setup_stations(const QMap<QString, QString>&);
49  bool has_loading_bar() const override;
50 
51  template<typename T, typename UiType>
52  void setup_parent(T* subclass, UiType** uiptr)
53  {
54  PlayerPluginInterface::setup_parent(subclass, uiptr);
55 
56  UiType* ui = *uiptr;
57  set_le_url( ui->le_url );
58  set_combo_stream( ui->combo_stream );
59  set_btn_play( ui->btn_play );
60  set_btn_tool( ui->btn_tool );
61  set_lab_listen( ui->lab_listen );
62 
63  GUI_AbstractStream::init_ui();
64  }
65 
66 protected slots:
67  void listen_clicked();
68  void combo_idx_changed(int idx);
69  void delete_clicked();
70  void save_clicked();
71  void new_clicked();
72  void text_changed(const QString& str);
73  void too_many_urls_found(int n_urls, int n_max_urls);
74 
75  void stopped();
76  void error();
77  void data_available();
78  void _sl_skin_changed();
79 
80 private:
81  PIMPL(GUI_AbstractStream)
82 
83  void init_connections();
84  void init_streams();
85 
86  void set_le_url(QLineEdit* le_url);
87  void set_combo_stream(QComboBox* le_combo_stream);
88  void set_btn_play(QPushButton* btn_play);
89  void set_btn_tool(MenuToolButton* btn_tool);
90  void set_lab_listen(QLabel* lab_listen);
91 
92  void set_searching(bool searching);
93 
94  virtual void init_ui() override;
95 };
96 
97 #endif // GUI_ABSTRACT_STREAM_H_
Definition: GUI_AbstractStream.h:34
virtual void language_changed() override
language_changed Has to be implemented and is called when language has changed
bool has_loading_bar() const override
indicates if the widget has a loading bar. If yes, there will be reserved some extra space at the bot...
Interface for PlayerPlugin classes. get_name() and language_changed() must be overwritten.
Definition: PlayerPlugin.h:38
This is the little button you often see near comboboxes It opens up a menu when clicked. The actions in the menu a configurable.
Definition: MenuTool.h:32
Used to interprete website data as streams. Some methods have to be overridden, to map their function...
Definition: AbstractStreamHandler.h:40