#include #include #include #include "controllers/NavigationController.h" #include "MouseEventSpy.h" #include "EnergySaver.h" int main(int argc, char *argv[]) { /* * @todo Add command line parser to specify a custom config file * https://doc.qt.io/qt-5/qcommandlineparser.html */ QGuiApplication app(argc, argv); QQmlApplicationEngine engine; /* Read Settings */ QSettings settings("me", "LenaPi"); const auto rootPath = settings.value("rootPath", "/home/ar/source/lenaMusic/").toString(); // path to music files const auto profile = settings.value("profile", "RasPiTouch").toString(); // known modes are "RasPiTouch" and "Desktop" const auto isEnergySavingEnabled = settings.value("enableEnergySaver", true).toBool(); // enable/disable energy saver const auto energySaverTimeout = settings.value("timeout", 60).toInt(); //timeout in seconds const auto shutdownScript = settings.value("shutdownScript", "/usr/local/sbin/do_shutdown.sh").toString(); /* @todo Hand over profile to UiStateModel via NavigationController * Add properties to UiStateModel for showing volume controls and close button. * Set those properties according to profile and use them to hide/show elements in qml */ NavigationController navController; navController.setContext(engine.rootContext()); navController.init(rootPath); if(isEnergySavingEnabled){ /* install MouseEventSpy and energy saver used for auto shut down of device * if not used for a predefined time. */ MouseEventSpy::init(); EnergySaver::init(energySaverTimeout, shutdownScript); QObject::connect(MouseEventSpy::instance(), &MouseEventSpy::mouseEventDetected, EnergySaver::instance(), &EnergySaver::restartTimer); } // load GUI engine.load(QUrl("qrc:/main.qml")); return app.exec(); }