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
42void
43CrashReportDialog::setCrashAnnotations(const QHash<QString,QString> &annotations)
44{
45 _annotations = annotations;
46}
47
48void
49CrashReportDialog::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
57void
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
void setCrashAnnotations(const QHash< QString, QString > &annotations)
QHash< QString, QString > _annotations
CrashReportDialog(QWidget *parent=0)
void setMinidumpFiles(const QString &minidump, const QString &annotations)
Ui::CrashReportDialog ui
virtual void accept()
QStringList string_parse_arguments(const QString &str, bool *ok)
Definition: stringutil.cpp:305