7 #include "DlgErrorReport.h" 9 #include <QCommonStyle> 10 #include <QCoreApplication> 12 #include <QHBoxLayout> 14 #include <QPushButton> 15 #include <QTextStream> 16 #include <QVBoxLayout> 18 const QString ERROR_REPORT_FILE (
"engauge_error_report.xml");
19 const int MAX_BTN_WIDTH = 80;
27 QVBoxLayout *layout =
new QVBoxLayout;
28 layout->setSizeConstraint (QLayout::SetFixedSize);
33 setWindowTitle (tr (
"Error Report"));
34 setWindowIcon(style.standardIcon (QStyle::SP_MessageBoxCritical));
36 QLabel *lblPreview =
new QLabel (tr (
"An unrecoverable error has occurred. Would you like to send an error report to " 37 "the Engauge developers?\n\n" 38 "The original document can be sent as part of the error report, which increases the " 39 "chances of finding and fixing the problem(s). However, if any information is private " 40 "then an anonymized version of the document will be sent."));
41 lblPreview->setWordWrap(
true);
42 layout->addWidget (lblPreview);
44 m_chkOriginal =
new QCheckBox (tr (
"Include original document information, otherwise anonymize the information"));
45 m_chkOriginal->setChecked (
true);
47 layout->addWidget (m_chkOriginal);
48 connect (m_chkOriginal, SIGNAL (stateChanged (
int)),
this, SLOT (slotDocumentCheckboxChanged (
int)));
50 QHBoxLayout *layoutButtons =
new QHBoxLayout;
52 QWidget *panelButtons =
new QWidget;
53 panelButtons->setLayout (layoutButtons);
54 layout->addWidget (panelButtons);
56 m_btnSend =
new QPushButton(tr (
"Send"));
57 m_btnSend->setMaximumWidth (MAX_BTN_WIDTH);
58 layoutButtons->addWidget (m_btnSend);
59 connect (m_btnSend, SIGNAL (released ()),
this, SLOT (slotSend()));
61 m_btnCancel =
new QPushButton(tr (
"Cancel"));
62 m_btnCancel->setMaximumWidth (MAX_BTN_WIDTH);
63 layoutButtons->addWidget (m_btnCancel);
64 connect (m_btnCancel, SIGNAL (released ()),
this, SLOT (reject ()));
67 DlgErrorReport::~DlgErrorReport()
72 QString DlgErrorReport::errorFile ()
const 74 return QCoreApplication::applicationDirPath() +
"/" + ERROR_REPORT_FILE;
77 void DlgErrorReport::removeFile()
const 79 QFile::remove (errorFile ());
82 void DlgErrorReport::saveFile (
const QString &xml)
const 84 QFile file (errorFile());
85 if (file.open (QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
87 QTextStream out (&file);
94 void DlgErrorReport::slotDocumentCheckboxChanged(
int )
99 void DlgErrorReport::slotSend()
102 if (m_chkOriginal->isChecked()) {
103 m_xmlToUpload = m_xmlOriginal;
105 m_xmlToUpload = m_xmlAnonymized;
108 done (QDialog::Accepted);
113 void DlgErrorReport::updateFile()
115 if (m_chkOriginal->isChecked()) {
116 saveFile (m_xmlOriginal);
118 saveFile (m_xmlAnonymized);
124 return m_xmlToUpload;
DlgErrorReport(const QString &xmlWithImage, QWidget *parent=0)
Single constructor. With the original data, the extra context improves debugging. With anonymization...
QString xmlToUpload() const
Xml to be uploaded. Includes document if user has approved.