mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -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 "../utility/logger.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
|
|
@ -36,6 +52,11 @@ 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();
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ protected:
|
|||
private:
|
||||
QPlainTextEdit *logArea;
|
||||
QCheckBox *coClearLog;
|
||||
QPushButton *copyToClipboardButton;
|
||||
|
||||
void loadInitialLogBuffer();
|
||||
private slots:
|
||||
void appendLogEntry(const QString &message);
|
||||
void actCheckBoxChanged(bool abNewValue);
|
||||
void actCopyToClipboard();
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue