Vidalia  0.3.1
CrashReportDialog.cpp
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If you
4 ** did not receive the LICENSE file with this file, you may obtain it from the
5 ** Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 /*
12 ** \file CrashReportDialog.cpp
13 ** \brief Dialog that asks the user whether they would like to
14 ** submit the crash report, along with optional additional details
15 ** about what they were doing at the time of the crash.
16 */
17 
18 #include "CrashReportDialog.h"
19 
20 #include "stringutil.h"
21 
22 #include <QProcess>
23 #include <QPushButton>
24 #include <QMessageBox>
25 #include <QFileInfo>
26 
27 
29  : QDialog(parent)
30 {
31  ui.setupUi(this);
32 
33  /* Tweak the text displayed on the buttons at the bottom of the dialog */
34  QPushButton *btn;
35  btn = ui.buttonBox->button(QDialogButtonBox::Ok);
36  btn->setText(tr("Restart Vidalia"));
37 
38  btn = ui.buttonBox->button(QDialogButtonBox::Cancel);
39  btn->setText(tr("Don't Restart"));
40 }
41 
42 void
43 CrashReportDialog::setCrashAnnotations(const QHash<QString,QString> &annotations)
44 {
45  _annotations = annotations;
46 }
47 
48 void
49 CrashReportDialog::setMinidumpFiles(const QString &minidump, const QString &annotations)
50 {
51  _minidumpPath = minidump;
52  _annotationsPath = annotations;
53 
54  ui.textDetails->setPlainText(QString("%1\n%2\n").arg(_minidumpPath).arg(_annotationsPath));
55 }
56 
57 void
59 {
60  /* Attempt to restart Vidalia with the saved arguments */
61  QString exe = _annotations.value("RestartExecutable");
62  QString args = _annotations.value("RestartExecutableArgs");
63  QStringList argList = string_parse_arguments(args);
64  if (! QProcess::startDetached(exe, argList, QFileInfo(exe).absolutePath())) {
65  QMessageBox dlg(QMessageBox::Warning, tr("Unable to restart Vidalia"),
66  tr("We were unable to automatically restart Vidalia. "
67  "Please restart Vidalia manually."),
68  QMessageBox::Ok, this);
69  dlg.exec();
70  }
71 
72  /* Close the dialog */
73  QDialog::accept();
74 }
75 
CrashReportDialog::_minidumpPath
QString _minidumpPath
Definition: CrashReportDialog.h:58
CrashReportDialog::ui
Ui::CrashReportDialog ui
Definition: CrashReportDialog.h:71
CrashReportDialog::_annotations
QHash< QString, QString > _annotations
Definition: CrashReportDialog.h:67
CrashReportDialog::CrashReportDialog
CrashReportDialog(QWidget *parent=0)
Definition: CrashReportDialog.cpp:28
CrashReportDialog::_annotationsPath
QString _annotationsPath
Definition: CrashReportDialog.h:62
CrashReportDialog::setMinidumpFiles
void setMinidumpFiles(const QString &minidump, const QString &annotations)
Definition: CrashReportDialog.cpp:49
stringutil.h
CrashReportDialog::accept
virtual void accept()
Definition: CrashReportDialog.cpp:58
CrashReportDialog::setCrashAnnotations
void setCrashAnnotations(const QHash< QString, QString > &annotations)
Definition: CrashReportDialog.cpp:43
string_parse_arguments
QStringList string_parse_arguments(const QString &str, bool *ok)
Definition: stringutil.cpp:305
CrashReportDialog.h