diff --git a/cockatrice/src/dialogs/dlg_view_log.cpp b/cockatrice/src/dialogs/dlg_view_log.cpp index 35accf80f..b60a9767b 100644 --- a/cockatrice/src/dialogs/dlg_view_log.cpp +++ b/cockatrice/src/dialogs/dlg_view_log.cpp @@ -3,24 +3,40 @@ #include "../settings/cache_settings.h" #include "../utility/logger.h" +#include #include +#include #include #include 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 logBuffer = Logger::getInstance().getLogBuffer(); diff --git a/cockatrice/src/dialogs/dlg_view_log.h b/cockatrice/src/dialogs/dlg_view_log.h index 870c23fc5..26d6ad5e1 100644 --- a/cockatrice/src/dialogs/dlg_view_log.h +++ b/cockatrice/src/dialogs/dlg_view_log.h @@ -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 \ No newline at end of file