Allow running in headless mode when no display server is present
This commit is contained in:
parent
93999abafa
commit
36171a221a
1 changed files with 17 additions and 10 deletions
27
src/main.cpp
27
src/main.cpp
|
|
@ -14,17 +14,14 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
//pw_init(&argc, &argv);
|
||||
|
||||
//set info
|
||||
QCoreApplication::setOrganizationName("UVOS");
|
||||
QCoreApplication::setOrganizationDomain("uvos.xyz");
|
||||
QCoreApplication::setApplicationName("SHinterface");
|
||||
QCoreApplication::setApplicationVersion("0.6");
|
||||
|
||||
QDir::setCurrent(a.applicationDirPath());
|
||||
QStringList args;
|
||||
for(int i = 0; i < argc; ++i)
|
||||
args<<argv[i];
|
||||
|
||||
//parse comand line
|
||||
QCommandLineParser parser;
|
||||
|
|
@ -42,9 +39,8 @@ int main(int argc, char *argv[])
|
|||
parser.addOption(settingsPathOption);
|
||||
QCommandLineOption headlessOption(QStringList()<<"e"<<"headless", QCoreApplication::translate("main", "Dont start the gui"));
|
||||
parser.addOption(headlessOption);
|
||||
parser.process(a);
|
||||
|
||||
int retVal;
|
||||
parser.process(args);
|
||||
|
||||
programMode = PROGRAM_MODE_UI_ONLY;
|
||||
if(parser.isSet(masterOption))
|
||||
|
|
@ -53,6 +49,15 @@ int main(int argc, char *argv[])
|
|||
if(parser.isSet(headlessOption))
|
||||
programMode = PROGRAM_MODE_HEADLESS_PRIMARY;
|
||||
}
|
||||
|
||||
QCoreApplication* a;
|
||||
if(programMode == PROGRAM_MODE_HEADLESS_PRIMARY)
|
||||
a = new QCoreApplication(argc, argv);
|
||||
else
|
||||
a = new QApplication(argc, argv);
|
||||
|
||||
int retVal;
|
||||
|
||||
if(programMode == PROGRAM_MODE_PRIMARY || programMode == PROGRAM_MODE_HEADLESS_PRIMARY)
|
||||
{
|
||||
QString settingsPath = parser.value(settingsPathOption);
|
||||
|
|
@ -118,7 +123,7 @@ int main(int argc, char *argv[])
|
|||
QObject::connect(w, &MainWindow::createdItem, &globalItems, &ItemStore::addItem);
|
||||
w->show();
|
||||
}
|
||||
retVal = a.exec();
|
||||
retVal = a->exec();
|
||||
|
||||
delete w;
|
||||
delete microDevice;
|
||||
|
|
@ -131,9 +136,11 @@ int main(int argc, char *argv[])
|
|||
QObject::connect(&w, &MainWindow::sigSave, mainObject.tcpClient, &TcpClient::sendItems);
|
||||
w.show();
|
||||
|
||||
retVal = a.exec();
|
||||
retVal = a->exec();
|
||||
}
|
||||
|
||||
delete a;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue