#include #include #include #include #include #include #include "controllers/NavigationController.h" #include "MouseEventSpy.h" #include "EnergySaver.h" #include "controllers/SettingsHandler.h" int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; QCommandLineParser parser; parser.setApplicationDescription("Lena's music app"); // Define a custom config file using -c or --config QCommandLineOption configOption(QStringList() << "c" << "config", "Optional: Define custom config file"); parser.addOption(configOption); // process commandline arguments parser.process(app); QSettings* settings = nullptr; if(!parser.value(configOption).isEmpty()){ // config was handed over via commandline argument. Use this config if file exists. QString configFilePath = parser.value(configOption); QFileInfo configInfo(configFilePath); if(configInfo.exists()){ settings = new QSettings(configFilePath, QSettings::Format::NativeFormat); } } if(!settings){ // default config settings = new QSettings(QSettings::Scope::UserScope, "MaleyanaSoft", "LenaPi"); } /* Read Settings */ const auto settingsHandler = SettingsHandler::createSettingsHandlerAndFillWithDefaultsIfMissing(settings); // init main app NavigationController navController; navController.setContext(engine.rootContext()); navController.init(settingsHandler->getRootPath()); navController.setUiProfile(settingsHandler->getProfile()); if(settingsHandler->isEnergySaverEnabled()){ /* install MouseEventSpy and energy saver used for auto shut down of device * if not used for a predefined time. */ MouseEventSpy::init(); EnergySaver::init(settingsHandler->getEnergySaverTimeout(), settingsHandler->getShutdownScript()); QObject::connect(MouseEventSpy::instance(), &MouseEventSpy::mouseEventDetected, EnergySaver::instance(), &EnergySaver::restartTimer); } // load GUI engine.load(QUrl("qrc:/main.qml")); return app.exec(); }