Sayonara Player
GUI_AbstractStream.h
1 /* GUI_AbstractStream.h */
2 
3 /* Copyright (C) 2011-2019 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 "Gui/Plugins/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;
33 
34 namespace Gui
35 {
36  class MenuToolButton;
37 
42  public PreferenceAction
43  {
44  Q_OBJECT
45 
46  public:
47  StreamPreferenceAction(QWidget* parent);
49 
50  QString identifier() const override;
51 
52  protected:
53  QString display_name() const override;
54  };
55 
57  public PlayerPlugin::Base
58  {
59  Q_OBJECT
60 
61  public:
62  explicit AbstractStream(QWidget* parent=nullptr);
63  virtual ~AbstractStream();
64 
65  protected:
66  virtual void retranslate_ui() override;
67  virtual void play(QString url, QString station_name);
68 
69  virtual QString get_title_fallback_name() const=0;
70 
71  bool has_loading_bar() const override;
72 
73  template<typename T, typename UiType>
74  void setup_parent(T* subclass, UiType** uiptr)
75  {
76  PlayerPlugin::Base::setup_parent(subclass, uiptr);
77  AbstractStream::init_ui();
78  }
79 
80  private slots:
81  void edit_finished();
82  void new_finished();
83 
84  protected slots:
85  void listen_clicked();
86  void combo_idx_changed(int idx);
87 
88  void new_clicked();
89  void save_clicked();
90  void edit_clicked();
91  void delete_clicked();
92 
93  void too_many_urls_found(int n_urls, int n_max_urls);
94 
95  void stopped();
96  void error();
97  void data_available();
98  void _sl_skin_changed();
99 
100 
101  protected:
102  virtual QComboBox* combo_stream()=0;
103  virtual QPushButton* btn_play()=0;
104  virtual MenuToolButton* btn_menu()=0;
105  virtual AbstractStreamHandler* stream_handler() const=0;
106  virtual QString url() const;
107  QString current_station() const;
108  void add_stream(const QString& name, const QString& url);
109 
110  private:
111  PIMPL(AbstractStream)
112 
113  void assign_ui_vars() override;
114 
115  void init_connections();
116  void setup_stations();
117 
118  void set_searching(bool searching);
119 
120  virtual void init_ui() override;
121  };
122 }
123 
124 #endif // GUI_ABSTRACT_STREAM_H_
Definition: PlayerPluginBase.h:38
Definition: AbstractLibrary.h:36
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: GUI_AbstractStream.h:56
A PreferenceAction can be added to each widget supporting QActions. When triggering this action...
Definition: PreferenceAction.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: MenuToolButton.h:38
Currently only a Radio Search Entry action.
Definition: GUI_AbstractStream.h:41
Used to interprete website data as streams. Some methods have to be overridden, to map their function...
Definition: AbstractStreamHandler.h:37