Skip to content

Commit

Permalink
Added offscreen CLI argument
Browse files Browse the repository at this point in the history
  • Loading branch information
vedderb committed Jan 26, 2024
1 parent 6082b67 commit 3cf84db
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ static void showHelp()
qDebug() << "--packFirmware [fileIn:fileOut] : Pack firmware-file for compatibility with the bootloader. ";
qDebug() << "--packLisp [fileIn:fileOut] : Pack lisp-file and the included imports.";
qDebug() << "--bridgeAppData : Send app data (such as data from send-data in lisp) to stdout.";
qDebug() << "--offscreen : Use offscreen QPA so that X is not required for the CLI-mode.";
}

#ifdef Q_OS_LINUX
Expand Down Expand Up @@ -310,6 +311,7 @@ int main(int argc, char *argv[])
QString lispPackIn = "";
QString lispPackOut = "";
bool bridgeAppData = false;
bool offscreen = false;

// Arguments can be hard-coded in a build like this:
// qmlWindowSize = QSize(400, 800);
Expand Down Expand Up @@ -670,6 +672,11 @@ int main(int argc, char *argv[])
found = true;
}

if (str == "--offscreen") {
offscreen = true;
found = true;
}

if (!found) {
if (dash) {
qCritical() << "At least one of the flags is invalid:" << str;
Expand Down Expand Up @@ -969,7 +976,9 @@ int main(int argc, char *argv[])
if (isMcConf || isAppConf || isCustomConf || !lispPath.isEmpty() ||
eraseLisp || !firmwarePath.isEmpty() || uploadBootloaderBuiltin ||
!fileForSdIn.isEmpty() || bridgeAppData) {
qputenv("QT_QPA_PLATFORM", "offscreen");
if (offscreen) {
qputenv("QT_QPA_PLATFORM", "offscreen");
}
app = new QCoreApplication(argc, argv);
vesc = new VescInterface;
vesc->fwConfig()->loadParamsXml("://res/config/fw.xml");
Expand Down Expand Up @@ -1328,7 +1337,9 @@ int main(int argc, char *argv[])
}
});
} else if (useTcp) {
qputenv("QT_QPA_PLATFORM", "offscreen");
if (offscreen) {
qputenv("QT_QPA_PLATFORM", "offscreen");
}
app = new QCoreApplication(argc, argv);
vesc = new VescInterface;
vesc->fwConfig()->loadParamsXml("://res/config/fw.xml");
Expand All @@ -1351,7 +1362,9 @@ int main(int argc, char *argv[])
}
});
} else if (isTcpHub) {
qputenv("QT_QPA_PLATFORM", "offscreen");
if (offscreen) {
qputenv("QT_QPA_PLATFORM", "offscreen");
}
app = new QCoreApplication(argc, argv);
tcpHub = new TcpHub;
if (tcpHub->start(tcpPort)) {
Expand Down

0 comments on commit 3cf84db

Please sign in to comment.