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