Sayonara Player
GUI_Player.h
1 /* GUI_Simpleplayer.h */
2 
3 /* Copyright (C) 2011-2017 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_SIMPLEPLAYER_H
22 #define GUI_SIMPLEPLAYER_H
23 
24 #include "GUI/Player/ui_GUI_Player.h"
25 
26 #include "Components/PlayManager/PlayState.h"
27 #include "Helper/MetaData/MetaData.h"
28 
29 #include "Helper/Message/GlobalMessageReceiverInterface.h"
30 #include "GUI/Helper/SayonaraWidget/SayonaraWidget.h"
31 #include "GUI/Helper/Shortcuts/ShortcutWidget.h"
32 
33 #include <QSystemTrayIcon>
34 
35 class GUI_TrayIcon;
36 class PlayManager;
41 class QTranslator;
42 class QMessageBox;
43 class GUI_Logger;
44 
45 #ifdef WITH_MTP
46  class GUI_MTP;
47 #endif
48 
49 class GUI_Player :
50  public SayonaraMainWindow,
51  public ShortcutWidget,
53  private Ui::Sayonara
54 {
55  Q_OBJECT
56 
57 signals:
58  void sig_player_closed();
59 
60 public:
61  explicit GUI_Player(QTranslator* translator, QWidget *parent=nullptr);
62  ~GUI_Player();
63 
64  void set_libraries(LibraryPluginHandler* plugin_loader);
65 
66  void register_player_plugin_handler(PlayerPluginHandler* pph);
67  void register_preference_dialog(PreferenceDialogInterface* dialog);
68 
69  void ui_loaded();
70  QString get_shortcut_text(const QString &shortcut_identifier) const override;
71 
72 
73 private:
74  PlayerPluginHandler* _pph=nullptr;
75  LibraryPluginHandler* _lph=nullptr;
76 
77 #ifdef WITH_MTP
78  GUI_MTP* _mtp=nullptr;
79 #endif
80 
81  GUI_TrayIcon* _tray_icon=nullptr;
82 
83  QTranslator* _translator=nullptr;
84  QStringList _translators;
85 
86  PlayManager* _play_manager=nullptr;
87  QMessageBox* _about_box=nullptr;
88  GUI_Logger* _logger=nullptr;
89 
90  MetaData _md;
91 
92 
93 private:
94  void init_gui();
95 
96  void setup_tray_actions ();
97  void setup_volume_button(int percent);
98  void setup_connections();
99 
100  void set_album_label();
101  void set_artist_label();
102  void set_title_label();
103  void set_info_labels();
104 
105  void set_radio_mode(RadioMode model);
106 
107  void closeEvent(QCloseEvent* e) override;
108  void keyPressEvent(QKeyEvent* e) override;
109  void resizeEvent(QResizeEvent* e) override;
110  void moveEvent(QMoveEvent* e) override;
111 
112  void language_changed() override;
113  void skin_changed() override;
114 
115  void set_total_time_label(qint64 length_ms);
116  void set_cur_pos_label(int val);
117  void set_cover_location();
118  void set_standard_cover();
119 
120  // Methods for other mudules to display info/warning/error
121  GlobalMessage::Answer error_received(const QString &error, const QString &sender_name=QString()) override;
122  GlobalMessage::Answer warning_received(const QString &error, const QString &sender_name=QString()) override;
123  GlobalMessage::Answer info_received(const QString &error, const QString &sender_name=QString()) override;
124  GlobalMessage::Answer question_received(const QString &info, const QString &sender_name=QString(), GlobalMessage::QuestionType type=GlobalMessage::QuestionType::YesNo) override;
125 
126 
127 private slots:
128  void play_clicked();
129  void stop_clicked();
130  void prev_clicked();
131  void next_clicked();
132  void rec_clicked(bool);
133  void buffering(int progress);
134  void set_progress_tooltip(int val);
135 
136  void played();
137  void paused();
138  void stopped();
139  void playstate_changed(PlayState state);
140 
141  void track_changed(const MetaData& md);
142 
143  void seek(int);
144 
145  void mute_button_clicked();
146  void volume_slider_moved(int val);
147  void volume_changed(int val);
148  void mute_changed(bool mute);
149  void rec_changed(bool on);
150  void change_volume_by_tick(int val);
151  void increase_volume();
152  void decrease_volume();
153 
154  /* File */
155  void open_files_clicked();
156  void open_dir_clicked();
157 
158 
159  /* View */
160  void show_library(bool);
161  void show_fullscreen_toggled(bool);
162  void skin_toggled(bool);
163 
164 
165  void main_splitter_moved(int pos, int idx);
166 
167  void library_idx_changed(int idx);
168  void check_library_menu_action();
169 
170  void about();
171  void help();
172 
173  void cover_changed(const QImage& cover);
174 
175  void awa_version_finished();
176  void awa_translators_finished();
177 
178  void id3_tags_changed(const MetaDataList& v_md_old, const MetaDataList& v_md_new);
179 
180  void cur_pos_changed(quint64 pos_ms);
181  void file_info_changed();
182 
183  void md_changed(const MetaData& md);
184  void dur_changed(const MetaData& md);
185  void br_changed(const MetaData& md);
186 
187  void really_close();
188 
189  void tray_icon_activated(QSystemTrayIcon::ActivationReason reason);
190 
191  /* Plugins */
192  void show_plugin(PlayerPluginInterface* plugin);
193  void hide_all_plugins();
194 
195  void _sl_sr_active_changed();
196 };
197 
198 #endif // GUI_SIMPLEPLAYER_H
Abstract Interface you should use when creating a preference dialog.
Definition: PreferenceDialogInterface.h:38
RadioMode
The RadioMode enum.
Definition: MetaData.h:42
Definition: GUI_TrayIcon.h:38
Definition: GUI_Player.h:49
Definition: ui_GUI_Player.h:647
The MetaData class MetaDataHelper.
Definition: MetaData.h:55
Definition: GUI_Logger.h:55
Definition: GUI_MTP.h:34
Definition: MetaDataList.h:39
Global handler for current playback state (Singleton)
Definition: PlayManager.h:37
Library Plugin Manager.
Definition: LibraryPluginHandler.h:35
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:38
Definition: PlayerPluginHandler.h:32
The SayonaraMainWindow class.
Definition: SayonaraWidget.h:60
Interface that should be implemented when using configurable shortcuts.
Definition: ShortcutWidget.h:30
PlayState
The PlayState enum.
Definition: PlayState.h:30