#include #include #include #include #include #include #include #include "controller.h" #include "widgetinfomodel.h" #include "availablewidgetsmodel.h" static bool launch_daemon = false; static QString settings_key_prefix("/apps/salmeta/watch0"); int main(int argc, char *argv[]) { QGuiApplication *app = SailfishApp::application(argc, argv); // TODO: Rudimentary command line parser ahead. Move to QCommandLineParser when it's ready. const QStringList args = app->arguments(); auto it = args.begin(); while (it != args.end()) { if (*it == "--daemon") { launch_daemon = true; } else if (*it == "--root") { ++it; settings_key_prefix = *it; } ++it; } qmlRegisterUncreatableType("com.javispedro.salmeta", 1, 0, "WidgetInfo", "Use the models, not this"); QFontDatabase::addApplicationFont(SailfishApp::pathTo("qml/watch/metawatch_8pt_5pxl_CAPS.ttf").toLocalFile()); QFontDatabase::addApplicationFont(SailfishApp::pathTo("qml/watch/metawatch_8pt_5pxl_Numerals.ttf").toLocalFile()); QFontDatabase::addApplicationFont(SailfishApp::pathTo("qml/watch/metawatch_8pt_6pxl_Numerals.ttf").toLocalFile()); QFontDatabase::addApplicationFont(SailfishApp::pathTo("qml/watch/metawatch_8pt_7pxl_CAPS.ttf").toLocalFile()); QFontDatabase::addApplicationFont(SailfishApp::pathTo("qml/watch/metawatch_16pt_11pxl.ttf").toLocalFile()); QFontDatabase::addApplicationFont(SailfishApp::pathTo("qml/watch/MetaWatch-Large-16pt-Sync.ttf").toLocalFile()); if (launch_daemon) { qDebug() << "Starting salmeta (daemon) with settings from" << settings_key_prefix; new Controller(settings_key_prefix, SailfishApp::createView()); } else { QQuickView *view = SailfishApp::createView(); view->rootContext()->setContextProperty("curSettingsPrefix", settings_key_prefix); view->rootContext()->setContextProperty("curWidgets", new WidgetInfoModel(settings_key_prefix)); view->rootContext()->setContextProperty("allWidgets", new AvailableWidgetsModel); view->setSource(SailfishApp::pathTo("qml/salmeta.qml")); view->show(); } return app->exec(); }