Newer
Older
// ************************************************************************************************
// BornAgain: simulate and fit reflection and scattering
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
// ************************************************************************************************

Wuttke, Joachim
committed
#include "Base/Util/Assert.h"
#include "GUI/Application/ApplicationSettings.h"
#include "config_build.h"

Wuttke, Joachim
committed
#include <QApplication>
#include <QMessageBox>

Wuttke, Joachim
committed
#include <QtGlobal>
int main(int argc, char* argv[])
{
ApplicationOptions options(argc, argv);
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
qRegisterMetaType<QVector<double>>("QVector<double>");

Wuttke, Joachim
committed
int ret = -1;
try {
QApplication app(argc, argv);
app.setApplicationName("BornAgain");
app.setApplicationVersion(GUI::Base::Path::getBornAgainVersionString());

Wuttke, Joachim
committed
app.setOrganizationName("BornAgain");

Wuttke, Joachim
committed
app.setWindowIcon(QIcon(":/images/BornAgain.ico"));

Wuttke, Joachim
committed
ApplicationSettings applicationSettings;

Wuttke, Joachim
committed
auto style = applicationSettings.styleToUse();
applicationSettings.loadStyle(style);
QString dir = GUI::Base::Path::appDataFolder();

Wuttke, Joachim
committed
if (!QDir().exists(dir))
QDir().mkpath(dir);

Wuttke, Joachim
committed
MainWindow win;
GUI::Global::mainWindow = &win;
if (options.find("geometry"))
win.resize(options.mainWindowSize());
if (options.find("project-file"))
win.loadProject(options.projectFile());
win.show();

Wuttke, Joachim
committed
} catch (const std::exception& ex) {

Wuttke, Joachim
committed
QApplication app(argc, argv);

Wuttke, Joachim
committed
QMessageBox msgbox(QMessageBox::Critical, "BornAgain: fatal bug",
QString("Sorry, you encountered a fatal bug.\n"
"The application will terminate.\n"
"Please note the following and inform the maintainers.\n\n")

Wuttke, Joachim
committed
QMessageBox::Ok, nullptr);

Wuttke, Joachim
committed
msgbox.exec();

Wuttke, Joachim
committed
}