1 /* GUI_Logger.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_LOGGER_H
22 #define GUI_LOGGER_H
23 
24 #include "Utils/Logger/LogListener.h"
25 #include "Gui/Utils/Widgets/Dialog.h"
26 #include "Utils/Pimpl.h"
27 
28 #include <QStringList>
29 #include <QWidget>
30 
31 class QShowEvent;
32 
UI_FWD(GUI_Logger)33 UI_FWD(GUI_Logger)
34 
35 class LogObject :
36 	public QObject,
37 	public LogListener
38 {
39 	Q_OBJECT
40 
41 	signals:
42 		void sigNewLog(const QDateTime& t, Log logType, const QString& className, const QString& str);
43 
44 	public:
45 		explicit LogObject(QObject* parent = nullptr);
46 		~LogObject() override;
47 
48 		void addLogLine(const LogEntry& le) override;
49 };
50 
51 struct LogLine;
52 class GUI_Logger :
53 	public Gui::Dialog
54 {
55 	Q_OBJECT
56 	UI_CLASS(GUI_Logger)
57 	PIMPL(GUI_Logger)
58 
59 	public:
60 		explicit GUI_Logger(QWidget* parent = nullptr);
61 		~GUI_Logger() override;
62 
63 		LogListener* logListener();
64 
65 	private:
66 		void initUi();
67 		QString calcLogLine(const LogLine& log_line);
68 
69 	private slots:
70 		void currentModuleChanged(const QString& module);
71 		void logReady(const QDateTime& t, Log log_type, const QString& class_name, const QString& str);
72 		void loglevelChanged(int index);
73 		void saveClicked();
74 
75 	protected:
76 		void showEvent(QShowEvent* e) override;
77 		void languageChanged() override;
78 };
79 
80 #endif // GUI_LOGGER_H
81