Sayonara Player
GUI_AbstractStream.h
1 /* GUI_AbstractStream.h */
2 
3 /* Copyright (C) 2011-2016 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 #ifndef GUI_AbstractStream_H
23 #define GUI_AbstractStream_H
24 
25 #include "GUI/Helper/MenuTool/MenuTool.h"
26 #include "Interfaces/PlayerPlugin/PlayerPlugin.h"
27 #include "Components/StreamPlugins/Streams/AbstractStreamHandler.h"
28 #include "GUI/Helper/Message/GlobalMessage.h"
29 
30 #include <QComboBox>
31 #include <QPushButton>
32 #include <QLineEdit>
33 #include <QLabel>
34 #include <QPainter>
35 #include <QModelIndex>
36 #include <QVariant>
37 
39 class DatabaseConnector;
40 
42 {
43 
44  Q_OBJECT
45 
46 private:
47  QLineEdit* _le_url=nullptr;
48  QComboBox* _combo_stream=nullptr;
49  QPushButton* _btn_play=nullptr;
50  MenuToolButton* _btn_tool=nullptr;
51  QLabel* _lab_listen=nullptr;
52 
53  virtual void init_connections();
54  virtual void init_streams();
55 
56 signals:
57  void sig_close_event();
58 
59 public:
60  GUI_AbstractStream(AbstractStreamHandler* stream_handler, QWidget* parent=nullptr);
61  virtual ~GUI_AbstractStream();
62 
63 
64 protected:
65  DatabaseConnector* _db=nullptr; // used to fetch entries from DB
66  AbstractStreamHandler* _stream_handler=nullptr;
67 
68  // url, name
69  QMap<QString, QString> _stations;
70 
71 
72  virtual void language_changed() override;
73  virtual void init_ui() override;
74 
75  virtual void play(QString url, QString station_name);
76  virtual GlobalMessage::Answer show_delete_confirm_dialog();
77 
78  virtual QString get_title_fallback_name() const=0;
79 
80 
81 
82 protected slots:
83  virtual void listen_clicked();
84  virtual void combo_idx_changed(int idx);
85  virtual void delete_clicked();
86  virtual void save_clicked();
87  virtual void new_clicked();
88  virtual void text_changed(const QString& str);
89 
90  void error();
91  void data_available();
92  void _sl_skin_changed();
93 
94 public:
95  virtual void setup_stations(const QMap<QString, QString>&);
96 
97  template<typename T>
98  void setup_parent(T* subclass){
99 
100  PlayerPluginInterface::setup_parent(subclass);
101 
102  _le_url = subclass->le_url;
103  _combo_stream = subclass->combo_stream;
104  _btn_play = subclass->btn_play;
105  _btn_tool = subclass->btn_tool;
106  _lab_listen = subclass->lab_listen;
107 
108  init_connections();
109  init_streams();
110  }
111 };
112 
113 #endif // GUI_AbstractStream_H
virtual void init_ui() override
GUI will be initialized on first show up. Please use this to make Sayonara starting fast...
Definition: GUI_AbstractStream.h:41
Definition: DatabaseConnector.h:40
virtual void language_changed() override
language_changed Has to be implemented and is called when language has changed
Interface for PlayerPlugin classes. get_name() and language_changed() must be overwritten.
Definition: PlayerPlugin.h:49
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:41
Used to interprete website data as streams. Some methods have to be overridden, to map their function...
Definition: AbstractStreamHandler.h:44