Skip to content

Commit

Permalink
feat(settings): Export and copy debug log
Browse files Browse the repository at this point in the history
Fixes qTox#2890
  • Loading branch information
AliceGrey committed Sep 28, 2016
1 parent 427176a commit 2dbec32
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 2 deletions.
47 changes: 47 additions & 0 deletions src/widget/form/settings/advancedform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <QDir>
#include <QMessageBox>
#include <QProcess>
#include <QClipboard>
#include <QFileDialog>

#include "src/core/core.h"
#include "src/core/coreav.h"
Expand Down Expand Up @@ -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()
{
Expand Down
3 changes: 3 additions & 0 deletions src/widget/form/settings/advancedform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
27 changes: 25 additions & 2 deletions src/widget/form/settings/advancedsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>489</width>
<height>549</height>
<width>485</width>
<height>545</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
Expand Down Expand Up @@ -64,6 +64,29 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="DebugGroup">
<property name="title">
<string>Debug</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnExportLog">
<property name="text">
<string>Export Debug Log</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCopyDebug">
<property name="text">
<string>Copy Debug Log</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="connectionGroup">
<property name="title">
Expand Down

0 comments on commit 2dbec32

Please sign in to comment.