utility: Headless Coati
switch from qt to boost commandlineoptions coati can now parse a coatiproject without gui with commandline flag -d show all commandline options with flag --hidden
This commit is contained in:
+46
-18
@@ -1,4 +1,5 @@
|
||||
#include "utility/AppPath.h"
|
||||
#include "utility/commandline/CommandLineParser.h"
|
||||
#include "utility/logging/ConsoleLogger.h"
|
||||
#include "utility/logging/FileLogger.h"
|
||||
#include "utility/logging/LogManager.h"
|
||||
@@ -9,9 +10,9 @@
|
||||
#include "Application.h"
|
||||
#include "includes.h" // defines 'void setup(int argc, char *argv[])'
|
||||
#include "LicenseChecker.h"
|
||||
#include "qt/commandline/QtCommandLineParser.h"
|
||||
#include "qt/network/QtNetworkFactory.h"
|
||||
#include "qt/QtApplication.h"
|
||||
#include "qt/QtCoreApplication.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/view/QtViewFactory.h"
|
||||
#include "qt/window/QtMainWindow.h"
|
||||
@@ -30,8 +31,17 @@ void init()
|
||||
fileLogger->setLogLevel(Logger::LOG_ALL);
|
||||
FileLogger::setFilePath(UserPaths::getLogPath());
|
||||
LogManager::getInstance()->addLogger(fileLogger);
|
||||
}
|
||||
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||
void prepare(int argc, char *argv[])
|
||||
{
|
||||
if (AppPath::getAppPath().empty())
|
||||
{
|
||||
AppPath::setAppPath(QCoreApplication::applicationDirPath().toStdString() + "/");
|
||||
}
|
||||
setup(argc, argv);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -41,31 +51,49 @@ int main(int argc, char *argv[])
|
||||
Version version = Version::fromString(GIT_VERSION_NUMBER);
|
||||
QApplication::setApplicationVersion(version.toDisplayString().c_str());
|
||||
|
||||
QtApplication qtApp(argc, argv);
|
||||
if(AppPath::getAppPath().empty())
|
||||
CommandLineParser commandLineParser(argc, argv, version.toString());
|
||||
if (commandLineParser.exitApplication())
|
||||
{
|
||||
AppPath::setAppPath(QCoreApplication::applicationDirPath().toStdString());
|
||||
return 0;
|
||||
}
|
||||
setup(argc, argv);
|
||||
|
||||
qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
if (commandLineParser.runWithoutGUI())
|
||||
{
|
||||
// headless Coati
|
||||
QtCoreApplication qtApp(argc, argv);
|
||||
prepare(argc,argv);
|
||||
|
||||
init();
|
||||
std::shared_ptr<Application> app = Application::create( version );
|
||||
|
||||
QtCommandLineParser commandLineParser;
|
||||
commandLineParser.setup();
|
||||
commandLineParser.process(qtApp);
|
||||
if (commandLineParser.startedWithLicense())
|
||||
{
|
||||
qtApp.saveLicense(commandLineParser.getLicense());
|
||||
return 0;
|
||||
}
|
||||
|
||||
QtViewFactory viewFactory;
|
||||
QtNetworkFactory networkFactory;
|
||||
commandLineParser.projectLoad();
|
||||
|
||||
LicenseChecker checker;
|
||||
return qtApp.exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
QtApplication qtApp(argc, argv);
|
||||
prepare(argc,argv);
|
||||
qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
std::shared_ptr<Application> app = Application::create(version, &viewFactory, &networkFactory);
|
||||
QtViewFactory viewFactory;
|
||||
QtNetworkFactory networkFactory;
|
||||
|
||||
checker.setApp(app.get());
|
||||
LicenseChecker checker;
|
||||
|
||||
commandLineParser.parseCommandline();
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||
std::shared_ptr<Application> app = Application::create(version, &viewFactory, &networkFactory);
|
||||
|
||||
return qtApp.exec();
|
||||
checker.setApp(app.get());
|
||||
|
||||
commandLineParser.projectLoad();
|
||||
|
||||
return qtApp.exec();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user