mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-29 01:53:54 -07:00
Add "copy to clipboard" button to Debug Log window (#5913)
This commit is contained in:
parent
29d93fb9c1
commit
a07c1badd8
2 changed files with 25 additions and 2 deletions
|
|
@ -3,24 +3,40 @@
|
||||||
#include "../settings/cache_settings.h"
|
#include "../settings/cache_settings.h"
|
||||||
#include "../utility/logger.h"
|
#include "../utility/logger.h"
|
||||||
|
|
||||||
|
#include <QClipboard>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
DlgViewLog::DlgViewLog(QWidget *parent) : QDialog(parent)
|
DlgViewLog::DlgViewLog(QWidget *parent) : QDialog(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
logArea = new QPlainTextEdit;
|
logArea = new QPlainTextEdit;
|
||||||
logArea->setReadOnly(true);
|
logArea->setReadOnly(true);
|
||||||
|
|
||||||
auto *mainLayout = new QVBoxLayout;
|
auto *mainLayout = new QVBoxLayout;
|
||||||
|
mainLayout->setSpacing(3);
|
||||||
|
mainLayout->setContentsMargins(20, 20, 20, 6);
|
||||||
|
|
||||||
mainLayout->addWidget(logArea);
|
mainLayout->addWidget(logArea);
|
||||||
|
|
||||||
|
auto *bottomLayout = new QHBoxLayout;
|
||||||
|
|
||||||
coClearLog = new QCheckBox;
|
coClearLog = new QCheckBox;
|
||||||
coClearLog->setText(tr("Clear log when closing"));
|
coClearLog->setText(tr("Clear log when closing"));
|
||||||
coClearLog->setChecked(SettingsCache::instance().servers().getClearDebugLogStatus(false));
|
coClearLog->setChecked(SettingsCache::instance().servers().getClearDebugLogStatus(false));
|
||||||
connect(coClearLog, &QCheckBox::toggled, this, &DlgViewLog::actCheckBoxChanged);
|
connect(coClearLog, &QCheckBox::toggled, this, &DlgViewLog::actCheckBoxChanged);
|
||||||
mainLayout->addWidget(coClearLog);
|
|
||||||
|
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);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
|
@ -36,6 +52,11 @@ void DlgViewLog::actCheckBoxChanged(bool abNewValue)
|
||||||
SettingsCache::instance().servers().setClearDebugLogStatus(abNewValue);
|
SettingsCache::instance().servers().setClearDebugLogStatus(abNewValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DlgViewLog::actCopyToClipboard()
|
||||||
|
{
|
||||||
|
QApplication::clipboard()->setText(logArea->toPlainText());
|
||||||
|
}
|
||||||
|
|
||||||
void DlgViewLog::loadInitialLogBuffer()
|
void DlgViewLog::loadInitialLogBuffer()
|
||||||
{
|
{
|
||||||
QList<QString> logBuffer = Logger::getInstance().getLogBuffer();
|
QList<QString> logBuffer = Logger::getInstance().getLogBuffer();
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ protected:
|
||||||
private:
|
private:
|
||||||
QPlainTextEdit *logArea;
|
QPlainTextEdit *logArea;
|
||||||
QCheckBox *coClearLog;
|
QCheckBox *coClearLog;
|
||||||
|
QPushButton *copyToClipboardButton;
|
||||||
|
|
||||||
void loadInitialLogBuffer();
|
void loadInitialLogBuffer();
|
||||||
private slots:
|
private slots:
|
||||||
void appendLogEntry(const QString &message);
|
void appendLogEntry(const QString &message);
|
||||||
void actCheckBoxChanged(bool abNewValue);
|
void actCheckBoxChanged(bool abNewValue);
|
||||||
|
void actCopyToClipboard();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Loading…
Add table
Add a link
Reference in a new issue