3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
7 #include "qmaemo5homescreenadaptor.h"
8 #include "marketstodayqmlview.h"
11 #include <QDeclarativeEngine>
12 #include <QDeclarativeContext>
14 #include <QNetworkConfigurationManager>
15 #include <QGraphicsObject>
16 #include "logutility.h"
17 #include "connectionutility.h"
19 int main(int argc, char *argv[])
22 bool isDesktopWidget = false;
24 if (argc > 2 && QString(argv[1]).contains("-plugin-id")) {
25 isDesktopWidget = true;
28 QApplication app(argc, argv);
30 QNetworkConfigurationManager manager;
31 ConnectionUtility connectionUtility;
33 //Signal to check available networks when auto-update is triggered
34 QObject::connect(&manager,SIGNAL(updateCompleted()),&connectionUtility,SLOT(connectionListUpdated()));
37 MarketsTodayQMLView qmlView;
39 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
40 //For maemo fremantle or harmattan use a common path
41 qmlView.engine()->setOfflineStoragePath("/home/user/.marketstoday/OfflineStorage");
43 qmlView.engine()->setOfflineStoragePath("qml/OfflineStorage");
45 qmlView.setResizeMode(QDeclarativeView::SizeRootObjectToView);
46 qmlView.setWindowTitle("Markets Today");
47 qmlView.setFixedSize(400,325);
49 LogUtility logUtility;
50 logUtility.logMessage(qmlView.engine()->offlineStoragePath());
52 if (isDesktopWidget) {
53 QMaemo5HomescreenAdaptor *adaptor = new QMaemo5HomescreenAdaptor(&qmlView);
54 adaptor->setSettingsAvailable(true); //Use the standard widget settings button for home screen widget
55 QObject::connect(adaptor, SIGNAL(settingsRequested()), &qmlView, SLOT(displayConfigWindow()));
57 qmlView.setSource(QUrl("qrc:/qml/MarketsTodayWidget.qml"));
61 qmlView.setSource(QUrl("qrc:/qml/MarketsTodayApp.qml"));
62 qmlView.showFullScreen();
65 QObject *rootObject = qmlView.rootObject();
66 //Signal to display config window when user clicks config icon
67 //QObject::connect(rootObject, SIGNAL(showConfigInNewWindow()), &qmlView, SLOT(displayConfigWindow()));
68 //Signal to reload configuration and update quotes after config window is clicked
69 QObject::connect(&qmlView, SIGNAL(initializeWidget()), rootObject, SLOT(initialize()));
71 QObject::connect(rootObject, SIGNAL(checkNetworkStatus()), &connectionUtility, SLOT(checkConnectionStatus()));
72 QObject::connect(&connectionUtility, SIGNAL(connectionsAvailable()), rootObject, SLOT(reloadQuotes()));
73 QObject::connect((QObject*)qmlView.engine(), SIGNAL(quit()), &app, SLOT(quit()));