Vidalia  0.2.15
CrashReportDialog.cpp
Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 
00007 **  including this file, may be copied, modified, propagated, or distributed 
00008 **  except according to the terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file CrashReportDialog.cpp
00013 ** \brief Dialog that asks the user whether they would like to
00014 ** submit the crash report, along with optional additional details
00015 ** about what they were doing at the time of the crash.
00016 */
00017 
00018 #include "CrashReportDialog.h"
00019 
00020 #include "stringutil.h"
00021 
00022 #include <QProcess>
00023 #include <QPushButton>
00024 #include <QMessageBox>
00025 #include <QFileInfo>
00026 
00027 
00028 CrashReportDialog::CrashReportDialog(QWidget *parent)
00029   : QDialog(parent)
00030 {
00031   ui.setupUi(this);
00032 
00033   /* Tweak the text displayed on the buttons at the bottom of the dialog */
00034   QPushButton *btn;
00035   btn = ui.buttonBox->button(QDialogButtonBox::Ok);
00036   btn->setText(tr("Restart Vidalia"));
00037 
00038   btn = ui.buttonBox->button(QDialogButtonBox::Cancel);
00039   btn->setText(tr("Don't Restart"));
00040 }
00041 
00042 void
00043 CrashReportDialog::setCrashAnnotations(const QHash<QString,QString> &annotations)
00044 {
00045   _annotations = annotations;
00046 }
00047 
00048 void
00049 CrashReportDialog::setMinidumpFiles(const QString &minidump, const QString &annotations)
00050 {
00051   _minidumpPath = minidump;
00052   _annotationsPath = annotations;
00053 
00054   ui.textDetails->setPlainText(QString("%1\n%2\n").arg(_minidumpPath).arg(_annotationsPath));
00055 }
00056 
00057 void
00058 CrashReportDialog::accept()
00059 {
00060   /* Attempt to restart Vidalia with the saved arguments */
00061   QString exe  = _annotations.value("RestartExecutable");
00062   QString args = _annotations.value("RestartExecutableArgs");
00063   QStringList argList = string_parse_arguments(args);
00064   if (! QProcess::startDetached(exe, argList, QFileInfo(exe).absolutePath())) {
00065     QMessageBox dlg(QMessageBox::Warning, tr("Unable to restart Vidalia"),
00066                     tr("We were unable to automatically restart Vidalia. "
00067                        "Please restart Vidalia manually."),
00068                     QMessageBox::Ok, this);
00069     dlg.exec();
00070   }
00071 
00072   /* Close the dialog */
00073   QDialog::accept();
00074 }
00075