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 "GUI/View/Loaders/DataLoaderUtil.h"
#include "GUI/View/Main/MainWindow.h"
#include "config_build.h"
#include <QMessageBox>

Wuttke, Joachim
committed
#include <QtGlobal>
auto guiFailedAssertion = [](std::string msg) {
#ifdef BA_DEBUG
std::cerr << "FATAL (catched in debug mode): " << msg << std::endl;
std::raise(11); // abort so that we can inspect the backtrace
#else
qFatal("%s", msg.c_str());
#endif
};
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
QApplication::setApplicationName("BornAgain");
QApplication::setApplicationVersion(GUI::Util::Path::getBornAgainVersionString());
QApplication::setOrganizationName("BornAgain");
#ifndef Q_OS_MAC
QApplication::setWindowIcon(QIcon(":/images/BornAgain.ico"));
#endif
ApplicationSettings applicationSettings;
qInstallMessageHandler(messageHandler);
failedAssertion = guiFailedAssertion;
Mohammad Mahadi Hasan
committed
auto style = applicationSettings.styleToUse();
applicationSettings.loadStyle(style);
QString dir = GUI::Util::Path::appDataFolder();
if (!QDir().exists(dir))
QDir().mkpath(dir);
MainWindow win;
GUI::Global::mainWindow = &win;
if (options.find("geometry"))
win.resize(options.mainWindowSize());
if (options.find("project-file"))
win.loadProject(options.projectFile());
return QApplication::exec();