File indexing completed on 2022-11-29 20:22:24

0001 /**
0002  * SPDX-FileCopyrightText: (C) 2003 by Sébastien Laoût <slaout@linux62.org>
0003  * SPDX-License-Identifier: GPL-2.0-or-later
0004  */
0005 
0006 #ifndef DEBUGWINDOW_H
0007 #define DEBUGWINDOW_H
0008 
0009 #include <QWidget>
0010 
0011 class QVBoxLayout;
0012 class QTextBrowser;
0013 class QString;
0014 class QCloseEvent;
0015 
0016 /**A simple window that display text through debugging messages.
0017  *@author Sébastien Laoût
0018  */
0019 
0020 class DebugWindow : public QWidget
0021 {
0022     Q_OBJECT
0023 public:
0024     /** Constructor and destructor */
0025     explicit DebugWindow(QWidget *parent = nullptr);
0026     ~DebugWindow() override;
0027     /** Methods to post a message to the debug window */
0028     Q_INVOKABLE void postMessage(const QString msg);
0029     DebugWindow &operator<<(const QString msg);
0030     void insertHLine();
0031 
0032 protected:
0033     void closeEvent(QCloseEvent *event) override;
0034 
0035 private:
0036     QVBoxLayout *layout;
0037     QTextBrowser *textBrowser;
0038 };
0039 
0040 #define DEBUG_WIN                                                                                                                                                                                                                              \
0041     if (Global::debugWindow)                                                                                                                                                                                                                   \
0042     *Global::debugWindow
0043 
0044 #endif // DEBUGWINDOW_H