Ilya Ashikhmin 730d0fa7a7 feat(app): add --simulate flag for headless demo captures
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 23:38:07 +02:00

31 lines
979 B
C++

#include "app/MainWindow.h"
#include <QApplication>
#include <QTimer>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QCoreApplication::setOrganizationName(QStringLiteral("PipeDiagram"));
QCoreApplication::setApplicationName(QStringLiteral("PipeDiagram"));
diag::MainWindow window;
window.show();
const QStringList args = app.arguments();
if (args.contains(QStringLiteral("--sample")))
window.loadSample();
if (args.contains(QStringLiteral("--simulate")))
window.setSimulationRunning(true);
// Headless smoke check: --screenshot <file.png> renders and exits.
const int shotIdx = args.indexOf(QStringLiteral("--screenshot"));
if (shotIdx >= 0 && shotIdx + 1 < args.size()) {
const QString path = args.at(shotIdx + 1);
QTimer::singleShot(300, &window, [&window, path] {
window.grab().save(path);
QApplication::quit();
});
}
return app.exec();
}