diff --git a/src/widget/form/settings/advancedform.cpp b/src/widget/form/settings/advancedform.cpp index fa842b961b..67f91cc539 100644 --- a/src/widget/form/settings/advancedform.cpp +++ b/src/widget/form/settings/advancedform.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include "src/core/core.h" #include "src/core/coreav.h" @@ -91,6 +93,51 @@ void AdvancedForm::on_cbMakeToxPortable_stateChanged() { Settings::getInstance().setMakeToxPortable(bodyUI->cbMakeToxPortable->isChecked()); } +void AdvancedForm::on_btnExportLog_clicked() +{ + QString savefile = QFileDialog::getSaveFileName(this, tr("Save File"),QDir::homePath(),tr("Logs (*.log)"), 0 ,QFileDialog::DontUseNativeDialog); + QString logFileDir = Settings::getInstance().getAppCacheDirPath(); + QString logfile = logFileDir + "qtox.log"; + + QFile file(logfile); + if (file.exists()) + qDebug() << "Found debug log for copying"; + else + qDebug() << "No debug file found"; + + QFile::copy(logfile, savefile); + QFile copyfile(savefile); + if (copyfile.exists()) + qDebug() << "Successfully copied to: " << savefile; + else + qDebug() << "File was not copied"; +} + +void AdvancedForm::on_btnCopyDebug_clicked() +{ + QString debugtext; + QString logFileDir = Settings::getInstance().getAppCacheDirPath(); + QString logfile = logFileDir + "qtox.log"; + + QFile file(logfile); + if (file.exists()) + qDebug() << "Found debug log for copying"; + else + qDebug() << "No debug file found"; + + + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QTextStream in(&file); + debugtext = in.readAll(); + } + file.close(); + + QClipboard* clipboard = QApplication::clipboard(); + + if (clipboard) + clipboard->setText(debugtext, QClipboard::Clipboard); +} void AdvancedForm::on_resetButton_clicked() { diff --git a/src/widget/form/settings/advancedform.h b/src/widget/form/settings/advancedform.h index 44825131c0..20d783ac49 100644 --- a/src/widget/form/settings/advancedform.h +++ b/src/widget/form/settings/advancedform.h @@ -43,6 +43,9 @@ private slots: // Portable void on_cbMakeToxPortable_stateChanged(); void on_resetButton_clicked(); + // Debug + void on_btnCopyDebug_clicked(); + void on_btnExportLog_clicked(); // Connection void on_cbEnableIPv6_stateChanged(); void on_cbEnableUDP_stateChanged(); diff --git a/src/widget/form/settings/advancedsettings.ui b/src/widget/form/settings/advancedsettings.ui index 898d284574..cd8375a93a 100644 --- a/src/widget/form/settings/advancedsettings.ui +++ b/src/widget/form/settings/advancedsettings.ui @@ -24,8 +24,8 @@ 0 0 - 489 - 549 + 485 + 545 @@ -64,6 +64,29 @@ + + + + Debug + + + + + + Export Debug Log + + + + + + + Copy Debug Log + + + + + +