ACAV 69797fb42a2b
Abstract Syntax Tree (AST) visualization tool for C, C++, and Objective-C
Loading...
Searching...
No Matches
LogDock.h
Go to the documentation of this file.
1/*$!{
2* Aurora Clang AST Viewer (ACAV)
3*
4* Copyright (c) 2026 Min Liu
5* Copyright (c) 2026 Michael David Adams
6*
7* SPDX-License-Identifier: GPL-2.0-or-later
8*
9* This program is free software; you can redistribute it and/or modify
10* it under the terms of the GNU General Public License as published by
11* the Free Software Foundation; either version 2 of the License, or
12* (at your option) any later version.
13*
14* This program is distributed in the hope that it will be useful,
15* but WITHOUT ANY WARRANTY; without even the implied warranty of
16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17* GNU General Public License for more details.
18*
19* You should have received a copy of the GNU General Public License along
20* with this program; if not, see <https://www.gnu.org/licenses/>.
21}$!*/
22
25#pragma once
26
27#include "core/LogEntry.h"
28#include <QDockWidget>
29#include <QMutex>
30#include <QTimer>
31#include <QVector>
32
33class QPlainTextEdit;
34class QTabWidget;
35class QFont;
36
37namespace acav {
38
39class LogDock : public QDockWidget {
40 Q_OBJECT
41
42public:
43 explicit LogDock(QWidget *parent = nullptr);
44
46 void applyFont(const QFont &font);
47
48public slots:
49 void enqueue(const LogEntry &entry);
50
52 void focusAllTab();
53
54private slots:
55 void flushPending();
56 void clearAll();
57
58private:
59 // For safety print log to avoid log flood
60 void appendBatch(const QVector<LogEntry> &batch);
61 void appendText(QPlainTextEdit *view, const QString &text);
62 static QString formatEntry(const LogEntry &entry);
63
64 QTabWidget *tabs_;
65 QPlainTextEdit *allView_;
66 QPlainTextEdit *errorView_;
67 QPlainTextEdit *infoView_;
68 QPlainTextEdit *debugView_;
69 bool autoScroll_ = true;
70
71 QMutex mutex_;
72 QVector<LogEntry> pending_;
73 QTimer *flushTimer_;
74 int maxBatchSize_ = 500;
75 int maxPendingSize_ = 20000;
76};
77
78} // namespace acav
void focusAllTab()
Switch to All tab and set focus.
Definition LogDock.cpp:218
void applyFont(const QFont &font)
Apply the display font to all log tabs and text editors.
Definition LogDock.cpp:115