// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef MAINMACRO_H #define MAINMACRO_H #include #include QT_BEGIN_NAMESPACE_AM // needed for syncqt QT_END_NAMESPACE_AM #define QT_AM_MAIN(...) \ Q_DECL_EXPORT int main(int argc, char *argv[]) \ { \ std::unique_ptr a; \ std::unique_ptr cfg; \ \ try { \ a = std::make_unique(argc, argv, QtAM::Main::InitFlag::ForkSudoServer \ | QtAM::Main::InitFlag::InitializeLogging); \ /* this is deliberately not using make_unique to be able to use initializer lists */ \ cfg.reset(new QtAM::Configuration(__VA_ARGS__)); \ cfg->parseWithArguments(QCoreApplication::arguments()); \ \ a->setup(cfg.get()); \ a->loadQml(); \ a->showWindow(); \ } catch (const std::exception &e) { \ qCritical() << "ERROR:" << e.what(); \ QtAM::Main::errorExit(); \ } \ \ return QtAM::Main::exec(); \ } #endif // MAINMACRO_H