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 
31 
32 #include <QComboBox>
33 #include <QPushButton>
34 #include <QLineEdit>
35 #include <QLabel>
36 #include <QPainter>
37 #include <QModelIndex>
38 #include <QVariant>
39 
41 class DatabaseConnector;
42 
44 {
45 
46  Q_OBJECT
47 
48 private:
49  QLineEdit* _le_url=nullptr;
50  QComboBox* _combo_stream=nullptr;
51  QPushButton* _btn_play=nullptr;
52  MenuToolButton* _btn_tool=nullptr;
53  QLabel* _lab_listen=nullptr;
54 
55  virtual void init_connections();
56  virtual void init_streams();
57 
58 signals:
59  void sig_close_event();
60 
61 public:
62  GUI_AbstractStream(AbstractStreamHandler* stream_handler, QWidget* parent=nullptr);
63  virtual ~GUI_AbstractStream();
64 
65 
66 protected:
67  DatabaseConnector* _db=nullptr; // used to fetch entries from DB
68  AbstractStreamHandler* _stream_handler=nullptr;
69 
70  QString _title_fallback_name;
71 
72  // url, name
73  QMap<QString, QString> _stations;
74 
75 
76  virtual void language_changed() override;
77  virtual void init_ui() override;
78 
79  virtual void play(QString url, QString station_name);
80  virtual GlobalMessage::Answer show_delete_confirm_dialog();
81 
82 
83 
84 protected slots:
85  virtual void listen_clicked();
86  virtual void combo_idx_changed(int idx);
87  virtual void delete_clicked();
88  virtual void save_clicked();
89  virtual void new_clicked();
90  virtual void text_changed(const QString& str);
91 
92  void error();
93  void data_available();
94 
95 public:
96  virtual void setup_stations(const QMap<QString, QString>&);
97 
98  template<typename T>
99  void setup_parent(T* subclass){
100 
101  PlayerPluginInterface::setup_parent(subclass);
102 
103  _le_url = subclass->le_url;
104  _combo_stream = subclass->combo_stream;
105  _btn_play = subclass->btn_play;
106  _btn_tool = subclass->btn_tool;
107  _lab_listen = subclass->lab_listen;
108 
109  init_connections();
110  init_streams();
111  }
112 };
113 
114 #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:43
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:48
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