summaryrefslogtreecommitdiff
path: root/src/salmeta.cpp
blob: f13cd649170db93f255a0b1b2f50b4408df0abf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <QtCore/QDebug>
#include <sailfishapp.h>

#include "controller.h"
#include "watchviewitem.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;
	}

	qmlRegisterType<WatchViewItem>("com.javispedro.salmeta", 1, 0, "WatchView");

	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("settingsPrefix", settings_key_prefix);
		view->setSource(SailfishApp::pathTo("qml/salmeta.qml"));
		view->show();
	}

	return app->exec();
}