2121#endif
2222
2323#include < QtCore/QTimer>
24+ #include < QtCore/QCoreApplication>
2425#include < QtCore/QEventLoop>
2526
2627#include < trikKernel/configurer.h>
4041
4142int main (int argc, char *argv[])
4243{
43- QApplication app (argc, argv);
44- app.setApplicationName (" TrikRun" );
44+ QStringList params;
45+ for (int i = 1 ; i < argc; ++i) {
46+ params << QString (argv[i]);
47+ }
48+
49+ QScopedPointer<QCoreApplication> app;
50+
51+ if (params.contains (" --no-display" ) || params.contains (" -no-display" )) {
52+ app.reset (new QCoreApplication (argc, argv));
53+ } else {
54+ app.reset (new QApplication (argc, argv));
55+ }
56+
57+ app->setApplicationName (" TrikRun" );
4558
4659 // RAII-style code to ensure that after brick gets destroyed there will be an event loop that cleans it up.
4760 trikKernel::DeinitializationHelper helper;
4861 Q_UNUSED (helper);
4962
50- trikKernel::ApplicationInitHelper initHelper (app);
63+ trikKernel::ApplicationInitHelper initHelper (* app);
5164
5265 initHelper.commandLineParser ().addPositionalArgument (" file" , QObject::tr (" File with script to execute" )
5366 + " " + QObject::tr (" (optional of -s option is specified)" ));
@@ -56,6 +69,10 @@ int main(int argc, char *argv[])
5669 , QObject::tr (" Script to be executed directly from command line." ) + " \n "
5770 + QObject::tr (" \t Example: ./trikRun -qws -s \" brick.smile(); script.wait(2000);\" " ));
5871
72+ initHelper.commandLineParser ().addFlag (" no-display" , " no-display"
73+ , QObject::tr (" Disable display support. When this flag is active, trikRun can work without QWS or even "
74+ " physical display" ));
75+
5976 initHelper.commandLineParser ().addApplicationDescription (QObject::tr (" Runner of JavaScript files." ));
6077
6178 if (!initHelper.parseCommandLine ()) {
@@ -78,9 +95,9 @@ int main(int argc, char *argv[])
7895 QScopedPointer<trikNetwork::MailboxInterface> mailbox (trikNetwork::MailboxFactory::create (configurer));
7996 trikScriptRunner::TrikScriptRunner result (*brick, mailbox.data (), gamepad.data ());
8097
81- QObject::connect (&result, SIGNAL (completed (QString, int )), & app, SLOT (quit ()));
98+ QObject::connect (&result, SIGNAL (completed (QString, int )), app. data () , SLOT (quit ()));
8299 result.run (script);
83- return app. exec ();
100+ return app-> exec ();
84101 };
85102
86103 if (initHelper.commandLineParser ().isSet (" s" )) {
0 commit comments