implemented simple crash handler
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#include "crashhandler.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QLabel>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
CrashHandlerDialog::CrashHandlerDialog(const char *log_file)
|
||||
{
|
||||
setWindowTitle(tr("Olive"));
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
layout->addWidget(new QLabel(tr("We're sorry, Olive has crashed. Please send the following log to the developers to "
|
||||
"help resolve this.")));
|
||||
|
||||
QTextEdit* edit = new QTextEdit();
|
||||
layout->addWidget(edit);
|
||||
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox();
|
||||
|
||||
// FIXME: Implement auto-reporting
|
||||
//buttons->addButton(tr("Send Error Report"), QDialogButtonBox::AcceptRole);
|
||||
//buttons->addButton(tr("Don't Send"), QDialogButtonBox::RejectRole);
|
||||
buttons->addButton(QDialogButtonBox::Ok);
|
||||
|
||||
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
layout->addWidget(buttons);
|
||||
|
||||
QFile log(log_file);
|
||||
if (log.open(QFile::ReadOnly | QFile::Text)) {
|
||||
edit->setText(log.readAll());
|
||||
log.close();
|
||||
}
|
||||
}
|
||||
|
||||
void CrashHandlerDialog::accept()
|
||||
{
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void CrashHandlerDialog::reject()
|
||||
{
|
||||
QDialog::reject();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef CRASHHANDLERDIALOG_H
|
||||
#define CRASHHANDLERDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class CrashHandlerDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CrashHandlerDialog(const char* log_file);
|
||||
|
||||
public slots:
|
||||
virtual void accept() override;
|
||||
|
||||
virtual void reject() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // CRASHHANDLERDIALOG_H
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "crashhandler.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
QApplication a(argc, argv);
|
||||
|
||||
CrashHandlerDialog chd(argv[1]);
|
||||
chd.open();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user