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/PlayerPluginBase.h"
25 #include "GUI/Utils/PreferenceAction.h"
26 #include "Utils/Pimpl.h"
27 
28 class QComboBox;
29 class QPushButton;
30 class QLineEdit;
31 class QLabel;
32 class MenuToolButton;
34 
36  public PreferenceAction
37 {
38  Q_OBJECT
39 
40 public:
41  StreamPreferenceAction(QWidget* parent);
43 
44  QString identifier() const override;
45 
46 protected:
47  QString display_name() const override;
48 };
49 
51  public PlayerPlugin::Base
52 {
53  Q_OBJECT
54 
55 public:
56  explicit GUI_AbstractStream(QWidget* parent=nullptr);
57  virtual ~GUI_AbstractStream();
58 
59 protected:
60  virtual void retranslate_ui() override;
61  virtual void play(QString url, QString station_name);
62 
63  virtual QString get_title_fallback_name() const=0;
64  void setup_stations(const QMap<QString, QString>&);
65  bool has_loading_bar() const override;
66 
67  template<typename T, typename UiType>
68  void setup_parent(T* subclass, UiType** uiptr)
69  {
70  PlayerPlugin::Base::setup_parent(subclass, uiptr);
71  GUI_AbstractStream::init_ui();
72  }
73 
74 protected slots:
75  void listen_clicked();
76  void combo_idx_changed(int idx);
77  void delete_clicked();
78  void save_clicked();
79  void new_clicked();
80  void text_changed(const QString& str);
81  void too_many_urls_found(int n_urls, int n_max_urls);
82 
83  void stopped();
84  void error();
85  void data_available();
86  void _sl_skin_changed();
87 
88 
89 protected:
90  virtual QLineEdit* le_url()=0;
91  virtual QComboBox* combo_stream()=0;
92  virtual QPushButton* btn_play()=0;
93  virtual MenuToolButton* btn_menu()=0;
94  virtual QLabel* lab_listen()=0;
95  virtual AbstractStreamHandler* stream_handler() const=0;
96 
97 
98 private:
99  PIMPL(GUI_AbstractStream)
100 
101  void assign_ui_vars() override;
102 
103  void init_connections();
104  void init_streams();
105 
106  void set_le_url(QLineEdit* le_url);
107  void set_combo_stream(QComboBox* le_combo_stream);
108  void set_btn_play(QPushButton* btn_play);
109  void set_btn_tool(MenuToolButton* btn_tool);
110  void set_lab_listen(QLabel* lab_listen);
111 
112  void set_searching(bool searching);
113 
114  virtual void init_ui() override;
115 };
116 
117 #endif // GUI_ABSTRACT_STREAM_H_
Definition: GUI_AbstractStream.h:50
Definition: PlayerPluginBase.h:40
Definition: GUI_AbstractStream.h:35
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...
Definition: PreferenceAction.h:35
This is the little button you often see near comboboxes It opens up a menu when clicked....
Definition: MenuTool.h:36
Used to interprete website data as streams. Some methods have to be overridden, to map their function...
Definition: AbstractStreamHandler.h:38