2015-01-01 17:15:05 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2013-02-20 18:29:12 +00:00
|
|
|
#include <QDir>
|
2013-06-26 08:09:26 +00:00
|
|
|
|
2023-03-21 20:27:25 +00:00
|
|
|
#include <boost/program_options/options_description.hpp>
|
|
|
|
#include <boost/program_options/variables_map.hpp>
|
|
|
|
|
2021-12-20 19:40:04 +00:00
|
|
|
#include <components/debug/debugging.hpp>
|
2023-03-21 20:27:25 +00:00
|
|
|
#include <components/files/configurationmanager.hpp>
|
2023-12-24 14:44:50 +00:00
|
|
|
#include <components/files/qtconversion.hpp>
|
2024-02-05 15:13:32 +00:00
|
|
|
#include <components/l10n/qttranslations.hpp>
|
2024-05-15 06:10:42 +00:00
|
|
|
#include <components/platform/application.hpp>
|
2022-06-01 07:34:53 +00:00
|
|
|
#include <components/platform/platform.hpp>
|
2021-12-20 19:40:04 +00:00
|
|
|
|
2013-11-10 16:58:57 +00:00
|
|
|
#ifdef MAC_OS_X_VERSION_MIN_REQUIRED
|
|
|
|
#undef MAC_OS_X_VERSION_MIN_REQUIRED
|
2013-09-01 19:17:41 +00:00
|
|
|
// We need to do this because of Qt: https://bugreports.qt-project.org/browse/QTBUG-22154
|
|
|
|
#define MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
|
2013-11-10 16:58:57 +00:00
|
|
|
#endif // MAC_OS_X_VERSION_MIN_REQUIRED
|
|
|
|
|
2011-04-07 21:57:03 +00:00
|
|
|
#include "maindialog.hpp"
|
2011-03-28 23:36:26 +00:00
|
|
|
|
2021-12-20 19:40:04 +00:00
|
|
|
int runLauncher(int argc, char* argv[])
|
2011-03-28 23:36:26 +00:00
|
|
|
{
|
2022-06-01 07:34:53 +00:00
|
|
|
Platform::init();
|
|
|
|
|
2023-03-21 20:27:25 +00:00
|
|
|
boost::program_options::variables_map variables;
|
|
|
|
boost::program_options::options_description description;
|
|
|
|
Files::ConfigurationManager configurationManager;
|
|
|
|
configurationManager.addCommonOptions(description);
|
|
|
|
configurationManager.readConfiguration(variables, description, true);
|
|
|
|
|
2024-06-15 10:42:50 +00:00
|
|
|
Debug::setupLogging(configurationManager.getLogPath(), "Launcher");
|
2023-03-21 20:27:25 +00:00
|
|
|
|
2014-12-18 02:24:10 +00:00
|
|
|
try
|
2013-06-23 18:45:24 +00:00
|
|
|
{
|
2024-05-15 06:10:42 +00:00
|
|
|
Platform::Application app(argc, argv);
|
2011-03-28 23:36:26 +00:00
|
|
|
|
2023-12-24 14:44:50 +00:00
|
|
|
QString resourcesPath(".");
|
|
|
|
if (!variables["resources"].empty())
|
|
|
|
{
|
|
|
|
resourcesPath = Files::pathToQString(variables["resources"].as<Files::MaybeQuotedPath>().u8string());
|
|
|
|
}
|
|
|
|
|
2024-02-05 15:13:32 +00:00
|
|
|
l10n::installQtTranslations(app, "launcher", resourcesPath);
|
2023-12-24 14:44:50 +00:00
|
|
|
|
2023-03-21 20:27:25 +00:00
|
|
|
Launcher::MainDialog mainWin(configurationManager);
|
2013-01-26 17:19:04 +00:00
|
|
|
|
2015-05-16 10:18:04 +00:00
|
|
|
Launcher::FirstRunDialogResult result = mainWin.showFirstRunDialog();
|
|
|
|
if (result == Launcher::FirstRunDialogResultFailure)
|
2014-12-18 02:24:10 +00:00
|
|
|
return 0;
|
2014-05-30 00:12:48 +00:00
|
|
|
|
2015-05-16 10:18:04 +00:00
|
|
|
if (result == Launcher::FirstRunDialogResultContinue)
|
|
|
|
mainWin.show();
|
2013-01-26 17:19:04 +00:00
|
|
|
|
2018-08-07 18:57:16 +00:00
|
|
|
int exitCode = app.exec();
|
|
|
|
|
|
|
|
return exitCode;
|
2014-12-18 02:24:10 +00:00
|
|
|
}
|
2023-03-21 20:27:25 +00:00
|
|
|
catch (const std::exception& e)
|
2014-12-18 02:24:10 +00:00
|
|
|
{
|
2023-03-21 20:27:25 +00:00
|
|
|
Log(Debug::Error) << "Unexpected exception: " << e.what();
|
2014-12-18 02:24:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2018-08-07 18:57:16 +00:00
|
|
|
}
|
2021-12-20 19:40:04 +00:00
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
2024-06-15 10:42:50 +00:00
|
|
|
return Debug::wrapApplication(runLauncher, argc, argv, "Launcher");
|
2021-12-20 19:40:04 +00:00
|
|
|
}
|