mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-03-21 17:55:21 -05:00
Some checks failed
Build Desktop / Configure (push) Has been cancelled
Build Docker Image / amd64 & arm64 (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, 13) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, skip, 11) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, skip, 12) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Fedora, RPM, 42) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Fedora, RPM, skip, 41) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Ubuntu, DEB, 24.04) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Ubuntu, DEB, skip, 22.04) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (yes, Arch, skip) (push) Has been cancelled
Build Desktop / macOS ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (1, macos-14, Apple, 14, Release, 15.4) (push) Has been cancelled
Build Desktop / macOS ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (1, macos-15, Apple, 15, Release, 16.4) (push) Has been cancelled
Build Desktop / macOS ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (1, macos-15-intel, 13, Intel, 13, Release, 16.4) (push) Has been cancelled
Build Desktop / macOS ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (macos-15, Apple, 15, Debug, 16.4) (push) Has been cancelled
Build Desktop / Windows ${{matrix.target}} (msvc2019_64, 5.15.*, 7) (push) Has been cancelled
Build Desktop / Windows ${{matrix.target}} (msvc2019_64, qtimageformats qtmultimedia qtwebsockets, 6.6.*, 10) (push) Has been cancelled
* Move logger and key signals from libcockatrice_utility to Cockatrice. Took 9 minutes * Only link Qt::Core instead of COCKATRICE_QT_MODULES to libraries, if possible. Took 2 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
86 lines
2.4 KiB
C++
86 lines
2.4 KiB
C++
#include "dlg_view_log.h"
|
|
|
|
#include "../../logger.h"
|
|
|
|
#include <QClipboard>
|
|
#include <QPlainTextEdit>
|
|
#include <QPushButton>
|
|
#include <QRegularExpression>
|
|
#include <QVBoxLayout>
|
|
#include <libcockatrice/settings/cache_settings.h>
|
|
|
|
DlgViewLog::DlgViewLog(QWidget *parent) : QDialog(parent)
|
|
{
|
|
logArea = new QPlainTextEdit;
|
|
logArea->setReadOnly(true);
|
|
|
|
auto *mainLayout = new QVBoxLayout;
|
|
mainLayout->setSpacing(3);
|
|
mainLayout->setContentsMargins(20, 20, 20, 6);
|
|
|
|
mainLayout->addWidget(logArea);
|
|
|
|
auto *bottomLayout = new QHBoxLayout;
|
|
|
|
coClearLog = new QCheckBox;
|
|
coClearLog->setText(tr("Clear log when closing"));
|
|
coClearLog->setChecked(SettingsCache::instance().servers().getClearDebugLogStatus(false));
|
|
connect(coClearLog, &QCheckBox::toggled, this, &DlgViewLog::actCheckBoxChanged);
|
|
|
|
copyToClipboardButton = new QPushButton;
|
|
copyToClipboardButton->setText(tr("Copy to clipboard"));
|
|
copyToClipboardButton->setAutoDefault(false);
|
|
connect(copyToClipboardButton, &QPushButton::clicked, this, &DlgViewLog::actCopyToClipboard);
|
|
|
|
bottomLayout->addWidget(coClearLog);
|
|
bottomLayout->addStretch();
|
|
bottomLayout->addWidget(copyToClipboardButton);
|
|
|
|
mainLayout->addLayout(bottomLayout);
|
|
|
|
setLayout(mainLayout);
|
|
|
|
setWindowTitle(tr("Debug Log"));
|
|
resize(800, 500);
|
|
|
|
loadInitialLogBuffer();
|
|
connect(&Logger::getInstance(), &Logger::logEntryAdded, this, &DlgViewLog::appendLogEntry);
|
|
}
|
|
|
|
void DlgViewLog::actCheckBoxChanged(bool abNewValue)
|
|
{
|
|
SettingsCache::instance().servers().setClearDebugLogStatus(abNewValue);
|
|
}
|
|
|
|
void DlgViewLog::actCopyToClipboard()
|
|
{
|
|
QApplication::clipboard()->setText(logArea->toPlainText());
|
|
}
|
|
|
|
void DlgViewLog::loadInitialLogBuffer()
|
|
{
|
|
QList<QString> logBuffer = Logger::getInstance().getLogBuffer();
|
|
for (const QString &message : logBuffer)
|
|
appendLogEntry(message);
|
|
}
|
|
|
|
void DlgViewLog::appendLogEntry(const QString &message)
|
|
{
|
|
static auto colorEscapeCodePattern = QRegularExpression("\033\\[\\d+m");
|
|
|
|
QString sanitizedMessage = message;
|
|
sanitizedMessage.replace(colorEscapeCodePattern, "");
|
|
|
|
logArea->appendPlainText(sanitizedMessage);
|
|
}
|
|
|
|
void DlgViewLog::closeEvent(QCloseEvent * /* event */)
|
|
{
|
|
if (coClearLog->isChecked()) {
|
|
logArea->clear();
|
|
|
|
logArea->appendPlainText(Logger::getInstance().getClientVersion());
|
|
logArea->appendPlainText(Logger::getInstance().getSystemArchitecture());
|
|
}
|
|
}
|