/** * @file main/GUI/fatalerr.cpp * @brief Fatal error message dialog box * @author Enar Vaikene * * Copyright (c) 2011 Enar Vaikene * * This file is part of the eVaf C++ cross-platform application development framework. * * This file can be used under the terms of the GNU General Public License * version 3.0 as published by the Free Software Foundation and appearing in * the file LICENSE included in the packaging of this file. Please review the * the following information to ensure the GNU General Public License version * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. * * Alternatively, this file may be used in accordance with the Commercial License * Agreement provided with the Software. */ #include "fatalerr.h" #include using namespace eVaf::GUI::Internal; //------------------------------------------------------------------- FatalErr::FatalErr(QString const & title, QString const & text, QWidget * parent) : QDialog(parent, Qt::WindowTitleHint) , mTimer(Timer) { setWindowTitle(title); QVBoxLayout * layout = new QVBoxLayout; layout->setSpacing(10); setLayout(layout); QHBoxLayout * messageBox = new QHBoxLayout; messageBox->setSpacing(20); layout->addLayout(messageBox); // Icon QLabel * l = new QLabel; l->setPixmap(QMessageBox::standardIcon(QMessageBox::Critical)); l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); messageBox->addWidget(l); // Error message text l = new QLabel(text); l->setWordWrap(true); l->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); messageBox->addWidget(l); // Warning about the Ignore button l = new QLabel; l->setTextFormat(Qt::RichText); l->setText(tr( "

Clicking on the 'Abort' button aborts the application.
" "Clicking on the 'Ignore' button keeps the application running for diagnostics.

" "

The application might be unstable if fatal errors are ignored!

" )); layout->addWidget(l); // Buttons QHBoxLayout * buttonBox = new QHBoxLayout; layout->addLayout(buttonBox); buttonBox->addStretch(); wAbort = new QPushButton(tr("%Abort (%1 sec)").arg(mTimer)); connect(wAbort, SIGNAL(clicked()), this, SLOT(abortClicked())); buttonBox->addWidget(wAbort); setFocusProxy(wAbort); QPushButton * b = new QPushButton(tr("&Ignore")); connect(b, SIGNAL(clicked()), this, SLOT(ignoreClicked())); buttonBox->addWidget(b); setResult(Abort); // Start the count-down timer startTimer(1000); } void FatalErr::timerEvent(QTimerEvent *) { --mTimer; wAbort->setText(tr("&Abort (%1 sec)").arg(mTimer)); if (mTimer <= 0) done(Abort); } void FatalErr::abortClicked() { done(Abort); } void FatalErr::ignoreClicked() { done(Ignore); } int FatalErr::message(QString const & title, QString const & text, QWidget * parent) { FatalErr msg(title, text, parent); return msg.exec(); }