Sayonara Player
GUI_Player.h
1 /* GUI_Simpleplayer.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_SIMPLEPLAYER_H
23 #define GUI_SIMPLEPLAYER_H
24 
25 #include "GUI/Player/ui_GUI_Player.h"
26 
27 #include "Components/PlayManager/PlayManager.h"
28 
29 #include "GUI/Player/GUI_TrayIcon.h"
30 #include "GUI/Helper/Message/GlobalMessageReceiverInterface.h"
31 
32 #include "GUI/Helper/SayonaraWidget/SayonaraWidget.h"
33 #include "GUI/Helper/Shortcuts/ShortcutWidget.h"
34 
35 
36 #include <QMessageBox>
37 #include <QMainWindow>
38 #include <QShowEvent>
39 #include <QCloseEvent>
40 #include <QTranslator>
41 #include <QKeySequence>
42 #include <QFileSystemWatcher>
43 
44 #include <QAction>
45 
46 class CoverLocation;
47 class CoverLookup;
48 class LocalLibrary;
50 class EngineHandler;
51 class GUI_Playlist;
52 class AsyncWebAccess;
57 class IconLoader;
58 
59 #ifdef WITH_MTP
60  class GUI_MTP;
61 #endif
62 
63 class GUI_Player :
64  public SayonaraMainWindow,
65  public ShortcutWidget,
67  private Ui::Sayonara
68 {
69 
70  Q_OBJECT
71 
72 public:
73 
74  GUI_Player(QTranslator* translator, QWidget *parent=nullptr);
75  ~GUI_Player();
76 
77  // set the playlist ui
78 
79  void set_libraries(LibraryPluginHandler* plugin_loader);
80 
81  void set_player_plugin_handler(PlayerPluginHandler* pph);
82  void register_preference_dialog(PreferenceDialogInterface* dialog);
83 
84  // called from signal handler
85  // show if there are files to play
86  void read_filelist(const QString& filename);
87 
88  void ui_loaded();
89  QString get_shortcut_text(const QString &shortcut_identifier) const override;
90 
91 
92 public slots:
93 
94  void set_cur_pos_ms(quint64 pos_ms);
95  void id3_tags_changed(const MetaDataList& v_md_old, const MetaDataList& v_md_new);
96 
97  void md_changed(const MetaData&);
98  void dur_changed(const MetaData&);
99  void br_changed(const MetaData&);
100 
101  void raise();
102  void really_close();
103  void reload_skin();
104 
105  void tray_icon_activated(QSystemTrayIcon::ActivationReason reason);
106 
107  /* Plugins */
108  void show_plugin(PlayerPluginInterface* plugin);
109  void hide_all_plugins();
110 
111 
112 private:
113 
114  QWidget* _cur_library=nullptr;
115  LocalLibrary* _local_library=nullptr;
116 
117  GUI_AlternativeCovers* _ui_alternative_covers=nullptr;
118 
119  EngineHandler* _engine=nullptr;
120  CoverLookup* _cov_lookup=nullptr;
121  PlayerPluginHandler* _pph=nullptr;
122  LibraryPluginHandler* _lph=nullptr;
123 
124 #ifdef WITH_MTP
125  GUI_MTP* _mtp=nullptr;
126 #endif
127 
128  GUI_TrayIcon* _tray_icon=nullptr;
129 
130 
131  QTranslator* _translator=nullptr;
132  QStringList _translators;
133 
134  PlayManager* _play_manager=nullptr;
135  QMessageBox* _about_box=nullptr;
136 
137  MetaData _md;
138  IconLoader* _icon_loader=nullptr;
139 
140 
141 private:
142  void init_gui();
143 
144  void setup_tray_actions ();
145  void setup_volume_button(int percent);
146  void setup_connections();
147 
148  void set_album_label();
149  void set_artist_label();
150  void set_title_label();
151  void set_info_labels();
152 
153  void set_radio_mode(RadioMode model);
154 
155  bool check_library_path();
156 
157  void closeEvent(QCloseEvent* e) override;
158  void keyPressEvent(QKeyEvent* e) override;
159  void resizeEvent(QResizeEvent* e) override;
160  void moveEvent(QMoveEvent* e) override;
161 
162  void language_changed() override;
163  void skin_changed() override;
164 
165  void set_total_time_label(qint64 length_ms);
166  void set_cur_pos_label(int val);
167 
168  template<typename T>
169  void init_action(QAction* action, T setting_key){
170  bool b = _settings->get(setting_key);
171  action->setChecked(b);
172  }
173 
174 
175  // Methods for other mudules to display info/warning/error
176  GlobalMessage::Answer error_received(const QString &error, const QString &sender_name=QString()) override;
177  GlobalMessage::Answer warning_received(const QString &error, const QString &sender_name=QString()) override;
178  GlobalMessage::Answer info_received(const QString &error, const QString &sender_name=QString()) override;
179  GlobalMessage::Answer question_received(const QString &info, const QString &sender_name=QString(), GlobalMessage::QuestionType type=GlobalMessage::QuestionType::YesNo) override;
180 
181 
182 
183 
184 private slots:
185 
186  void play_clicked();
187  void stop_clicked();
188  void prev_clicked();
189  void next_clicked();
190  void rec_clicked(bool);
191  void buffering(int progress);
192 
193  void played();
194  void paused();
195  void stopped();
196  void playstate_changed(PlayManager::PlayState);
197 
198  void track_changed(const MetaData& md);
199 
200  void cover_clicked();
201  void seek(int);
202  void jump_forward();
203  void jump_backward();
204  void jump_forward_ms();
205  void jump_backward_ms();
206 
207  void mute_button_clicked();
208  void volume_slider_moved(int val);
209  void volume_changed(int val);
210  void mute_changed(bool mute);
211  void change_volume_by_tick(int val);
212  void increase_volume();
213  void decrease_volume();
214 
215  /* File */
216  void open_files_clicked();
217  void open_dir_clicked();
218 
219 
220  /* View */
221  void show_library(bool);
222  void show_notification_toggled(bool);
223  void show_fullscreen_toggled(bool);
224  void _sl_fullscreen_toggled();
225  void skin_toggled(bool);
226 
227  void set_library_path_clicked();
228 
229  void min2tray_toggled(bool);
230  void only_one_instance_toggled(bool);
231  void live_search_toggled(bool);
232  void notify_new_version_toggled(bool);
233 
234  void main_splitter_moved(int pos, int idx);
235 
236  void library_idx_changed(int idx);
237  void check_library_menu_action();
238 
239 
240  void about();
241  void help();
242 
243  void set_standard_cover();
244  void set_cover_image(const CoverLocation&);
245  void fetch_cover();
246 
247  void awa_version_finished(bool success);
248  void awa_translators_finished(bool success);
249 
250  void _sl_sr_active_changed();
251 
252 
253 };
254 
255 
256 #endif // GUI_SIMPLEPLAYER_H
Abstract Interface you should use when creating a preference dialog.
Definition: PreferenceDialogInterface.h:40
RadioMode
The RadioMode enum.
Definition: MetaData.h:41
Definition: GUI_TrayIcon.h:38
Definition: GUI_Player.h:63
Definition: ui_GUI_Player.h:704
Definition: MetaData.h:49
PlayState
Current Playing state.
Definition: PlayManager.h:79
Definition: LocalLibrary.h:31
Definition: GUI_MTP.h:38
Definition: MetaDataList.h:46
Definition: GUI_Playlist.h:42
Definition: IconLoader.h:35
Global handler for current playback state (Singleton)
Definition: PlayManager.h:67
Library Plugin Manager.
Definition: LibraryPluginHandler.h:38
The CoverLocation class.
Definition: CoverLocation.h:37
Definition: EngineHandler.h:36
Definition: GUI_AlternativeCovers.h:46
The GlobalMessageReceiverInterface class implement this class in order to have the possibility to sho...
Definition: GlobalMessageReceiverInterface.h:33
Interface for PlayerPlugin classes. get_name() and language_changed() must be overwritten.
Definition: PlayerPlugin.h:48
Asynchgronous web access class.
Definition: AsyncWebAccess.h:37
The CoverLookup class.
Definition: CoverLookup.h:65
Definition: PlayerPluginHandler.h:34
Definition: SayonaraWidget.h:62
Interface that should be implemented when using configurable shortcuts.
Definition: ShortcutWidget.h:33