blob: de8c049530b3534c33335c3450a2fc0d5e17543d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright 2016-2021 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#include "DeveloperConsole.h"
#include "LogEmitter.h"
#include "Global.h"
#include <QtWidgets/QTextBrowser>
DeveloperConsole::DeveloperConsole(QObject *parent) : QObject(parent) {
connect(Global::get().le.data(), SIGNAL(newLogEntry(const QString &)), this, SLOT(addLogMessage(const QString &)));
}
DeveloperConsole::~DeveloperConsole() {
QMainWindow *mw = m_window.data();
delete mw;
}
void DeveloperConsole::show() {
if (m_window.isNull()) {
QMainWindow *mw = new QMainWindow();
mw->setAttribute(Qt::WA_DeleteOnClose);
QTextBrowser *tb = new QTextBrowser();
mw->resize(675, 300);
mw->setCentralWidget(tb);
mw->setWindowTitle(tr("Developer Console"));
connect(Global::get().le.data(), SIGNAL(newLogEntry(const QString &)), tb, SLOT(append(const QString &)));
foreach (const QString &m, m_logEntries)
tb->append(m);
m_window = QPointer< QMainWindow >(mw);
}
m_window.data()->show();
m_window.data()->activateWindow();
}
void DeveloperConsole::addLogMessage(const QString &msg) {
if (m_logEntries.count() >= 1000)
m_logEntries.removeFirst();
m_logEntries.append(msg);
}
|