1 #include "DlgErrorReport.h"
3 #include <QCommonStyle>
4 #include <QCoreApplication>
10 #include <QVBoxLayout>
12 const QString ERROR_REPORT_FILE (
"engauge_error_report.xml");
13 const int MAX_BTN_WIDTH = 80;
16 const QString &xmlWithDocument,
19 m_xmlWithoutDocument (xmlWithoutDocument),
20 m_xmlWithDocument (xmlWithDocument)
22 QVBoxLayout *layout =
new QVBoxLayout;
23 layout->setSizeConstraint (QLayout::SetFixedSize);
28 setWindowTitle (tr (
"Error Report"));
29 setWindowIcon(style.standardIcon (QStyle::SP_MessageBoxCritical));
31 QLabel *lblPreview =
new QLabel (tr (
"An unrecoverable error has occurred. Would you like to send an error report to "
32 "the Engauge developers?\n\n"
33 "Adding document information to the error report greatly increases the chances of finding "
34 "and fixing the problems. However, document information should not be included if your document "
35 "contains any information that should remain private."));
36 lblPreview->setWordWrap(
true);
37 layout->addWidget (lblPreview);
39 m_chkWithDocument =
new QCheckBox (
"Include document information");
40 m_chkWithDocument->setChecked (
true);
42 layout->addWidget (m_chkWithDocument);
43 connect (m_chkWithDocument, SIGNAL (stateChanged (
int)),
this, SLOT (slotDocumentCheckboxChanged (
int)));
45 QHBoxLayout *layoutButtons =
new QHBoxLayout;
47 QWidget *panelButtons =
new QWidget;
48 panelButtons->setLayout (layoutButtons);
49 layout->addWidget (panelButtons);
51 m_btnSend =
new QPushButton(tr (
"Send"));
52 m_btnSend->setMaximumWidth (MAX_BTN_WIDTH);
53 layoutButtons->addWidget (m_btnSend);
54 connect (m_btnSend, SIGNAL (released ()),
this, SLOT (slotSend()));
56 m_btnCancel =
new QPushButton(tr (
"Cancel"));
57 m_btnCancel->setMaximumWidth (MAX_BTN_WIDTH);
58 layoutButtons->addWidget (m_btnCancel);
59 connect (m_btnCancel, SIGNAL (released ()),
this, SLOT (reject ()));
62 DlgErrorReport::~DlgErrorReport()
67 QString DlgErrorReport::errorFile ()
const
69 return QCoreApplication::applicationDirPath() +
"/" + ERROR_REPORT_FILE;
72 void DlgErrorReport::removeFile()
const
74 QFile::remove (errorFile ());
77 void DlgErrorReport::saveFile (
const QString &xml)
const
79 QFile file (errorFile());
80 if (file.open (QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
82 QTextStream out (&file);
89 void DlgErrorReport::slotDocumentCheckboxChanged(
int )
94 void DlgErrorReport::slotSend()
97 if (m_chkWithDocument->isChecked()) {
98 m_xmlToUpload = m_xmlWithDocument;
100 m_xmlToUpload = m_xmlWithoutDocument;
103 done (QDialog::Accepted);
108 void DlgErrorReport::updateFile()
110 if (m_chkWithDocument->isChecked()) {
111 saveFile (m_xmlWithDocument);
113 saveFile (m_xmlWithoutDocument);
119 return m_xmlToUpload;
QString xmlToUpload() const
Xml to be uploaded. Includes document if user has approved.
DlgErrorReport(const QString &xmlWithoutDocument, const QString &xmlWithDocument, QWidget *parent=0)
Single constructor. With the Document, the extra context improves debugging. Without the Document...