Browse Source

feat(settings): Export and copy debug log

Fixes #2890
pull/3756/head
Alice Weigt 9 years ago
parent
commit
3c6bd043a0
  1. 69
      src/widget/form/settings/advancedform.cpp
  2. 3
      src/widget/form/settings/advancedform.h
  3. 27
      src/widget/form/settings/advancedsettings.ui

69
src/widget/form/settings/advancedform.cpp

@ -24,6 +24,8 @@
#include <QDir> #include <QDir>
#include <QMessageBox> #include <QMessageBox>
#include <QProcess> #include <QProcess>
#include <QClipboard>
#include <QFileDialog>
#include "src/core/core.h" #include "src/core/core.h"
#include "src/core/coreav.h" #include "src/core/coreav.h"
@ -91,6 +93,73 @@ void AdvancedForm::on_cbMakeToxPortable_stateChanged()
{ {
Settings::getInstance().setMakeToxPortable(bodyUI->cbMakeToxPortable->isChecked()); 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);
if (savefile.isNull() || savefile.isEmpty())
{
qDebug() << "Debug log save file was not properly chosen";
return;
}
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";
return;
}
if (QFile::copy(logfile, savefile))
qDebug() << "Successfully copied to: " << savefile;
else
qDebug() << "File was not copied";
}
void AdvancedForm::on_btnCopyDebug_clicked()
{
QString logFileDir = Settings::getInstance().getAppCacheDirPath();
QString logfile = logFileDir + "qtox.log";
QFile file(logfile);
if (!file.exists())
{
qDebug() << "No debug file found";
return;
}
QClipboard* clipboard = QApplication::clipboard();
if (clipboard)
{
QString debugtext;
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file);
debugtext = in.readAll();
file.close();
}
else
{
qDebug() << "Unable to open file for copying to clipboard";
return;
}
clipboard->setText(debugtext, QClipboard::Clipboard);
qDebug() << "Debug log copied to clipboard";
}
else
{
qDebug() << "Unable to access clipboard";
}
}
void AdvancedForm::on_resetButton_clicked() void AdvancedForm::on_resetButton_clicked()
{ {

3
src/widget/form/settings/advancedform.h

@ -43,6 +43,9 @@ private slots:
// Portable // Portable
void on_cbMakeToxPortable_stateChanged(); void on_cbMakeToxPortable_stateChanged();
void on_resetButton_clicked(); void on_resetButton_clicked();
// Debug
void on_btnCopyDebug_clicked();
void on_btnExportLog_clicked();
// Connection // Connection
void on_cbEnableIPv6_stateChanged(); void on_cbEnableIPv6_stateChanged();
void on_cbEnableUDP_stateChanged(); void on_cbEnableUDP_stateChanged();

27
src/widget/form/settings/advancedsettings.ui

@ -24,8 +24,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>489</width> <width>485</width>
<height>549</height> <height>545</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@ -64,6 +64,29 @@
</layout> </layout>
</widget> </widget>
</item> </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> <item>
<widget class="QGroupBox" name="connectionGroup"> <widget class="QGroupBox" name="connectionGroup">
<property name="title"> <property name="title">

Loading…
Cancel
Save