mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #3756
Alice Weigt (1): feat(settings): Export and copy debug log
This commit is contained in:
commit
c600609f9f
|
@ -24,6 +24,8 @@
|
|||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QClipboard>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "src/core/core.h"
|
||||
#include "src/core/coreav.h"
|
||||
|
@ -91,6 +93,73 @@ 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);
|
||||
|
||||
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()
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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">
|
||||
|
@ -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">
|
||||
|
|
Loading…
Reference in New Issue
Block a user