mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Display dialog of crash handling options at startup if Interface crashed
Default option and Esc continue without taking any action.
This commit is contained in:
parent
63ad972576
commit
9c782f6a6d
3 changed files with 71 additions and 0 deletions
|
@ -257,6 +257,7 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
// Set build version
|
||||
QCoreApplication::setApplicationVersion(BUILD_VERSION);
|
||||
|
||||
CrashHandler::checkForAndHandleCrash();
|
||||
CrashHandler::writeRunningMarkerFiler();
|
||||
qAddPostRoutine(CrashHandler::deleteRunningMarkerFile);
|
||||
|
||||
|
|
|
@ -12,13 +12,72 @@
|
|||
#include "CrashHandler.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFile>
|
||||
#include <QLabel>
|
||||
#include <PathUtils.h>
|
||||
#include <QRadioButton>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
static const QString RUNNING_MARKER_FILENAME = "Interface.running";
|
||||
|
||||
void CrashHandler::checkForAndHandleCrash() {
|
||||
QFile runningMarkerFile(runningMarkerFilePath());
|
||||
if (runningMarkerFile.exists()) {
|
||||
Action action = promptUserForAction();
|
||||
if (action != DO_NOTHING) {
|
||||
handleCrash(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CrashHandler::Action CrashHandler::promptUserForAction() {
|
||||
QDialog crashDialog;
|
||||
crashDialog.setWindowTitle("Interface Crashed Last Run");
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout;
|
||||
|
||||
QLabel* label = new QLabel("What would you like to do?");
|
||||
layout->addWidget(label);
|
||||
|
||||
QRadioButton* option1 = new QRadioButton("Delete Interface.ini");
|
||||
QRadioButton* option2 = new QRadioButton("Delete Interface.ini but retain login and avatar info.");
|
||||
QRadioButton* option3 = new QRadioButton("Continue with my current Interface.ini");
|
||||
option3->setChecked(true);
|
||||
layout->addWidget(option1);
|
||||
layout->addWidget(option2);
|
||||
layout->addWidget(option3);
|
||||
layout->addSpacing(12);
|
||||
layout->addStretch();
|
||||
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
layout->addWidget(buttons);
|
||||
crashDialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
|
||||
|
||||
crashDialog.setLayout(layout);
|
||||
|
||||
int result = crashDialog.exec();
|
||||
|
||||
if (result == QDialog::Accepted) {
|
||||
if (option1->isChecked()) {
|
||||
return CrashHandler::DELETE_INTERFACE;
|
||||
}
|
||||
if (option2->isChecked()) {
|
||||
return CrashHandler::RETAIN_LOGIN_AND_AVATAR_INFO;
|
||||
}
|
||||
}
|
||||
|
||||
// Dialog cancelled or "do nothing" option chosen
|
||||
return CrashHandler::DO_NOTHING;
|
||||
}
|
||||
|
||||
void CrashHandler::handleCrash(CrashHandler::Action action) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CrashHandler::writeRunningMarkerFiler() {
|
||||
QFile runningMarkerFile(runningMarkerFilePath());
|
||||
if (!runningMarkerFile.exists()) {
|
||||
|
|
|
@ -17,10 +17,21 @@
|
|||
class CrashHandler {
|
||||
|
||||
public:
|
||||
static void checkForAndHandleCrash();
|
||||
|
||||
static void writeRunningMarkerFiler();
|
||||
static void deleteRunningMarkerFile();
|
||||
|
||||
private:
|
||||
enum Action {
|
||||
DELETE_INTERFACE,
|
||||
RETAIN_LOGIN_AND_AVATAR_INFO,
|
||||
DO_NOTHING
|
||||
};
|
||||
|
||||
static Action promptUserForAction();
|
||||
static void handleCrash(Action action);
|
||||
|
||||
static const QString runningMarkerFilePath();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue