216240d2444888f86c7faac66cda1e39162f637c
6 #include <sailfishapp.h>
9 #include "journeymodel.h"
12 #include "imageprovider.h"
14 #include "harbour-pedalo.h"
16 int main(int argc
, char *argv
[])
18 // SailfishApp::main() will display "qml/harbour-pedalo.qml", if you need more
19 // control over initialization, you can use:
21 // - SailfishApp::application(int, char *[]) to get the QGuiApplication *
22 // - SailfishApp::createView() to get a new QQuickView * instance
23 // - SailfishApp::pathTo(QString) to get a QUrl to a resource file
24 // - SailfishApp::pathToMainQml() to get a QUrl to the main QML file
26 // To display the view, call "show()" (will show fullscreen on device).
28 QScopedPointer
<QGuiApplication
> app(SailfishApp::application(argc
, argv
));
29 // These values are used by QSettings to access the config file in
30 // /home/nemo/.local/share/flypig/harbour-pedalo.conf
31 //QCoreApplication::setOrganizationName("flypig");
32 QCoreApplication::setOrganizationDomain("www.flypig.co.uk");
33 QCoreApplication::setApplicationName(APP_NAME
);
35 Settings::instantiate();
36 qmlRegisterSingletonType
<Settings
>("harbour.pedalo.settings", 1, 0, "Settings", Settings::provider
);
38 JourneyModel journeys
;
40 Settings::getInstance().setMainStatus(currentStatus
);
41 Settings::getInstance().loadSettings();
44 file
.setFileName(Settings::getConfigDir() + "/journeys.csv");
45 journeys
.importFromFile(file
);
47 QScopedPointer
<QQuickView
> view(SailfishApp::createView());
48 view
->engine()->addImageProvider(QLatin1String("pedalo"), new ImageProvider(Settings::getInstance()));
49 view
->setSource(SailfishApp::pathTo("qml/harbour-pedalo.qml"));
51 QQmlContext
*ctxt
= view
->rootContext();
52 ctxt
->setContextProperty("version", VERSION
);
53 qDebug() << "harbour-pedalo VERSION string: " << VERSION
;
54 qDebug() << "VERSION_MAJOR: " << VERSION_MAJOR
;
55 qDebug() << "VERSION_MINOR: " << VERSION_MINOR
;
56 qDebug() << "VERSION_BUILD: " << VERSION_BUILD
;
57 ctxt
->setContextProperty("journeymodel", &journeys
);
58 ctxt
->setContextProperty("currentStatus", ¤tStatus
);
61 int result
= app
->exec();
63 // Write out the journey data
65 dir
.mkpath(Settings::getConfigDir());
66 file
.setFileName(Settings::getConfigDir() + "/journeys.csv");
67 qDebug() << "File saved as: " << file
.fileName();
68 journeys
.exportToFile(file
);
70 Settings::getInstance().saveSettings();