Sayonara Player
GUI_Logger.h
1 /* GUI_Logger.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 
22 
23 #ifndef GUI_LOGGER_H
24 #define GUI_LOGGER_H
25 
26 #include "Utils/Logger/LogListener.h"
27 #include "GUI/Utils/Widgets/Widget.h"
28 
29 #include <QStringList>
30 #include <QWidget>
31 
32 class QShowEvent;
33 
34 UI_FWD(GUI_Logger)
35 
36 class LogObject :
37  public QObject,
38  public LogListener
39 {
40  Q_OBJECT
41 
42  signals:
43  void sig_new_log(const QDateTime& t, Log log_type, const QString& class_name, const QString& str);
44 
45  public:
46  explicit LogObject(QObject* parent=nullptr);
47  ~LogObject();
48 
49  void add_log_line(const LogEntry& le) override;
50 };
51 
52 
53 class GUI_Logger :
54  public Gui::Widget
55 {
56  Q_OBJECT
57  UI_CLASS(GUI_Logger)
58 
59  public:
60  explicit GUI_Logger(QWidget *parent = 0);
61  ~GUI_Logger();
62 
63  LogListener* get_log_listener();
64 
65  protected:
66  void showEvent(QShowEvent* e) override;
67  void language_changed() override;
68 
69  private:
70  QStringList _buffer;
71 
72  void init_ui();
73  QString calc_log_line(const QDateTime& t, Log log_type, const QString& class_name, const QString& str);
74 
75  private slots:
76  void log_ready(const QDateTime& t, Log log_type, const QString& class_name, const QString& str);
77  void save_clicked();
78 };
79 
80 #endif // GUI_LOGGER_H
Definition: LogListener.h:32
Definition: GUI_Logger.h:36
Definition: GUI_Logger.h:53
Definition: Logger.h:54
Widget with Settings connection. Also contains triggers for language_changed() and skin_changed() wi...
Definition: Widget.h:38