1 /* GUI_Simpleplayer.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (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/Utils/GuiClass.h"
25 #include "Gui/Utils/Widgets/Widget.h"
26 #include "Utils/Message/MessageReceiverInterface.h"
27 #include "Utils/Pimpl.h"
28 
29 #include <QSystemTrayIcon>
30 
31 class GUI_TrayIcon;
32 class GUI_Logger;
33 class QAction;
34 class QMessageBox;
35 class QTranslator;
36 
37 UI_FWD(GUI_Player)
38 
39 class CoverDataProvider;
40 class DynamicPlaybackChecker;
41 
42 namespace PlayerPlugin
43 {
44 	class Handler;
45 	class Base;
46 }
47 
48 namespace Playlist
49 {
50 	class Handler;
51 }
52 
53 class PlayManager;
54 
55 class GUI_Player :
56 	public Gui::MainWindow,
57 	public MessageReceiverInterface
58 {
59 	Q_OBJECT
60 	PIMPL(GUI_Player)
61 	UI_CLASS(GUI_Player)
62 
63 	signals:
64 		void sigClosed();
65 
66 	public:
67 		GUI_Player(PlayManager* playManager, Playlist::Handler* playlistHandler, CoverDataProvider* coverProvider,
68 		           DynamicPlaybackChecker* dynamicPlaybackChecker, QWidget* parent = nullptr);
69 		~GUI_Player() override;
70 
71 		void registerPreferenceDialog(QAction* dialog_action);
72 		void requestShutdown();
73 
74 	private:
75 		void initTrayActions();
76 		void initConnections();
77 		void initLibrary();
78 		void initControlSplitter();
79 		void initMainSplitter();
80 		void initFontChangeFix();
81 		void initGeometry();
82 
83 		void checkControlSplitter();
84 
85 		void fullscreenChanged();
86 		void initControls();
87 		void controlstyleChanged();
88 
89 		void showLibraryChanged();
90 		void addCurrentLibrary();
91 		void removeCurrentLibrary();
92 
93 	private slots:
94 		void playstateChanged(PlayState state);
95 		void playError(const QString& message);
96 
97 		void splitterMainMoved(int pos, int idx);
98 		void splitterControlsMoved(int pos, int idx);
99 
100 		void currentLibraryChanged();
101 
102 		void minimize();
103 		void reallyClose();
104 
105 		void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
106 		void currentTrackChanged(const MetaData& md);
107 
108 		/* Plugins */
109 		void pluginAdded(PlayerPlugin::Base* plugin);
110 		void pluginActionTriggered(bool b);
111 
112 	protected:
113 		void closeEvent(QCloseEvent* e) override;
114 		void resizeEvent(QResizeEvent* e) override;
115 		bool event(QEvent* e) override;
116 
117 		// Methods for other mudules to display info/warning/error
118 		Message::Answer errorReceived(const QString& error, const QString& senderName = QString()) override;
119 		Message::Answer warningReceived(const QString& error, const QString& senderName = QString()) override;
120 		Message::Answer infoReceived(const QString& error, const QString& senderName = QString()) override;
121 		Message::Answer questionReceived(const QString& info, const QString& senderName = QString(),
122 		                                 Message::QuestionType type = Message::QuestionType::YesNo) override;
123 
124 		void languageChanged() override;
125 };
126 
127 #endif // GUI_SIMPLEPLAYER_H
128