-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathdiagnosticdialog.cpp
65 lines (51 loc) · 1.73 KB
/
diagnosticdialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "diagnosticdialog.h"
#include "ui_diagnosticdialog.h"
#include <QTemporaryFile>
#include <QTextDocumentWriter>
#include <QFileDialog>
#include <QPushButton>
extern QTemporaryFile gLogFile;
DiagnosticDialog::DiagnosticDialog(QWidget *parent) :
QDialog(parent),_filename(""),
ui(new Ui::DiagnosticDialog)
{
ui->setupUi(this);
this->setWindowTitle("Diagnostic");
QFile* log_file = new QFile(gLogFile.fileName());
log_file->open(QIODevice::ReadOnly);
QString log(log_file->readAll());
log_file->close();
_vboxlayout = new QVBoxLayout(this);
_log_textedit = new QTextEdit();
_log_textedit->setText(log);
_log_textedit->setReadOnly(true);
_buttonbox = new QDialogButtonBox();
_ok_button = new QPushButton(tr("&OK"));
_save_button = new QPushButton(tr("&Save"));
_buttonbox->addButton(_ok_button, QDialogButtonBox::AcceptRole);
_buttonbox->addButton(_save_button,QDialogButtonBox::ActionRole);
_ok_button->setAutoDefault(true);
QObject::connect(_ok_button, SIGNAL(clicked()), this, SLOT(onOkButtonClicked()));
QObject::connect(_save_button, SIGNAL(clicked()), this, SLOT(onSaveButtonClicked()));
_vboxlayout->addWidget(_log_textedit);
_vboxlayout->addWidget(_buttonbox);
setLayout(_vboxlayout);
delete log_file;
log_file = nullptr;
}
DiagnosticDialog::~DiagnosticDialog()
{
delete ui;
}
void DiagnosticDialog::onOkButtonClicked()
{
this->close();
return;
}
void DiagnosticDialog::onSaveButtonClicked()
{
if( _filename.isEmpty() )
_filename = QFileDialog::getSaveFileName( this, tr("Save Diagnostic"), "." ,tr("All Files (*)"));
QTextDocumentWriter writer(_filename);
writer.write(_log_textedit->document());
}